@decaf-ts/mcp-server 1.5.5 → 1.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/code/patterns/builder.enc +0 -0
- package/dist/assets/prompts/agent/agent.enc +0 -0
- package/dist/assets/prompts/agent/init.enc +0 -0
- package/dist/assets/prompts/constitution_commands.enc +0 -0
- package/dist/assets/prompts/documentation/class.enc +0 -0
- package/dist/assets/prompts/documentation/constant.enc +0 -0
- package/dist/assets/prompts/documentation/decorator.enc +0 -0
- package/dist/assets/prompts/documentation/file.enc +0 -0
- package/dist/assets/prompts/documentation/function.enc +0 -0
- package/dist/assets/prompts/documentation/interface.enc +0 -0
- package/dist/assets/prompts/documentation/iterate.enc +0 -0
- package/dist/assets/prompts/documentation/module.enc +0 -0
- package/dist/assets/prompts/documentation/prefix.enc +0 -0
- package/dist/assets/prompts/documentation/repo.enc +0 -0
- package/dist/assets/prompts/documentation/suffix.enc +0 -0
- package/dist/assets/prompts/git_commands.enc +0 -0
- package/dist/assets/prompts/jira/operational_prompts.enc +0 -0
- package/dist/assets/prompts/jira/system_prompt.enc +0 -0
- package/dist/assets/prompts/mode_commands.enc +0 -0
- package/dist/assets/prompts/plan_commands.enc +0 -0
- package/dist/assets/prompts/repository/readme.enc +0 -0
- package/dist/assets/prompts/repository/release_notes.enc +0 -0
- package/dist/assets/prompts/repository/setup.enc +0 -0
- package/dist/assets/prompts/specification_commands.enc +0 -0
- package/dist/assets/prompts/startup_command.enc +0 -0
- package/dist/assets/prompts/task_commands.enc +0 -0
- package/dist/assets/prompts/tests/coverage.enc +0 -0
- package/dist/assets/templates/AGENTS.enc +0 -0
- package/dist/assets/templates/agents_template.enc +0 -0
- package/dist/assets/templates/constitution_template.enc +0 -0
- package/dist/assets/templates/decaf/context/logCtx.enc +0 -0
- package/dist/assets/templates/decaf/services/client_based_service.enc +0 -0
- package/dist/assets/templates/decaf/services/model_service.enc +0 -0
- package/dist/assets/templates/decaf/services/service.enc +0 -0
- package/dist/assets/templates/decaf_guidelines.enc +1 -1
- package/dist/assets/templates/instructions_template.enc +0 -0
- package/dist/assets/templates/jira_templates.enc +0 -0
- package/dist/assets/templates/plan_template.enc +0 -0
- package/dist/assets/templates/specification_template.enc +0 -0
- package/dist/assets/templates/task_template.enc +0 -0
- package/dist/mcp-server.cjs +1 -1
- package/dist/mcp-server.cjs.map +1 -1
- package/dist/mcp-server.js +1 -1
- package/dist/mcp-server.js.map +1 -1
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
DCAF1�ĺo>��$� �eT"�ef��yqxN�a믾�s�'*tL=A}k�Pn�J�������Jc
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/mcp-server.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var e,t;e=this,t=function(e,t,r,n,s,i,o,a,c,l,p,u,d,m,h,f,g,y,b,v,w,j){"use strict";function S(e){var t=Object.create(null);return e&&Object.keys(e).forEach(r=>{if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}),t.default=e,Object.freeze(t)}var x=S(t),I=S(c);class _ extends r.MiniLogger{constructor(e,t,r){super(e,t,r)}log(e,t,n,s){const i=this.config("level");r.NumericLogLevels[i],r.NumericLogLevels[e]}}const z=(e,t,...r)=>{const n=(e=>{if("string"==typeof e)return e;if(!e)return"unknown";if("function"==typeof e)return e.name||"unknown";if("object"==typeof e&&"constructor"in e){const t=e.constructor;if(t&&t.name)return t.name}return"unknown"})(e);return new _(n,t)};var k,E,T,A,O;(e=>{e[e.NONE=0]="NONE",e[e.BASIC=1]="BASIC",e[e.ADVANCED=2]="ADVANCED",e[e.HIGH=3]="HIGH"})(k||(k={})),(e=>{e[e.NONE=0]="NONE",e[e.LOW=1]="LOW",e[e.MEDIUM=2]="MEDIUM",e[e.HIGH=3]="HIGH"})(E||(E={})),(e=>{e[e.FREE=0]="FREE",e[e.LOW=1]="LOW",e[e.MEDIUM=2]="MEDIUM",e[e.HIGH=3]="HIGH"})(T||(T={}));class N extends s.Model{get log(){return this._log||(this._log=r.Logging.for(this)),this._log}constructor(e){super(e)}logFor(e){const{sessionId:t,requestId:r,authInfo:n}=e||{};let s="string"==typeof t&&t.length>0?this.log.for(t):this.log;return n&&n.clientId&&(s=s.for(n.clientId)),r&&(s=s.for(r.toString())),s}setDescription(e){return this.description=e,this}getDescription(){return this.description}setName(e){return this.name=e,this}getName(){return this.name}setTitle(e){return this.title=e,this}}n.__decorate([s.required(),n.__metadata("design:type",String)],N.prototype,"description",void 0),n.__decorate([s.required(),n.__metadata("design:type",String)],N.prototype,"name",void 0),n.__decorate([s.required(),n.__metadata("design:type",String)],N.prototype,"title",void 0);class C extends N{constructor(e){super(e),this.reasoning=k.NONE,this.effort=E.NONE,this.cost=T.FREE}setReasoning(e){return this.reasoning=e,this}setEffort(e){return this.effort=e,this}setCost(e){return this.cost=e,this}}function H(e){if(!e)return;let t=e,r=t&&t._def;for(;r&&"ZodObject"!==r.typeName;){if("ZodEffects"===r.typeName&&r.schema)t=r.schema;else if("ZodOptional"===r.typeName&&r.innerType)t=r.innerType;else if("ZodDefault"===r.typeName&&r.innerType)t=r.innerType;else if("ZodNullable"===r.typeName&&r.innerType)t=r.innerType;else{if(!r.schema)return;t=r.schema}r=t&&t._def}return r&&"ZodObject"===r.typeName?r:void 0}function J(e,t="schema"){if(H(e))return e;if(e&&"object"==typeof e){const t=e.def&&"object"==typeof e.def?e.def:void 0,r=t&&(t.shape||"object"===t.type)&&t.shape||("object"===e.type?e.shape:void 0)||(t&&"object"===t.type?{}:void 0);if(t||"object"===e.type||r){const e={};if(r&&"object"==typeof r)for(const[t,n]of Object.entries(r))e[t]=D(n)?n:i.z.any();return i.z.object(e)}}throw Error(`Registration error: provided a non-canonical ${t}. Export a ZodObject (z.object(...)).`)}function q(e){if(!e)return;if(e&&"object"==typeof e&&!e._def)return e.def&&"object"==typeof e.def&&e.def.shape?e.def.shape:e;const t=H(e);return t?"function"==typeof t.shape?t.shape():t.shape||void 0:void 0}function D(e){return!(!e||"object"!=typeof e||!e._def)}n.__decorate([s.required(),n.__metadata("design:type",Number)],C.prototype,"reasoning",void 0),n.__decorate([s.required(),n.__metadata("design:type",Number)],C.prototype,"effort",void 0),n.__decorate([s.required(),n.__metadata("design:type",Number)],C.prototype,"cost",void 0),(e=>{e.ASSETS="assets"})(A||(A={})),(e=>{e.PROMPT="prompts",e.DOCUMENTATION="documentation",e.CODE="code"})(O||(O={}));const P=Buffer.from("DCAF1","ascii");function $(e){let r=c.resolve(e);for(;;){if(t.existsSync(c.join(r,"package.json")))return r;const e=c.dirname(r);if(e===r)break;r=e}}const R=process.argv?.[1]?$(c.dirname(c.resolve(process.argv[1]))):void 0,M=(()=>{const e=Error().stack;if(!e)return;const t=e.split(/\r?\n/).slice(1);for(const e of t){const t=e.match(/\(?([^()]+?):\d+:\d+\)?/);if(!t)continue;let r=t[1];if(r.startsWith("file://"))try{r=d.fileURLToPath(r)}catch{continue}if(!r.includes("node:internal"))return c.dirname(r)}})(),L=M?$(M):void 0,F=R??L??process.cwd();function B(...e){return c.join(F,...e)}function U(e){let t=e;for(;;){const e=I.join(t,"lib","assets");if(x.existsSync(e))return e;const r=I.join(t,"src","assets");if(x.existsSync(r))return r;const n=I.join(t,"assets");if(x.existsSync(n))return n;const s=I.dirname(t);if(s===t)break;t=s}}function W(){const e=process.env.DECAF_ASSET_DIR||process.env.MCP_ASSET_DIR||process.env.ASSET_DIR||"";if(e&&x.existsSync(e))return e;const t=U(__dirname);if(t)return t;const r=process.argv?.[1];if(r){const e=U(I.dirname(r));if(e)return e}const n=[F,process.env.INIT_CWD].filter(Boolean);for(const e of n){const t=U(e);if(t)return t}return B("assets")}let K=class extends r.LoggedClass{constructor(e){super(),this.basePath=e||W()}listAssets(...e){const t=I.join(this.basePath,...e);return x.readdirSync(t)}listPrompts(){return this.listAssets(O.PROMPT)}getAsset(e,t="md",...r){const n=I.join(this.basePath,...r),s=(e,t=!1)=>{try{return t?(e=>{if(e.length<P.length+16+12+16)throw Error("Invalid prompt payload (too short)");if(!e.subarray(0,P.length).equals(P))throw Error("Invalid prompt payload (bad magic)");const t=process.env.ENCRYPTION_KEY||"";if(!t)throw Error("Missing encryption key. Set ENCRYPTION_KEY to load obfuscated assets.");let r=P.length;const n=e.subarray(r,r+16);r+=16;const s=e.subarray(r,r+12);r+=12;const i=e.subarray(r,r+16);r+=16;const o=e.subarray(r),a=((e,t)=>p.scryptSync(e,t,32))(t,n),c=p.createDecipheriv("aes-256-gcm",a,s);c.setAuthTag(i);const l=Buffer.concat([c.update(o),c.final()]);return u.gunzipSync(l)})(x.readFileSync(e)).toString("utf-8"):x.readFileSync(e,"utf-8")}catch(e){if("ENOENT"===e.code)return null;throw e}},i=s(I.join(n,`${e}.${t}`),"enc"===t);if(null!==i)return i;const o=s(I.join(n,e+".enc"),!0);if(null!==o)return o;throw Error("Asset not found: "+I.join(n,`${e}.${t}`))}getAllAssets(e,...t){return this.listAssets(e,...t).reduce((r,n)=>{const s=I.extname(n),i=I.basename(n,s),o=s.replace(/^\./,"")||void 0;return r[i]=this.getAsset(i,o??void 0,e,...t),r},{})}toPromptDef(e){const t=e=>"number"==typeof e?e:"string"==typeof e?(e=>{switch(e){case"none":return k.NONE;case"basic":return k.BASIC;case"advanced":return k.ADVANCED;case"high":return k.HIGH;case"medium":return E.MEDIUM;case"low":return T.LOW;case"free":return T.FREE;default:throw new l.InternalError("Cannon convert unknown level "+e)}})(e.toLowerCase()):k.NONE;return e.effort=t(e.effort),e.reasoning=t(e.reasoning),e.cost=t(e.cost),e}getPrompt(e,...t){const n=this.getAsset(r.toSnakeCase(e),"json",O.PROMPT,...t);let s;try{s=JSON.parse(n)}catch(r){throw new l.SerializationError(`Failed to parse prompt ${e} in categories ${t}: ${r}`)}return this.toPromptDef(s)}getAllPrompts(...e){const t=this.getAllAssets(O.PROMPT,...e);return Object.entries(t).reduce((t,[r,n])=>{try{t[r]=JSON.parse(n)}catch(t){throw new l.SerializationError(`Failed to parse prompt ${r} in categories ${e}: ${t}`)}return t},t)}};K=n.__decorate([o.injectable(),n.__metadata("design:paramtypes",[String])],K);class Y extends C{constructor(e){super(e)}setCb(e){return this.cb=e,this}setArgsSchema(e){return this.argsSchema=e,this}static get builder(){return new Y}static patchPrompt(e,t,n,s){const i=(t=Array.isArray(t)?t:Object.keys(t)).filter(e=>!Object.prototype.hasOwnProperty.call(n,e));if(i.length)throw new l.ValidationError("Missing replacements for placeholders: "+i.join(", "));s&&(s.verbose("Patching prompt with placeholders: "+JSON.stringify(t)),s.debug("Values: "+JSON.stringify(n)));const o=t.reduce((e,t)=>(e[t]=n[t],e),{});return r.sf(e,o)}patchPrompt(e,t,r,n){return Y.patchPrompt(e,t,r,n||this.log.for(this.patchPrompt))}build(e,t){const r=this.log.for(this.build),n=this.hasErrors();if(n)throw new l.ValidationError(n.toString());try{this.argsSchema&&J(this.argsSchema,"argsSchema");const r=q(this.argsSchema);return e.registerPrompt(this.name,{title:this.title,description:this.description,argsSchema:r},async(e,r)=>{const n=this.logFor(r);e=Object.assign({},t,e||{}),n.verbose(`Executing prompt ${this.name} with args: ${JSON.stringify(e)}`),e._meta=Object.assign(e._meta||{},{usage:{reasoning:this.reasoning,effort:this.effort,cost:this.cost}});const s=await Promise.resolve(this.cb(e,r));return n.verbose(`Prompt ${this.name} executed successfully.`),n.debug("Prompt execution meta: "+JSON.stringify(s._meta)),s})}catch(e){throw r.error("Failed to register prompt "+(this.name||this.constructor.name),e),e}}}n.__decorate([o.inject(K),n.__metadata("design:type",K)],Y.prototype,"assets",void 0),n.__decorate([s.required(),n.__metadata("design:type",Object)],Y.prototype,"cb",void 0),n.__decorate([s.required(),n.__metadata("design:type",i.ZodObject)],Y.prototype,"argsSchema",void 0),n.__decorate([a.prop(),n.__metadata("design:type",Object)],Y.prototype,"placeholders",void 0);class V extends Y{setCategory(e){return this.promptCategory=e,this}addPrefix(e){return this.prefixes=this.prefixes||[],this.prefixes.push(e),this}addSuffix(e){return this.suffixes=this.suffixes||[],this.suffixes.push(e),this}constructor(e){super(e)}build(e){const t=this.assets.getPrompt(this.name,this.promptCategory);s.Model.fromObject(this,t);const r=new Set((a.Metadata.properties(V)||[]).filter(e=>!["assets","promptCategory","prefixes","suffixes"].includes(e)));["cb","argsSchema"].forEach(e=>r.add(e));const n=this.hasErrors(...Array.from(r));if(n)throw new l.ValidationError(n.toString());const o=(this.prefixes||[]).map(e=>this.assets.getPrompt(e,this.promptCategory)),c=(this.suffixes||[]).map(e=>this.assets.getPrompt(e,this.promptCategory)),p=[...new Set([...t.placeholders,...o.map(e=>e.placeholders||[]),...c.map(e=>e.placeholders||[])].flat())].reduce((e,t)=>(e[t]=i.z.string().describe("The description for "+t),e),{});return this.setArgsSchema(i.z.object(p)),this.setCb((e,t)=>{const r=this.logFor(t).for(V).for(this.promptCategory).for(this.name);function n(e=[]){return Array.isArray(e)?e:Object.keys(e)}const s=(this.prefixes||[]).map(e=>this.assets.getPrompt(e,this.promptCategory)),i=(this.suffixes||[]).map(e=>this.assets.getPrompt(e,this.promptCategory)),o=this.assets.getPrompt(this.name,this.promptCategory),a=[...new Set([...s.map(e=>n(e.placeholders)).flat(),...i.map(e=>n(e.placeholders)).flat(),...n(o.placeholders).flat()])];return{messages:[{role:"user",content:{type:"text",text:this.patchPrompt([...s.map(e=>e.prompt),o.prompt,...i.map(e=>e.prompt)].join("\n\n"),a,e,r)}}],_meta:{}}}),super.build(e)}setReasoning(e){throw new l.InternalError("Named prompt builders don't require callback")}setEffort(e){throw new l.InternalError("Named prompt builders don't require callback")}setCost(e){throw new l.InternalError("Named prompt builders don't require callback")}setDescription(e){throw new l.InternalError("Named prompt builders don't require callback")}setTitle(e){throw new l.InternalError("Named prompt builders don't require callback")}static get builder(){return new V}}n.__decorate([s.required(),n.__metadata("design:type",String)],V.prototype,"promptCategory",void 0),n.__decorate([s.list(String),s.minlength(1),n.__metadata("design:type",Array)],V.prototype,"prefixes",void 0),n.__decorate([s.minlength(1),s.list(String),n.__metadata("design:type",Array)],V.prototype,"suffixes",void 0);const G=Y.builder.setName("example-prompt").setTitle("Example prompt").setDescription("Example prompt for testing").setArgsSchema(i.z.object({message:i.z.string().optional()})).setCb(async e=>{const t=e.message??"default";return{messages:[{role:"assistant",content:{type:"text",text:t}}],content:[],structuredContent:{message:t},result:{message:t}}}),Z=Y.builder.setName("interactive-jsdoc").setTitle("Interactive JSDoc prompt").setDescription("Interactive prompt for jogging JSDoc helpers").setArgsSchema(i.z.object({gist:i.z.string().optional()})).setCb(async e=>{const t=e.gist??"interactive jsdoc response";return{messages:[{role:"assistant",content:{type:"text",text:t}}],content:[],structuredContent:{message:t},result:{message:t}}}),Q=Object.assign(Z,{name:Z.getName()});var X;function ee(e,t=[],r=[]){const n=V.builder.setCategory(X.DOCS).setName(e);return["prefix",...t].forEach(e=>n.addPrefix(e)),["suffix",...r].forEach(e=>n.addSuffix(e)),n}(e=>{e.DOCS="documentation",e.CODE="code"})(X||(X={}));const te=[ee("class"),ee("constant"),ee("decorator"),ee("function"),ee("module"),ee("file"),ee("repo",[],["iterate"])],re=i.z.object({className:i.z.string().describe("the class name to turn into a builder")}),ne=[G,Q,...te,Y.builder.setName("ts-code-dp-builder").setTitle("Typescript builder design patter prompt").setDescription("for a class, with a defined set of properties, scafold a builder design pattern").setArgsSchema(re).setReasoning(k.BASIC).setCb((e,t)=>(e.className=r.toPascalCase(e.className),{messages:[{role:"user",content:{type:"text",text:`You're a senior TypeScript developer writing typescript code.You're a senior TypeScript developer writing typescript code.\nTransform the selected class into a builder design pattern implementation in Typescript.\nuse @decaf-ts validation decorators to enforce the validation of your builder.\n\n- must extend the Model Class from @decaf-ts/decorator-validation;\n- each property must be marked as protected;\n- each property must have a setter method that returns 'this' for chaining;\n- the build() method must validate the properties using hasErrors() method from Model class;\n- if validation fails, throw an error with the validation errors;\n- if validation passes, return an instance of the original class with the set properties;\n- optionally (but do so by default) add the static builder and from methods from the example;\n- if the clasee already follows the pattern but has properties without decoration or without setters, simple add them;\n\nexample:\n\noriginal class:\n\`\`\`typescript\nexport class ${e.className} {\n description!: string;\n name!: string = "default name";\n title!: string;\n age?: string;\n dateOfBirth!: Date;\n}}\n\`\`\` \n\nresulting builder pattern implementation:\n\`\`\`typescript\nexport class ${e.className}Builder extends Model {\n\n @minlength(10\n @required()\n protected description!: string;\n \n @required()\n protected name!: string = "default value;\n \n @required()\n protected title!: string;\n \n @min(18)\n protected age?: string;\n \n @date()\n protected dateOfBirth!: Date;\n\n protected constructor(arg?: ModelArg<${e.className}Builder>>) {\n super(arg);\n Model.fromModel(this, arg);\n }\n\n setDescription(value: string) {\n this.description = value;\n return this;\n }\n\n setName(value: string) {\n this.name = value;\n return this;\n }\n\n setTitle(value: string) {\n this.title = value;\n return this;\n }\n setAge(value: number) {\n this.age = value;\n return this;\n }\n setDate(value: Date) {\n this.age = value;\n return this;\n }\n \n build(...args: any[]): ${e.className}Builder | Promise<${e.className}Builder> {\n const errs = this.hasErrors();\n if (errs) throw new Error(errs.toString());\n \n return // code that builds OBJ here\n }\n \n static get builder(): ${e.className}Builder {\n return new ${e.className}Builder(); // static method to get a new builder instance\n }\n \n static from<K extends keyof ${e.className}Builder>(obj: K, ${e.className}Builder[K]): ${e.className}Builder {\n return new ${e.className}Builder(); // static method to create a builder from an object\n }\n}\n\`\`\` \n\n`}}],_meta:{}}))];class se extends C{setAnnotations(e){return this.annotations=Object.assign(this.annotations,e),this}setCb(e){return this.cb=e,this}setInputSchema(e){return this.inputSchema=e,this}setOutputSchema(e){return this.outputSchema=e,this}constructor(e){super(e),this.annotations={readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}static get builder(){return new se}build(e){const t=this.hasErrors();if(t)throw Error(t.toString());try{this.inputSchema&&J(this.inputSchema,"inputSchema"),this.outputSchema&&J(this.outputSchema,"outputSchema");const t=q(this.inputSchema),r=q(this.outputSchema);return e.registerTool(this.name,{title:this.title,description:this.description,inputSchema:t,outputSchema:r,annotations:this.annotations,_meta:{usage:{reasoning:this.reasoning,effort:this.effort,cost:this.cost}}},async(e,t)=>{const r=this.logFor(t);r.verbose(`Executing tool ${this.name} with args: ${JSON.stringify(e)}`),t._meta=Object.assign(t._meta||{},{usage:{reasoning:this.reasoning,effort:this.effort,cost:this.cost}});const n=await Promise.resolve(this.cb(e,t));return r.verbose(`Tool ${this.name} executed successfully.`),r.debug("Tool execution meta: "+JSON.stringify(n._meta)),n})}catch(e){const t=e?.message||e+"";if("string"==typeof t&&t.includes("already registered"))return r.Logging.for(this).warn(`Tool ${this.name} already registered - skipping duplicate registration`),{name:this.name};throw r.Logging.for(this).error("Error building tool",e),e}}}n.__decorate([s.required(),n.__metadata("design:type",Object)],se.prototype,"annotations",void 0),n.__decorate([s.required(),n.__metadata("design:type",Object)],se.prototype,"cb",void 0),n.__decorate([s.required(),n.__metadata("design:type",Function)],se.prototype,"inputSchema",void 0);const ie=se.builder.setName("example-tool").setTitle("Example tool").setDescription("A smoke tool used for quick testing").setInputSchema(i.z.object({})).setCb(async()=>({content:[{type:"text",text:"example tool ok"}],result:{status:"ok"}}));Object.assign(ie,{name:ie.getName()});const oe=se.builder.setName("file-summarizer").setTitle("File summarizer").setDescription("Summaries files for quick previews").setInputSchema(i.z.object({filePath:i.z.string().optional()})).setCb(async()=>({content:[{type:"text",text:"file summary stub"}],result:{summary:"file summary stub"}}));function ae(){try{let e=process.argv[1]?c.dirname(c.resolve(process.argv[1])):process.cwd();for(;;){const r=c.join(e,"package.json");if(t.existsSync(r))return JSON.parse(t.readFileSync(r,"utf-8"));const n=c.dirname(e);if(n===e)break;e=n}}catch{}return{}}Object.assign(oe,{name:oe.getName()});const ce=ae().version??"0.0.0",le=ae().name??"unknown";a.Metadata.registerLibrary(le,ce);const pe={mcpId:"decaf",name:"decaf-ts mcp server",title:"Decaf-TS MCP Server",description:"Provides precise coding assistance for the decaf-ts framework",version:ce,websiteUrl:"https://decaf-ts.github.io",repositoryUrl:"https://github.com/decaf-ts/mcp-server",license:"AGPL-3.0",workingDir:F,assetDir:W(),contacts:[{name:"Decaf-TS",url:"https://decaf-ts.github.io"}],tags:"server,official,decaf-ts",metadata:{},icons:[{src:"workdocs/assets/favicon.svg",mimeType:"image/svg+xml",sizes:"any"}],jira:{host:process.env.JIRA__HOST||"decaf-ts.atlassian.net",email:process.env.JIRA__EMAIL||"",apiKey:process.env.JIRA__API_KEY||process.env.JIRA__APIKEY||"",projectKey:process.env.JIRA__PROJECT_KEY||void 0,issueType:process.env.JIRA__ISSUE_TYPE||void 0,parentIssue:process.env.JIRA__PARENT_ISSUE||void 0},level:r.LogLevel.error},ue=r.LoggedEnvironment.accumulate(pe);function de(){const{host:e,email:t,apiKey:r,projectKey:n,issueType:s}=ue.jira;return{host:e?.trim(),email:t?.trim(),apiKey:r?.trim(),projectKey:n?.trim(),issueType:s?.trim(),parentIssue:ue.jira.parentIssue?.trim()}}function me(){const e=de();return[{name:"JIRA__HOST",required:!0,description:"Atlassian host (e.g. decaf-ts.atlassian.net) where your Jira instance is hosted.",value:e.host},{name:"JIRA__EMAIL",required:!0,description:"Email address of the Jira account that has API access.",value:e.email},{name:"JIRA__API_KEY",required:!0,description:"API token created in your Atlassian profile (a.k.a. APIKEY alias) for authenticating requests.",sensitive:!0,value:e.apiKey},{name:"JIRA__PROJECT_KEY",required:!1,description:"Default Jira project key (e.g. DECAF) used when an issue creation request omits a project.",value:e.projectKey},{name:"JIRA__ISSUE_TYPE",required:!1,description:"Default Jira issue type (e.g. Task, Bug) used when creating issues without an explicit type.",value:e.issueType},{name:"JIRA__PARENT_ISSUE",required:!1,description:"Default parent issue key (e.g. DECAF-123) applied when a child issue is created without an explicit parent.",value:e.parentIssue}]}function he(e){const t=e.value?((e,t)=>{if(e)return t?"<configured>":e})(e.value,e.sensitive):"not set",r=e.required?"(required)":"(optional)";return`\u2022 ${e.name} ${r}: ${e.description} Current state: ${t}.`}r.Logging.setConfig(ue);class fe extends Error{constructor(e){const t=me(),r=(e=>{const t=me();return`${e.length?`Missing Jira credentials: ${e.map(e=>e.name).join(", ")}.`:"Jira credentials are configured."}\n\nThis setup uses the following environment variables:\n${t.map(he).join("\n")}`})(e);super(r),this.name="MissingJiraEnvironmentError",this.descriptors=t,this.missing=e,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,fe)}}function ge(e){if(!e)return{code:"jira_error",message:"Unknown Jira error",details:{raw:e}};const t=e?.status??e?.statusCode??e?.response?.status??e?.response?.statusCode,r="number"==typeof t?t:Number(t)||void 0,n=e?.response?.data??e?.data??e?.response?.body??e?.body,s=[];"string"==typeof e?.message&&s.push(e.message),((e,t)=>{e&&(Array.isArray(e.errorMessages)&&e.errorMessages.forEach(e=>"string"==typeof e&&t.push(e)),"string"==typeof e.errorMessage&&t.push(e.errorMessage),e.errorCollection&&Array.isArray(e.errorCollection.errors)&&e.errorCollection.errors.forEach(e=>{"string"==typeof e?t.push(e):e&&"string"==typeof e.message&&t.push(e.message)}),e?.errors&&"object"==typeof e.errors&&Object.values(e.errors).forEach(e=>{"string"==typeof e?t.push(e):"string"==typeof e?.message&&t.push(e.message)}))})(n,s);const i=r?`Jira API error (${r})`:"Jira API error",o=s.length>0?s.join(" | "):i;return{code:r?"jira_"+r:e?.code??"jira_error",message:o,details:{httpStatus:r,body:n,raw:e}}}function ye(e){if(!e||0>=Object.keys(e).length)return[];const t=(e=>{if(null==e)return"";try{return JSON.stringify(e,null,2)}catch{return e+""}})(e);return t?[{type:"text",text:t}]:[]}function be(e={},t=[]){return{content:t.length?t:ye(e),result:e,structuredContent:e}}const ve=i.z.object({issueId:i.z.string().min(1),deleteSubtasks:i.z.boolean().optional().default(!0)}),we={name:"jira-issue-delete",inputSchema:ve,runTool:async(e,t)=>{try{const r=ve.parse(t),n=e.issues??e.issue??e,s=n?.delete??n?.deleteIssue;if("function"!=typeof s)throw Error("jira client delete endpoint is not available");return await s.call(n,{issueId:r.issueId,deleteSubtasks:r.deleteSubtasks}),be({success:!0,message:`Issue ${t.issueId} deleted successfully`})}catch(e){throw ge(e)}}},je=i.z.object({projectKey:i.z.string().trim().min(1).optional(),issueType:i.z.string().trim().min(1).optional(),parentIssueId:i.z.string().trim().min(1).optional(),name:i.z.string().trim().min(1).optional(),reference:i.z.string().trim().min(1).optional(),jql:i.z.string().trim().min(1).optional(),startAt:i.z.number().int().min(0).optional(),maxResults:i.z.number().int().min(1).optional(),fields:i.z.array(i.z.string()).optional(),expand:i.z.string().optional(),orderBy:i.z.string().trim().min(1).optional()});function Se(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}const xe={name:"jira-issue-list",inputSchema:je,runTool:async(e,t)=>{try{const r=je.parse(t),n=r.startAt??0,s=r.maxResults??50;let i=r.jql?.trim();if(i){if(r.orderBy){const e=r.orderBy.trim();e&&(i=/\border\s+by\b/i.test(i)?`${i}, ${e}`:`${i} ORDER BY ${e}`)}}else i=(e=>{const t=[];if(e.projectKey&&t.push(`project = "${Se(e.projectKey)}"`),e.issueType&&t.push(`issuetype = "${Se(e.issueType)}"`),e.parentIssueId&&t.push(`parent = "${Se(e.parentIssueId)}"`),e.name&&t.push(`summary ~ "${Se(e.name)}"`),e.reference){const r=Se(e.reference);t.push(`(key ~ "${r}" OR summary ~ "${r}" OR text ~ "${r}")`)}if(0===t.length){const e=Error("Provide a jql query or at least one filter (project, name, reference, parent, issue type, etc.).");throw e.code="validation_error",e}let r=t.join(" AND ");if(e.orderBy){const t=e.orderBy.trim();t&&(r=/\border\s+by\b/i.test(r)?`${r}, ${t}`:`${r} ORDER BY ${t}`)}return r})(r);const o={jql:i,startAt:n,maxResults:s};r.fields&&(o.fields=r.fields),r.expand&&(o.expand=r.expand);const a=e.issueSearch,c=a&&"function"==typeof a.searchForIssuesUsingJqlEnhancedSearch?a.searchForIssuesUsingJqlEnhancedSearch:a&&"function"==typeof a.searchForIssuesUsingJql?a.searchForIssuesUsingJql:void 0;if(!c)throw Error("Jira search API is unavailable on the client");const l=await c.call(a,o);return be(l?.data??l)}catch(e){throw ge(e)}}},Ie=i.z.object({issueId:i.z.string().min(1),expand:i.z.string().optional(),fields:i.z.array(i.z.string()).optional(),properties:i.z.array(i.z.string()).optional()}),_e={name:"jira-issue-read",inputSchema:Ie,runTool:async(e,t)=>{try{const r=Ie.parse(t),n={issueIdOrKey:r.issueId};r.expand&&(n.expand=r.expand),r.fields&&(n.fields=r.fields),r.properties&&(n.properties=r.properties);const s=await e.issues.get(n);return be(s?.data??s)}catch(e){throw ge(e)}}};function ze(e,t,r){const n=((e.url??"")+"").match(/^(attachment|jira-attachment):(.+)$/i);if(!n)return null;const s=n[2],i=r.resolveAttachment?.(s);return i?{type:"block",node:{type:"mediaSingle",attrs:{layout:"center"},content:[{type:"media",attrs:{type:"file",id:i.id,collection:i.collection??"attachments"}}]}}:null}function ke(e,t){if(!e)return[];if(!t.enableAtMentions&&!t.enableEmojiShortcodes)return[{type:"text",text:e}];let r=0;const n=[],s=/(^|[^A-Za-z0-9_])@([A-Za-z0-9._-]{1,64})/g,i=/:([a-z0-9_+-]{1,64}):/gi;for(;r<e.length;){const o=Te(t.enableAtMentions?Ee(s,e,r):null,t.enableEmojiShortcodes?Ee(i,e,r):null);if(!o){n.push({type:"text",text:e.slice(r)});break}if(o.index>r&&n.push({type:"text",text:e.slice(r,o.index)}),"mention"===o.kind){const{full:e,groups:s}=o,i=s[0]??"",a=s[1]??"";i&&n.push({type:"text",text:i});const c=t.resolveMention?.(a);c?n.push({type:"mention",attrs:{id:c.id,text:c.text}}):n.push({type:"text",text:"@"+a}),r=o.index+e.length;continue}if("emoji"===o.kind){const{full:e,groups:s}=o,i=`:${s[0]}:`,a=t.resolveEmoji?.(i);n.push({type:"emoji",attrs:a?{shortName:a.shortName,text:a.text}:{shortName:i}}),r=o.index+e.length;continue}}return(e=>{const t=[];for(const r of e){const e=t[t.length-1];"text"!==r.type||"text"!==e?.type||e.marks||r.marks?t.push(r):e.text=(e.text??"")+(r.text??"")}return t})(n)}function Ee(e,t,r){e.lastIndex=r;const n=e.exec(t);if(!n)return null;const s=e.source.includes("@")?"mention":"emoji";return{index:n.index,full:n[0],groups:n.slice(1),kind:s}}function Te(e,t){return e?t&&e.index>t.index?t:e:t}function Ae(e){const t=(e.children??[])[0];return"text"===t?.type?(t.value??"")+"":"paragraph"===t?.type?((t.children??[]).map(e=>"text"===e.type?(e.value??"")+"":"").join("")||"")+"":""}function Oe(e){const t=((e??"")+"").toLowerCase().trim();return t?"info"===t||"note"===t||"success"===t||"warning"===t||"error"===t?t:"danger"===t?"error":null:null}function Ne(e){const t=((e??"")+"").toLowerCase().trim();return!t||"neutral"!==t&&"green"!==t&&"yellow"!==t&&"red"!==t&&"blue"!==t&&"purple"!==t?null:t}function Ce(e,t){const r=[];for(const n of e??[])if(n?.type)if("text"!==n.type)if("strong"!==n.type)if("emphasis"!==n.type)if("delete"!==n.type)if("inlineCode"!==n.type)if("break"!==n.type){if("link"===n.type){const e=(n.url??"")+"",s=Je(n.children??[],e),i=ze(n,0,t);if(i){"inline"===i.type?r.push(i.node):r.push({type:"text",text:s,marks:[{type:"link",attrs:{href:e}}]});continue}if(t.enableSmartCards&&qe(s,e)){r.push({type:"inlineCard",attrs:{url:e}});continue}r.push({type:"text",text:s,marks:[{type:"link",attrs:{href:e}}]});continue}if("textDirective"===n.type&&"status"===n.name){const e=Ae(n)||"Status",t=Ne(n.attributes?.color)??"neutral";r.push({type:"status",attrs:{text:e,color:t}});continue}if("textDirective"===n.type&&"emoji"===n.name){const e=De(n);r.push(Pe(e,t));continue}}else r.push({type:"hardBreak"});else r.push({type:"text",text:(n.value??"")+"",marks:[{type:"code"}]});else r.push(...He(Ce(n.children??[],t),{type:"strike"}));else r.push(...He(Ce(n.children??[],t),{type:"em"}));else r.push(...He(Ce(n.children??[],t),{type:"strong"}));else r.push(...ke((n.value??"")+"",t));return r.filter(e=>!("text"===e.type&&""===(e.text??"")))}function He(e,t){return e.map(e=>{if("text"!==e.type)return e;const r=e.marks?[...e.marks,t]:[t];return{...e,marks:r}})}function Je(e,t){const r=[];for(const t of e??[])"text"===t.type||"inlineCode"===t.type?r.push((t.value??"")+""):"emphasis"!==t.type&&"strong"!==t.type&&"delete"!==t.type||r.push(Je(t.children??[],""));return r.join("")||t}function qe(e,t){const r=(e??"").trim(),n=(t??"").trim();return r===n&&/^https?:\/\//i.test(n)}function De(e){return(e.children??[]).map(e=>"text"===e.type?(e.value??"")+"":"").join("").trim()||""}function Pe(e,t){const r=e.startsWith(":")?e:`:${e}:`,n=t.resolveEmoji?.(r);return n?{type:"emoji",attrs:{shortName:n.shortName,text:n.text}}:{type:"emoji",attrs:{shortName:r}}}function $e(e){return e?"string"==typeof e?e:"text"===e.type||"inlineCode"===e.type?(e.value??"")+"":Array.isArray(e.children)?e.children.map($e).join(""):"":""}function Re(e,t){if(!e?.type)return null;if((e=>"containerDirective"===e?.type&&"panel"===e?.name)(e))return((e,t)=>{const r=e.attributes??{},n=Oe(r.type)??"info",s="string"==typeof r.title?r.title:void 0,i=(e.children??[]).map(e=>Re(e,t)).flat().filter(Boolean);return{type:"panel",attrs:{panelType:n,...s?{panelType:n,title:s}:{panelType:n}},content:i.length?i:[{type:"paragraph",content:[]}]}})(e,t);switch(e.type){case"heading":return{type:"heading",attrs:{level:Le(e.depth??1,1,6)},content:Ce(e.children??[],t)};case"paragraph":{const r=(e=>{const t=e.children??[];if(1!==t.length)return null;const r=t[0];if("image"!==r?.type)return null;const n=(r.url??"")+"";return n?{type:"mediaSingle",attrs:{layout:"center"},content:[{type:"media",attrs:{type:"external",url:n}}]}:null})(e);return r||{type:"paragraph",content:Ce(e.children??[],t)}}case"blockquote":return{type:"blockquote",content:(e.children??[]).map(e=>Re(e,t)).flat().filter(Boolean)};case"list":return((e,t)=>t.enableTaskLists&&(e.children??[]).some(e=>"boolean"==typeof e.checked)?((e,t)=>{const r=[];let n=0;for(const s of e.children??[]){if("boolean"!=typeof s.checked)continue;n+=1;const e=(s.children??[]).map(e=>Re(e,t)).flat().filter(Boolean);r.push({type:"taskItem",attrs:{localId:"task-"+n,state:s.checked?"DONE":"TODO"},content:e.length?e:[{type:"paragraph",content:[]}]})}return{type:"taskList",content:r}})(e,t):{type:e.ordered?"orderedList":"bulletList",content:(e.children??[]).map(e=>((e,t)=>{const r=(e.children??[]).map(e=>Re(e,t)).flat().filter(Boolean);return{type:"listItem",content:r.length?r:[{type:"paragraph",content:[]}]}})(e,t))})(e,t);case"code":{const r=((e,t)=>{const r=(e??"").toString().trim().toLowerCase();return r?t.enableMermaid&&"mermaid"===r?"mermaid":(e=>{const t=e.trim().toLowerCase();return{js:"javascript",javascript:"javascript",jsx:"javascript",ts:"typescript",typescript:"typescript",tsx:"typescript",py:"python",python:"python",rb:"ruby",ruby:"ruby",sh:"bash",bash:"bash",zsh:"bash",shell:"bash",yml:"yaml",yaml:"yaml",json:"json",toml:"toml",xml:"xml",html:"html",css:"css",scss:"scss",sql:"sql",go:"go",rust:"rust",java:"java",c:"c",cpp:"cpp","c++":"cpp",cs:"csharp",csharp:"csharp",php:"php",kotlin:"kotlin",swift:"swift",md:"markdown",markdown:"markdown",graphql:"graphql",gql:"graphql",dockerfile:"docker",makefile:"make",ini:"ini"}[t]??t})(r):null})(e.lang,t);return{type:"codeBlock",attrs:{language:r},content:[{type:"text",text:(e.value??"")+""}]}}case"thematicBreak":return{type:"rule"};case"table":return((e,t)=>({type:"table",content:(e.children??[]).map((e,r)=>({type:"tableRow",content:(e.children??[]).map(e=>({type:0===r?"tableHeader":"tableCell",content:[{type:"paragraph",content:Ce(e.children??[],t)}]}))}))}))(e,t);case"leafDirective":return"status"===e.name?(e=>{const t=Ne((e.attributes??{}).color)??"neutral";return{type:"paragraph",content:[{type:"status",attrs:{text:Ae(e)||"Status",color:t}}]}})(e):"panel"===e.name?((e,t)=>{const r=e.attributes??{},n=Oe(r.type)??"info",s="string"==typeof r.title?r.title:void 0;return{type:"panel",attrs:{panelType:n,...s?{title:s}:{}},content:[{type:"paragraph",content:Ce([{type:"text",value:Ae(e)}],t)}]}})(e,t):Me(e,t);default:return Me(e,t)}}function Me(e,t){if("drop"===t.unknownNodeStrategy)return null;const r=$e(e);return r?{type:"paragraph",content:[{type:"text",text:r}]}:null}function Le(e,t,r){const n=Number.isFinite(e)?Math.trunc(e):t;return Math.max(t,Math.min(r,n))}const Fe={resolveMention:void 0,resolveAttachment:void 0,resolveEmoji:void 0,enableSmartCards:!0,enableMermaid:!0,enableEmojiShortcodes:!0,enableAtMentions:!0,enableTaskLists:!0,unknownNodeStrategy:"text"};function Be(e,t={}){const r={...Fe,...t},n=e??"",s=m.unified().use(g).use(f).use(h),i=s.parse(n),o=s.runSync(i);return Ue(o),((e,t)=>{const r=[];for(const n of e.children??[]){const e=Re(n,t);e&&(Array.isArray(e)?r.push(...e):r.push(e))}return((e,t)=>{if(!t.enableSmartCards)return e;const r=e.content.map(e=>(e=>{if("paragraph"!==e.type)return e;const t=e.content??[];if(1!==t.length)return e;const r=t[0];if("inlineCard"!==r?.type)return e;const n=r.attrs?.url;return n?[{type:"blockCard",attrs:{url:n}}]:e})(e)).flat();return{...e,content:r}})({version:1,type:"doc",content:r},t)})(o,r)}function Ue(e){if(!e||!Array.isArray(e.children))return;const t=[];for(const r of e.children)"definition"!==r?.type&&("html"!==r?.type?(Ue(r),t.push(r)):t.push({type:"text",value:(r.value??"")+""}));e.children=t}const We=i.z.object({issueId:i.z.string().min(1),transitionId:i.z.union([i.z.string(),i.z.number()]),fields:i.z.record(i.z.any()).optional(),update:i.z.record(i.z.array(i.z.object({set:i.z.any().optional(),add:i.z.any().optional(),remove:i.z.any().optional()}))).optional(),comment:i.z.string().optional()}),Ke={name:"jira-issue-transition",inputSchema:We,runTool:async(e,t)=>{try{const r=We.parse(t),n={id:r.transitionId};r.fields&&(n.fields=r.fields),r.update&&(n.update=r.update),r.comment&&(n.comment={body:Be(r.comment)});const s=await e.issues.transition({issueId:r.issueId,transition:n});return be(s?.data??s)}catch(e){throw ge(e)}}},Ye=i.z.object({issueId:i.z.string().min(1),fields:i.z.record(i.z.any()).optional(),update:i.z.record(i.z.array(i.z.object({set:i.z.any().optional(),add:i.z.any().optional(),remove:i.z.any().optional(),edit:i.z.any().optional()}))).optional(),properties:i.z.array(i.z.any()).optional(),notifyUsers:i.z.boolean().optional().default(!0),issueTemplateId:i.z.string().optional(),overrideScreenSecurity:i.z.boolean().optional().default(!1),overrideEditableFlag:i.z.boolean().optional().default(!1)}),Ve={name:"jira-issue-update",inputSchema:Ye,runTool:async(e,t)=>{try{const r=Ye.parse(t),n={issueId:r.issueId};r.fields&&(n.fields=r.fields),r.update&&(n.update=r.update),r.properties&&(n.properties=r.properties),void 0!==r.notifyUsers&&(n.notifyUsers=r.notifyUsers),r.issueTemplateId&&(n.issueTemplateId=r.issueTemplateId),void 0!==r.overrideScreenSecurity&&(n.overrideScreenSecurity=r.overrideScreenSecurity),void 0!==r.overrideEditableFlag&&(n.overrideEditableFlag=r.overrideEditableFlag);const s=await e.issues.update(n);return be(s?.data??s)}catch(e){throw ge(e)}}},Ge=i.z.object({issueId:i.z.string().min(1),assignee:i.z.union([i.z.string(),i.z.object({accountId:i.z.string().min(1)}),i.z.object({accountType:i.z.string().min(1)})])}),Ze={name:"jira-assign-issue",inputSchema:Ge,runTool:async(e,t)=>{try{const r=Ge.parse(t);let n;n="string"==typeof r.assignee?{accountId:r.assignee}:r.assignee;const s=await e.issues.assign({issueId:r.issueId,assignee:n});return be(s?.data??s)}catch(e){throw ge(e)}}},Qe=i.z.object({issueId:i.z.string().min(1)}),Xe={name:"jira-unassign-issue",inputSchema:Qe,runTool:async(e,t)=>{try{const r=Qe.parse(t),n=await e.issues.assign({issueId:r.issueId,assignee:{accountId:"-1"}});return be(n?.data??n)}catch(e){throw ge(e)}}},et=i.z.object({issueId:i.z.string().min(1),body:i.z.string().min(1),visibility:i.z.object({type:i.z.enum(["role","group"]),value:i.z.string().min(1)}).optional()}),tt={name:"jira-comment-add",inputSchema:et,runTool:async(e,t)=>{try{const r=et.parse(t),n={body:Be(r.body)};r.visibility&&(n.visibility=r.visibility);const s=await e.issues.addComment({issueId:r.issueId,comment:n});return be(s?.data??s)}catch(e){throw ge(e)}}},rt=i.z.object({issueId:i.z.string().min(1),start:i.z.number().optional().default(0),maxResults:i.z.number().optional().default(50),orderBy:i.z.string().optional(),expand:i.z.string().optional()}),nt={name:"jira-comment-list",inputSchema:rt,runTool:async(e,t)=>{try{const r=rt.parse(t),n=await e.issues.getComments({issueId:r.issueId,start:r.start,maxResults:r.maxResults,orderBy:r.orderBy,expand:r.expand});return be(n?.data??n)}catch(e){throw ge(e)}}},st=i.z.object({link:i.z.object({relationship:i.z.enum(["Blocks","Relates to","Duplicates","Is blocked by","Is related to","Is duplicated by","Causes","Is caused by","Clone","Required","Work on","Split","Roll up"]),inwardIssue:i.z.object({id:i.z.string().optional(),key:i.z.string().optional()}),outwardIssue:i.z.object({id:i.z.string().optional(),key:i.z.string().optional()}),comment:i.z.object({body:i.z.string().optional(),visibility:i.z.object({type:i.z.enum(["role","group"]),value:i.z.string().min(1)}).optional()}).optional()})}),it={name:"jira-link-create",inputSchema:st,runTool:async(e,t)=>{try{const r=st.parse(t).link,n={relationship:r.relationship,inwardIssue:r.inwardIssue.id||r.inwardIssue.key,outwardIssue:r.outwardIssue.id||r.outwardIssue.key};r.comment&&(r.comment.body&&(n.comment=Be(r.comment.body)),r.comment.visibility&&(n.visibility=r.comment.visibility));const s=await e.issues.link(n);return be(s?.data??s)}catch(e){throw ge(e)}}},ot=i.z.object({issueId:i.z.string().min(1),file:i.z.string().min(1),mimeType:i.z.string().optional(),comment:i.z.string().optional()}),at={name:"jira-attach",inputSchema:ot,runTool:async(e,r)=>{try{const n=ot.parse(r),s=c.resolve(n.file),i=await t.promises.readFile(s),o=c.basename(s),a=await e.issues.addAttachment({issueId:n.issueId,file:{name:o,content:i,mimeType:n.mimeType??"application/octet-stream"},comment:n.comment});return be(a?.data??a)}catch(e){if(e&&e.code&&"string"==typeof e.code&&["ENOENT","EACCES"].includes(e.code))throw Error("Attachment file error: "+e.message);throw ge(e)}}},ct=i.z.object({issueId:i.z.string().min(1)}),lt={name:"jira-attachment-list",inputSchema:ct,runTool:async(e,t)=>{try{const r=ct.parse(t),n=await e.issues.getAttachments({issueId:r.issueId});return be(n?.data??n)}catch(e){throw ge(e)}}},pt=i.z.object({issueId:i.z.string().min(1),attachmentId:i.z.string().min(1)}),ut={name:"jira-attachment-delete",inputSchema:pt,runTool:async(e,t)=>{try{const r=pt.parse(t);return await e.issues.deleteAttachment({issueId:r.issueId,attachmentId:r.attachmentId}),be({success:!0,message:`Attachment ${t.attachmentId} deleted successfully`})}catch(e){throw ge(e)}}},dt=i.z.object({issueId:i.z.string().min(1),timeSpent:i.z.string().min(1),comment:i.z.string().optional(),author:i.z.object({accountId:i.z.string().min(1)}).optional(),startingOn:i.z.string().optional(),artifact:i.z.string().optional()}),mt={name:"jira-worklog-add",inputSchema:dt,runTool:async(e,t)=>{try{const r=dt.parse(t),n={timeSpent:r.timeSpent};r.comment&&(n.comment=r.comment),r.author&&(n.author=r.author),r.startingOn&&(n.started=r.startingOn),r.artifact&&(n.artifact=r.artifact);const s=await e.issues.addWorklog({issueId:r.issueId,...n});return be(s?.data??s)}catch(e){throw ge(e)}}},ht={[_e.name]:{title:"Jira Issue Read",description:"Read a Jira issue with expandable fields and properties",annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},[xe.name]:{title:"Jira Issue List",description:"Search issues by summary, reference, parent, or JQL and list the matching tickets",annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},[Ve.name]:{title:"Jira Issue Update",description:"Update a Jira issue using fields, update ops, and property toggles",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[we.name]:{title:"Jira Issue Delete",description:"Delete a Jira issue and optionally remove its subtasks",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0}},[Ke.name]:{title:"Jira Issue Transition",description:"Transition a Jira issue while optionally adding a comment",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[Ze.name]:{title:"Jira Issue Assign",description:"Assign a Jira issue to a user or account",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[Xe.name]:{title:"Jira Issue Unassign",description:"Unassign the current owner from a Jira issue",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[tt.name]:{title:"Jira Comment Add",description:"Add a comment to a Jira issue with optional visibility",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[nt.name]:{title:"Jira Comment List",description:"List comments on a Jira issue with pagination support",annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},[it.name]:{title:"Jira Link Create",description:"Create an issue link relationship with optional comment",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[at.name]:{title:"Jira Attachment Add",description:"Attach a local file to a Jira issue",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[lt.name]:{title:"Jira Attachment List",description:"List attachments on a Jira issue",annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},[ut.name]:{title:"Jira Attachment Delete",description:"Delete an attachment from a Jira issue",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0}},[mt.name]:{title:"Jira Worklog Add",description:"Log time spent on a Jira issue",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}}};async function ft(e){const t=r.Logging.for(ft);let n,s=null;try{n=(()=>{let e;try{const t=require("jira.js");e=t?.Version3Client||t.default?.Version3Client||t.default||t}catch(e){throw Error("Unable to require 'jira.js' \u2014 ensure it is installed as a dependency: "+e)}const{host:t,email:r,apiKey:n}=(()=>{const e=de(),t=me().filter(e=>e.required&&!e.value);if(t.length>0)throw new fe(t);return{host:e.host,email:e.email,apiKey:e.apiKey}})();return new e({host:t.startsWith("http://")||t.startsWith("https://")?t:"https://"+t,authentication:{basic:{email:r,apiToken:n}}})})()}catch(e){if(!(e instanceof fe))return void t.warn("Skipping Jira tool registration; unable to create Jira client",{error:e});s=e,t.warn("Registering Jira tools without credentials; each tool will report configuration requirements.",{error:e})}const i=[_e,xe,Ve,we,Ke,Ze,Xe,tt,nt,it,at,lt,ut,mt];for(const r of i){const i=ht[r.name];if(i)try{await e.registerTool(r.name,{title:i.title,description:i.description,inputSchema:q(r.inputSchema),annotations:i.annotations},async e=>{if(!n)throw s??Error("Jira client unavailable because credentials could not be loaded.");return r.runTool(n,e)}),t.info("Registered Jira tool "+r.name)}catch(e){t.error("Failed to register Jira tool "+r.name,{error:e})}}}async function gt(e){await(async e=>{e.registerTool("decaf-server-info",{title:"Decaf MCP Server Info",description:"Return server metadata, version, and registered prompt names for diagnostics.",inputSchema:{},outputSchema:void 0,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async()=>{const e=ne.map(e=>e.getName()).sort();return{content:[{type:"text",text:["Name: "+ue.name,"Title: "+ue.title,"Version: "+ue.version,"Prompts: "+(e.join(", ")||"<none>")].join("\n")}]}})})(e);const t=r.Logging.for(gt);try{await ft(e)}catch(e){t.error("Failed to register Jira tools",e)}}class yt extends N{setCb(e){return this.cb=e,this}setConfig(e){return this.config=e,this}setUriOtTemplate(e){return this.uriOrTemplate=e,this}constructor(e){super(e)}static get builder(){return new yt}build(e){const t=this.hasErrors();if(t)throw Error(t.toString());try{const t="string"==typeof this.uriOrTemplate&&this.uriOrTemplate.includes("{")?new b.ResourceTemplate(new y.UriTemplate(this.uriOrTemplate),{list:void 0}):this.uriOrTemplate,r=Object.assign(this.config,{_meta:{}}),n=async(e,t)=>{const r=this.logFor(t);r.verbose(`Requesting resource ${this.name} from ${e.toString()}`);const n=await Promise.resolve(this.cb(e,t));return r.verbose(`Resource ${this.name} retrieved successfully.`),r.debug("Resource retrieval meta: "+JSON.stringify(n._meta)),n};return e.resource(this.name,t,r,n)}catch(e){throw r.Logging.for(this).error("Error registering resource "+this.name,e),e}}}n.__decorate([s.required(),n.__metadata("design:type",String)],yt.prototype,"uriOrTemplate",void 0),n.__decorate([s.required(),n.__metadata("design:type",Function)],yt.prototype,"cb",void 0),n.__decorate([s.required(),n.__metadata("design:type",Object)],yt.prototype,"config",void 0);const bt=W()??I.join(__dirname,"..","assets"),vt=I.join(bt,"templates"),wt=I.join(bt,"prompts"),jt=new WeakMap;class St extends r.LoggedClass{get client(){const e=jt.get(this);if(!e)throw Error("Mcp server requires Mcp client");return e}constructor(){super()}async load(){const e=this.log.for(this.load);for(const t of ne)try{e.info("loading prompt "+t.getName());const r=t.build(this.client);e.verbose(`Loaded prompt ${r.title} from ${t.getName()} definition`)}catch(r){e.error("Failed to load prompt "+t.getName(),r)}try{await gt(this.client),e.verbose("Registered built-in tools")}catch(e){}try{await(async(e,t)=>{t.info("Registering agent templates as resources...");const r=x.readdirSync(vt).filter(e=>e.endsWith(".md"));for(const n of r){const r=I.basename(n,".md"),s=I.join(vt,n),i=yt.builder.setName(r).setTitle("Template: "+r).setDescription("Resource template for "+r).setUriOtTemplate("file:///"+s).setConfig({mimeType:"text/markdown",description:"Template for "+r}).setCb(async e=>{const t=x.readFileSync(e.pathname,"utf8");return{contents:[{uri:e.toString(),text:t,mimeType:"text/markdown"}],_meta:{}}});try{i.build(e),t.info("Registered template: "+r)}catch(e){t.error(`Failed to register template ${r}:`,e)}}t.info("Registering agent prompts...");const n=x.readdirSync(wt).filter(e=>e.endsWith(".md"));for(const r of n){const n=I.basename(r,".md"),s=I.join(wt,r),o=x.readFileSync(s,"utf8"),a=Y.builder.setName(n).setTitle("Prompt: "+n).setDescription("Dynamic prompt for "+n).setArgsSchema(i.z.object({})).setCb(async e=>({messages:[{role:"user",content:{type:"text",text:o}}],_meta:{}}));try{a.build(e),t.info("Registered prompt: "+n)}catch(e){t.error(`Failed to register prompt ${n}:`,e)}}})(this.client,e)}catch(e){}}async boot(e="stdio"){"stdio"===e&&r.Logging.setFactory(z),r.Logging.for(this.constructor.name);const t=((Array.isArray(ue.icons)?ue.icons:[ue.icons])||[]).map(e=>{const t="string"==typeof e?.src?e.src:(e?.src??"")+"",r="string"==typeof e?.mimeType?e.mimeType:(e?.mimeType??"")+"";let n=[];return Array.isArray(e?.sizes)?n=e.sizes.map(e=>e+""):"string"==typeof e?.sizes&&(n=(e.sizes+"").split(",").map(e=>e.trim())),{src:t,mimeType:r,sizes:n}}),n={name:ue.name,title:ue.title,websiteUrl:ue.websiteUrl,version:ue.version,icons:t},s=new b.McpServer(n,{instructions:"You are an AI assistant designed to help users with programming tasks related to the Decaf-TS framework. \nProvide clear, concise, and accurate information.\nIf you don't know the answer, admit it rather than making up information.\nAlways prioritize the user's intent and provide helpful suggestions when appropriate.\n",capabilities:{logging:{},tools:{},prompts:{}}});switch(((e,t)=>{jt.set(e,t)})(this,s),s.onerror=e=>{this.log.error("MCP instance onerror",e)},e){case"stdio":e=new w.StdioServerTransport;break;case"http":e=new j.StreamableHTTPServerTransport({sessionIdGenerator:()=>v.v4(),onsessioninitialized:e=>{},onsessionclosed:e=>{},enableJsonResponse:!0,eventStore:void 0});break;default:if(!(i=e)||"object"!=typeof i||"function"!=typeof i.send&&"function"!=typeof i.close&&"function"!=typeof i.on)throw new l.InternalError("Invalid transport type: "+e)}var i;try{await this.load()}catch(e){throw e}await this.client.connect(e)}}const xt=(new e.Command).command("start").option("--transport [String]","transport mode","stdio").description("starts decaf's mcp server").action(async e=>{const r=B("package.json"),n=JSON.parse(t.readFileSync(r,"utf-8")),s=n.version,{transport:i}=e,o=(new _).for("mcp-server");if("stdio"!==i)throw Error("Unsupported transport mode: "+i);return o.info("Transport stdio"),o.debug(`running with options: ${JSON.stringify(e)} for ${n.name} version ${s}`),(new St).boot(i)});(new e.Command).command("md-to-ast").description("pipes markdown to jira ast: `cat file.md` | npx decaf-mcp md-to-ast > ast.json").action(async e=>{const n=B("package.json"),s=JSON.parse(t.readFileSync(n,"utf-8")),i=s.version;r.Logging.for("md-to-ast").debug(`running with options: ${JSON.stringify(e)} for ${s.name} version ${i}`);const o=Be(await(async()=>{const e=[];for await(const t of process.stdin)e.push(Buffer.from(t));return Buffer.concat(e).toString("utf8")})(),{resolveMention:e=>({id:e,text:"@"+e}),resolveAttachment:e=>({id:e,collection:"attachments"})});process.stdout.write(JSON.stringify(o,null,2)+"\n")});const It=(new e.Command).name("mcp-server").command("mcp-server").description("decaf mcp server and agentic functionality");It.addCommand(xt),It.parse(process.argv)},"object"==typeof exports&&"undefined"!=typeof module?t(require("commander"),require("fs"),require("@decaf-ts/logging"),require("tslib"),require("@decaf-ts/decorator-validation"),require("zod"),require("@decaf-ts/injectable-decorators"),require("@decaf-ts/decoration"),require("path"),require("@decaf-ts/db-decorators"),require("crypto"),require("zlib"),require("url"),require("unified"),require("remark-directive"),require("remark-gfm"),require("remark-parse"),require("@modelcontextprotocol/sdk/shared/uriTemplate.js"),require("@modelcontextprotocol/sdk/server/mcp.js"),require("uuid"),require("@modelcontextprotocol/sdk/server/stdio.js"),require("@modelcontextprotocol/sdk/server/streamableHttp.js")):"function"==typeof define&&define.amd?define(["commander","fs","@decaf-ts/logging","tslib","@decaf-ts/decorator-validation","zod","@decaf-ts/injectable-decorators","@decaf-ts/decoration","path","@decaf-ts/db-decorators","crypto","zlib","url","unified","remark-directive","remark-gfm","remark-parse","@modelcontextprotocol/sdk/shared/uriTemplate.js","@modelcontextprotocol/sdk/server/mcp.js","uuid","@modelcontextprotocol/sdk/server/stdio.js","@modelcontextprotocol/sdk/server/streamableHttp.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).commander,e.fs,e.decafTsLogging,e.tslib,e.decafTsDecoratorValidation,e.zod,e.decafTsInjectableDecorators,e.decafTsDecoration,e.path,e.decafTsDbDecorators,e.crypto,e.zlib,e.url,e.unified,e.remarkDirective,e.remarkGfm,e.remarkParse,e.uriTemplate_js,e.mcp_js,e.uuid,e.stdio_js,e.streamableHttp_js);
|
|
2
|
+
var e,t;e=this,t=function(e,t,r,n,s,i,o,a,c,l,p,u,d,m,h,f,g,y,b,v,w,j,S){"use strict";function x(e){var t=Object.create(null);return e&&Object.keys(e).forEach(r=>{if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}),t.default=e,Object.freeze(t)}var I=x(t),_=x(c);class z extends r.MiniLogger{constructor(e,t,r){super(e,t,r)}log(e,t,n,s){const i=this.config("level");r.NumericLogLevels[i],r.NumericLogLevels[e]}}const k=(e,t,...r)=>{const n=(e=>{if("string"==typeof e)return e;if(!e)return"unknown";if("function"==typeof e)return e.name||"unknown";if("object"==typeof e&&"constructor"in e){const t=e.constructor;if(t&&t.name)return t.name}return"unknown"})(e);return new z(n,t)};var E,T,A,O,N;(e=>{e[e.NONE=0]="NONE",e[e.BASIC=1]="BASIC",e[e.ADVANCED=2]="ADVANCED",e[e.HIGH=3]="HIGH"})(E||(E={})),(e=>{e[e.NONE=0]="NONE",e[e.LOW=1]="LOW",e[e.MEDIUM=2]="MEDIUM",e[e.HIGH=3]="HIGH"})(T||(T={})),(e=>{e[e.FREE=0]="FREE",e[e.LOW=1]="LOW",e[e.MEDIUM=2]="MEDIUM",e[e.HIGH=3]="HIGH"})(A||(A={}));class C extends s.Model{get log(){return this._log||(this._log=r.Logging.for(this)),this._log}constructor(e){super(e)}logFor(e){const{sessionId:t,requestId:r,authInfo:n}=e||{};let s="string"==typeof t&&t.length>0?this.log.for(t):this.log;return n&&n.clientId&&(s=s.for(n.clientId)),r&&(s=s.for(r.toString())),s}setDescription(e){return this.description=e,this}getDescription(){return this.description}setName(e){return this.name=e,this}getName(){return this.name}setTitle(e){return this.title=e,this}}n.__decorate([s.required(),n.__metadata("design:type",String)],C.prototype,"description",void 0),n.__decorate([s.required(),n.__metadata("design:type",String)],C.prototype,"name",void 0),n.__decorate([s.required(),n.__metadata("design:type",String)],C.prototype,"title",void 0);class H extends C{constructor(e){super(e),this.reasoning=E.NONE,this.effort=T.NONE,this.cost=A.FREE}setReasoning(e){return this.reasoning=e,this}setEffort(e){return this.effort=e,this}setCost(e){return this.cost=e,this}}function q(e){if(!e)return;let t=e,r=t&&t._def;for(;r&&"ZodObject"!==r.typeName;){if("ZodEffects"===r.typeName&&r.schema)t=r.schema;else if("ZodOptional"===r.typeName&&r.innerType)t=r.innerType;else if("ZodDefault"===r.typeName&&r.innerType)t=r.innerType;else if("ZodNullable"===r.typeName&&r.innerType)t=r.innerType;else{if(!r.schema)return;t=r.schema}r=t&&t._def}return r&&"ZodObject"===r.typeName?r:void 0}function J(e,t="schema"){if(q(e))return e;if(e&&"object"==typeof e){const t=e.def&&"object"==typeof e.def?e.def:void 0,r=t&&(t.shape||"object"===t.type)&&t.shape||("object"===e.type?e.shape:void 0)||(t&&"object"===t.type?{}:void 0);if(t||"object"===e.type||r){const e={};if(r&&"object"==typeof r)for(const[t,n]of Object.entries(r))e[t]=P(n)?n:i.z.any();return i.z.object(e)}}throw Error(`Registration error: provided a non-canonical ${t}. Export a ZodObject (z.object(...)).`)}function D(e){if(!e)return;if(e&&"object"==typeof e&&!e._def)return e.def&&"object"==typeof e.def&&e.def.shape?e.def.shape:e;const t=q(e);return t?"function"==typeof t.shape?t.shape():t.shape||void 0:void 0}function P(e){return!(!e||"object"!=typeof e||!e._def)}n.__decorate([s.required(),n.__metadata("design:type",Number)],H.prototype,"reasoning",void 0),n.__decorate([s.required(),n.__metadata("design:type",Number)],H.prototype,"effort",void 0),n.__decorate([s.required(),n.__metadata("design:type",Number)],H.prototype,"cost",void 0),(e=>{e.ASSETS="assets"})(O||(O={})),(e=>{e.PROMPT="prompts",e.DOCUMENTATION="documentation",e.CODE="code"})(N||(N={}));const $=Buffer.from("DCAF1","ascii");function R(e){let r=c.resolve(e);for(;;){if(t.existsSync(c.join(r,"package.json")))return r;const e=c.dirname(r);if(e===r)break;r=e}}const M=process.argv?.[1]?R(c.dirname(c.resolve(process.argv[1]))):void 0,L=(()=>{const e=Error().stack;if(!e)return;const t=e.split(/\r?\n/).slice(1);for(const e of t){const t=e.match(/\(?([^()]+?):\d+:\d+\)?/);if(!t)continue;let r=t[1];if(r.startsWith("file://"))try{r=d.fileURLToPath(r)}catch{continue}if(!r.includes("node:internal"))return c.dirname(r)}})(),F=L?R(L):void 0,B=M??F??process.cwd();function U(...e){return c.join(B,...e)}function W(e){let t=e;for(;;){const e=_.join(t,"lib","assets");if(I.existsSync(e))return e;const r=_.join(t,"src","assets");if(I.existsSync(r))return r;const n=_.join(t,"assets");if(I.existsSync(n))return n;const s=_.dirname(t);if(s===t)break;t=s}}function K(){const e=process.env.DECAF_ASSET_DIR||process.env.MCP_ASSET_DIR||process.env.ASSET_DIR||"";if(e&&I.existsSync(e))return e;const t=W(__dirname);if(t)return t;const r=process.argv?.[1];if(r){const e=W(_.dirname(r));if(e)return e}const n=[B,process.env.INIT_CWD].filter(Boolean);for(const e of n){const t=W(e);if(t)return t}return U("assets")}let Y=class extends r.LoggedClass{constructor(e){super(),this.basePath=e||K()}listAssets(...e){const t=_.join(this.basePath,...e);return I.readdirSync(t)}listPrompts(){return this.listAssets(N.PROMPT)}getAsset(e,t="md",...r){const n=_.join(this.basePath,...r),s=(e,t=!1)=>{try{return t?(e=>{if(e.length<$.length+16+12+16)throw Error("Invalid prompt payload (too short)");if(!e.subarray(0,$.length).equals($))throw Error("Invalid prompt payload (bad magic)");const t=process.env.ENCRYPTION_KEY||"";if(!t)throw Error("Missing encryption key. Set ENCRYPTION_KEY to load obfuscated assets.");let r=$.length;const n=e.subarray(r,r+16);r+=16;const s=e.subarray(r,r+12);r+=12;const i=e.subarray(r,r+16);r+=16;const o=e.subarray(r),a=((e,t)=>p.scryptSync(e,t,32))(t,n),c=p.createDecipheriv("aes-256-gcm",a,s);c.setAuthTag(i);const l=Buffer.concat([c.update(o),c.final()]);return u.gunzipSync(l)})(I.readFileSync(e)).toString("utf-8"):I.readFileSync(e,"utf-8")}catch(e){if("ENOENT"===e.code)return null;throw e}},i=s(_.join(n,`${e}.${t}`),"enc"===t);if(null!==i)return i;const o=s(_.join(n,e+".enc"),!0);if(null!==o)return o;throw Error("Asset not found: "+_.join(n,`${e}.${t}`))}getAllAssets(e,...t){return this.listAssets(e,...t).reduce((r,n)=>{const s=_.extname(n),i=_.basename(n,s),o=s.replace(/^\./,"")||void 0;return r[i]=this.getAsset(i,o??void 0,e,...t),r},{})}toPromptDef(e){const t=e=>"number"==typeof e?e:"string"==typeof e?(e=>{switch(e){case"none":return E.NONE;case"basic":return E.BASIC;case"advanced":return E.ADVANCED;case"high":return E.HIGH;case"medium":return T.MEDIUM;case"low":return A.LOW;case"free":return A.FREE;default:throw new l.InternalError("Cannon convert unknown level "+e)}})(e.toLowerCase()):E.NONE;return e.effort=t(e.effort),e.reasoning=t(e.reasoning),e.cost=t(e.cost),e}getPrompt(e,...t){const n=this.getAsset(r.toSnakeCase(e),"json",N.PROMPT,...t);let s;try{s=JSON.parse(n)}catch(r){throw new l.SerializationError(`Failed to parse prompt ${e} in categories ${t}: ${r}`)}return this.toPromptDef(s)}getAllPrompts(...e){const t=this.getAllAssets(N.PROMPT,...e);return Object.entries(t).reduce((t,[r,n])=>{try{t[r]=JSON.parse(n)}catch(t){throw new l.SerializationError(`Failed to parse prompt ${r} in categories ${e}: ${t}`)}return t},t)}};Y=n.__decorate([o.injectable(),n.__metadata("design:paramtypes",[String])],Y);class V extends H{constructor(e){super(e)}setCb(e){return this.cb=e,this}setArgsSchema(e){return this.argsSchema=e,this}static get builder(){return new V}static patchPrompt(e,t,n,s){const i=(t=Array.isArray(t)?t:Object.keys(t)).filter(e=>!Object.prototype.hasOwnProperty.call(n,e));if(i.length)throw new l.ValidationError("Missing replacements for placeholders: "+i.join(", "));s&&(s.verbose("Patching prompt with placeholders: "+JSON.stringify(t)),s.debug("Values: "+JSON.stringify(n)));const o=t.reduce((e,t)=>(e[t]=n[t],e),{});return r.sf(e,o)}patchPrompt(e,t,r,n){return V.patchPrompt(e,t,r,n||this.log.for(this.patchPrompt))}build(e,t){const r=this.log.for(this.build),n=this.hasErrors();if(n)throw new l.ValidationError(n.toString());try{this.argsSchema&&J(this.argsSchema,"argsSchema");const r=D(this.argsSchema);return e.registerPrompt(this.name,{title:this.title,description:this.description,argsSchema:r},async(e,r)=>{const n=this.logFor(r);e=Object.assign({},t,e||{}),n.verbose(`Executing prompt ${this.name} with args: ${JSON.stringify(e)}`),e._meta=Object.assign(e._meta||{},{usage:{reasoning:this.reasoning,effort:this.effort,cost:this.cost}});const s=await Promise.resolve(this.cb(e,r));return n.verbose(`Prompt ${this.name} executed successfully.`),n.debug("Prompt execution meta: "+JSON.stringify(s._meta)),s})}catch(e){throw r.error("Failed to register prompt "+(this.name||this.constructor.name),e),e}}}n.__decorate([o.inject(Y),n.__metadata("design:type",Y)],V.prototype,"assets",void 0),n.__decorate([s.required(),n.__metadata("design:type",Object)],V.prototype,"cb",void 0),n.__decorate([s.required(),n.__metadata("design:type",i.ZodObject)],V.prototype,"argsSchema",void 0),n.__decorate([a.prop(),n.__metadata("design:type",Object)],V.prototype,"placeholders",void 0);class G extends V{setCategory(e){return this.promptCategory=e,this}addPrefix(e){return this.prefixes=this.prefixes||[],this.prefixes.push(e),this}addSuffix(e){return this.suffixes=this.suffixes||[],this.suffixes.push(e),this}constructor(e){super(e)}build(e){const t=this.assets.getPrompt(this.name,this.promptCategory);s.Model.fromObject(this,t);const r=new Set((a.Metadata.properties(G)||[]).filter(e=>!["assets","promptCategory","prefixes","suffixes"].includes(e)));["cb","argsSchema"].forEach(e=>r.add(e));const n=this.hasErrors(...Array.from(r));if(n)throw new l.ValidationError(n.toString());const o=(this.prefixes||[]).map(e=>this.assets.getPrompt(e,this.promptCategory)),c=(this.suffixes||[]).map(e=>this.assets.getPrompt(e,this.promptCategory)),p=[...new Set([...t.placeholders,...o.map(e=>e.placeholders||[]),...c.map(e=>e.placeholders||[])].flat())].reduce((e,t)=>(e[t]=i.z.string().describe("The description for "+t),e),{});return this.setArgsSchema(i.z.object(p)),this.setCb((e,t)=>{const r=this.logFor(t).for(G).for(this.promptCategory).for(this.name);function n(e=[]){return Array.isArray(e)?e:Object.keys(e)}const s=(this.prefixes||[]).map(e=>this.assets.getPrompt(e,this.promptCategory)),i=(this.suffixes||[]).map(e=>this.assets.getPrompt(e,this.promptCategory)),o=this.assets.getPrompt(this.name,this.promptCategory),a=[...new Set([...s.map(e=>n(e.placeholders)).flat(),...i.map(e=>n(e.placeholders)).flat(),...n(o.placeholders).flat()])];return{messages:[{role:"user",content:{type:"text",text:this.patchPrompt([...s.map(e=>e.prompt),o.prompt,...i.map(e=>e.prompt)].join("\n\n"),a,e,r)}}],_meta:{}}}),super.build(e)}setReasoning(e){throw new l.InternalError("Named prompt builders don't require callback")}setEffort(e){throw new l.InternalError("Named prompt builders don't require callback")}setCost(e){throw new l.InternalError("Named prompt builders don't require callback")}setDescription(e){throw new l.InternalError("Named prompt builders don't require callback")}setTitle(e){throw new l.InternalError("Named prompt builders don't require callback")}static get builder(){return new G}}n.__decorate([s.required(),n.__metadata("design:type",String)],G.prototype,"promptCategory",void 0),n.__decorate([s.list(String),s.minlength(1),n.__metadata("design:type",Array)],G.prototype,"prefixes",void 0),n.__decorate([s.minlength(1),s.list(String),n.__metadata("design:type",Array)],G.prototype,"suffixes",void 0);const Z=V.builder.setName("example-prompt").setTitle("Example prompt").setDescription("Example prompt for testing").setArgsSchema(i.z.object({message:i.z.string().optional()})).setCb(async e=>{const t=e.message??"default";return{messages:[{role:"assistant",content:{type:"text",text:t}}],content:[],structuredContent:{message:t},result:{message:t}}}),Q=V.builder.setName("interactive-jsdoc").setTitle("Interactive JSDoc prompt").setDescription("Interactive prompt for jogging JSDoc helpers").setArgsSchema(i.z.object({gist:i.z.string().optional()})).setCb(async e=>{const t=e.gist??"interactive jsdoc response";return{messages:[{role:"assistant",content:{type:"text",text:t}}],content:[],structuredContent:{message:t},result:{message:t}}}),X=Object.assign(Q,{name:Q.getName()});var ee;function te(e,t=[],r=[]){const n=G.builder.setCategory(ee.DOCS).setName(e);return["prefix",...t].forEach(e=>n.addPrefix(e)),["suffix",...r].forEach(e=>n.addSuffix(e)),n}(e=>{e.DOCS="documentation",e.CODE="code"})(ee||(ee={}));const re=[te("class"),te("constant"),te("decorator"),te("function"),te("module"),te("file"),te("repo",[],["iterate"])],ne=i.z.object({className:i.z.string().describe("the class name to turn into a builder")}),se=[Z,X,...re,V.builder.setName("ts-code-dp-builder").setTitle("Typescript builder design patter prompt").setDescription("for a class, with a defined set of properties, scafold a builder design pattern").setArgsSchema(ne).setReasoning(E.BASIC).setCb((e,t)=>(e.className=r.toPascalCase(e.className),{messages:[{role:"user",content:{type:"text",text:`You're a senior TypeScript developer writing typescript code.You're a senior TypeScript developer writing typescript code.\nTransform the selected class into a builder design pattern implementation in Typescript.\nuse @decaf-ts validation decorators to enforce the validation of your builder.\n\n- must extend the Model Class from @decaf-ts/decorator-validation;\n- each property must be marked as protected;\n- each property must have a setter method that returns 'this' for chaining;\n- the build() method must validate the properties using hasErrors() method from Model class;\n- if validation fails, throw an error with the validation errors;\n- if validation passes, return an instance of the original class with the set properties;\n- optionally (but do so by default) add the static builder and from methods from the example;\n- if the clasee already follows the pattern but has properties without decoration or without setters, simple add them;\n\nexample:\n\noriginal class:\n\`\`\`typescript\nexport class ${e.className} {\n description!: string;\n name!: string = "default name";\n title!: string;\n age?: string;\n dateOfBirth!: Date;\n}}\n\`\`\` \n\nresulting builder pattern implementation:\n\`\`\`typescript\nexport class ${e.className}Builder extends Model {\n\n @minlength(10\n @required()\n protected description!: string;\n \n @required()\n protected name!: string = "default value;\n \n @required()\n protected title!: string;\n \n @min(18)\n protected age?: string;\n \n @date()\n protected dateOfBirth!: Date;\n\n protected constructor(arg?: ModelArg<${e.className}Builder>>) {\n super(arg);\n Model.fromModel(this, arg);\n }\n\n setDescription(value: string) {\n this.description = value;\n return this;\n }\n\n setName(value: string) {\n this.name = value;\n return this;\n }\n\n setTitle(value: string) {\n this.title = value;\n return this;\n }\n setAge(value: number) {\n this.age = value;\n return this;\n }\n setDate(value: Date) {\n this.age = value;\n return this;\n }\n \n build(...args: any[]): ${e.className}Builder | Promise<${e.className}Builder> {\n const errs = this.hasErrors();\n if (errs) throw new Error(errs.toString());\n \n return // code that builds OBJ here\n }\n \n static get builder(): ${e.className}Builder {\n return new ${e.className}Builder(); // static method to get a new builder instance\n }\n \n static from<K extends keyof ${e.className}Builder>(obj: K, ${e.className}Builder[K]): ${e.className}Builder {\n return new ${e.className}Builder(); // static method to create a builder from an object\n }\n}\n\`\`\` \n\n`}}],_meta:{}}))];class ie extends H{setAnnotations(e){return this.annotations=Object.assign(this.annotations,e),this}setCb(e){return this.cb=e,this}setInputSchema(e){return this.inputSchema=e,this}setOutputSchema(e){return this.outputSchema=e,this}constructor(e){super(e),this.annotations={readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}static get builder(){return new ie}build(e){const t=this.hasErrors();if(t)throw Error(t.toString());try{this.inputSchema&&J(this.inputSchema,"inputSchema"),this.outputSchema&&J(this.outputSchema,"outputSchema");const t=D(this.inputSchema),r=D(this.outputSchema);return e.registerTool(this.name,{title:this.title,description:this.description,inputSchema:t,outputSchema:r,annotations:this.annotations,_meta:{usage:{reasoning:this.reasoning,effort:this.effort,cost:this.cost}}},async(e,t)=>{const r=this.logFor(t);r.verbose(`Executing tool ${this.name} with args: ${JSON.stringify(e)}`),t._meta=Object.assign(t._meta||{},{usage:{reasoning:this.reasoning,effort:this.effort,cost:this.cost}});const n=await Promise.resolve(this.cb(e,t));return r.verbose(`Tool ${this.name} executed successfully.`),r.debug("Tool execution meta: "+JSON.stringify(n._meta)),n})}catch(e){const t=e?.message||e+"";if("string"==typeof t&&t.includes("already registered"))return r.Logging.for(this).warn(`Tool ${this.name} already registered - skipping duplicate registration`),{name:this.name};throw r.Logging.for(this).error("Error building tool",e),e}}}n.__decorate([s.required(),n.__metadata("design:type",Object)],ie.prototype,"annotations",void 0),n.__decorate([s.required(),n.__metadata("design:type",Object)],ie.prototype,"cb",void 0),n.__decorate([s.required(),n.__metadata("design:type",Function)],ie.prototype,"inputSchema",void 0);const oe=ie.builder.setName("example-tool").setTitle("Example tool").setDescription("A smoke tool used for quick testing").setInputSchema(i.z.object({})).setCb(async()=>({content:[{type:"text",text:"example tool ok"}],result:{status:"ok"}}));Object.assign(oe,{name:oe.getName()});const ae=ie.builder.setName("file-summarizer").setTitle("File summarizer").setDescription("Summaries files for quick previews").setInputSchema(i.z.object({filePath:i.z.string().optional()})).setCb(async()=>({content:[{type:"text",text:"file summary stub"}],result:{summary:"file summary stub"}}));function ce(){try{let e=process.argv[1]?c.dirname(c.resolve(process.argv[1])):process.cwd();for(;;){const r=c.join(e,"package.json");if(t.existsSync(r))return JSON.parse(t.readFileSync(r,"utf-8"));const n=c.dirname(e);if(n===e)break;e=n}}catch{}return{}}Object.assign(ae,{name:ae.getName()});const le=ce().version??"0.0.0",pe=ce().name??"unknown";a.Metadata.registerLibrary(pe,le);const ue={mcpId:"decaf",name:"decaf-ts mcp server",title:"Decaf-TS MCP Server",description:"Provides precise coding assistance for the decaf-ts framework",version:le,websiteUrl:"https://decaf-ts.github.io",repositoryUrl:"https://github.com/decaf-ts/mcp-server",license:"AGPL-3.0",workingDir:B,assetDir:K(),contacts:[{name:"Decaf-TS",url:"https://decaf-ts.github.io"}],tags:"server,official,decaf-ts",metadata:{},icons:[{src:"workdocs/assets/favicon.svg",mimeType:"image/svg+xml",sizes:"any"}],jira:{host:process.env.JIRA__HOST||"decaf-ts.atlassian.net",email:process.env.JIRA__EMAIL||"",apiKey:process.env.JIRA__API_KEY||process.env.JIRA__APIKEY||"",projectKey:process.env.JIRA__PROJECT_KEY||void 0,issueType:process.env.JIRA__ISSUE_TYPE||void 0,parentIssue:process.env.JIRA__PARENT_ISSUE||void 0},level:r.LogLevel.error},de=r.LoggedEnvironment.accumulate(ue);function me(){const{host:e,email:t,apiKey:r,projectKey:n,issueType:s}=de.jira;return{host:e?.trim(),email:t?.trim(),apiKey:r?.trim(),projectKey:n?.trim(),issueType:s?.trim(),parentIssue:de.jira.parentIssue?.trim()}}function he(){const e=me();return[{name:"JIRA__HOST",required:!0,description:"Atlassian host (e.g. decaf-ts.atlassian.net) where your Jira instance is hosted.",value:e.host},{name:"JIRA__EMAIL",required:!0,description:"Email address of the Jira account that has API access.",value:e.email},{name:"JIRA__API_KEY",required:!0,description:"API token created in your Atlassian profile (a.k.a. APIKEY alias) for authenticating requests.",sensitive:!0,value:e.apiKey},{name:"JIRA__PROJECT_KEY",required:!1,description:"Default Jira project key (e.g. DECAF) used when an issue creation request omits a project.",value:e.projectKey},{name:"JIRA__ISSUE_TYPE",required:!1,description:"Default Jira issue type (e.g. Task, Bug) used when creating issues without an explicit type.",value:e.issueType},{name:"JIRA__PARENT_ISSUE",required:!1,description:"Default parent issue key (e.g. DECAF-123) applied when a child issue is created without an explicit parent.",value:e.parentIssue}]}function fe(e){const t=e.value?((e,t)=>{if(e)return t?"<configured>":e})(e.value,e.sensitive):"not set",r=e.required?"(required)":"(optional)";return`\u2022 ${e.name} ${r}: ${e.description} Current state: ${t}.`}r.Logging.setConfig(de);class ge extends Error{constructor(e){const t=he(),r=(e=>{const t=he();return`${e.length?`Missing Jira credentials: ${e.map(e=>e.name).join(", ")}.`:"Jira credentials are configured."}\n\nThis setup uses the following environment variables:\n${t.map(fe).join("\n")}`})(e);super(r),this.name="MissingJiraEnvironmentError",this.descriptors=t,this.missing=e,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,ge)}}function ye(e){if(!e)return{code:"jira_error",message:"Unknown Jira error",details:{raw:e}};const t=e?.status??e?.statusCode??e?.response?.status??e?.response?.statusCode,r="number"==typeof t?t:Number(t)||void 0,n=e?.response?.data??e?.data??e?.response?.body??e?.body,s=[];"string"==typeof e?.message&&s.push(e.message),((e,t)=>{e&&(Array.isArray(e.errorMessages)&&e.errorMessages.forEach(e=>"string"==typeof e&&t.push(e)),"string"==typeof e.errorMessage&&t.push(e.errorMessage),e.errorCollection&&Array.isArray(e.errorCollection.errors)&&e.errorCollection.errors.forEach(e=>{"string"==typeof e?t.push(e):e&&"string"==typeof e.message&&t.push(e.message)}),e?.errors&&"object"==typeof e.errors&&Object.values(e.errors).forEach(e=>{"string"==typeof e?t.push(e):"string"==typeof e?.message&&t.push(e.message)}))})(n,s);const i=r?`Jira API error (${r})`:"Jira API error",o=s.length>0?s.join(" | "):i;return{code:r?"jira_"+r:e?.code??"jira_error",message:o,details:{httpStatus:r,body:n,raw:e}}}function be(e){if(!e||0>=Object.keys(e).length)return[];const t=(e=>{if(null==e)return"";try{return JSON.stringify(e,null,2)}catch{return m.inspect(e,{depth:null})}})(e);return t?[{type:"text",text:t}]:[]}function ve(e={},t=[]){return{content:t.length?t:be(e),result:e,structuredContent:e}}const we=i.z.object({issueId:i.z.string().min(1),deleteSubtasks:i.z.boolean().optional().default(!0)}),je={name:"jira-issue-delete",inputSchema:we,runTool:async(e,t)=>{try{const r=we.parse(t),n=e.issues??e.issue??e,s=n?.delete??n?.deleteIssue;if("function"!=typeof s)throw Error("jira client delete endpoint is not available");return await s.call(n,{issueId:r.issueId,deleteSubtasks:r.deleteSubtasks}),ve({success:!0,message:`Issue ${t.issueId} deleted successfully`})}catch(e){throw ye(e)}}},Se=i.z.object({projectKey:i.z.string().trim().min(1).optional(),issueType:i.z.string().trim().min(1).optional(),parentIssueId:i.z.string().trim().min(1).optional(),name:i.z.string().trim().min(1).optional(),reference:i.z.string().trim().min(1).optional(),jql:i.z.string().trim().min(1).optional(),startAt:i.z.number().int().min(0).optional(),maxResults:i.z.number().int().min(1).optional(),fields:i.z.array(i.z.string()).optional(),expand:i.z.string().optional(),orderBy:i.z.string().trim().min(1).optional()});function xe(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}const Ie={name:"jira-issue-list",inputSchema:Se,runTool:async(e,t)=>{try{const r=Se.parse(t),n=r.startAt??0,s=r.maxResults??50;let i=r.jql?.trim();if(i){if(r.orderBy){const e=r.orderBy.trim();e&&(i=/\border\s+by\b/i.test(i)?`${i}, ${e}`:`${i} ORDER BY ${e}`)}}else i=(e=>{const t=[];if(e.projectKey&&t.push(`project = "${xe(e.projectKey)}"`),e.issueType&&t.push(`issuetype = "${xe(e.issueType)}"`),e.parentIssueId&&t.push(`parent = "${xe(e.parentIssueId)}"`),e.name&&t.push(`summary ~ "${xe(e.name)}"`),e.reference){const r=xe(e.reference);t.push(`(key ~ "${r}" OR summary ~ "${r}" OR text ~ "${r}")`)}if(0===t.length){const e=Error("Provide a jql query or at least one filter (project, name, reference, parent, issue type, etc.).");throw e.code="validation_error",e}let r=t.join(" AND ");if(e.orderBy){const t=e.orderBy.trim();t&&(r=/\border\s+by\b/i.test(r)?`${r}, ${t}`:`${r} ORDER BY ${t}`)}return r})(r);const o={jql:i,startAt:n,maxResults:s};r.fields&&(o.fields=r.fields),r.expand&&(o.expand=r.expand);const a=e.issueSearch,c=a&&"function"==typeof a.searchForIssuesUsingJqlEnhancedSearch?a.searchForIssuesUsingJqlEnhancedSearch:a&&"function"==typeof a.searchForIssuesUsingJql?a.searchForIssuesUsingJql:void 0;if(!c)throw Error("Jira search API is unavailable on the client");const l=await c.call(a,o);return ve(l?.data??l)}catch(e){throw ye(e)}}},_e=i.z.object({issueId:i.z.string().min(1),expand:i.z.string().optional(),fields:i.z.array(i.z.string()).optional(),properties:i.z.array(i.z.string()).optional()}),ze={name:"jira-issue-read",inputSchema:_e,runTool:async(e,t)=>{try{const r=_e.parse(t),n={issueIdOrKey:r.issueId};r.expand&&(n.expand=r.expand),r.fields&&(n.fields=r.fields),r.properties&&(n.properties=r.properties);const s=await e.issues.get(n);return ve(s?.data??s)}catch(e){throw ye(e)}}};function ke(e,t,r){const n=((e.url??"")+"").match(/^(attachment|jira-attachment):(.+)$/i);if(!n)return null;const s=n[2],i=r.resolveAttachment?.(s);return i?{type:"block",node:{type:"mediaSingle",attrs:{layout:"center"},content:[{type:"media",attrs:{type:"file",id:i.id,collection:i.collection??"attachments"}}]}}:null}function Ee(e,t){if(!e)return[];if(!t.enableAtMentions&&!t.enableEmojiShortcodes)return[{type:"text",text:e}];let r=0;const n=[],s=/(^|[^A-Za-z0-9_])@([A-Za-z0-9._-]{1,64})/g,i=/:([a-z0-9_+-]{1,64}):/gi;for(;r<e.length;){const o=Ae(t.enableAtMentions?Te(s,e,r):null,t.enableEmojiShortcodes?Te(i,e,r):null);if(!o){n.push({type:"text",text:e.slice(r)});break}if(o.index>r&&n.push({type:"text",text:e.slice(r,o.index)}),"mention"===o.kind){const{full:e,groups:s}=o,i=s[0]??"",a=s[1]??"";i&&n.push({type:"text",text:i});const c=t.resolveMention?.(a);c?n.push({type:"mention",attrs:{id:c.id,text:c.text}}):n.push({type:"text",text:"@"+a}),r=o.index+e.length;continue}if("emoji"===o.kind){const{full:e,groups:s}=o,i=`:${s[0]}:`,a=t.resolveEmoji?.(i);n.push({type:"emoji",attrs:a?{shortName:a.shortName,text:a.text}:{shortName:i}}),r=o.index+e.length;continue}}return(e=>{const t=[];for(const r of e){const e=t[t.length-1];"text"!==r.type||"text"!==e?.type||e.marks||r.marks?t.push(r):e.text=(e.text??"")+(r.text??"")}return t})(n)}function Te(e,t,r){e.lastIndex=r;const n=e.exec(t);if(!n)return null;const s=e.source.includes("@")?"mention":"emoji";return{index:n.index,full:n[0],groups:n.slice(1),kind:s}}function Ae(e,t){return e?t&&e.index>t.index?t:e:t}function Oe(e){const t=(e.children??[])[0];return"text"===t?.type?(t.value??"")+"":"paragraph"===t?.type?((t.children??[]).map(e=>"text"===e.type?(e.value??"")+"":"").join("")||"")+"":""}function Ne(e){const t=((e??"")+"").toLowerCase().trim();return t?"info"===t||"note"===t||"success"===t||"warning"===t||"error"===t?t:"danger"===t?"error":null:null}function Ce(e){const t=((e??"")+"").toLowerCase().trim();return!t||"neutral"!==t&&"green"!==t&&"yellow"!==t&&"red"!==t&&"blue"!==t&&"purple"!==t?null:t}function He(e,t){const r=[];for(const n of e??[])if(n?.type)if("text"!==n.type)if("strong"!==n.type)if("emphasis"!==n.type)if("delete"!==n.type)if("inlineCode"!==n.type)if("break"!==n.type){if("link"===n.type){const e=(n.url??"")+"",s=Je(n.children??[],e),i=ke(n,0,t);if(i){"inline"===i.type?r.push(i.node):r.push({type:"text",text:s,marks:[{type:"link",attrs:{href:e}}]});continue}if(t.enableSmartCards&&De(s,e)){r.push({type:"inlineCard",attrs:{url:e}});continue}r.push({type:"text",text:s,marks:[{type:"link",attrs:{href:e}}]});continue}if("textDirective"===n.type&&"status"===n.name){const e=Oe(n)||"Status",t=Ce(n.attributes?.color)??"neutral";r.push({type:"status",attrs:{text:e,color:t}});continue}if("textDirective"===n.type&&"emoji"===n.name){const e=Pe(n);r.push($e(e,t));continue}}else r.push({type:"hardBreak"});else r.push({type:"text",text:(n.value??"")+"",marks:[{type:"code"}]});else r.push(...qe(He(n.children??[],t),{type:"strike"}));else r.push(...qe(He(n.children??[],t),{type:"em"}));else r.push(...qe(He(n.children??[],t),{type:"strong"}));else r.push(...Ee((n.value??"")+"",t));return r.filter(e=>!("text"===e.type&&""===(e.text??"")))}function qe(e,t){return e.map(e=>{if("text"!==e.type)return e;const r=e.marks?[...e.marks,t]:[t];return{...e,marks:r}})}function Je(e,t){const r=[];for(const t of e??[])"text"===t.type||"inlineCode"===t.type?r.push((t.value??"")+""):"emphasis"!==t.type&&"strong"!==t.type&&"delete"!==t.type||r.push(Je(t.children??[],""));return r.join("")||t}function De(e,t){const r=(e??"").trim(),n=(t??"").trim();return r===n&&/^https?:\/\//i.test(n)}function Pe(e){return(e.children??[]).map(e=>"text"===e.type?(e.value??"")+"":"").join("").trim()||""}function $e(e,t){const r=e.startsWith(":")?e:`:${e}:`,n=t.resolveEmoji?.(r);return n?{type:"emoji",attrs:{shortName:n.shortName,text:n.text}}:{type:"emoji",attrs:{shortName:r}}}function Re(e){return e?"string"==typeof e?e:"text"===e.type||"inlineCode"===e.type?(e.value??"")+"":Array.isArray(e.children)?e.children.map(Re).join(""):"":""}function Me(e,t){if(!e?.type)return null;if((e=>"containerDirective"===e?.type&&"panel"===e?.name)(e))return((e,t)=>{const r=e.attributes??{},n=Ne(r.type)??"info",s="string"==typeof r.title?r.title:void 0,i=(e.children??[]).map(e=>Me(e,t)).flat().filter(Boolean);return{type:"panel",attrs:{panelType:n,...s?{panelType:n,title:s}:{panelType:n}},content:i.length?i:[{type:"paragraph",content:[]}]}})(e,t);switch(e.type){case"heading":return{type:"heading",attrs:{level:Fe(e.depth??1,1,6)},content:He(e.children??[],t)};case"paragraph":{const r=(e=>{const t=e.children??[];if(1!==t.length)return null;const r=t[0];if("image"!==r?.type)return null;const n=(r.url??"")+"";return n?{type:"mediaSingle",attrs:{layout:"center"},content:[{type:"media",attrs:{type:"external",url:n}}]}:null})(e);return r||{type:"paragraph",content:He(e.children??[],t)}}case"blockquote":return{type:"blockquote",content:(e.children??[]).map(e=>Me(e,t)).flat().filter(Boolean)};case"list":return((e,t)=>t.enableTaskLists&&(e.children??[]).some(e=>"boolean"==typeof e.checked)?((e,t)=>{const r=[];let n=0;for(const s of e.children??[]){if("boolean"!=typeof s.checked)continue;n+=1;const e=(s.children??[]).map(e=>Me(e,t)).flat().filter(Boolean);r.push({type:"taskItem",attrs:{localId:"task-"+n,state:s.checked?"DONE":"TODO"},content:e.length?e:[{type:"paragraph",content:[]}]})}return{type:"taskList",content:r}})(e,t):{type:e.ordered?"orderedList":"bulletList",content:(e.children??[]).map(e=>((e,t)=>{const r=(e.children??[]).map(e=>Me(e,t)).flat().filter(Boolean);return{type:"listItem",content:r.length?r:[{type:"paragraph",content:[]}]}})(e,t))})(e,t);case"code":{const r=((e,t)=>{const r=(e??"").toString().trim().toLowerCase();return r?t.enableMermaid&&"mermaid"===r?"mermaid":(e=>{const t=e.trim().toLowerCase();return{js:"javascript",javascript:"javascript",jsx:"javascript",ts:"typescript",typescript:"typescript",tsx:"typescript",py:"python",python:"python",rb:"ruby",ruby:"ruby",sh:"bash",bash:"bash",zsh:"bash",shell:"bash",yml:"yaml",yaml:"yaml",json:"json",toml:"toml",xml:"xml",html:"html",css:"css",scss:"scss",sql:"sql",go:"go",rust:"rust",java:"java",c:"c",cpp:"cpp","c++":"cpp",cs:"csharp",csharp:"csharp",php:"php",kotlin:"kotlin",swift:"swift",md:"markdown",markdown:"markdown",graphql:"graphql",gql:"graphql",dockerfile:"docker",makefile:"make",ini:"ini"}[t]??t})(r):null})(e.lang,t);return{type:"codeBlock",attrs:{language:r},content:[{type:"text",text:(e.value??"")+""}]}}case"thematicBreak":return{type:"rule"};case"table":return((e,t)=>({type:"table",content:(e.children??[]).map((e,r)=>({type:"tableRow",content:(e.children??[]).map(e=>({type:0===r?"tableHeader":"tableCell",content:[{type:"paragraph",content:He(e.children??[],t)}]}))}))}))(e,t);case"leafDirective":return"status"===e.name?(e=>{const t=Ce((e.attributes??{}).color)??"neutral";return{type:"paragraph",content:[{type:"status",attrs:{text:Oe(e)||"Status",color:t}}]}})(e):"panel"===e.name?((e,t)=>{const r=e.attributes??{},n=Ne(r.type)??"info",s="string"==typeof r.title?r.title:void 0;return{type:"panel",attrs:{panelType:n,...s?{title:s}:{}},content:[{type:"paragraph",content:He([{type:"text",value:Oe(e)}],t)}]}})(e,t):Le(e,t);default:return Le(e,t)}}function Le(e,t){if("drop"===t.unknownNodeStrategy)return null;const r=Re(e);return r?{type:"paragraph",content:[{type:"text",text:r}]}:null}function Fe(e,t,r){const n=Number.isFinite(e)?Math.trunc(e):t;return Math.max(t,Math.min(r,n))}const Be={resolveMention:void 0,resolveAttachment:void 0,resolveEmoji:void 0,enableSmartCards:!0,enableMermaid:!0,enableEmojiShortcodes:!0,enableAtMentions:!0,enableTaskLists:!0,unknownNodeStrategy:"text"};function Ue(e,t={}){const r={...Be,...t},n=e??"",s=h.unified().use(y).use(g).use(f),i=s.parse(n),o=s.runSync(i);return We(o),((e,t)=>{const r=[];for(const n of e.children??[]){const e=Me(n,t);e&&(Array.isArray(e)?r.push(...e):r.push(e))}return((e,t)=>{if(!t.enableSmartCards)return e;const r=e.content.map(e=>(e=>{if("paragraph"!==e.type)return e;const t=e.content??[];if(1!==t.length)return e;const r=t[0];if("inlineCard"!==r?.type)return e;const n=r.attrs?.url;return n?[{type:"blockCard",attrs:{url:n}}]:e})(e)).flat();return{...e,content:r}})({version:1,type:"doc",content:r},t)})(o,r)}function We(e){if(!e||!Array.isArray(e.children))return;const t=[];for(const r of e.children)"definition"!==r?.type&&("html"!==r?.type?(We(r),t.push(r)):t.push({type:"text",value:(r.value??"")+""}));e.children=t}const Ke=i.z.object({issueId:i.z.string().min(1),transitionId:i.z.union([i.z.string(),i.z.number()]),fields:i.z.record(i.z.any()).optional(),update:i.z.record(i.z.array(i.z.object({set:i.z.any().optional(),add:i.z.any().optional(),remove:i.z.any().optional()}))).optional(),comment:i.z.string().optional()}),Ye={name:"jira-issue-transition",inputSchema:Ke,runTool:async(e,t)=>{try{const r=Ke.parse(t),n={id:r.transitionId};r.fields&&(n.fields=r.fields),r.update&&(n.update=r.update),r.comment&&(n.comment={body:Ue(r.comment)});const s=await e.issues.transition({issueId:r.issueId,transition:n});return ve(s?.data??s)}catch(e){throw ye(e)}}},Ve=i.z.object({issueId:i.z.string().min(1),fields:i.z.record(i.z.any()).optional(),update:i.z.record(i.z.array(i.z.object({set:i.z.any().optional(),add:i.z.any().optional(),remove:i.z.any().optional(),edit:i.z.any().optional()}))).optional(),properties:i.z.array(i.z.any()).optional(),notifyUsers:i.z.boolean().optional().default(!0),issueTemplateId:i.z.string().optional(),overrideScreenSecurity:i.z.boolean().optional().default(!1),overrideEditableFlag:i.z.boolean().optional().default(!1)}),Ge={name:"jira-issue-update",inputSchema:Ve,runTool:async(e,t)=>{try{const r=Ve.parse(t),n={issueId:r.issueId};r.fields&&(n.fields=r.fields),r.update&&(n.update=r.update),r.properties&&(n.properties=r.properties),void 0!==r.notifyUsers&&(n.notifyUsers=r.notifyUsers),r.issueTemplateId&&(n.issueTemplateId=r.issueTemplateId),void 0!==r.overrideScreenSecurity&&(n.overrideScreenSecurity=r.overrideScreenSecurity),void 0!==r.overrideEditableFlag&&(n.overrideEditableFlag=r.overrideEditableFlag);const s=await e.issues.update(n);return ve(s?.data??s)}catch(e){throw ye(e)}}},Ze=i.z.object({issueId:i.z.string().min(1),assignee:i.z.union([i.z.string(),i.z.object({accountId:i.z.string().min(1)}),i.z.object({accountType:i.z.string().min(1)})])}),Qe={name:"jira-assign-issue",inputSchema:Ze,runTool:async(e,t)=>{try{const r=Ze.parse(t);let n;n="string"==typeof r.assignee?{accountId:r.assignee}:r.assignee;const s=await e.issues.assign({issueId:r.issueId,assignee:n});return ve(s?.data??s)}catch(e){throw ye(e)}}},Xe=i.z.object({issueId:i.z.string().min(1)}),et={name:"jira-unassign-issue",inputSchema:Xe,runTool:async(e,t)=>{try{const r=Xe.parse(t),n=await e.issues.assign({issueId:r.issueId,assignee:{accountId:"-1"}});return ve(n?.data??n)}catch(e){throw ye(e)}}},tt=i.z.object({issueId:i.z.string().min(1),body:i.z.string().min(1),visibility:i.z.object({type:i.z.enum(["role","group"]),value:i.z.string().min(1)}).optional()}),rt={name:"jira-comment-add",inputSchema:tt,runTool:async(e,t)=>{try{const r=tt.parse(t),n={body:Ue(r.body)};r.visibility&&(n.visibility=r.visibility);const s=await e.issues.addComment({issueId:r.issueId,comment:n});return ve(s?.data??s)}catch(e){throw ye(e)}}},nt=i.z.object({issueId:i.z.string().min(1),start:i.z.number().optional().default(0),maxResults:i.z.number().optional().default(50),orderBy:i.z.string().optional(),expand:i.z.string().optional()}),st={name:"jira-comment-list",inputSchema:nt,runTool:async(e,t)=>{try{const r=nt.parse(t),n=await e.issues.getComments({issueId:r.issueId,start:r.start,maxResults:r.maxResults,orderBy:r.orderBy,expand:r.expand});return ve(n?.data??n)}catch(e){throw ye(e)}}},it=i.z.object({link:i.z.object({relationship:i.z.enum(["Blocks","Relates to","Duplicates","Is blocked by","Is related to","Is duplicated by","Causes","Is caused by","Clone","Required","Work on","Split","Roll up"]),inwardIssue:i.z.object({id:i.z.string().optional(),key:i.z.string().optional()}),outwardIssue:i.z.object({id:i.z.string().optional(),key:i.z.string().optional()}),comment:i.z.object({body:i.z.string().optional(),visibility:i.z.object({type:i.z.enum(["role","group"]),value:i.z.string().min(1)}).optional()}).optional()})}),ot={name:"jira-link-create",inputSchema:it,runTool:async(e,t)=>{try{const r=it.parse(t).link,n={relationship:r.relationship,inwardIssue:r.inwardIssue.id||r.inwardIssue.key,outwardIssue:r.outwardIssue.id||r.outwardIssue.key};r.comment&&(r.comment.body&&(n.comment=Ue(r.comment.body)),r.comment.visibility&&(n.visibility=r.comment.visibility));const s=await e.issues.link(n);return ve(s?.data??s)}catch(e){throw ye(e)}}},at=i.z.object({issueId:i.z.string().min(1),file:i.z.string().min(1),mimeType:i.z.string().optional(),comment:i.z.string().optional()}),ct={name:"jira-attach",inputSchema:at,runTool:async(e,r)=>{try{const n=at.parse(r),s=c.resolve(n.file),i=await t.promises.readFile(s),o=c.basename(s),a=await e.issues.addAttachment({issueId:n.issueId,file:{name:o,content:i,mimeType:n.mimeType??"application/octet-stream"},comment:n.comment});return ve(a?.data??a)}catch(e){if(e&&e.code&&"string"==typeof e.code&&["ENOENT","EACCES"].includes(e.code))throw Error("Attachment file error: "+e.message);throw ye(e)}}},lt=i.z.object({issueId:i.z.string().min(1)}),pt={name:"jira-attachment-list",inputSchema:lt,runTool:async(e,t)=>{try{const r=lt.parse(t),n=await e.issues.getAttachments({issueId:r.issueId});return ve(n?.data??n)}catch(e){throw ye(e)}}},ut=i.z.object({issueId:i.z.string().min(1),attachmentId:i.z.string().min(1)}),dt={name:"jira-attachment-delete",inputSchema:ut,runTool:async(e,t)=>{try{const r=ut.parse(t);return await e.issues.deleteAttachment({issueId:r.issueId,attachmentId:r.attachmentId}),ve({success:!0,message:`Attachment ${t.attachmentId} deleted successfully`})}catch(e){throw ye(e)}}},mt=i.z.object({issueId:i.z.string().min(1),timeSpent:i.z.string().min(1),comment:i.z.string().optional(),author:i.z.object({accountId:i.z.string().min(1)}).optional(),startingOn:i.z.string().optional(),artifact:i.z.string().optional()}),ht={name:"jira-worklog-add",inputSchema:mt,runTool:async(e,t)=>{try{const r=mt.parse(t),n={timeSpent:r.timeSpent};r.comment&&(n.comment=r.comment),r.author&&(n.author=r.author),r.startingOn&&(n.started=r.startingOn),r.artifact&&(n.artifact=r.artifact);const s=await e.issues.addWorklog({issueId:r.issueId,...n});return ve(s?.data??s)}catch(e){throw ye(e)}}},ft={[ze.name]:{title:"Jira Issue Read",description:"Read a Jira issue with expandable fields and properties",annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},[Ie.name]:{title:"Jira Issue List",description:"Search issues by summary, reference, parent, or JQL and list the matching tickets",annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},[Ge.name]:{title:"Jira Issue Update",description:"Update a Jira issue using fields, update ops, and property toggles",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[je.name]:{title:"Jira Issue Delete",description:"Delete a Jira issue and optionally remove its subtasks",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0}},[Ye.name]:{title:"Jira Issue Transition",description:"Transition a Jira issue while optionally adding a comment",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[Qe.name]:{title:"Jira Issue Assign",description:"Assign a Jira issue to a user or account",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[et.name]:{title:"Jira Issue Unassign",description:"Unassign the current owner from a Jira issue",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[rt.name]:{title:"Jira Comment Add",description:"Add a comment to a Jira issue with optional visibility",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[st.name]:{title:"Jira Comment List",description:"List comments on a Jira issue with pagination support",annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},[ot.name]:{title:"Jira Link Create",description:"Create an issue link relationship with optional comment",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[ct.name]:{title:"Jira Attachment Add",description:"Attach a local file to a Jira issue",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[pt.name]:{title:"Jira Attachment List",description:"List attachments on a Jira issue",annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},[dt.name]:{title:"Jira Attachment Delete",description:"Delete an attachment from a Jira issue",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0}},[ht.name]:{title:"Jira Worklog Add",description:"Log time spent on a Jira issue",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}}};async function gt(e){const t=r.Logging.for(gt);let n,s=null;try{n=(()=>{let e;try{const t=require("jira.js");e=t?.Version3Client||t.default?.Version3Client||t.default||t}catch(e){throw Error("Unable to require 'jira.js' \u2014 ensure it is installed as a dependency: "+e)}const{host:t,email:r,apiKey:n}=(()=>{const e=me(),t=he().filter(e=>e.required&&!e.value);if(t.length>0)throw new ge(t);return{host:e.host,email:e.email,apiKey:e.apiKey}})();return new e({host:t.startsWith("http://")||t.startsWith("https://")?t:"https://"+t,authentication:{basic:{email:r,apiToken:n}}})})()}catch(e){if(!(e instanceof ge))return void t.warn("Skipping Jira tool registration; unable to create Jira client",{error:e});s=e,t.warn("Registering Jira tools without credentials; each tool will report configuration requirements.",{error:e})}const i=[ze,Ie,Ge,je,Ye,Qe,et,rt,st,ot,ct,pt,dt,ht];for(const r of i){const i=ft[r.name];if(i)try{await e.registerTool(r.name,{title:i.title,description:i.description,inputSchema:D(r.inputSchema),annotations:i.annotations},async e=>{if(!n)throw s??Error("Jira client unavailable because credentials could not be loaded.");return r.runTool(n,e)}),t.info("Registered Jira tool "+r.name)}catch(e){t.error("Failed to register Jira tool "+r.name,{error:e})}}}async function yt(e){await(async e=>{e.registerTool("decaf-server-info",{title:"Decaf MCP Server Info",description:"Return server metadata, version, and registered prompt names for diagnostics.",inputSchema:{},outputSchema:void 0,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async()=>{const e=se.map(e=>e.getName()).sort();return{content:[{type:"text",text:["Name: "+de.name,"Title: "+de.title,"Version: "+de.version,"Prompts: "+(e.join(", ")||"<none>")].join("\n")}]}})})(e);const t=r.Logging.for(yt);try{await gt(e)}catch(e){t.error("Failed to register Jira tools",e)}}class bt extends C{setCb(e){return this.cb=e,this}setConfig(e){return this.config=e,this}setUriOtTemplate(e){return this.uriOrTemplate=e,this}constructor(e){super(e)}static get builder(){return new bt}build(e){const t=this.hasErrors();if(t)throw Error(t.toString());try{const t="string"==typeof this.uriOrTemplate&&this.uriOrTemplate.includes("{")?new v.ResourceTemplate(new b.UriTemplate(this.uriOrTemplate),{list:void 0}):this.uriOrTemplate,r=Object.assign(this.config,{_meta:{}}),n=async(e,t)=>{const r=this.logFor(t);r.verbose(`Requesting resource ${this.name} from ${e.toString()}`);const n=await Promise.resolve(this.cb(e,t));return r.verbose(`Resource ${this.name} retrieved successfully.`),r.debug("Resource retrieval meta: "+JSON.stringify(n._meta)),n};return e.resource(this.name,t,r,n)}catch(e){throw r.Logging.for(this).error("Error registering resource "+this.name,e),e}}}n.__decorate([s.required(),n.__metadata("design:type",String)],bt.prototype,"uriOrTemplate",void 0),n.__decorate([s.required(),n.__metadata("design:type",Function)],bt.prototype,"cb",void 0),n.__decorate([s.required(),n.__metadata("design:type",Object)],bt.prototype,"config",void 0);const vt=K()??_.join(__dirname,"..","assets"),wt=_.join(vt,"templates"),jt=_.join(vt,"prompts"),St=new WeakMap;class xt extends r.LoggedClass{get client(){const e=St.get(this);if(!e)throw Error("Mcp server requires Mcp client");return e}constructor(){super()}async load(){const e=this.log.for(this.load);for(const t of se)try{e.info("loading prompt "+t.getName());const r=t.build(this.client);e.verbose(`Loaded prompt ${r.title} from ${t.getName()} definition`)}catch(r){e.error("Failed to load prompt "+t.getName(),r)}try{await yt(this.client),e.verbose("Registered built-in tools")}catch(e){}try{await(async(e,t)=>{t.info("Registering agent templates as resources...");const r=I.readdirSync(wt).filter(e=>e.endsWith(".md"));for(const n of r){const r=_.basename(n,".md"),s=_.join(wt,n),i=bt.builder.setName(r).setTitle("Template: "+r).setDescription("Resource template for "+r).setUriOtTemplate("file:///"+s).setConfig({mimeType:"text/markdown",description:"Template for "+r}).setCb(async e=>{const t=I.readFileSync(e.pathname,"utf8");return{contents:[{uri:e.toString(),text:t,mimeType:"text/markdown"}],_meta:{}}});try{i.build(e),t.info("Registered template: "+r)}catch(e){t.error(`Failed to register template ${r}:`,e)}}t.info("Registering agent prompts...");const n=I.readdirSync(jt).filter(e=>e.endsWith(".md"));for(const r of n){const n=_.basename(r,".md"),s=_.join(jt,r),o=I.readFileSync(s,"utf8"),a=V.builder.setName(n).setTitle("Prompt: "+n).setDescription("Dynamic prompt for "+n).setArgsSchema(i.z.object({})).setCb(async e=>({messages:[{role:"user",content:{type:"text",text:o}}],_meta:{}}));try{a.build(e),t.info("Registered prompt: "+n)}catch(e){t.error(`Failed to register prompt ${n}:`,e)}}})(this.client,e)}catch(e){}}async boot(e="stdio"){"stdio"===e&&r.Logging.setFactory(k),r.Logging.for(this.constructor.name);const t=((Array.isArray(de.icons)?de.icons:[de.icons])||[]).map(e=>{const t="string"==typeof e?.src?e.src:(e?.src??"")+"",r="string"==typeof e?.mimeType?e.mimeType:(e?.mimeType??"")+"";let n=[];return Array.isArray(e?.sizes)?n=e.sizes.map(e=>e+""):"string"==typeof e?.sizes&&(n=(e.sizes+"").split(",").map(e=>e.trim())),{src:t,mimeType:r,sizes:n}}),n={name:de.name,title:de.title,websiteUrl:de.websiteUrl,version:de.version,icons:t},s=new v.McpServer(n,{instructions:"You are an AI assistant designed to help users with programming tasks related to the Decaf-TS framework. \nProvide clear, concise, and accurate information.\nIf you don't know the answer, admit it rather than making up information.\nAlways prioritize the user's intent and provide helpful suggestions when appropriate.\n",capabilities:{logging:{},tools:{},prompts:{}}});switch(((e,t)=>{St.set(e,t)})(this,s),s.onerror=e=>{this.log.error("MCP instance onerror",e)},e){case"stdio":e=new j.StdioServerTransport;break;case"http":e=new S.StreamableHTTPServerTransport({sessionIdGenerator:()=>w.v4(),onsessioninitialized:e=>{},onsessionclosed:e=>{},enableJsonResponse:!0,eventStore:void 0});break;default:if(!(i=e)||"object"!=typeof i||"function"!=typeof i.send&&"function"!=typeof i.close&&"function"!=typeof i.on)throw new l.InternalError("Invalid transport type: "+e)}var i;try{await this.load()}catch(e){throw e}await this.client.connect(e)}}const It=(new e.Command).command("start").option("--transport [String]","transport mode","stdio").description("starts decaf's mcp server").action(async e=>{const r=U("package.json"),n=JSON.parse(t.readFileSync(r,"utf-8")),s=n.version,{transport:i}=e,o=(new z).for("mcp-server");if("stdio"!==i)throw Error("Unsupported transport mode: "+i);return o.info("Transport stdio"),o.debug(`running with options: ${JSON.stringify(e)} for ${n.name} version ${s}`),(new xt).boot(i)});(new e.Command).command("md-to-ast").description("pipes markdown to jira ast: `cat file.md` | npx decaf-mcp md-to-ast > ast.json").action(async e=>{const n=U("package.json"),s=JSON.parse(t.readFileSync(n,"utf-8")),i=s.version;r.Logging.for("md-to-ast").debug(`running with options: ${JSON.stringify(e)} for ${s.name} version ${i}`);const o=Ue(await(async()=>{const e=[];for await(const t of process.stdin)e.push(Buffer.from(t));return Buffer.concat(e).toString("utf8")})(),{resolveMention:e=>({id:e,text:"@"+e}),resolveAttachment:e=>({id:e,collection:"attachments"})});process.stdout.write(JSON.stringify(o,null,2)+"\n")});const _t=(new e.Command).name("mcp-server").command("mcp-server").description("decaf mcp server and agentic functionality");_t.addCommand(It),_t.parse(process.argv)},"object"==typeof exports&&"undefined"!=typeof module?t(require("commander"),require("fs"),require("@decaf-ts/logging"),require("tslib"),require("@decaf-ts/decorator-validation"),require("zod"),require("@decaf-ts/injectable-decorators"),require("@decaf-ts/decoration"),require("path"),require("@decaf-ts/db-decorators"),require("crypto"),require("zlib"),require("url"),require("node:util"),require("unified"),require("remark-directive"),require("remark-gfm"),require("remark-parse"),require("@modelcontextprotocol/sdk/shared/uriTemplate.js"),require("@modelcontextprotocol/sdk/server/mcp.js"),require("uuid"),require("@modelcontextprotocol/sdk/server/stdio.js"),require("@modelcontextprotocol/sdk/server/streamableHttp.js")):"function"==typeof define&&define.amd?define(["commander","fs","@decaf-ts/logging","tslib","@decaf-ts/decorator-validation","zod","@decaf-ts/injectable-decorators","@decaf-ts/decoration","path","@decaf-ts/db-decorators","crypto","zlib","url","node:util","unified","remark-directive","remark-gfm","remark-parse","@modelcontextprotocol/sdk/shared/uriTemplate.js","@modelcontextprotocol/sdk/server/mcp.js","uuid","@modelcontextprotocol/sdk/server/stdio.js","@modelcontextprotocol/sdk/server/streamableHttp.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).commander,e.fs,e.decafTsLogging,e.tslib,e.decafTsDecoratorValidation,e.zod,e.decafTsInjectableDecorators,e.decafTsDecoration,e.path,e.decafTsDbDecorators,e.crypto,e.zlib,e.url,e.node_util,e.unified,e.remarkDirective,e.remarkGfm,e.remarkParse,e.uriTemplate_js,e.mcp_js,e.uuid,e.stdio_js,e.streamableHttp_js);
|
|
3
3
|
//# sourceMappingURL=mcp-server.cjs.map
|