@decaf-ts/mcp-server 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/assets/code/patterns/builder.enc +0 -0
  2. package/dist/assets/prompts/agent/agent.enc +0 -0
  3. package/dist/assets/prompts/agent/init.enc +0 -0
  4. package/dist/assets/prompts/constitution_commands.enc +0 -0
  5. package/dist/assets/prompts/documentation/class.enc +0 -0
  6. package/dist/assets/prompts/documentation/constant.enc +0 -0
  7. package/dist/assets/prompts/documentation/decorator.enc +0 -0
  8. package/dist/assets/prompts/documentation/file.enc +0 -0
  9. package/dist/assets/prompts/documentation/function.enc +0 -0
  10. package/dist/assets/prompts/documentation/interface.enc +0 -0
  11. package/dist/assets/prompts/documentation/iterate.enc +0 -0
  12. package/dist/assets/prompts/documentation/module.enc +0 -0
  13. package/dist/assets/prompts/documentation/prefix.enc +0 -0
  14. package/dist/assets/prompts/documentation/repo.enc +0 -0
  15. package/dist/assets/prompts/documentation/suffix.enc +0 -0
  16. package/dist/assets/prompts/git_commands.enc +0 -0
  17. package/dist/assets/prompts/jira/operational_prompts.enc +0 -0
  18. package/dist/assets/prompts/jira/system_prompt.enc +0 -0
  19. package/dist/assets/prompts/mode_commands.enc +0 -0
  20. package/dist/assets/prompts/plan_commands.enc +0 -0
  21. package/dist/assets/prompts/repository/readme.enc +0 -0
  22. package/dist/assets/prompts/repository/release_notes.enc +0 -0
  23. package/dist/assets/prompts/repository/setup.enc +0 -0
  24. package/dist/assets/prompts/specification_commands.enc +0 -0
  25. package/dist/assets/prompts/startup_command.enc +0 -0
  26. package/dist/assets/prompts/task_commands.enc +0 -0
  27. package/dist/assets/prompts/tests/coverage.enc +0 -0
  28. package/dist/assets/templates/AGENTS.enc +0 -0
  29. package/dist/assets/templates/agents_template.enc +0 -0
  30. package/dist/assets/templates/constitution_template.enc +0 -0
  31. package/dist/assets/templates/decaf/context/logCtx.enc +0 -0
  32. package/dist/assets/templates/decaf/services/client_based_service.enc +0 -0
  33. package/dist/assets/templates/decaf/services/model_service.enc +0 -0
  34. package/dist/assets/templates/decaf/services/service.enc +0 -0
  35. package/dist/assets/templates/decaf_guidelines.enc +1 -1
  36. package/dist/assets/templates/instructions_template.enc +0 -0
  37. package/dist/assets/templates/jira_templates.enc +0 -0
  38. package/dist/assets/templates/plan_template.enc +0 -0
  39. package/dist/assets/templates/specification_template.enc +0 -0
  40. package/dist/assets/templates/task_template.enc +0 -0
  41. package/dist/mcp-server.cjs +1 -1
  42. package/dist/mcp-server.cjs.map +1 -1
  43. package/dist/mcp-server.js +1 -1
  44. package/dist/mcp-server.js.map +1 -1
  45. package/package.json +5 -3
Binary file
Binary file
Binary file
@@ -1 +1 @@
1
- DCAF11P"f+�T�n�n�I� j����_�OWNm����������'dg*��=�� ��%��p�
1
+ DCAF1(υqRGP��(Y�ԣh;#�R��M����`�g��I��W�!}~Л�ǦMups�����
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- var e,t;e=this,t=function(e,t,r,s,n,i,o,a,c,l,p,d,u,m,h,f,g,y,b,v,w,S){"use strict";function j(e){var t=Object.create(null);return e&&Object.keys(e).forEach(r=>{if("default"!==r){var s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>e[r]})}}),t.default=e,Object.freeze(t)}var x=j(t),I=j(r);class _ extends s.MiniLogger{log(e,t,r,n){const i=this.config("level");s.NumericLogLevels[i],s.NumericLogLevels[e]}}const z=(e,t,...r)=>{const s=(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 _(s,t)},E=["\x1b[38;5;215m","\x1b[38;5;209m","\x1b[38;5;205m","\x1b[38;5;210m","\x1b[38;5;217m","\x1b[38;5;216m","\x1b[38;5;224m","\x1b[38;5;230m","\x1b[38;5;230m"];var T,k,A,O,N;(e=>{e[e.NONE=0]="NONE",e[e.BASIC=1]="BASIC",e[e.ADVANCED=2]="ADVANCED",e[e.HIGH=3]="HIGH"})(T||(T={})),(e=>{e[e.NONE=0]="NONE",e[e.LOW=1]="LOW",e[e.MEDIUM=2]="MEDIUM",e[e.HIGH=3]="HIGH"})(k||(k={})),(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 o.Model{get log(){return this._log||(this._log=s.Logging.for(this)),this._log}constructor(e){super(e)}logFor(e){const{sessionId:t,requestId:r,authInfo:s}=e||{};let n="string"==typeof t&&t.length>0?this.log.for(t):this.log;return s&&s.clientId&&(n=n.for(s.clientId)),r&&(n=n.for(r.toString())),n}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}}i.__decorate([o.required(),i.__metadata("design:type",String)],C.prototype,"description",void 0),i.__decorate([o.required(),i.__metadata("design:type",String)],C.prototype,"name",void 0),i.__decorate([o.required(),i.__metadata("design:type",String)],C.prototype,"title",void 0);class H extends C{constructor(e){super(e),this.reasoning=T.NONE,this.effort=k.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 D(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(D(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,s]of Object.entries(r))e[t]=P(s)?s:a.z.any();return a.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=D(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)}i.__decorate([o.required(),i.__metadata("design:type",Number)],H.prototype,"reasoning",void 0),i.__decorate([o.required(),i.__metadata("design:type",Number)],H.prototype,"effort",void 0),i.__decorate([o.required(),i.__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 M=Buffer.from("DCAF1","ascii");function R(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 s=I.join(t,"assets");if(x.existsSync(s))return s;const n=I.dirname(t);if(n===t)break;t=n}}function $(){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=process.argv?.[1];if(t){const e=R(I.dirname(t));if(e)return e}const r=[process.cwd(),process.env.INIT_CWD].filter(Boolean);for(const e of r){const t=R(e);if(t)return t}return I.join(process.cwd(),"assets")}let L=class extends s.LoggedClass{constructor(e){super(),this.basePath=e||$()}listAssets(...e){const t=I.join(this.basePath,...e);return x.readdirSync(t)}listPrompts(){return this.listAssets(N.PROMPT)}getAsset(e,t="md",...r){const s=I.join(this.basePath,...r),n=(e,t=!1)=>{try{return t?(e=>{if(e.length<M.length+16+12+16)throw Error("Invalid prompt payload (too short)");if(!e.subarray(0,M.length).equals(M))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=M.length;const s=e.subarray(r,r+16);r+=16;const n=e.subarray(r,r+12);r+=12;const i=e.subarray(r,r+16);r+=16;const o=e.subarray(r),a=((e,t)=>d.scryptSync(e,t,32))(t,s),c=d.createDecipheriv("aes-256-gcm",a,n);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=n(I.join(s,`${e}.${t}`),"enc"===t);if(null!==i)return i;const o=n(I.join(s,e+".enc"),!0);if(null!==o)return o;throw Error("Asset not found: "+I.join(s,`${e}.${t}`))}getAllAssets(e,...t){return this.listAssets(e,...t).reduce((r,s)=>{const n=I.extname(s),i=I.basename(s,n),o=n.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 T.NONE;case"basic":return T.BASIC;case"advanced":return T.ADVANCED;case"high":return T.HIGH;case"medium":return k.MEDIUM;case"low":return A.LOW;case"free":return A.FREE;default:throw new p.InternalError("Cannon convert unknown level "+e)}})(e.toLowerCase()):T.NONE;return e.effort=t(e.effort),e.reasoning=t(e.reasoning),e.cost=t(e.cost),e}getPrompt(e,...t){const r=this.getAsset(s.toSnakeCase(e),"json",N.PROMPT,...t);let n;try{n=JSON.parse(r)}catch(r){throw new p.SerializationError(`Failed to parse prompt ${e} in categories ${t}: ${r}`)}return this.toPromptDef(n)}getAllPrompts(...e){const t=this.getAllAssets(N.PROMPT,...e);return Object.entries(t).reduce((t,[r,s])=>{try{t[r]=JSON.parse(s)}catch(t){throw new p.SerializationError(`Failed to parse prompt ${r} in categories ${e}: ${t}`)}return t},t)}};L=i.__decorate([c.injectable(),i.__metadata("design:paramtypes",[String])],L);class F 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 F}static patchPrompt(e,t,r,n){const i=(t=Array.isArray(t)?t:Object.keys(t)).filter(e=>!Object.prototype.hasOwnProperty.call(r,e));if(i.length)throw new p.ValidationError("Missing replacements for placeholders: "+i.join(", "));n&&(n.verbose("Patching prompt with placeholders: "+JSON.stringify(t)),n.debug("Values: "+JSON.stringify(r)));const o=t.reduce((e,t)=>(e[t]=r[t],e),{});return s.sf(e,o)}patchPrompt(e,t,r,s){return F.patchPrompt(e,t,r,s||this.log.for(this.patchPrompt))}build(e,t){const r=this.log.for(this.build),s=this.hasErrors();if(s)throw new p.ValidationError(s.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 s=this.logFor(r);e=Object.assign({},t,e||{}),s.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 n=await Promise.resolve(this.cb(e,r));return s.verbose(`Prompt ${this.name} executed successfully.`),s.debug("Prompt execution meta: "+JSON.stringify(n._meta)),n})}catch(e){throw r.error("Failed to register prompt "+(this.name||this.constructor.name),e),e}}}i.__decorate([c.inject(L),i.__metadata("design:type",L)],F.prototype,"assets",void 0),i.__decorate([o.required(),i.__metadata("design:type",Object)],F.prototype,"cb",void 0),i.__decorate([o.required(),i.__metadata("design:type",a.ZodObject)],F.prototype,"argsSchema",void 0),i.__decorate([l.prop(),i.__metadata("design:type",Object)],F.prototype,"placeholders",void 0);class B extends F{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);o.Model.fromObject(this,t);const r=new Set((l.Metadata.properties(B)||[]).filter(e=>!["assets","promptCategory","prefixes","suffixes"].includes(e)));["cb","argsSchema"].forEach(e=>r.add(e));const s=this.hasErrors(...Array.from(r));if(s)throw new p.ValidationError(s.toString());const n=(this.prefixes||[]).map(e=>this.assets.getPrompt(e,this.promptCategory)),i=(this.suffixes||[]).map(e=>this.assets.getPrompt(e,this.promptCategory)),c=[...new Set([...t.placeholders,...n.map(e=>e.placeholders||[]),...i.map(e=>e.placeholders||[])].flat())].reduce((e,t)=>(e[t]=a.z.string().describe("The description for "+t),e),{});return this.setArgsSchema(a.z.object(c)),this.setCb((e,t)=>{const r=this.logFor(t).for(B).for(this.promptCategory).for(this.name);function s(e=[]){return Array.isArray(e)?e:Object.keys(e)}const n=(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([...n.map(e=>s(e.placeholders)).flat(),...i.map(e=>s(e.placeholders)).flat(),...s(o.placeholders).flat()])];return{messages:[{role:"user",content:{type:"text",text:this.patchPrompt([...n.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 p.InternalError("Named prompt builders don't require callback")}setEffort(e){throw new p.InternalError("Named prompt builders don't require callback")}setCost(e){throw new p.InternalError("Named prompt builders don't require callback")}setDescription(e){throw new p.InternalError("Named prompt builders don't require callback")}setTitle(e){throw new p.InternalError("Named prompt builders don't require callback")}static get builder(){return new B}}i.__decorate([o.required(),i.__metadata("design:type",String)],B.prototype,"promptCategory",void 0),i.__decorate([o.list(String),o.minlength(1),i.__metadata("design:type",Array)],B.prototype,"prefixes",void 0),i.__decorate([o.minlength(1),o.list(String),i.__metadata("design:type",Array)],B.prototype,"suffixes",void 0);const W=F.builder.setName("example.prompt").setTitle("Example prompt").setDescription("Example prompt for testing").setArgsSchema(a.z.object({message:a.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}}}),U=F.builder.setName("interactive.jsdoc").setTitle("Interactive JSDoc prompt").setDescription("Interactive prompt for jogging JSDoc helpers").setArgsSchema(a.z.object({gist:a.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}}}),K=Object.assign(U,{name:U.getName()});var Y;function V(e,t=[],r=[]){const s=B.builder.setCategory(Y.DOCS).setName(e);return["prefix",...t].forEach(e=>s.addPrefix(e)),["suffix",...r].forEach(e=>s.addSuffix(e)),s}(e=>{e.DOCS="documentation",e.CODE="code"})(Y||(Y={}));const G=[V("class"),V("constant"),V("decorator"),V("function"),V("module"),V("file"),V("repo",[],["iterate"])],Z=a.z.object({className:a.z.string().describe("the class name to turn into a builder")}),Q=[W,K,...G,F.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(Z).setReasoning(T.BASIC).setCb((e,t)=>(e.className=s.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 X 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 X}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 s=await Promise.resolve(this.cb(e,t));return r.verbose(`Tool ${this.name} executed successfully.`),r.debug("Tool execution meta: "+JSON.stringify(s._meta)),s})}catch(e){const t=e?.message||e+"";if("string"==typeof t&&t.includes("already registered"))return s.Logging.for(this).warn(`Tool ${this.name} already registered - skipping duplicate registration`),{name:this.name};throw s.Logging.for(this).error("Error building tool",e),e}}}i.__decorate([o.required(),i.__metadata("design:type",Object)],X.prototype,"annotations",void 0),i.__decorate([o.required(),i.__metadata("design:type",Object)],X.prototype,"cb",void 0),i.__decorate([o.required(),i.__metadata("design:type",Function)],X.prototype,"inputSchema",void 0);const ee=X.builder.setName("example.tool").setTitle("Example tool").setDescription("A smoke tool used for quick testing").setInputSchema(a.z.object({})).setCb(async()=>({content:[{type:"text",text:"example tool ok"}],result:{status:"ok"}}));Object.assign(ee,{name:ee.getName()});const te=X.builder.setName("file.summarizer").setTitle("File summarizer").setDescription("Summaries files for quick previews").setInputSchema(a.z.object({filePath:a.z.string().optional()})).setCb(async()=>({content:[{type:"text",text:"file summary stub"}],result:{summary:"file summary stub"}}));Object.assign(te,{name:te.getName()});const re="##VERSION##";l.Metadata.registerLibrary("##PACKAGE##",re);const se={mcpId:"decaf",name:"decaf-ts mcp server",title:"Decaf-TS MCP Server",description:"Provides precise coding assistance for the decaf-ts framework",version:re,websiteUrl:"https://decaf-ts.github.io",repositoryUrl:"https://github.com/decaf-ts/mcp-server",license:"AGPL-3.0",workingDir:process.cwd(),assetDir:$(),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:s.LogLevel.error},ne=s.LoggedEnvironment.accumulate(se);function ie(){const{host:e,email:t,apiKey:r,projectKey:s,issueType:n}=ne.jira;return{host:e?.trim(),email:t?.trim(),apiKey:r?.trim(),projectKey:s?.trim(),issueType:n?.trim(),parentIssue:ne.jira.parentIssue?.trim()}}function oe(){const e=ie();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 ae(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}.`}s.Logging.setConfig(ne);class ce extends Error{constructor(e){const t=oe(),r=(e=>{const t=oe();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(ae).join("\n")}`})(e);super(r),this.name="MissingJiraEnvironmentError",this.descriptors=t,this.missing=e,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,ce)}}function le(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,s=e?.response?.data??e?.data??e?.response?.body??e?.body,n=[];"string"==typeof e?.message&&n.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)}))})(s,n);const i=r?`Jira API error (${r})`:"Jira API error",o=n.length>0?n.join(" | "):i;return{code:r?"jira_"+r:e?.code??"jira_error",message:o,details:{httpStatus:r,body:s,raw:e}}}const pe=a.z.object({issueId:a.z.string().min(1),deleteSubtasks:a.z.boolean().optional().default(!0)}),de={name:"jira.issue-delete",inputSchema:pe,runTool:async(e,t)=>{try{const r=pe.parse(t),s=e.issues??e.issue??e,n=s?.delete??s?.deleteIssue;if("function"!=typeof n)throw Error("jira client delete endpoint is not available");return await n.call(s,{issueId:r.issueId,deleteSubtasks:r.deleteSubtasks}),{success:!0,message:`Issue ${t.issueId} deleted successfully`}}catch(e){throw le(e)}}},ue=a.z.object({issueId:a.z.string().min(1),expand:a.z.string().optional(),fields:a.z.array(a.z.string()).optional(),properties:a.z.array(a.z.string()).optional()}),me={name:"jira.issue-read",inputSchema:ue,runTool:async(e,t)=>{try{const r=ue.parse(t),s={issueIdOrKey:r.issueId};r.expand&&(s.expand=r.expand),r.fields&&(s.fields=r.fields),r.properties&&(s.properties=r.properties);const n=await e.issues.get(s);return n?.data??n}catch(e){throw le(e)}}};function he(e,t,r){const s=((e.url??"")+"").match(/^(attachment|jira-attachment):(.+)$/i);if(!s)return null;const n=s[2],i=r.resolveAttachment?.(n);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 fe(e,t){if(!e)return[];if(!t.enableAtMentions&&!t.enableEmojiShortcodes)return[{type:"text",text:e}];let r=0;const s=[],n=/(^|[^A-Za-z0-9_])@([A-Za-z0-9._-]{1,64})/g,i=/:([a-z0-9_+-]{1,64}):/gi;for(;r<e.length;){const o=ye(t.enableAtMentions?ge(n,e,r):null,t.enableEmojiShortcodes?ge(i,e,r):null);if(!o){s.push({type:"text",text:e.slice(r)});break}if(o.index>r&&s.push({type:"text",text:e.slice(r,o.index)}),"mention"===o.kind){const{full:e,groups:n}=o,i=n[0]??"",a=n[1]??"";i&&s.push({type:"text",text:i});const c=t.resolveMention?.(a);c?s.push({type:"mention",attrs:{id:c.id,text:c.text}}):s.push({type:"text",text:"@"+a}),r=o.index+e.length;continue}if("emoji"===o.kind){const{full:e,groups:n}=o,i=`:${n[0]}:`,a=t.resolveEmoji?.(i);s.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})(s)}function ge(e,t,r){e.lastIndex=r;const s=e.exec(t);if(!s)return null;const n=e.source.includes("@")?"mention":"emoji";return{index:s.index,full:s[0],groups:s.slice(1),kind:n}}function ye(e,t){return e?t&&e.index>t.index?t:e:t}function be(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 ve(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 we(e){const t=((e??"")+"").toLowerCase().trim();return!t||"neutral"!==t&&"green"!==t&&"yellow"!==t&&"red"!==t&&"blue"!==t&&"purple"!==t?null:t}function Se(e,t){const r=[];for(const s of e??[])if(s?.type)if("text"!==s.type)if("strong"!==s.type)if("emphasis"!==s.type)if("delete"!==s.type)if("inlineCode"!==s.type)if("break"!==s.type){if("link"===s.type){const e=(s.url??"")+"",n=xe(s.children??[],e),i=he(s,0,t);if(i){"inline"===i.type?r.push(i.node):r.push({type:"text",text:n,marks:[{type:"link",attrs:{href:e}}]});continue}if(t.enableSmartCards&&Ie(n,e)){r.push({type:"inlineCard",attrs:{url:e}});continue}r.push({type:"text",text:n,marks:[{type:"link",attrs:{href:e}}]});continue}if("textDirective"===s.type&&"status"===s.name){const e=be(s)||"Status",t=we(s.attributes?.color)??"neutral";r.push({type:"status",attrs:{text:e,color:t}});continue}if("textDirective"===s.type&&"emoji"===s.name){const e=_e(s);r.push(ze(e,t));continue}}else r.push({type:"hardBreak"});else r.push({type:"text",text:(s.value??"")+"",marks:[{type:"code"}]});else r.push(...je(Se(s.children??[],t),{type:"strike"}));else r.push(...je(Se(s.children??[],t),{type:"em"}));else r.push(...je(Se(s.children??[],t),{type:"strong"}));else r.push(...fe((s.value??"")+"",t));return r.filter(e=>!("text"===e.type&&""===(e.text??"")))}function je(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 xe(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(xe(t.children??[],""));return r.join("")||t}function Ie(e,t){const r=(e??"").trim(),s=(t??"").trim();return r===s&&/^https?:\/\//i.test(s)}function _e(e){return(e.children??[]).map(e=>"text"===e.type?(e.value??"")+"":"").join("").trim()||""}function ze(e,t){const r=e.startsWith(":")?e:`:${e}:`,s=t.resolveEmoji?.(r);return s?{type:"emoji",attrs:{shortName:s.shortName,text:s.text}}:{type:"emoji",attrs:{shortName:r}}}function Ee(e){return e?"string"==typeof e?e:"text"===e.type||"inlineCode"===e.type?(e.value??"")+"":Array.isArray(e.children)?e.children.map(Ee).join(""):"":""}function Te(e,t){if(!e?.type)return null;if((e=>"containerDirective"===e?.type&&"panel"===e?.name)(e))return((e,t)=>{const r=e.attributes??{},s=ve(r.type)??"info",n="string"==typeof r.title?r.title:void 0,i=(e.children??[]).map(e=>Te(e,t)).flat().filter(Boolean);return{type:"panel",attrs:{panelType:s,...n?{panelType:s,title:n}:{panelType:s}},content:i.length?i:[{type:"paragraph",content:[]}]}})(e,t);switch(e.type){case"heading":return{type:"heading",attrs:{level:Ae(e.depth??1,1,6)},content:Se(e.children??[],t)};case"paragraph":return(e=>{const t=e.children??[];if(1!==t.length)return null;const r=t[0];if("image"!==r?.type)return null;const s=(r.url??"")+"";return s?{type:"mediaSingle",attrs:{layout:"center"},content:[{type:"media",attrs:{type:"external",url:s}}]}:null})(e)||{type:"paragraph",content:Se(e.children??[],t)};case"blockquote":return{type:"blockquote",content:(e.children??[]).map(e=>Te(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 s=0;for(const n of e.children??[]){if("boolean"!=typeof n.checked)continue;s+=1;const e=(n.children??[]).map(e=>Te(e,t)).flat().filter(Boolean);r.push({type:"taskItem",attrs:{localId:"task-"+s,state:n.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=>Te(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:Se(e.children??[],t)}]}))}))}))(e,t);case"leafDirective":return"status"===e.name?(e=>{const t=we((e.attributes??{}).color)??"neutral";return{type:"paragraph",content:[{type:"status",attrs:{text:be(e)||"Status",color:t}}]}})(e):"panel"===e.name?((e,t)=>{const r=e.attributes??{},s=ve(r.type)??"info",n="string"==typeof r.title?r.title:void 0;return{type:"panel",attrs:{panelType:s,...n?{title:n}:{}},content:[{type:"paragraph",content:Se([{type:"text",value:be(e)}],t)}]}})(e,t):ke(e,t);default:return ke(e,t)}}function ke(e,t){if("drop"===t.unknownNodeStrategy)return null;const r=Ee(e);return r?{type:"paragraph",content:[{type:"text",text:r}]}:null}function Ae(e,t,r){const s=Number.isFinite(e)?Math.trunc(e):t;return Math.max(t,Math.min(r,s))}const Oe={resolveMention:void 0,resolveAttachment:void 0,resolveEmoji:void 0,enableSmartCards:!0,enableMermaid:!0,enableEmojiShortcodes:!0,enableAtMentions:!0,enableTaskLists:!0,unknownNodeStrategy:"text"};function Ne(e,t={}){const r={...Oe,...t},s=e??"",n=m.unified().use(g).use(f).use(h),i=n.parse(s),o=n.runSync(i);return Ce(o),((e,t)=>{const r=[];for(const s of e.children??[]){const e=Te(s,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 s=r.attrs?.url;return s?[{type:"blockCard",attrs:{url:s}}]:e})(e)).flat();return{...e,content:r}})({version:1,type:"doc",content:r},t)})(o,r)}function Ce(e){if(!e||!Array.isArray(e.children))return;const t=[];for(const r of e.children)"definition"!==r?.type&&("html"!==r?.type?(Ce(r),t.push(r)):t.push({type:"text",value:(r.value??"")+""}));e.children=t}const He=a.z.object({issueId:a.z.string().min(1),transitionId:a.z.union([a.z.string(),a.z.number()]),fields:a.z.record(a.z.any()).optional(),update:a.z.record(a.z.array(a.z.object({set:a.z.any().optional(),add:a.z.any().optional(),remove:a.z.any().optional()}))).optional(),comment:a.z.string().optional()}),De={name:"jira.issue-transition",inputSchema:He,runTool:async(e,t)=>{try{const r=He.parse(t),s={id:r.transitionId};r.fields&&(s.fields=r.fields),r.update&&(s.update=r.update),r.comment&&(s.comment={body:Ne(r.comment)});const n=await e.issues.transition({issueId:r.issueId,transition:s});return n?.data??n}catch(e){throw le(e)}}},Je=a.z.object({issueId:a.z.string().min(1),fields:a.z.record(a.z.any()).optional(),update:a.z.record(a.z.array(a.z.object({set:a.z.any().optional(),add:a.z.any().optional(),remove:a.z.any().optional(),edit:a.z.any().optional()}))).optional(),properties:a.z.array(a.z.any()).optional(),notifyUsers:a.z.boolean().optional().default(!0),issueTemplateId:a.z.string().optional(),overrideScreenSecurity:a.z.boolean().optional().default(!1),overrideEditableFlag:a.z.boolean().optional().default(!1)}),qe={name:"jira.issue-update",inputSchema:Je,runTool:async(e,t)=>{try{const r=Je.parse(t),s={issueId:r.issueId};r.fields&&(s.fields=r.fields),r.update&&(s.update=r.update),r.properties&&(s.properties=r.properties),void 0!==r.notifyUsers&&(s.notifyUsers=r.notifyUsers),r.issueTemplateId&&(s.issueTemplateId=r.issueTemplateId),void 0!==r.overrideScreenSecurity&&(s.overrideScreenSecurity=r.overrideScreenSecurity),void 0!==r.overrideEditableFlag&&(s.overrideEditableFlag=r.overrideEditableFlag);const n=await e.issues.update(s);return n?.data??n}catch(e){throw le(e)}}},Pe=a.z.object({issueId:a.z.string().min(1),assignee:a.z.union([a.z.string(),a.z.object({accountId:a.z.string().min(1)}),a.z.object({accountType:a.z.string().min(1)})])}),Me={name:"jira.assign-issue",inputSchema:Pe,runTool:async(e,t)=>{try{const r=Pe.parse(t);let s;s="string"==typeof r.assignee?{accountId:r.assignee}:r.assignee;const n=await e.issues.assign({issueId:r.issueId,assignee:s});return n?.data??n}catch(e){throw le(e)}}},Re=a.z.object({issueId:a.z.string().min(1)}),$e={name:"jira.unassign-issue",inputSchema:Re,runTool:async(e,t)=>{try{const r=Re.parse(t),s=await e.issues.assign({issueId:r.issueId,assignee:{accountId:"-1"}});return s?.data??s}catch(e){throw le(e)}}},Le=a.z.object({issueId:a.z.string().min(1),body:a.z.string().min(1),visibility:a.z.object({type:a.z.enum(["role","group"]),value:a.z.string().min(1)}).optional()}),Fe={name:"jira.comment-add",inputSchema:Le,runTool:async(e,t)=>{try{const r=Le.parse(t),s={body:Ne(r.body)};r.visibility&&(s.visibility=r.visibility);const n=await e.issues.addComment({issueId:r.issueId,comment:s});return n?.data??n}catch(e){throw le(e)}}},Be=a.z.object({issueId:a.z.string().min(1),start:a.z.number().optional().default(0),maxResults:a.z.number().optional().default(50),orderBy:a.z.string().optional(),expand:a.z.string().optional()}),We={name:"jira.comment-list",inputSchema:Be,runTool:async(e,t)=>{try{const r=Be.parse(t),s=await e.issues.getComments({issueId:r.issueId,start:r.start,maxResults:r.maxResults,orderBy:r.orderBy,expand:r.expand});return s?.data??s}catch(e){throw le(e)}}},Ue=a.z.object({link:a.z.object({relationship:a.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:a.z.object({id:a.z.string().optional(),key:a.z.string().optional()}),outwardIssue:a.z.object({id:a.z.string().optional(),key:a.z.string().optional()}),comment:a.z.object({body:a.z.string().optional(),visibility:a.z.object({type:a.z.enum(["role","group"]),value:a.z.string().min(1)}).optional()}).optional()})}),Ke={name:"jira.link-create",inputSchema:Ue,runTool:async(e,t)=>{try{const r=Ue.parse(t).link,s={relationship:r.relationship,inwardIssue:r.inwardIssue.id||r.inwardIssue.key,outwardIssue:r.outwardIssue.id||r.outwardIssue.key};r.comment&&(r.comment.body&&(s.comment=Ne(r.comment.body)),r.comment.visibility&&(s.visibility=r.comment.visibility));const n=await e.issues.link(s);return n?.data??n}catch(e){throw le(e)}}},Ye=a.z.object({issueId:a.z.string().min(1),file:a.z.string().min(1),mimeType:a.z.string().optional(),comment:a.z.string().optional()}),Ve={name:"jira.attach",inputSchema:Ye,runTool:async(e,s)=>{try{const n=Ye.parse(s),i=r.resolve(n.file),o=await t.promises.readFile(i),a=r.basename(i),c=await e.issues.addAttachment({issueId:n.issueId,file:{name:a,content:o,mimeType:n.mimeType??"application/octet-stream"},comment:n.comment});return c?.data??c}catch(e){if(e&&e.code&&"string"==typeof e.code&&["ENOENT","EACCES"].includes(e.code))throw Error("Attachment file error: "+e.message);throw le(e)}}},Ge=a.z.object({issueId:a.z.string().min(1)}),Ze={name:"jira.attachment-list",inputSchema:Ge,runTool:async(e,t)=>{try{const r=Ge.parse(t),s=await e.issues.getAttachments({issueId:r.issueId});return s?.data??s}catch(e){throw le(e)}}},Qe=a.z.object({issueId:a.z.string().min(1),attachmentId:a.z.string().min(1)}),Xe={name:"jira.attachment-delete",inputSchema:Qe,runTool:async(e,t)=>{try{const r=Qe.parse(t);return await e.issues.deleteAttachment({issueId:r.issueId,attachmentId:r.attachmentId}),{success:!0,message:`Attachment ${t.attachmentId} deleted successfully`}}catch(e){throw le(e)}}},et=a.z.object({issueId:a.z.string().min(1),timeSpent:a.z.string().min(1),comment:a.z.string().optional(),author:a.z.object({accountId:a.z.string().min(1)}).optional(),startingOn:a.z.string().optional(),artifact:a.z.string().optional()}),tt={name:"jira.worklog-add",inputSchema:et,runTool:async(e,t)=>{try{const r=et.parse(t),s={timeSpent:r.timeSpent};r.comment&&(s.comment=r.comment),r.author&&(s.author=r.author),r.startingOn&&(s.started=r.startingOn),r.artifact&&(s.artifact=r.artifact);const n=await e.issues.addWorklog({issueId:r.issueId,...s});return n?.data??n}catch(e){throw le(e)}}},rt={[me.name]:{title:"Jira Issue Read",description:"Read a Jira issue with expandable fields and properties",annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},[qe.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}},[de.name]:{title:"Jira Issue Delete",description:"Delete a Jira issue and optionally remove its subtasks",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0}},[De.name]:{title:"Jira Issue Transition",description:"Transition a Jira issue while optionally adding a comment",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[Me.name]:{title:"Jira Issue Assign",description:"Assign a Jira issue to a user or account",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[$e.name]:{title:"Jira Issue Unassign",description:"Unassign the current owner from a Jira issue",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[Fe.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}},[We.name]:{title:"Jira Comment List",description:"List comments on a Jira issue with pagination support",annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},[Ke.name]:{title:"Jira Link Create",description:"Create an issue link relationship with optional comment",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[Ve.name]:{title:"Jira Attachment Add",description:"Attach a local file to a Jira issue",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[Ze.name]:{title:"Jira Attachment List",description:"List attachments on a Jira issue",annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},[Xe.name]:{title:"Jira Attachment Delete",description:"Delete an attachment from a Jira issue",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0}},[tt.name]:{title:"Jira Worklog Add",description:"Log time spent on a Jira issue",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}}};async function st(e){const t=s.Logging.for(st);let r,n=null;try{r=(()=>{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:s}=(()=>{const e=ie(),t=oe().filter(e=>e.required&&!e.value);if(t.length>0)throw new ce(t);return{host:e.host,email:e.email,apiKey:e.apiKey}})();return new e({host:t,authentication:{basic:{email:r,apiToken:s}}})})()}catch(e){if(!(e instanceof ce))return void t.warn("Skipping Jira tool registration; unable to create Jira client",{error:e});n=e,t.warn("Registering Jira tools without credentials; each tool will report configuration requirements.",{error:e})}const i=[me,qe,de,De,Me,$e,Fe,We,Ke,Ve,Ze,Xe,tt];for(const s of i){const i=rt[s.name];if(i)try{await e.registerTool(s.name,{title:i.title,description:i.description,inputSchema:q(s.inputSchema),annotations:i.annotations},async e=>{if(!r)throw n??Error("Jira client unavailable because credentials could not be loaded.");return s.runTool(r,e)}),t.info("Registered Jira tool "+s.name)}catch(e){t.error("Failed to register Jira tool "+s.name,{error:e})}}}async function nt(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=Q.map(e=>e.getName()).sort();return{content:[{type:"text",text:["Name: "+ne.name,"Title: "+ne.title,"Version: "+ne.version,"Prompts: "+(e.join(", ")||"<none>")].join("\n")}]}})})(e);const t=s.Logging.for(nt);try{await st(e)}catch(e){t.error("Failed to register Jira tools",e)}}class it 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 it}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:{}}),s=async(e,t)=>{const r=this.logFor(t);r.verbose(`Requesting resource ${this.name} from ${e.toString()}`);const s=await Promise.resolve(this.cb(e,t));return r.verbose(`Resource ${this.name} retrieved successfully.`),r.debug("Resource retrieval meta: "+JSON.stringify(s._meta)),s};return e.resource(this.name,t,r,s)}catch(e){throw s.Logging.for(this).error("Error registering resource "+this.name,e),e}}}i.__decorate([o.required(),i.__metadata("design:type",String)],it.prototype,"uriOrTemplate",void 0),i.__decorate([o.required(),i.__metadata("design:type",Function)],it.prototype,"cb",void 0),i.__decorate([o.required(),i.__metadata("design:type",Object)],it.prototype,"config",void 0);const ot=I.join(process.cwd(),"src/assets"),at=I.join(ot,"templates"),ct=I.join(ot,"prompts"),lt=new WeakMap;class pt extends s.LoggedClass{get client(){const e=lt.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 Q)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 nt(this.client),e.verbose("Registered built-in tools")}catch(t){e.error("Failed to register tools",t)}try{await(async(e,t)=>{t.info("Registering agent templates as resources...");const r=x.readdirSync(at).filter(e=>e.endsWith(".md"));for(const s of r){const r=I.basename(s,".md"),n=I.join(at,s),i=it.builder.setName(r).setTitle("Template: "+r).setDescription("Resource template for "+r).setUriOtTemplate("file:///"+n).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 s=x.readdirSync(ct).filter(e=>e.endsWith(".md"));for(const r of s){const s=I.basename(r,".md"),n=I.join(ct,r),i=x.readFileSync(n,"utf8"),o=F.builder.setName(s).setTitle("Prompt: "+s).setDescription("Dynamic prompt for "+s).setArgsSchema(a.z.object({})).setCb(async e=>({messages:[{role:"user",content:{type:"text",text:i}}],_meta:{}}));try{o.build(e),t.info("Registered prompt: "+s)}catch(e){t.error(`Failed to register prompt ${s}:`,e)}}})(this.client,e),e.verbose("Registered agent-specific assets")}catch(t){e.error("Failed to register agent assets",t)}}async boot(e="stdio"){let t=this.log;this.log.for(this.boot).info("McpServer booting..."),((e=s.Logging.get())=>{let t;try{t=(()=>{let e,t=__dirname;try{for(;t&&t!==I.parse(t).root;){const r=I.join(t,"node_modules");if(x.existsSync(r)&&x.statSync(r).isDirectory()){e=r;break}const s=I.dirname(t);if(s===t)break;t=s}}catch{}const r=[];if(e){const t=I.join(e,"@decaf-ts");try{if(x.existsSync(t)&&x.statSync(t).isDirectory()){const e=x.readdirSync(t);for(const s of e){const e=I.join(t,s);try{const t=I.join(e,"workdocs","assets","slogans.json");if(x.existsSync(t)&&x.statSync(t).isFile()){const e=x.readFileSync(t,"utf-8"),s=JSON.parse(e);if(Array.isArray(s))for(const e of s)"string"==typeof e&&e.trim().length>0&&r.push(e.trim())}}catch{}}}}catch{}}return 0===r.length?"Decaf: strongly brewed TypeScript.":r[Math.floor(Math.random()*r.length)]})()}catch{t="Decaf: strongly brewed TypeScript."}const r="# \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \n# ( ( \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \n# ) ) \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \n# [=======] \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \n# `-----\xb4 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \n# \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \n# \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \n#".split("\n"),i=r.reduce((e,t)=>Math.max(e,t.length),0);r.push("# "+t.padStart(i-3)),r.forEach((t,r)=>{const s=E[r%E.length]||"",i=e.info.bind(e);try{i(n.style(t||"").raw(s).text)}catch{i((t||"")+"")}})})(this.log),"stdio"===e&&(s.Logging.setFactory(z),t=s.Logging.for(this.constructor.name));const r=((Array.isArray(ne.icons)?ne.icons:[ne.icons])||[]).map(e=>{const t="string"==typeof e?.src?e.src:(e?.src??"")+"",r="string"==typeof e?.mimeType?e.mimeType:(e?.mimeType??"")+"";let s=[];return Array.isArray(e?.sizes)?s=e.sizes.map(e=>e+""):"string"==typeof e?.sizes&&(s=(e.sizes+"").split(",").map(e=>e.trim())),{src:t,mimeType:r,sizes:s}}),i={name:ne.name,title:ne.title,websiteUrl:ne.websiteUrl,version:ne.version,icons:r},o=new b.McpServer(i,{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)=>{lt.set(e,t)})(this,o),o.onerror=e=>{this.log.error("MCP instance onerror",e)},e){case"stdio":e=new w.StdioServerTransport;break;case"http":e=new S.StreamableHTTPServerTransport({sessionIdGenerator:()=>v.v4(),onsessioninitialized:e=>t.verbose("Session initialized: "+e),onsessionclosed:e=>t.verbose("Session closed: "+e),enableJsonResponse:!0,eventStore:void 0});break;default:if(!(a=e)||"object"!=typeof a||"function"!=typeof a.send&&"function"!=typeof a.close&&"function"!=typeof a.on)throw new p.InternalError("Invalid transport type: "+e)}var a;try{this.log.info("Loading resources/prompts/tools..."),await this.load()}catch(e){throw this.log.error("Error loading resources/prompts/tools: "+e),e}await this.client.connect(e),t.info(`MCP Server connected via ${e.constructor.name} and running. Waiting for client connections...`)}}const dt=(new e.Command).command("start").option("--transport [String]","transport mode","stdio").description("starts decaf's mcp server").action(async e=>{const s=JSON.parse(t.readFileSync(r.join(process.cwd(),"package.json"),"utf-8")),n=s.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 ${s.name} version ${n}`),(new pt).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=JSON.parse(t.readFileSync(r.join(process.cwd(),"package.json"),"utf-8")),i=n.version;s.Logging.for("md-to-ast").debug(`running with options: ${JSON.stringify(e)} for ${n.name} version ${i}`);const o=Ne(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 ut=(new e.Command).name("mcp-server").command("mcp-server").description("decaf mcp server and agentic functionality");ut.addCommand(dt),ut.parse(process.argv)},"object"==typeof exports&&"undefined"!=typeof module?t(require("commander"),require("fs"),require("path"),require("@decaf-ts/logging"),require("styled-string-builder"),require("tslib"),require("@decaf-ts/decorator-validation"),require("zod"),require("@decaf-ts/injectable-decorators"),require("@decaf-ts/decoration"),require("@decaf-ts/db-decorators"),require("crypto"),require("zlib"),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","path","@decaf-ts/logging","styled-string-builder","tslib","@decaf-ts/decorator-validation","zod","@decaf-ts/injectable-decorators","@decaf-ts/decoration","@decaf-ts/db-decorators","crypto","zlib","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.path,e.decafTsLogging,e.styledStringBuilder,e.tslib,e.decafTsDecoratorValidation,e.zod,e.decafTsInjectableDecorators,e.decafTsDecoration,e.decafTsDbDecorators,e.crypto,e.zlib,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,s,n,i,o,a,c,l,p,d,u,m,h,f,g,y,b,v,w,S){"use strict";function j(e){var t=Object.create(null);return e&&Object.keys(e).forEach(r=>{if("default"!==r){var s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>e[r]})}}),t.default=e,Object.freeze(t)}var x=j(t),I=j(r);class _ extends s.MiniLogger{log(e,t,r,n){const i=this.config("level");s.NumericLogLevels[i],s.NumericLogLevels[e]}}const z=(e,t,...r)=>{const s=(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 _(s,t)},E=["\x1b[38;5;215m","\x1b[38;5;209m","\x1b[38;5;205m","\x1b[38;5;210m","\x1b[38;5;217m","\x1b[38;5;216m","\x1b[38;5;224m","\x1b[38;5;230m","\x1b[38;5;230m"];var T,k,A,O,N;(e=>{e[e.NONE=0]="NONE",e[e.BASIC=1]="BASIC",e[e.ADVANCED=2]="ADVANCED",e[e.HIGH=3]="HIGH"})(T||(T={})),(e=>{e[e.NONE=0]="NONE",e[e.LOW=1]="LOW",e[e.MEDIUM=2]="MEDIUM",e[e.HIGH=3]="HIGH"})(k||(k={})),(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 o.Model{get log(){return this._log||(this._log=s.Logging.for(this)),this._log}constructor(e){super(e)}logFor(e){const{sessionId:t,requestId:r,authInfo:s}=e||{};let n="string"==typeof t&&t.length>0?this.log.for(t):this.log;return s&&s.clientId&&(n=n.for(s.clientId)),r&&(n=n.for(r.toString())),n}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}}i.__decorate([o.required(),i.__metadata("design:type",String)],C.prototype,"description",void 0),i.__decorate([o.required(),i.__metadata("design:type",String)],C.prototype,"name",void 0),i.__decorate([o.required(),i.__metadata("design:type",String)],C.prototype,"title",void 0);class H extends C{constructor(e){super(e),this.reasoning=T.NONE,this.effort=k.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 D(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(D(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,s]of Object.entries(r))e[t]=P(s)?s:a.z.any();return a.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=D(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)}i.__decorate([o.required(),i.__metadata("design:type",Number)],H.prototype,"reasoning",void 0),i.__decorate([o.required(),i.__metadata("design:type",Number)],H.prototype,"effort",void 0),i.__decorate([o.required(),i.__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 M=Buffer.from("DCAF1","ascii");function R(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 s=I.join(t,"assets");if(x.existsSync(s))return s;const n=I.dirname(t);if(n===t)break;t=n}}function $(){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=process.argv?.[1];if(t){const e=R(I.dirname(t));if(e)return e}const r=[process.cwd(),process.env.INIT_CWD].filter(Boolean);for(const e of r){const t=R(e);if(t)return t}return I.join(process.cwd(),"assets")}let L=class extends s.LoggedClass{constructor(e){super(),this.basePath=e||$()}listAssets(...e){const t=I.join(this.basePath,...e);return x.readdirSync(t)}listPrompts(){return this.listAssets(N.PROMPT)}getAsset(e,t="md",...r){const s=I.join(this.basePath,...r),n=(e,t=!1)=>{try{return t?(e=>{if(e.length<M.length+16+12+16)throw Error("Invalid prompt payload (too short)");if(!e.subarray(0,M.length).equals(M))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=M.length;const s=e.subarray(r,r+16);r+=16;const n=e.subarray(r,r+12);r+=12;const i=e.subarray(r,r+16);r+=16;const o=e.subarray(r),a=((e,t)=>d.scryptSync(e,t,32))(t,s),c=d.createDecipheriv("aes-256-gcm",a,n);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=n(I.join(s,`${e}.${t}`),"enc"===t);if(null!==i)return i;const o=n(I.join(s,e+".enc"),!0);if(null!==o)return o;throw Error("Asset not found: "+I.join(s,`${e}.${t}`))}getAllAssets(e,...t){return this.listAssets(e,...t).reduce((r,s)=>{const n=I.extname(s),i=I.basename(s,n),o=n.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 T.NONE;case"basic":return T.BASIC;case"advanced":return T.ADVANCED;case"high":return T.HIGH;case"medium":return k.MEDIUM;case"low":return A.LOW;case"free":return A.FREE;default:throw new p.InternalError("Cannon convert unknown level "+e)}})(e.toLowerCase()):T.NONE;return e.effort=t(e.effort),e.reasoning=t(e.reasoning),e.cost=t(e.cost),e}getPrompt(e,...t){const r=this.getAsset(s.toSnakeCase(e),"json",N.PROMPT,...t);let n;try{n=JSON.parse(r)}catch(r){throw new p.SerializationError(`Failed to parse prompt ${e} in categories ${t}: ${r}`)}return this.toPromptDef(n)}getAllPrompts(...e){const t=this.getAllAssets(N.PROMPT,...e);return Object.entries(t).reduce((t,[r,s])=>{try{t[r]=JSON.parse(s)}catch(t){throw new p.SerializationError(`Failed to parse prompt ${r} in categories ${e}: ${t}`)}return t},t)}};L=i.__decorate([c.injectable(),i.__metadata("design:paramtypes",[String])],L);class F 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 F}static patchPrompt(e,t,r,n){const i=(t=Array.isArray(t)?t:Object.keys(t)).filter(e=>!Object.prototype.hasOwnProperty.call(r,e));if(i.length)throw new p.ValidationError("Missing replacements for placeholders: "+i.join(", "));n&&(n.verbose("Patching prompt with placeholders: "+JSON.stringify(t)),n.debug("Values: "+JSON.stringify(r)));const o=t.reduce((e,t)=>(e[t]=r[t],e),{});return s.sf(e,o)}patchPrompt(e,t,r,s){return F.patchPrompt(e,t,r,s||this.log.for(this.patchPrompt))}build(e,t){const r=this.log.for(this.build),s=this.hasErrors();if(s)throw new p.ValidationError(s.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 s=this.logFor(r);e=Object.assign({},t,e||{}),s.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 n=await Promise.resolve(this.cb(e,r));return s.verbose(`Prompt ${this.name} executed successfully.`),s.debug("Prompt execution meta: "+JSON.stringify(n._meta)),n})}catch(e){throw r.error("Failed to register prompt "+(this.name||this.constructor.name),e),e}}}i.__decorate([c.inject(L),i.__metadata("design:type",L)],F.prototype,"assets",void 0),i.__decorate([o.required(),i.__metadata("design:type",Object)],F.prototype,"cb",void 0),i.__decorate([o.required(),i.__metadata("design:type",a.ZodObject)],F.prototype,"argsSchema",void 0),i.__decorate([l.prop(),i.__metadata("design:type",Object)],F.prototype,"placeholders",void 0);class B extends F{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);o.Model.fromObject(this,t);const r=new Set((l.Metadata.properties(B)||[]).filter(e=>!["assets","promptCategory","prefixes","suffixes"].includes(e)));["cb","argsSchema"].forEach(e=>r.add(e));const s=this.hasErrors(...Array.from(r));if(s)throw new p.ValidationError(s.toString());const n=(this.prefixes||[]).map(e=>this.assets.getPrompt(e,this.promptCategory)),i=(this.suffixes||[]).map(e=>this.assets.getPrompt(e,this.promptCategory)),c=[...new Set([...t.placeholders,...n.map(e=>e.placeholders||[]),...i.map(e=>e.placeholders||[])].flat())].reduce((e,t)=>(e[t]=a.z.string().describe("The description for "+t),e),{});return this.setArgsSchema(a.z.object(c)),this.setCb((e,t)=>{const r=this.logFor(t).for(B).for(this.promptCategory).for(this.name);function s(e=[]){return Array.isArray(e)?e:Object.keys(e)}const n=(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([...n.map(e=>s(e.placeholders)).flat(),...i.map(e=>s(e.placeholders)).flat(),...s(o.placeholders).flat()])];return{messages:[{role:"user",content:{type:"text",text:this.patchPrompt([...n.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 p.InternalError("Named prompt builders don't require callback")}setEffort(e){throw new p.InternalError("Named prompt builders don't require callback")}setCost(e){throw new p.InternalError("Named prompt builders don't require callback")}setDescription(e){throw new p.InternalError("Named prompt builders don't require callback")}setTitle(e){throw new p.InternalError("Named prompt builders don't require callback")}static get builder(){return new B}}i.__decorate([o.required(),i.__metadata("design:type",String)],B.prototype,"promptCategory",void 0),i.__decorate([o.list(String),o.minlength(1),i.__metadata("design:type",Array)],B.prototype,"prefixes",void 0),i.__decorate([o.minlength(1),o.list(String),i.__metadata("design:type",Array)],B.prototype,"suffixes",void 0);const W=F.builder.setName("example.prompt").setTitle("Example prompt").setDescription("Example prompt for testing").setArgsSchema(a.z.object({message:a.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}}}),U=F.builder.setName("interactive.jsdoc").setTitle("Interactive JSDoc prompt").setDescription("Interactive prompt for jogging JSDoc helpers").setArgsSchema(a.z.object({gist:a.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}}}),K=Object.assign(U,{name:U.getName()});var Y;function V(e,t=[],r=[]){const s=B.builder.setCategory(Y.DOCS).setName(e);return["prefix",...t].forEach(e=>s.addPrefix(e)),["suffix",...r].forEach(e=>s.addSuffix(e)),s}(e=>{e.DOCS="documentation",e.CODE="code"})(Y||(Y={}));const G=[V("class"),V("constant"),V("decorator"),V("function"),V("module"),V("file"),V("repo",[],["iterate"])],Z=a.z.object({className:a.z.string().describe("the class name to turn into a builder")}),Q=[W,K,...G,F.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(Z).setReasoning(T.BASIC).setCb((e,t)=>(e.className=s.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 X 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 X}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 s=await Promise.resolve(this.cb(e,t));return r.verbose(`Tool ${this.name} executed successfully.`),r.debug("Tool execution meta: "+JSON.stringify(s._meta)),s})}catch(e){const t=e?.message||e+"";if("string"==typeof t&&t.includes("already registered"))return s.Logging.for(this).warn(`Tool ${this.name} already registered - skipping duplicate registration`),{name:this.name};throw s.Logging.for(this).error("Error building tool",e),e}}}i.__decorate([o.required(),i.__metadata("design:type",Object)],X.prototype,"annotations",void 0),i.__decorate([o.required(),i.__metadata("design:type",Object)],X.prototype,"cb",void 0),i.__decorate([o.required(),i.__metadata("design:type",Function)],X.prototype,"inputSchema",void 0);const ee=X.builder.setName("example.tool").setTitle("Example tool").setDescription("A smoke tool used for quick testing").setInputSchema(a.z.object({})).setCb(async()=>({content:[{type:"text",text:"example tool ok"}],result:{status:"ok"}}));Object.assign(ee,{name:ee.getName()});const te=X.builder.setName("file.summarizer").setTitle("File summarizer").setDescription("Summaries files for quick previews").setInputSchema(a.z.object({filePath:a.z.string().optional()})).setCb(async()=>({content:[{type:"text",text:"file summary stub"}],result:{summary:"file summary stub"}}));Object.assign(te,{name:te.getName()});const re="##VERSION##";l.Metadata.registerLibrary("##PACKAGE##",re);const se={mcpId:"decaf",name:"decaf-ts mcp server",title:"Decaf-TS MCP Server",description:"Provides precise coding assistance for the decaf-ts framework",version:re,websiteUrl:"https://decaf-ts.github.io",repositoryUrl:"https://github.com/decaf-ts/mcp-server",license:"AGPL-3.0",workingDir:process.cwd(),assetDir:$(),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:s.LogLevel.error},ne=s.LoggedEnvironment.accumulate(se);function ie(){const{host:e,email:t,apiKey:r,projectKey:s,issueType:n}=ne.jira;return{host:e?.trim(),email:t?.trim(),apiKey:r?.trim(),projectKey:s?.trim(),issueType:n?.trim(),parentIssue:ne.jira.parentIssue?.trim()}}function oe(){const e=ie();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 ae(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}.`}s.Logging.setConfig(ne);class ce extends Error{constructor(e){const t=oe(),r=(e=>{const t=oe();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(ae).join("\n")}`})(e);super(r),this.name="MissingJiraEnvironmentError",this.descriptors=t,this.missing=e,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,ce)}}function le(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,s=e?.response?.data??e?.data??e?.response?.body??e?.body,n=[];"string"==typeof e?.message&&n.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)}))})(s,n);const i=r?`Jira API error (${r})`:"Jira API error",o=n.length>0?n.join(" | "):i;return{code:r?"jira_"+r:e?.code??"jira_error",message:o,details:{httpStatus:r,body:s,raw:e}}}const pe=a.z.object({issueId:a.z.string().min(1),deleteSubtasks:a.z.boolean().optional().default(!0)}),de={name:"jira.issue-delete",inputSchema:pe,runTool:async(e,t)=>{try{const r=pe.parse(t),s=e.issues??e.issue??e,n=s?.delete??s?.deleteIssue;if("function"!=typeof n)throw Error("jira client delete endpoint is not available");return await n.call(s,{issueId:r.issueId,deleteSubtasks:r.deleteSubtasks}),{success:!0,message:`Issue ${t.issueId} deleted successfully`}}catch(e){throw le(e)}}},ue=a.z.object({issueId:a.z.string().min(1),expand:a.z.string().optional(),fields:a.z.array(a.z.string()).optional(),properties:a.z.array(a.z.string()).optional()}),me={name:"jira.issue-read",inputSchema:ue,runTool:async(e,t)=>{try{const r=ue.parse(t),s={issueIdOrKey:r.issueId};r.expand&&(s.expand=r.expand),r.fields&&(s.fields=r.fields),r.properties&&(s.properties=r.properties);const n=await e.issues.get(s);return n?.data??n}catch(e){throw le(e)}}};function he(e,t,r){const s=((e.url??"")+"").match(/^(attachment|jira-attachment):(.+)$/i);if(!s)return null;const n=s[2],i=r.resolveAttachment?.(n);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 fe(e,t){if(!e)return[];if(!t.enableAtMentions&&!t.enableEmojiShortcodes)return[{type:"text",text:e}];let r=0;const s=[],n=/(^|[^A-Za-z0-9_])@([A-Za-z0-9._-]{1,64})/g,i=/:([a-z0-9_+-]{1,64}):/gi;for(;r<e.length;){const o=ye(t.enableAtMentions?ge(n,e,r):null,t.enableEmojiShortcodes?ge(i,e,r):null);if(!o){s.push({type:"text",text:e.slice(r)});break}if(o.index>r&&s.push({type:"text",text:e.slice(r,o.index)}),"mention"===o.kind){const{full:e,groups:n}=o,i=n[0]??"",a=n[1]??"";i&&s.push({type:"text",text:i});const c=t.resolveMention?.(a);c?s.push({type:"mention",attrs:{id:c.id,text:c.text}}):s.push({type:"text",text:"@"+a}),r=o.index+e.length;continue}if("emoji"===o.kind){const{full:e,groups:n}=o,i=`:${n[0]}:`,a=t.resolveEmoji?.(i);s.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})(s)}function ge(e,t,r){e.lastIndex=r;const s=e.exec(t);if(!s)return null;const n=e.source.includes("@")?"mention":"emoji";return{index:s.index,full:s[0],groups:s.slice(1),kind:n}}function ye(e,t){return e?t&&e.index>t.index?t:e:t}function be(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 ve(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 we(e){const t=((e??"")+"").toLowerCase().trim();return!t||"neutral"!==t&&"green"!==t&&"yellow"!==t&&"red"!==t&&"blue"!==t&&"purple"!==t?null:t}function Se(e,t){const r=[];for(const s of e??[])if(s?.type)if("text"!==s.type)if("strong"!==s.type)if("emphasis"!==s.type)if("delete"!==s.type)if("inlineCode"!==s.type)if("break"!==s.type){if("link"===s.type){const e=(s.url??"")+"",n=xe(s.children??[],e),i=he(s,0,t);if(i){"inline"===i.type?r.push(i.node):r.push({type:"text",text:n,marks:[{type:"link",attrs:{href:e}}]});continue}if(t.enableSmartCards&&Ie(n,e)){r.push({type:"inlineCard",attrs:{url:e}});continue}r.push({type:"text",text:n,marks:[{type:"link",attrs:{href:e}}]});continue}if("textDirective"===s.type&&"status"===s.name){const e=be(s)||"Status",t=we(s.attributes?.color)??"neutral";r.push({type:"status",attrs:{text:e,color:t}});continue}if("textDirective"===s.type&&"emoji"===s.name){const e=_e(s);r.push(ze(e,t));continue}}else r.push({type:"hardBreak"});else r.push({type:"text",text:(s.value??"")+"",marks:[{type:"code"}]});else r.push(...je(Se(s.children??[],t),{type:"strike"}));else r.push(...je(Se(s.children??[],t),{type:"em"}));else r.push(...je(Se(s.children??[],t),{type:"strong"}));else r.push(...fe((s.value??"")+"",t));return r.filter(e=>!("text"===e.type&&""===(e.text??"")))}function je(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 xe(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(xe(t.children??[],""));return r.join("")||t}function Ie(e,t){const r=(e??"").trim(),s=(t??"").trim();return r===s&&/^https?:\/\//i.test(s)}function _e(e){return(e.children??[]).map(e=>"text"===e.type?(e.value??"")+"":"").join("").trim()||""}function ze(e,t){const r=e.startsWith(":")?e:`:${e}:`,s=t.resolveEmoji?.(r);return s?{type:"emoji",attrs:{shortName:s.shortName,text:s.text}}:{type:"emoji",attrs:{shortName:r}}}function Ee(e){return e?"string"==typeof e?e:"text"===e.type||"inlineCode"===e.type?(e.value??"")+"":Array.isArray(e.children)?e.children.map(Ee).join(""):"":""}function Te(e,t){if(!e?.type)return null;if((e=>"containerDirective"===e?.type&&"panel"===e?.name)(e))return((e,t)=>{const r=e.attributes??{},s=ve(r.type)??"info",n="string"==typeof r.title?r.title:void 0,i=(e.children??[]).map(e=>Te(e,t)).flat().filter(Boolean);return{type:"panel",attrs:{panelType:s,...n?{panelType:s,title:n}:{panelType:s}},content:i.length?i:[{type:"paragraph",content:[]}]}})(e,t);switch(e.type){case"heading":return{type:"heading",attrs:{level:Ae(e.depth??1,1,6)},content:Se(e.children??[],t)};case"paragraph":return(e=>{const t=e.children??[];if(1!==t.length)return null;const r=t[0];if("image"!==r?.type)return null;const s=(r.url??"")+"";return s?{type:"mediaSingle",attrs:{layout:"center"},content:[{type:"media",attrs:{type:"external",url:s}}]}:null})(e)||{type:"paragraph",content:Se(e.children??[],t)};case"blockquote":return{type:"blockquote",content:(e.children??[]).map(e=>Te(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 s=0;for(const n of e.children??[]){if("boolean"!=typeof n.checked)continue;s+=1;const e=(n.children??[]).map(e=>Te(e,t)).flat().filter(Boolean);r.push({type:"taskItem",attrs:{localId:"task-"+s,state:n.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=>Te(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:Se(e.children??[],t)}]}))}))}))(e,t);case"leafDirective":return"status"===e.name?(e=>{const t=we((e.attributes??{}).color)??"neutral";return{type:"paragraph",content:[{type:"status",attrs:{text:be(e)||"Status",color:t}}]}})(e):"panel"===e.name?((e,t)=>{const r=e.attributes??{},s=ve(r.type)??"info",n="string"==typeof r.title?r.title:void 0;return{type:"panel",attrs:{panelType:s,...n?{title:n}:{}},content:[{type:"paragraph",content:Se([{type:"text",value:be(e)}],t)}]}})(e,t):ke(e,t);default:return ke(e,t)}}function ke(e,t){if("drop"===t.unknownNodeStrategy)return null;const r=Ee(e);return r?{type:"paragraph",content:[{type:"text",text:r}]}:null}function Ae(e,t,r){const s=Number.isFinite(e)?Math.trunc(e):t;return Math.max(t,Math.min(r,s))}const Oe={resolveMention:void 0,resolveAttachment:void 0,resolveEmoji:void 0,enableSmartCards:!0,enableMermaid:!0,enableEmojiShortcodes:!0,enableAtMentions:!0,enableTaskLists:!0,unknownNodeStrategy:"text"};function Ne(e,t={}){const r={...Oe,...t},s=e??"",n=m.unified().use(g).use(f).use(h),i=n.parse(s),o=n.runSync(i);return Ce(o),((e,t)=>{const r=[];for(const s of e.children??[]){const e=Te(s,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 s=r.attrs?.url;return s?[{type:"blockCard",attrs:{url:s}}]:e})(e)).flat();return{...e,content:r}})({version:1,type:"doc",content:r},t)})(o,r)}function Ce(e){if(!e||!Array.isArray(e.children))return;const t=[];for(const r of e.children)"definition"!==r?.type&&("html"!==r?.type?(Ce(r),t.push(r)):t.push({type:"text",value:(r.value??"")+""}));e.children=t}const He=a.z.object({issueId:a.z.string().min(1),transitionId:a.z.union([a.z.string(),a.z.number()]),fields:a.z.record(a.z.any()).optional(),update:a.z.record(a.z.array(a.z.object({set:a.z.any().optional(),add:a.z.any().optional(),remove:a.z.any().optional()}))).optional(),comment:a.z.string().optional()}),De={name:"jira.issue-transition",inputSchema:He,runTool:async(e,t)=>{try{const r=He.parse(t),s={id:r.transitionId};r.fields&&(s.fields=r.fields),r.update&&(s.update=r.update),r.comment&&(s.comment={body:Ne(r.comment)});const n=await e.issues.transition({issueId:r.issueId,transition:s});return n?.data??n}catch(e){throw le(e)}}},Je=a.z.object({issueId:a.z.string().min(1),fields:a.z.record(a.z.any()).optional(),update:a.z.record(a.z.array(a.z.object({set:a.z.any().optional(),add:a.z.any().optional(),remove:a.z.any().optional(),edit:a.z.any().optional()}))).optional(),properties:a.z.array(a.z.any()).optional(),notifyUsers:a.z.boolean().optional().default(!0),issueTemplateId:a.z.string().optional(),overrideScreenSecurity:a.z.boolean().optional().default(!1),overrideEditableFlag:a.z.boolean().optional().default(!1)}),qe={name:"jira.issue-update",inputSchema:Je,runTool:async(e,t)=>{try{const r=Je.parse(t),s={issueId:r.issueId};r.fields&&(s.fields=r.fields),r.update&&(s.update=r.update),r.properties&&(s.properties=r.properties),void 0!==r.notifyUsers&&(s.notifyUsers=r.notifyUsers),r.issueTemplateId&&(s.issueTemplateId=r.issueTemplateId),void 0!==r.overrideScreenSecurity&&(s.overrideScreenSecurity=r.overrideScreenSecurity),void 0!==r.overrideEditableFlag&&(s.overrideEditableFlag=r.overrideEditableFlag);const n=await e.issues.update(s);return n?.data??n}catch(e){throw le(e)}}},Pe=a.z.object({issueId:a.z.string().min(1),assignee:a.z.union([a.z.string(),a.z.object({accountId:a.z.string().min(1)}),a.z.object({accountType:a.z.string().min(1)})])}),Me={name:"jira.assign-issue",inputSchema:Pe,runTool:async(e,t)=>{try{const r=Pe.parse(t);let s;s="string"==typeof r.assignee?{accountId:r.assignee}:r.assignee;const n=await e.issues.assign({issueId:r.issueId,assignee:s});return n?.data??n}catch(e){throw le(e)}}},Re=a.z.object({issueId:a.z.string().min(1)}),$e={name:"jira.unassign-issue",inputSchema:Re,runTool:async(e,t)=>{try{const r=Re.parse(t),s=await e.issues.assign({issueId:r.issueId,assignee:{accountId:"-1"}});return s?.data??s}catch(e){throw le(e)}}},Le=a.z.object({issueId:a.z.string().min(1),body:a.z.string().min(1),visibility:a.z.object({type:a.z.enum(["role","group"]),value:a.z.string().min(1)}).optional()}),Fe={name:"jira.comment-add",inputSchema:Le,runTool:async(e,t)=>{try{const r=Le.parse(t),s={body:Ne(r.body)};r.visibility&&(s.visibility=r.visibility);const n=await e.issues.addComment({issueId:r.issueId,comment:s});return n?.data??n}catch(e){throw le(e)}}},Be=a.z.object({issueId:a.z.string().min(1),start:a.z.number().optional().default(0),maxResults:a.z.number().optional().default(50),orderBy:a.z.string().optional(),expand:a.z.string().optional()}),We={name:"jira.comment-list",inputSchema:Be,runTool:async(e,t)=>{try{const r=Be.parse(t),s=await e.issues.getComments({issueId:r.issueId,start:r.start,maxResults:r.maxResults,orderBy:r.orderBy,expand:r.expand});return s?.data??s}catch(e){throw le(e)}}},Ue=a.z.object({link:a.z.object({relationship:a.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:a.z.object({id:a.z.string().optional(),key:a.z.string().optional()}),outwardIssue:a.z.object({id:a.z.string().optional(),key:a.z.string().optional()}),comment:a.z.object({body:a.z.string().optional(),visibility:a.z.object({type:a.z.enum(["role","group"]),value:a.z.string().min(1)}).optional()}).optional()})}),Ke={name:"jira.link-create",inputSchema:Ue,runTool:async(e,t)=>{try{const r=Ue.parse(t).link,s={relationship:r.relationship,inwardIssue:r.inwardIssue.id||r.inwardIssue.key,outwardIssue:r.outwardIssue.id||r.outwardIssue.key};r.comment&&(r.comment.body&&(s.comment=Ne(r.comment.body)),r.comment.visibility&&(s.visibility=r.comment.visibility));const n=await e.issues.link(s);return n?.data??n}catch(e){throw le(e)}}},Ye=a.z.object({issueId:a.z.string().min(1),file:a.z.string().min(1),mimeType:a.z.string().optional(),comment:a.z.string().optional()}),Ve={name:"jira.attach",inputSchema:Ye,runTool:async(e,s)=>{try{const n=Ye.parse(s),i=r.resolve(n.file),o=await t.promises.readFile(i),a=r.basename(i),c=await e.issues.addAttachment({issueId:n.issueId,file:{name:a,content:o,mimeType:n.mimeType??"application/octet-stream"},comment:n.comment});return c?.data??c}catch(e){if(e&&e.code&&"string"==typeof e.code&&["ENOENT","EACCES"].includes(e.code))throw Error("Attachment file error: "+e.message);throw le(e)}}},Ge=a.z.object({issueId:a.z.string().min(1)}),Ze={name:"jira.attachment-list",inputSchema:Ge,runTool:async(e,t)=>{try{const r=Ge.parse(t),s=await e.issues.getAttachments({issueId:r.issueId});return s?.data??s}catch(e){throw le(e)}}},Qe=a.z.object({issueId:a.z.string().min(1),attachmentId:a.z.string().min(1)}),Xe={name:"jira.attachment-delete",inputSchema:Qe,runTool:async(e,t)=>{try{const r=Qe.parse(t);return await e.issues.deleteAttachment({issueId:r.issueId,attachmentId:r.attachmentId}),{success:!0,message:`Attachment ${t.attachmentId} deleted successfully`}}catch(e){throw le(e)}}},et=a.z.object({issueId:a.z.string().min(1),timeSpent:a.z.string().min(1),comment:a.z.string().optional(),author:a.z.object({accountId:a.z.string().min(1)}).optional(),startingOn:a.z.string().optional(),artifact:a.z.string().optional()}),tt={name:"jira.worklog-add",inputSchema:et,runTool:async(e,t)=>{try{const r=et.parse(t),s={timeSpent:r.timeSpent};r.comment&&(s.comment=r.comment),r.author&&(s.author=r.author),r.startingOn&&(s.started=r.startingOn),r.artifact&&(s.artifact=r.artifact);const n=await e.issues.addWorklog({issueId:r.issueId,...s});return n?.data??n}catch(e){throw le(e)}}},rt={[me.name]:{title:"Jira Issue Read",description:"Read a Jira issue with expandable fields and properties",annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},[qe.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}},[de.name]:{title:"Jira Issue Delete",description:"Delete a Jira issue and optionally remove its subtasks",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0}},[De.name]:{title:"Jira Issue Transition",description:"Transition a Jira issue while optionally adding a comment",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[Me.name]:{title:"Jira Issue Assign",description:"Assign a Jira issue to a user or account",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[$e.name]:{title:"Jira Issue Unassign",description:"Unassign the current owner from a Jira issue",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[Fe.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}},[We.name]:{title:"Jira Comment List",description:"List comments on a Jira issue with pagination support",annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},[Ke.name]:{title:"Jira Link Create",description:"Create an issue link relationship with optional comment",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[Ve.name]:{title:"Jira Attachment Add",description:"Attach a local file to a Jira issue",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}},[Ze.name]:{title:"Jira Attachment List",description:"List attachments on a Jira issue",annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},[Xe.name]:{title:"Jira Attachment Delete",description:"Delete an attachment from a Jira issue",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0}},[tt.name]:{title:"Jira Worklog Add",description:"Log time spent on a Jira issue",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0}}};async function st(e){const t=s.Logging.for(st);let r,n=null;try{r=(()=>{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:s}=(()=>{const e=ie(),t=oe().filter(e=>e.required&&!e.value);if(t.length>0)throw new ce(t);return{host:e.host,email:e.email,apiKey:e.apiKey}})();return new e({host:t,authentication:{basic:{email:r,apiToken:s}}})})()}catch(e){if(!(e instanceof ce))return void t.warn("Skipping Jira tool registration; unable to create Jira client",{error:e});n=e,t.warn("Registering Jira tools without credentials; each tool will report configuration requirements.",{error:e})}const i=[me,qe,de,De,Me,$e,Fe,We,Ke,Ve,Ze,Xe,tt];for(const s of i){const i=rt[s.name];if(i)try{await e.registerTool(s.name,{title:i.title,description:i.description,inputSchema:q(s.inputSchema),annotations:i.annotations},async e=>{if(!r)throw n??Error("Jira client unavailable because credentials could not be loaded.");return s.runTool(r,e)}),t.info("Registered Jira tool "+s.name)}catch(e){t.error("Failed to register Jira tool "+s.name,{error:e})}}}async function nt(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=Q.map(e=>e.getName()).sort();return{content:[{type:"text",text:["Name: "+ne.name,"Title: "+ne.title,"Version: "+ne.version,"Prompts: "+(e.join(", ")||"<none>")].join("\n")}]}})})(e);const t=s.Logging.for(nt);try{await st(e)}catch(e){t.error("Failed to register Jira tools",e)}}class it 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 it}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:{}}),s=async(e,t)=>{const r=this.logFor(t);r.verbose(`Requesting resource ${this.name} from ${e.toString()}`);const s=await Promise.resolve(this.cb(e,t));return r.verbose(`Resource ${this.name} retrieved successfully.`),r.debug("Resource retrieval meta: "+JSON.stringify(s._meta)),s};return e.resource(this.name,t,r,s)}catch(e){throw s.Logging.for(this).error("Error registering resource "+this.name,e),e}}}i.__decorate([o.required(),i.__metadata("design:type",String)],it.prototype,"uriOrTemplate",void 0),i.__decorate([o.required(),i.__metadata("design:type",Function)],it.prototype,"cb",void 0),i.__decorate([o.required(),i.__metadata("design:type",Object)],it.prototype,"config",void 0);const ot=$()??I.join(__dirname,"..","assets"),at=I.join(ot,"templates"),ct=I.join(ot,"prompts"),lt=new WeakMap;class pt extends s.LoggedClass{get client(){const e=lt.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 Q)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 nt(this.client),e.verbose("Registered built-in tools")}catch(t){e.error("Failed to register tools",t)}try{await(async(e,t)=>{t.info("Registering agent templates as resources...");const r=x.readdirSync(at).filter(e=>e.endsWith(".md"));for(const s of r){const r=I.basename(s,".md"),n=I.join(at,s),i=it.builder.setName(r).setTitle("Template: "+r).setDescription("Resource template for "+r).setUriOtTemplate("file:///"+n).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 s=x.readdirSync(ct).filter(e=>e.endsWith(".md"));for(const r of s){const s=I.basename(r,".md"),n=I.join(ct,r),i=x.readFileSync(n,"utf8"),o=F.builder.setName(s).setTitle("Prompt: "+s).setDescription("Dynamic prompt for "+s).setArgsSchema(a.z.object({})).setCb(async e=>({messages:[{role:"user",content:{type:"text",text:i}}],_meta:{}}));try{o.build(e),t.info("Registered prompt: "+s)}catch(e){t.error(`Failed to register prompt ${s}:`,e)}}})(this.client,e),e.verbose("Registered agent-specific assets")}catch(t){e.error("Failed to register agent assets",t)}}async boot(e="stdio"){let t=this.log;this.log.for(this.boot).info("McpServer booting..."),((e=s.Logging.get())=>{let t;try{t=(()=>{let e,t=__dirname;try{for(;t&&t!==I.parse(t).root;){const r=I.join(t,"node_modules");if(x.existsSync(r)&&x.statSync(r).isDirectory()){e=r;break}const s=I.dirname(t);if(s===t)break;t=s}}catch{}const r=[];if(e){const t=I.join(e,"@decaf-ts");try{if(x.existsSync(t)&&x.statSync(t).isDirectory()){const e=x.readdirSync(t);for(const s of e){const e=I.join(t,s);try{const t=I.join(e,"workdocs","assets","slogans.json");if(x.existsSync(t)&&x.statSync(t).isFile()){const e=x.readFileSync(t,"utf-8"),s=JSON.parse(e);if(Array.isArray(s))for(const e of s)"string"==typeof e&&e.trim().length>0&&r.push(e.trim())}}catch{}}}}catch{}}return 0===r.length?"Decaf: strongly brewed TypeScript.":r[Math.floor(Math.random()*r.length)]})()}catch{t="Decaf: strongly brewed TypeScript."}const r="# \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \n# ( ( \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \n# ) ) \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \n# [=======] \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \n# `-----\xb4 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \n# \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \n# \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \n#".split("\n"),i=r.reduce((e,t)=>Math.max(e,t.length),0);r.push("# "+t.padStart(i-3)),r.forEach((t,r)=>{const s=E[r%E.length]||"",i=e.info.bind(e);try{i(n.style(t||"").raw(s).text)}catch{i((t||"")+"")}})})(this.log),"stdio"===e&&(s.Logging.setFactory(z),t=s.Logging.for(this.constructor.name));const r=((Array.isArray(ne.icons)?ne.icons:[ne.icons])||[]).map(e=>{const t="string"==typeof e?.src?e.src:(e?.src??"")+"",r="string"==typeof e?.mimeType?e.mimeType:(e?.mimeType??"")+"";let s=[];return Array.isArray(e?.sizes)?s=e.sizes.map(e=>e+""):"string"==typeof e?.sizes&&(s=(e.sizes+"").split(",").map(e=>e.trim())),{src:t,mimeType:r,sizes:s}}),i={name:ne.name,title:ne.title,websiteUrl:ne.websiteUrl,version:ne.version,icons:r},o=new b.McpServer(i,{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)=>{lt.set(e,t)})(this,o),o.onerror=e=>{this.log.error("MCP instance onerror",e)},e){case"stdio":e=new w.StdioServerTransport;break;case"http":e=new S.StreamableHTTPServerTransport({sessionIdGenerator:()=>v.v4(),onsessioninitialized:e=>t.verbose("Session initialized: "+e),onsessionclosed:e=>t.verbose("Session closed: "+e),enableJsonResponse:!0,eventStore:void 0});break;default:if(!(a=e)||"object"!=typeof a||"function"!=typeof a.send&&"function"!=typeof a.close&&"function"!=typeof a.on)throw new p.InternalError("Invalid transport type: "+e)}var a;try{this.log.info("Loading resources/prompts/tools..."),await this.load()}catch(e){throw this.log.error("Error loading resources/prompts/tools: "+e),e}await this.client.connect(e),t.info(`MCP Server connected via ${e.constructor.name} and running. Waiting for client connections...`)}}const dt=(new e.Command).command("start").option("--transport [String]","transport mode","stdio").description("starts decaf's mcp server").action(async e=>{const s=JSON.parse(t.readFileSync(r.join(process.cwd(),"package.json"),"utf-8")),n=s.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 ${s.name} version ${n}`),(new pt).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=JSON.parse(t.readFileSync(r.join(process.cwd(),"package.json"),"utf-8")),i=n.version;s.Logging.for("md-to-ast").debug(`running with options: ${JSON.stringify(e)} for ${n.name} version ${i}`);const o=Ne(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 ut=(new e.Command).name("mcp-server").command("mcp-server").description("decaf mcp server and agentic functionality");ut.addCommand(dt),ut.parse(process.argv)},"object"==typeof exports&&"undefined"!=typeof module?t(require("commander"),require("fs"),require("path"),require("@decaf-ts/logging"),require("styled-string-builder"),require("tslib"),require("@decaf-ts/decorator-validation"),require("zod"),require("@decaf-ts/injectable-decorators"),require("@decaf-ts/decoration"),require("@decaf-ts/db-decorators"),require("crypto"),require("zlib"),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","path","@decaf-ts/logging","styled-string-builder","tslib","@decaf-ts/decorator-validation","zod","@decaf-ts/injectable-decorators","@decaf-ts/decoration","@decaf-ts/db-decorators","crypto","zlib","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.path,e.decafTsLogging,e.styledStringBuilder,e.tslib,e.decafTsDecoratorValidation,e.zod,e.decafTsInjectableDecorators,e.decafTsDecoration,e.decafTsDbDecorators,e.crypto,e.zlib,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