@eui/mcp 1.5.8 → 21.2.4-snapshot-1776931045923

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 (2) hide show
  1. package/package.json +25 -63
  2. package/dist/main.js +0 -542
package/package.json CHANGED
@@ -1,64 +1,26 @@
1
1
  {
2
- "name": "@eui/mcp",
3
- "version": "1.5.8",
4
- "description": "MCP server for EUI Angular component library using Compodoc documentation",
5
- "main": "dist/main.js",
6
- "type": "module",
7
- "bin": {
8
- "eui-mcp": "./dist/main.js"
9
- },
10
- "files": [
11
- "dist",
12
- "README.md",
13
- "LICENSE"
14
- ],
15
- "scripts": {
16
- "build": "esbuild src/main.ts --bundle --minify --platform=node --target=node18 --format=esm --outfile=dist/main.js --banner:js='#!/usr/bin/env node' --external:@modelcontextprotocol/sdk --external:chokidar --external:zod --external:pino --external:pino-pretty && chmod +x dist/main.js",
17
- "dev": "tsc --watch",
18
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
19
- "test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch",
20
- "test:coverage": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
21
- "start": "node dist/main.js",
22
- "lint": "eslint src --ext .ts",
23
- "version": "npm run changelog && git add CHANGELOG.md",
24
- "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
25
- "changelog:simple": "conventional-changelog -p angular -i CHANGELOG.md -s",
26
- "release:patch": "npm version patch -m 'chore(release): %s [skip ci]'",
27
- "release:minor": "npm version minor -m 'chore(release): %s [skip ci]'",
28
- "release:major": "npm version major -m 'chore(release): %s [skip ci]'"
29
- },
30
- "keywords": [
31
- "mcp",
32
- "model-context-protocol",
33
- "angular",
34
- "documentation",
35
- "eui"
36
- ],
37
- "author": "",
38
- "license": "MIT",
39
- "dependencies": {
40
- "@modelcontextprotocol/sdk": "^1.7.0",
41
- "chokidar": "^5.0.0",
42
- "pino": "^10.3.1",
43
- "pino-pretty": "^13.1.3",
44
- "zod": "^3.22.4"
45
- },
46
- "devDependencies": {
47
- "@types/jest": "^29.5.11",
48
- "@types/node": "^20.10.6",
49
- "@typescript-eslint/eslint-plugin": "^8.57.0",
50
- "@typescript-eslint/parser": "^8.57.0",
51
- "conventional-changelog-cli": "^4.1.0",
52
- "eslint": "^8.56.0",
53
- "esbuild": "^0.27.3",
54
- "fast-check": "^3.15.0",
55
- "jest": "^29.7.0",
56
- "semver": "^7.7.3",
57
- "ts-jest": "^29.1.1",
58
- "ts-node": "^10.9.2",
59
- "typescript": "^5.3.3"
60
- },
61
- "engines": {
62
- "node": ">=18.0.0"
63
- }
64
- }
2
+ "name": "@eui/mcp",
3
+ "version": "21.2.4-snapshot-1776931045923",
4
+ "description": "MCP server for EUI Angular component library using Compodoc documentation",
5
+ "main": "dist/main.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "eui-mcp": "./dist/main.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "keywords": [
16
+ "mcp",
17
+ "model-context-protocol",
18
+ "angular",
19
+ "documentation",
20
+ "eui"
21
+ ],
22
+ "engines": {
23
+ "node": ">=18.0.0"
24
+ },
25
+ "tag": "snapshot"
26
+ }
package/dist/main.js DELETED
@@ -1,542 +0,0 @@
1
- #!/usr/bin/env node
2
- import{z as l}from"zod";var g=class{static detect(e){let t=e.trim();return this.isRemoteUrl(t)?{type:new URL(t).protocol==="https:"?"https_url":"http_url",originalPath:e,normalizedPath:t}:{type:"local",originalPath:e,normalizedPath:t}}static isValidUrl(e){try{return new URL(e.trim()).protocol.length>0}catch{return!1}}static isRemoteUrl(e){try{let t=e.trim();if(!t.startsWith("http://")&&!t.startsWith("https://"))return!1;let r=new URL(t);return!(r.protocol!=="http:"&&r.protocol!=="https:"||!r.hostname||r.hostname.length===0)}catch{return!1}}};var me=l.object({name:l.string().default("eui-compodoc-mcp"),version:l.string().default("1.0.0")}),de=l.object({path:l.string().min(1,"Documentation path cannot be empty").refine(i=>i.trim().length>0,{message:"Documentation path cannot be only whitespace"}).refine(i=>{let e=i.trim();return e.startsWith("http://")||e.startsWith("https://")?g.isRemoteUrl(e):!0},{message:"Path must be a valid local file path or HTTP/HTTPS URL"}),watchForChanges:l.boolean().default(!0),reloadDebounce:l.number().min(0).default(1e3),timeout:l.number().min(1e3).default(1e4),maxRetries:l.number().min(0).max(10).default(3),pollingInterval:l.number().min(5e3).default(6e4)}),fe=l.object({maxResults:l.number().min(1).max(1e3).default(50),minQueryLength:l.number().min(1).default(2)}),ge=l.object({level:l.enum(["debug","info","warn","error"]).default("info"),format:l.enum(["json","text"]).default("text")}),oe=l.object({server:me.default({}),documentation:de,search:fe.default({}),logging:ge.default({})}),X={server:{name:"eui-compodoc-mcp",version:"1.0.0"},documentation:{path:"./documentation.json",watchForChanges:!0,reloadDebounce:1e3,timeout:1e4,maxRetries:3,pollingInterval:6e4},search:{maxResults:50,minQueryLength:2},logging:{level:"info",format:"text"}};function ee(i){return oe.safeParse(i)}import*as $ from"fs";import*as ie from"path";function se(){let i={};return process.env.COMPODOC_MCP_DOC_PATH&&(i.documentation={path:process.env.COMPODOC_MCP_DOC_PATH}),process.env.COMPODOC_MCP_LOG_LEVEL&&(i.logging={level:process.env.COMPODOC_MCP_LOG_LEVEL}),process.env.COMPODOC_MCP_WATCH!==void 0&&(i.documentation||(i.documentation={path:""}),i.documentation.watchForChanges=process.env.COMPODOC_MCP_WATCH==="true"),i}function ae(i){let e={};for(let t=0;t<i.length;t++)switch(i[t]){case"--doc-path":case"--documentation-path":e.documentation||(e.documentation={path:""}),e.documentation.path=i[++t];break;case"--watch":e.documentation||(e.documentation={path:""}),e.documentation.watchForChanges=!0;break;case"--no-watch":e.documentation||(e.documentation={path:""}),e.documentation.watchForChanges=!1;break;case"--log-level":e.logging={level:i[++t]};break;case"--max-results":e.search={maxResults:parseInt(i[++t],10)};break;case"--help":case"-h":ye(),process.exit(0);break}return e}function ce(i){try{if(!$.existsSync(i))return process.stderr.write(`Configuration file not found: ${i}
3
- `),{};let e=$.readFileSync(i,"utf-8"),t=ie.extname(i).toLowerCase();return t===".json"?JSON.parse(e):(process.stderr.write(`Unsupported configuration file format: ${t}
4
- `),{})}catch(e){let t=e instanceof Error?e.message:"Unknown error occurred";return process.stderr.write(`Failed to load config file ${i}: ${t}
5
- `),{}}}function _(i,e){let t={...i};for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)){let n=e[r],o=t[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?t[r]=_(o,n):n!==void 0&&(t[r]=n)}return t}function te(i=process.argv.slice(2)){try{let e=i.indexOf("--config"),t=e>=0?i[e+1]:void 0,r=t?ce(t):{},n=se(),o=ae(i),s={...X};s=_(s,r),s=_(s,n),s=_(s,o);let a=ee(s);if(!a.success){let p=he(a.error);return process.stderr.write(`Configuration validation failed:
6
- `),p.forEach(u=>process.stderr.write(` - ${u}
7
- `)),{success:!1,errors:p}}return{success:!0,config:a.data}}catch(e){return{success:!1,errors:[`Failed to load configuration: ${e instanceof Error?e.message:"Configuration error"}`]}}}function he(i){return i.errors.map(e=>`${e.path.join(".")}: ${e.message}`)}function ye(){process.stderr.write(`
8
- EUI Compodoc MCP Server - Model Context Protocol server for Angular component documentation
9
-
10
- Usage:
11
- eui-compodoc-mcp [options]
12
-
13
- Options:
14
- --doc-path <path> Path to documentation.json file (required)
15
- --watch Watch for changes to documentation.json (default: true)
16
- --no-watch Disable file watching
17
- --log-level <level> Logging level: debug, info, warn, error (default: info)
18
- --max-results <number> Maximum search results (default: 50)
19
- --config <file> Load configuration from JSON file
20
- --help, -h Show this help message
21
-
22
- Environment Variables:
23
- COMPODOC_MCP_DOC_PATH Path to documentation.json file
24
- COMPODOC_MCP_LOG_LEVEL Logging level
25
- COMPODOC_MCP_WATCH Enable/disable file watching (true/false)
26
-
27
- Configuration File Format (JSON):
28
- {
29
- "server": {
30
- "name": "eui-compodoc-mcp",
31
- "version": "1.0.0"
32
- },
33
- "documentation": {
34
- "path": "./documentation.json",
35
- "watchForChanges": true,
36
- "reloadDebounce": 1000
37
- },
38
- "search": {
39
- "maxResults": 50,
40
- "minQueryLength": 2
41
- },
42
- "logging": {
43
- "level": "info",
44
- "format": "text"
45
- }
46
- }
47
-
48
- Examples:
49
- eui-compodoc-mcp --doc-path ./documentation.json
50
- eui-compodoc-mcp --doc-path ./docs/documentation.json --log-level debug
51
- eui-compodoc-mcp --config ./config.json
52
- COMPODOC_MCP_DOC_PATH=./documentation.json eui-compodoc-mcp
53
-
54
- For more information, visit: https://github.com/your-org/eui-compodoc-mcp
55
- `)}import*as V from"fs";import*as ue from"path";import{watch as we}from"chokidar";import pe from"pino";var O=class i{pino;context;constructor(e){this.context=e.context,this.pino=pe({level:e.level},pe.destination({dest:2,sync:!0}))}child(e){let t=new i({level:this.pino.level,format:"json",context:this.context?`${this.context}:${e}`:e});return t.pino=this.pino.child({context:e}),t}setLevel(e){this.pino.level=e}debug(e,t){this.pino.debug(t||{},e)}info(e,t){this.pino.info(t||{},e)}warn(e,t){this.pino.warn(t||{},e)}error(e,t,r){let n=r&&typeof r=="object"?r:{};this.pino.error({err:t,...n},e)}},P=null;function re(i){return P=new O(i),P}function c(){return P||(P=new O({level:"info",format:"text"})),P}var ve={failureThreshold:5,successThreshold:2,timeout:1e4,resetTimeout:6e4},G=class{state="CLOSED";failureCount=0;successCount=0;nextAttempt=Date.now();options;name;constructor(e,t={}){this.name=e,this.options={...ve,...t}}getState(){return this.state}getStats(){return{state:this.state,failureCount:this.failureCount,successCount:this.successCount,nextAttempt:this.nextAttempt}}async execute(e){let t=c();if(this.state==="OPEN"){if(Date.now()<this.nextAttempt){let r=new Error(`Circuit breaker '${this.name}' is OPEN. Next attempt at ${new Date(this.nextAttempt).toISOString()}`);throw t.warn("Circuit breaker is open",{name:this.name,nextAttempt:this.nextAttempt}),r}this.state="HALF_OPEN",this.successCount=0,t.info("Circuit breaker transitioning to HALF_OPEN",{name:this.name})}try{let r=await this.executeWithTimeout(e);return this.onSuccess(),r}catch(r){throw this.onFailure(),r}}async executeWithTimeout(e){return Promise.race([e(),new Promise((t,r)=>setTimeout(()=>r(new Error(`Operation timed out after ${this.options.timeout}ms`)),this.options.timeout))])}onSuccess(){let e=c();this.failureCount=0,this.state==="HALF_OPEN"&&(this.successCount++,e.debug("Circuit breaker success in HALF_OPEN",{name:this.name,successCount:this.successCount,threshold:this.options.successThreshold}),this.successCount>=this.options.successThreshold&&(this.state="CLOSED",this.successCount=0,e.info("Circuit breaker closed",{name:this.name})))}onFailure(){let e=c();this.failureCount++,e.debug("Circuit breaker failure",{name:this.name,failureCount:this.failureCount,threshold:this.options.failureThreshold,state:this.state}),(this.state==="HALF_OPEN"||this.failureCount>=this.options.failureThreshold)&&(this.state="OPEN",this.nextAttempt=Date.now()+this.options.resetTimeout,e.warn("Circuit breaker opened",{name:this.name,failureCount:this.failureCount,nextAttempt:this.nextAttempt}))}reset(){let e=c();this.state="CLOSED",this.failureCount=0,this.successCount=0,this.nextAttempt=Date.now(),e.info("Circuit breaker manually reset",{name:this.name})}},H=class{breakers=new Map;get(e,t){return this.breakers.has(e)||this.breakers.set(e,new G(e,t)),this.breakers.get(e)}getAll(){return new Map(this.breakers)}resetAll(){this.breakers.forEach(e=>{e.reset()})}getAllStats(){let e={};return this.breakers.forEach((t,r)=>{e[r]=t.getStats()}),e}},Ce=new H;var q=class{filePath;watchForChanges;reloadDebounce;watcher;reloadTimer;onReloadCallback;onErrorCallback;currentData;constructor(e){this.filePath=ue.resolve(e.path),this.watchForChanges=e.watchForChanges,this.reloadDebounce=e.reloadDebounce,this.onReloadCallback=e.onReload,this.onErrorCallback=e.onError}async load(){try{if(!V.existsSync(this.filePath))return{success:!1,error:`Documentation file not found: ${this.filePath}`};let e=await V.promises.readFile(this.filePath,"utf-8"),t;try{t=JSON.parse(e)}catch(n){return{success:!1,error:`Failed to parse JSON: ${n instanceof Error?n.message:String(n)}`}}let r=this.validateStructure(t);return r?{success:!1,error:r}:(this.currentData=t,this.watchForChanges&&!this.watcher&&this.startMonitoring(),{success:!0,data:t})}catch(e){return{success:!1,error:`Failed to load documentation: ${e instanceof Error?e.message:String(e)}`}}}startMonitoring(){!this.watchForChanges||this.watcher||this.startWatching()}async stopMonitoring(){this.reloadTimer&&(clearTimeout(this.reloadTimer),this.reloadTimer=void 0),this.watcher&&(await this.watcher.close(),this.watcher=void 0,c().info("Stopped watching documentation file"))}getCurrentData(){return this.currentData}async dispose(){await this.stopMonitoring(),this.currentData=void 0,this.onReloadCallback=void 0,this.onErrorCallback=void 0}validateStructure(e){if(!e||typeof e!="object")return"Documentation must be an object";let t=e,r=["pipes","components","directives","injectables","interfaces","classes","modules"];for(let n of r){let o=t[n];if(o!==void 0&&!Array.isArray(o))return`${n} must be an array`}return null}startWatching(){this.watcher||(this.watcher=we(this.filePath,{persistent:!0,ignoreInitial:!0}),this.watcher.on("change",()=>{this.scheduleReload()}),this.watcher.on("error",e=>{let t=e instanceof Error?e:new Error(String(e));c().error("File watcher error",t),this.onErrorCallback&&this.onErrorCallback(t)}),c().info(`Watching for changes: ${this.filePath}`))}scheduleReload(){this.reloadTimer&&clearTimeout(this.reloadTimer),this.reloadTimer=setTimeout(()=>{this.reload()},this.reloadDebounce)}async reload(){c().info("Reloading documentation...");let e=await this.load();e.success&&e.data?(c().info("Documentation reloaded successfully"),this.onReloadCallback&&this.onReloadCallback(e.data)):(c().error("Failed to reload documentation",new Error(e.error)),this.onErrorCallback&&this.onErrorCallback(new Error(e.error)))}};var B=class{options;constructor(e){this.options=e}async fetch(e,t){let r;for(let n=0;n<=this.options.maxRetries;n++)try{let o=await this.fetchOnce(e,t);if(!this.isRetryableError(void 0,o.status)||n>=this.options.maxRetries)return o;let s=this.calculateBackoff(n);await this.sleep(s)}catch(o){if(r=o instanceof Error?o:new Error(String(o)),n<this.options.maxRetries&&this.isRetryableError(r)){let s=this.calculateBackoff(n);await this.sleep(s);continue}throw r}throw r||new Error("Unknown error during fetch")}async fetchOnce(e,t){let r=new AbortController,n=setTimeout(()=>r.abort(),this.options.timeout);try{let o={Accept:"application/json","User-Agent":this.options.userAgent||"DocumentationLoader/1.0"};t&&t.forEach((u,m)=>{o[m]=u});let s=await fetch(e,{signal:r.signal,headers:o});clearTimeout(n);let a=new Map;s.headers.forEach((u,m)=>{a.set(m,u)});let p=await s.text();return{status:s.status,statusText:s.statusText,data:p,headers:a}}catch(o){throw clearTimeout(n),o instanceof Error&&o.name==="AbortError"?new Error(`Request timeout after ${this.options.timeout}ms`):o}}isRetryableError(e,t){if(t!==void 0){if(t>=200&&t<400)return!1;if(t>=500||t===408||t===429)return!0;if(t>=400&&t<500)return!1}if(e){let r=e.message.toLowerCase();if(r.includes("timeout")||r.includes("network")||r.includes("econnrefused")||r.includes("enotfound")||r.includes("econnreset"))return!0}return!0}calculateBackoff(e){return this.options.retryDelay*Math.pow(2,e)}sleep(e){return new Promise(t=>setTimeout(t,e))}};var z=class{cache;constructor(){this.cache=new Map}set(e,t,r){let n={data:t,timestamp:Date.now()},o=this.getHeaderCaseInsensitive(r,"etag");o&&(n.etag=o);let s=this.getHeaderCaseInsensitive(r,"last-modified");s&&(n.lastModified=s),this.cache.set(e,n)}get(e){return this.cache.get(e)}getConditionalHeaders(e){let t=new Map,r=this.cache.get(e);return r&&(r.etag&&t.set("If-None-Match",r.etag),r.lastModified&&t.set("If-Modified-Since",r.lastModified)),t}clear(e){this.cache.delete(e)}clearAll(){this.cache.clear()}getHeaderCaseInsensitive(e,t){let r=t.toLowerCase();for(let[n,o]of e.entries())if(n.toLowerCase()===r)return o}};var ne=class i extends Error{constructor(t,r,n){super(t);this.url=r;this.cause=n;this.name="NetworkError",Error.captureStackTrace&&Error.captureStackTrace(this,i)}};var k=class i extends ne{constructor(t,r,n,o){super(t,r);this.statusCode=n;this.statusText=o;this.name="HttpError",Error.captureStackTrace&&Error.captureStackTrace(this,i)}},L=class i extends Error{constructor(t,r){super(t);this.content=r;this.name="ParseError",Error.captureStackTrace&&Error.captureStackTrace(this,i)}};var W=class{url;httpClient;cacheManager;pollingTimer;currentData;pollingInterval;onReloadCallback;onErrorCallback;constructor(e){this.url=e.url,this.pollingInterval=e.pollingInterval,this.onReloadCallback=e.onReload,this.onErrorCallback=e.onError;let t={timeout:e.timeout,maxRetries:e.maxRetries,retryDelay:1e3,userAgent:"DocumentationLoader/1.0"};this.httpClient=new B(t),this.cacheManager=new z}async load(){return this.fetchDocumentation()}startMonitoring(){this.pollingTimer||(this.pollingTimer=setInterval(()=>{this.poll()},this.pollingInterval),c().info(`Started polling ${this.url} every ${this.pollingInterval}ms`))}async stopMonitoring(){this.pollingTimer&&(clearInterval(this.pollingTimer),this.pollingTimer=void 0,c().info(`Stopped polling ${this.url}`))}getCurrentData(){return this.currentData}async dispose(){await this.stopMonitoring(),this.cacheManager.clear(this.url),this.currentData=void 0,this.onReloadCallback=void 0,this.onErrorCallback=void 0}async poll(){try{c().debug(`Polling ${this.url} for updates...`);let e=this.cacheManager.getConditionalHeaders(this.url),t=await this.httpClient.fetch(this.url,e);if(t.status===304){c().debug("No changes detected (304 Not Modified)");return}if(t.status===200){let r=this.parseJson(t.data),n=this.validateStructure(r);if(n)throw new L(n,t.data);this.cacheManager.set(this.url,r,t.headers),this.currentData=r,c().info(`Documentation updated from ${this.url}`),this.onReloadCallback&&this.onReloadCallback(r);return}throw new k(`HTTP ${t.status}: ${t.statusText}`,this.url,t.status,t.statusText)}catch(e){let t=e instanceof Error?e.message:String(e);c().error(`Polling error for ${this.url}`,e instanceof Error?e:new Error(t)),this.onErrorCallback&&this.onErrorCallback(e instanceof Error?e:new Error(t))}}async fetchDocumentation(){try{let e=this.cacheManager.get(this.url),t=e?this.cacheManager.getConditionalHeaders(this.url):void 0,r=await this.httpClient.fetch(this.url,t);if(r.status===304&&e)return c().debug("Using cached documentation (304 Not Modified)"),this.currentData=e.data,{success:!0,data:e.data};if(r.status!==200)return{success:!1,error:`${new k(`HTTP ${r.status}: ${r.statusText}`,this.url,r.status,r.statusText).message} (URL: ${this.url})`};let n=this.parseJson(r.data),o=this.validateStructure(n);return o?{success:!1,error:o}:(this.cacheManager.set(this.url,n,r.headers),this.currentData=n,{success:!0,data:n})}catch(e){let t=e instanceof Error?e.message:String(e);return{success:!1,error:`Failed to fetch documentation from ${this.url}: ${t}`}}}parseJson(e){try{return JSON.parse(e)}catch(t){let r=t instanceof Error?t.message:String(t);throw new L(`Failed to parse JSON: ${r}`,e)}}validateStructure(e){if(!e||typeof e!="object")return"Documentation must be an object";let t=e,r=["pipes","components","directives","injectables","interfaces","classes","modules"];for(let n of r){let o=t[n];if(o!==void 0&&!Array.isArray(o))return`${n} must be an array`}return null}};var M=class{source;constructor(e){this.source=this.createSource(e)}async load(){let e=await this.source.load();return e.success&&this.source.startMonitoring(),e}getCurrentData(){return this.source.getCurrentData()}async stopWatching(){await this.source.stopMonitoring()}async dispose(){await this.source.dispose()}createSource(e){let t=g.detect(e.path);return t.type==="local"?new q({path:t.normalizedPath,watchForChanges:e.watchForChanges??!0,reloadDebounce:e.reloadDebounce??1e3,onReload:e.onReload,onError:e.onError}):new W({url:t.normalizedPath,timeout:e.timeout??1e4,maxRetries:e.maxRetries??3,pollingInterval:e.pollingInterval??6e4,onReload:e.onReload,onError:e.onError})}};var A=class{build(e){let t={byName:new Map,bySelector:new Map,searchIndex:new Map,components:[],directives:[],pipes:[],services:[],lastUpdated:new Date,totalCount:0},r=new Map;if(e.components)for(let n of e.components){if(r.has(n.name))throw new Error(`Duplicate name detected: "${n.name}" exists as both ${r.get(n.name)} and component. All component, directive, pipe, and service names must be unique across the entire documentation.`);r.set(n.name,"component"),this.indexComponent(n,t)}if(e.directives)for(let n of e.directives){if(r.has(n.name))throw new Error(`Duplicate name detected: "${n.name}" exists as both ${r.get(n.name)} and directive. All component, directive, pipe, and service names must be unique across the entire documentation.`);r.set(n.name,"directive"),this.indexDirective(n,t)}if(e.pipes)for(let n of e.pipes){if(r.has(n.name))throw new Error(`Duplicate name detected: "${n.name}" exists as both ${r.get(n.name)} and pipe. All component, directive, pipe, and service names must be unique across the entire documentation.`);r.set(n.name,"pipe"),this.indexPipe(n,t)}if(e.injectables)for(let n of e.injectables){if(r.has(n.name))throw new Error(`Duplicate name detected: "${n.name}" exists as both ${r.get(n.name)} and injectable. All component, directive, pipe, and service names must be unique across the entire documentation.`);r.set(n.name,"injectable"),this.indexInjectable(n,t)}return t.totalCount=t.components.length+t.directives.length+t.pipes.length+t.services.length,t}indexComponent(e,t){t.components.push(e),t.byName.set(e.name,e),e.selector&&t.bySelector.set(e.selector,e),this.addToSearchIndex(e,t)}indexDirective(e,t){t.directives.push(e),t.byName.set(e.name,e),e.selector&&t.bySelector.set(e.selector,e),this.addToSearchIndex(e,t)}indexPipe(e,t){t.pipes.push(e),t.byName.set(e.name,e),this.addToSearchIndex(e,t)}indexInjectable(e,t){t.services.push(e),t.byName.set(e.name,e),this.addToSearchIndex(e,t)}addToSearchIndex(e,t){let r=new Set;if(this.extractWords(e.name,r),"selector"in e&&e.selector&&this.extractWords(e.selector,r),e.description&&this.extractWords(e.description,r),"inputs"in e&&e.inputs)for(let n of e.inputs)this.extractWords(n.name,r),n.description&&this.extractWords(n.description,r);if("outputs"in e&&e.outputs)for(let n of e.outputs)this.extractWords(n.name,r),n.description&&this.extractWords(n.description,r);if("methods"in e&&e.methods)for(let n of e.methods)this.extractWords(n.name,r);for(let n of r)t.searchIndex.has(n)||t.searchIndex.set(n,new Set),t.searchIndex.get(n).add(e.name)}extractWords(e,t){let r=e.toLowerCase(),n=r.split(/[^a-z0-9]+/).filter(o=>o.length>0);for(let o of n)t.add(o);n.length===0&&e.trim().length>0&&t.add(r.trim())}getStatistics(e){return{totalCount:e.totalCount,componentCount:e.components.length,directiveCount:e.directives.length,pipeCount:e.pipes.length,serviceCount:e.services.length,lastUpdated:e.lastUpdated}}rebuild(e,t){return this.build(e)}};import{Server as Se}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as Ie}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as Re,ListToolsRequestSchema as Te}from"@modelcontextprotocol/sdk/types.js";var N=class{index;constructor(e){this.index=e}getByName(e){return this.index.byName.get(e)}getBySelector(e){return this.index.bySelector.get(e)}getByType(e){switch(e){case"component":return this.index.components;case"directive":return this.index.directives;case"pipe":return this.index.pipes;case"service":return this.index.services;case"all":return[...this.index.components,...this.index.directives,...this.index.pipes,...this.index.services];default:return[]}}getAll(e=!1){let t=this.getByType("all");return e?t:t.filter(r=>!r.deprecated)}updateIndex(e){this.index=e}};var F=class{index;constructor(e){this.index=e}search(e){let{query:t,types:r,includeDeprecated:n=!1,limit:o=50,offset:s=0}=e,a=t.toLowerCase().trim();if(a.length===0)return{items:[],total:0,hasMore:!1};let p=this.getCandidates(a,r),u=[];for(let T of p){if(!n&&T.deprecated)continue;let U=this.calculateRelevanceScore(T,a);U>0&&u.push({doc:T,relevanceScore:U})}u.sort((T,U)=>U.relevanceScore-T.relevanceScore);let m=u.length,f=u.slice(s,s+o),K=s+o<m;return{items:f,total:m,hasMore:K}}getCandidates(e,t){let r=e.split(/[^a-z0-9]+/).filter(s=>s.length>0),n=new Set;for(let s of r){if(this.index.searchIndex.has(s)){let a=this.index.searchIndex.get(s);for(let p of a)n.add(p)}for(let[a,p]of this.index.searchIndex.entries())if(a.startsWith(s))for(let u of p)n.add(u)}let o=[];for(let s of n){let a=this.index.byName.get(s);a&&(t&&t.length>0?t.includes(a.type)&&o.push(a):o.push(a))}return o}calculateRelevanceScore(e,t){let r=0,n=e.name.toLowerCase();if(n===t&&(r+=100),"selector"in e&&e.selector){let o=e.selector.toLowerCase();(o===t||o.includes(t))&&(r+=80)}if(n.startsWith(t)&&(r+=60),!n.startsWith(t)&&n.includes(t)&&(r+=30),e.description&&e.description.toLowerCase().includes(t)&&(r+=40),"inputs"in e&&e.inputs){for(let o of e.inputs)if(o.name.toLowerCase().includes(t)){r+=30;break}}if("outputs"in e&&e.outputs){for(let o of e.outputs)if(o.name.toLowerCase().includes(t)){r+=30;break}}if("methods"in e&&e.methods){for(let o of e.methods)if(o.name.toLowerCase().includes(t)){r+=20;break}}return e.deprecated&&(r=Math.floor(r*.5)),r}updateIndex(e){this.index=e}};var J=class{getPreferredDescription(e){return e.rawdescription??e.description??""}formatList(e,t=!1){return e.filter(r=>t||!r.deprecated).map(r=>this.formatSummary(r))}formatSummary(e){let t=e.type==="injectable"?"service":e.type,r="selector"in e?e.selector:void 0;return{name:e.name,type:t,selector:r,description:this.getPreferredDescription(e),deprecated:e.deprecated}}formatDetails(e){let t=this.formatInputs(e),r=this.formatOutputs(e),n=this.formatMethods(e),o=this.formatExamples(e),s=e.type==="injectable"?"service":e.type,a="selector"in e?e.selector:void 0,p="standalone"in e?e.standalone:void 0,u="imports"in e?e.imports:void 0;return{name:e.name,type:s,selector:a,description:this.getPreferredDescription(e),inputs:t,outputs:r,methods:n,examples:o,deprecated:e.deprecated,deprecationMessage:e.deprecationMessage,standalone:p,imports:u}}formatInputs(e){let t=[];return"inputs"in e&&e.inputs&&t.push(...e.inputs.map(r=>this.formatProperty(r))),"inputsClass"in e&&e.inputsClass&&t.push(...e.inputsClass.map(r=>this.formatProperty(r))),t}formatOutputs(e){let t=[];return"outputs"in e&&e.outputs&&t.push(...e.outputs.map(r=>this.formatProperty(r))),"outputsClass"in e&&e.outputsClass&&t.push(...e.outputsClass.map(r=>this.formatProperty(r))),t}formatProperty(e){return{name:e.name,type:e.type||"any",required:!e.optional,description:this.getPreferredDescription(e),defaultValue:e.defaultValue}}formatMethods(e){return!("methods"in e)||!e.methods?[]:e.methods.map(t=>this.formatMethod(t))}formatMethod(e){let t=(e.args||[]).map(o=>({name:o.name,type:o.type||"any",optional:o.optional||!1,defaultValue:o.defaultValue})),r=t.map(o=>{let s=o.optional?"?":"",a=o.defaultValue?` = ${o.defaultValue}`:"";return`${o.name}${s}: ${o.type}${a}`}).join(", "),n=`${e.name}(${r}): ${e.returnType||"void"}`;return{name:e.name,signature:n,description:this.getPreferredDescription(e),parameters:t,returnType:e.returnType||"void"}}formatExamples(e){return!("examples"in e)||!e.examples?[]:e.examples}formatSearchResults(e){return e.map(t=>{let r=t.doc.type==="injectable"?"service":t.doc.type,n="selector"in t.doc?t.doc.selector:void 0;return{name:t.doc.name,type:r,selector:n,description:this.getPreferredDescription(t.doc),deprecated:t.doc.deprecated,relevanceScore:t.relevanceScore}})}toJSON(e){return JSON.stringify(e,null,2)}formatDeprecatedList(e,t){if(e.length===0)return"No deprecated items found.";let r=e.reduce((o,s)=>(o[s.type]||(o[s.type]=[]),o[s.type].push(s),o),{}),n=`Found ${e.length} deprecated item(s):
56
-
57
- `;for(let[o,s]of Object.entries(r)){n+=`## ${o.charAt(0).toUpperCase()+o.slice(1)}s
58
-
59
- `;for(let a of s)n+=`### ${a.name}
60
- `,n+=`- **Message**: ${a.deprecationMessage}
61
- `,a.versionDeprecated&&(n+=`- **Deprecated in**: v${a.versionDeprecated}
62
- `),t&&a.replacementSuggestion&&(n+=`- **Replacement**: ${a.replacementSuggestion}
63
- `),n+=`
64
- `}return n}formatDeprecationInfo(e){if(!e.isDeprecated)return`${e.name} (${e.type}) is not deprecated.`;let t=`# ${e.name} (${e.type})
65
-
66
- `;return t+=`**Status**: DEPRECATED
67
-
68
- `,e.deprecationMessage&&(t+=`**Message**: ${e.deprecationMessage}
69
-
70
- `),e.versionDeprecated&&(t+=`**Deprecated in**: v${e.versionDeprecated}
71
-
72
- `),e.replacementSuggestion&&(t+=`**Recommended replacement**: ${e.replacementSuggestion}
73
-
74
- `),t}};var h=class{query;formatter;constructor(e,t){this.query=e,this.formatter=t}execute(e={}){let{includeDeprecated:t=!1,type:r="all",limit:n=50,offset:o=0}=e;if(n<1||n>1e3)throw new Error("Limit must be between 1 and 1000");if(o<0)throw new Error("Offset must be non-negative");let s=this.query.getByType(r),a=t?s:s.filter(K=>!K.deprecated),p=a.length,u=a.slice(o,o+n),m=o+n<p;return{items:this.formatter.formatList(u,!0),total:p,hasMore:m,offset:o,limit:n}}static getToolDefinition(){return{name:"list-components",description:"Lists all available components, directives, pipes, and services from the EUI component library. Supports filtering by type and deprecated status, with pagination for large result sets.",inputSchema:{type:"object",properties:{includeDeprecated:{type:"boolean",description:"Whether to include deprecated components in the results (default: false)",default:!1},type:{type:"string",enum:["component","directive","pipe","service","all"],description:"Filter by type (default: all)",default:"all"},limit:{type:"number",description:"Maximum number of results to return (default: 50, max: 1000)",default:50,minimum:1,maximum:1e3},offset:{type:"number",description:"Number of results to skip for pagination (default: 0)",default:0,minimum:0}}}}}};var y=class{query;formatter;constructor(e,t){this.query=e,this.formatter=t}execute(e){let{name:t}=e;if(!t||typeof t!="string"||t.trim().length===0)throw new Error("Component name is required and must be a non-empty string");let r=this.query.getByName(t.trim());if(!r)throw new Error(`Component "${t}" not found in documentation`);return{component:this.formatter.formatDetails(r)}}static getToolDefinition(){return{name:"get-component-docs",description:"Retrieves detailed documentation for a specific component, directive, pipe, or service by name. Returns complete metadata including inputs, outputs, methods, examples, selector information, standalone flag, and module import requirements.",inputSchema:{type:"object",properties:{name:{type:"string",description:"The name of the component, directive, pipe, or service to retrieve"}},required:["name"]}}}};var v=class{searchEngine;formatter;constructor(e,t){this.searchEngine=e,this.formatter=t}execute(e){let{query:t,types:r,includeDeprecated:n=!1,limit:o=50}=e;if(t==null||typeof t!="string")throw new Error("Query is required and must be a string");let s=t.trim();if(s.length===0)throw new Error("Query cannot be empty");if(o<1||o>1e3)throw new Error("Limit must be between 1 and 1000");if(r&&r.length>0){let m=["component","directive","pipe","service"];for(let f of r)if(!m.includes(f))throw new Error(`Invalid type "${f}". Must be one of: ${m.join(", ")}`)}let a={query:s,types:r,includeDeprecated:n,limit:o,offset:0},p=this.searchEngine.search(a);return{items:this.formatter.formatSearchResults(p.items),total:p.total,hasMore:p.hasMore,query:s}}static getToolDefinition(){return{name:"search-components",description:"Searches for components, directives, pipes, and services by keyword or functionality. Returns results ranked by relevance, matching against component names, selectors, descriptions, inputs, outputs, and methods. Supports filtering by type and deprecated status.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Search query to match against component metadata"},types:{type:"array",items:{type:"string",enum:["component","directive","pipe","service"]},description:"Filter results by type (optional). If not specified, searches all types."},includeDeprecated:{type:"boolean",description:"Whether to include deprecated components in results (default: false)",default:!1},limit:{type:"number",description:"Maximum number of results to return (default: 50, max: 1000)",default:50,minimum:1,maximum:1e3}},required:["query"]}}}};var C=class{query;formatter;constructor(e,t){this.query=e,this.formatter=t}execute(e){let{name:t}=e;if(!t||typeof t!="string"||t.trim().length===0)throw new Error("Component name is required and must be a non-empty string");let r=this.query.getByName(t.trim());if(!r)throw new Error(`Component "${t}" not found in documentation`);let n=this.formatter.formatInputs(r);return{componentName:r.name,inputs:n}}static getToolDefinition(){return{name:"get-component-inputs",description:"Retrieves all input properties for a specific component, directive, pipe, or service by name. Returns detailed information about each input including name, type, description, default value, and required flag.",inputSchema:{type:"object",properties:{name:{type:"string",description:"The name of the component, directive, pipe, or service"}},required:["name"]}}}};var x=class{query;formatter;constructor(e,t){this.query=e,this.formatter=t}execute(e){let{name:t}=e;if(!t||typeof t!="string"||t.trim().length===0)throw new Error("Component name is required and must be a non-empty string");let r=this.query.getByName(t.trim());if(!r)throw new Error(`Component "${t}" not found in documentation`);let n=this.formatter.formatOutputs(r);return{componentName:r.name,outputs:n}}static getToolDefinition(){return{name:"get-component-outputs",description:"Retrieves all output events for a specific component, directive, pipe, or service by name. Returns detailed information about each output including name, type, and description.",inputSchema:{type:"object",properties:{name:{type:"string",description:"The name of the component, directive, pipe, or service"}},required:["name"]}}}};var b=class{query;formatter;constructor(e,t){this.query=e,this.formatter=t}execute(e){let{name:t}=e;if(!t||typeof t!="string"||t.trim().length===0)throw new Error("Component name is required and must be a non-empty string");let r=this.query.getByName(t.trim());if(!r)throw new Error(`Component "${t}" not found in documentation`);let n=this.formatter.formatExamples(r);return{componentName:r.name,examples:n}}static getToolDefinition(){return{name:"get-component-examples",description:"Retrieves all usage examples for a specific component, directive, pipe, or service by name. Returns code examples with HTML templates and TypeScript code, preserving formatting. Returns an empty array if no examples are available.",inputSchema:{type:"object",properties:{name:{type:"string",description:"The name of the component, directive, pipe, or service"}},required:["name"]}}}};var w=class{async execute(e={}){try{let t=await fetch("https://registry.npmjs.org/@eui/components");if(!t.ok)throw t.status===404?new Error('Package "@eui/components" not found in npm registry'):new Error(`npm registry returned status ${t.status}`);let r=await t.json();if(!r["dist-tags"]||!r["dist-tags"].latest)throw new Error("Invalid response: missing dist-tags.latest");if(!r.time)throw new Error("Invalid response: missing time field");let n=r["dist-tags"].latest,o=r.time[n];if(!o)throw new Error(`Invalid response: no publish date for version ${n}`);return{packageName:"@eui/components",version:n,publishDate:o}}catch(t){throw t instanceof Error?t:new Error(`Unexpected error querying npm registry: ${String(t)}`)}}static getToolDefinition(){return{name:"get-library-version",description:"Queries the npm registry to retrieve the latest version information for the @eui/components package, including the version number and publish date.",inputSchema:{type:"object",properties:{}}}}};var Q=class{isDeprecated(e){return!!(e.deprecated===!0||e.decorators&&e.decorators.some(t=>t.name==="deprecated")||e.jsdoctags&&e.jsdoctags.some(t=>t.tagName?.text==="deprecated"))}extractDeprecationMessage(e){let t=e.jsdoctags?.find(r=>r.tagName?.text==="deprecated");return t?.comment?t.comment:e.deprecationMessage?e.deprecationMessage:"This item is deprecated."}extractVersion(e){let t=[/since\s+v?(\d+\.\d+\.\d+)/i,/deprecated\s+in\s+v?(\d+\.\d+\.\d+)/i,/v(\d+\.\d+\.\d+)/i];for(let r of t){let n=e.match(r);if(n)return n[1]}}extractReplacement(e){let t=[/use\s+([A-Za-z0-9_-]+)\s+instead/i,/replaced\s+by\s+([A-Za-z0-9_-]+)/i,/migrate\s+to\s+([A-Za-z0-9_-]+)/i,/see\s+([A-Za-z0-9_-]+)/i];for(let r of t){let n=e.match(r);if(n)return n[1]}}parseDeprecationInfo(e){let t=this.extractDeprecationMessage(e);return{deprecationMessage:t,versionDeprecated:this.extractVersion(t),replacementSuggestion:this.extractReplacement(t),filePath:e.file}}};var E=class{constructor(e){this.index=e;this.parser=new Q}parser;listDeprecated(e={}){let t=[],r=[{items:this.index.components,type:"component"},{items:this.index.directives,type:"directive"},{items:this.index.pipes,type:"pipe"},{items:this.index.services,type:"injectable"}];for(let{items:n,type:o}of r)if(!(e.type&&e.type!==o)){for(let s of n)if(this.parser.isDeprecated(s)){let a=this.parser.parseDeprecationInfo(s),p=e.includeReplacements?a.replacementSuggestion:void 0;t.push({name:s.name,type:o,deprecationMessage:a.deprecationMessage,versionDeprecated:a.versionDeprecated,replacementSuggestion:p,filePath:a.filePath})}}return t}getDeprecationInfo(e){let t=this.index.byName.get(e);if(!t)return null;if(!this.parser.isDeprecated(t))return{name:e,type:t.type,isDeprecated:!1};let n=this.parser.parseDeprecationInfo(t);return{name:e,type:t.type,isDeprecated:!0,deprecationMessage:n.deprecationMessage,versionDeprecated:n.versionDeprecated,replacementSuggestion:n.replacementSuggestion}}};var D=class{query;formatter;constructor(e,t){this.query=new E(e),this.formatter=t}execute(e={}){let{type:t,includeReplacements:r=!1}=e,n=this.query.listDeprecated({type:t,includeReplacements:r});return{content:[{type:"text",text:this.formatter.formatDeprecatedList(n,r)}]}}static getToolDefinition(){return{name:"list-deprecated",description:"Lists all deprecated items in the library (components, directives, pipes, services). Supports filtering by type and optionally includes replacement suggestions.",inputSchema:{type:"object",properties:{type:{type:"string",description:"Filter by type (component, directive, pipe, injectable)"},includeReplacements:{type:"boolean",description:"Include replacement suggestions in results (default: false)",default:!1}}}}}};var S=class{query;formatter;constructor(e,t){this.query=new E(e),this.formatter=t}execute(e){let{componentName:t}=e;if(!t||typeof t!="string"||t.trim().length===0)throw new Error("Component name is required and must be a non-empty string");let r=this.query.getDeprecationInfo(t.trim());if(!r)throw new Error(`Component "${t}" not found in documentation`);return{content:[{type:"text",text:this.formatter.formatDeprecationInfo(r)}]}}static getToolDefinition(){return{name:"get-deprecation-info",description:"Retrieves detailed deprecation information for a specific component, directive, pipe, or service. Returns deprecation status, message, version deprecated, and replacement suggestions.",inputSchema:{type:"object",properties:{componentName:{type:"string",description:"The name of the component or library element to check"}},required:["componentName"]}}}};var I=class{execute(e={}){return Promise.resolve({content:Ee,format:"markdown"})}static getToolDefinition(){return{name:"get-eui-cli-guide",description:"Returns a comprehensive markdown guide for getting started with EUI CLI, including installation, project creation, and basic usage instructions.",inputSchema:{type:"object",properties:{}}}}},Ee=`# Getting Started with EUI CLI
75
-
76
- The EUI CLI is a command-line tool for scaffolding and managing EUI applications.
77
-
78
- ## Installation
79
-
80
- Install the EUI CLI globally using npm:
81
-
82
- \`\`\`bash
83
- npm install -g @eui/cli
84
- \`\`\`
85
-
86
- Verify the installation:
87
-
88
- \`\`\`bash
89
- eui-cli --version
90
- \`\`\`
91
-
92
- ## Creating a New Application
93
-
94
- Generate a new EUI application using the \`new\` command:
95
-
96
- \`\`\`bash
97
- eui-cli new
98
- \`\`\`
99
-
100
- This will:
101
- - Create a new directory called \`my-app\`
102
- - Set up the project structure
103
- - Install dependencies
104
- - Configure build tools
105
-
106
- ### Interactive Setup
107
-
108
- The CLI will prompt you for:
109
- - **Application name**: Your app's display name
110
- - **Description**: Brief description of your application
111
- - **Framework**: Choose between Angular, React, or Vue
112
- - **Styling**: Select CSS, SCSS, or styled-components
113
- - **Features**: Optional features like routing, state management, etc.
114
-
115
- ### Non-Interactive Setup
116
-
117
- Skip prompts by providing options:
118
-
119
- eui-cli globally installed
120
- \`\`\`bash
121
- eui-cli new --config appType:angular,npmInstall:false --targetPath my-app
122
- \`\`\`
123
- or using npx
124
- \`\`\`bash
125
- npx @eui/cli new --config appType:angular,npmInstall:false --targetPath my-app
126
- \`\`\`
127
-
128
- ## Project Structure
129
-
130
- A generated EUI application has this structure:
131
-
132
- \`\`\`
133
- my-app/
134
- \u251C\u2500\u2500 src/
135
- \u2502 \u251C\u2500\u2500 app/
136
- \u2502 \u2502 \u251C\u2500\u2500 features/
137
- \u2502 \u2502 \u2502 \u251C\u2500\u2500 home/
138
- \u2502 \u2502 \u2502 \u2502 \u251C\u2500\u2500 home.component.html
139
- \u2502 \u2502 \u2502 \u2502 \u251C\u2500\u2500 home.component.ts
140
- \u2502 \u2502 \u2502 \u2502 \u2514\u2500\u2500 home.routes.ts
141
- \u2502 \u2502 \u2502 \u251C\u2500\u2500 module1/
142
- \u2502 \u2502 \u2502 \u2502 \u251C\u2500\u2500 components/
143
- \u2502 \u2502 \u2502 \u2502 \u2502 \u251C\u2500\u2500 page1/
144
- \u2502 \u2502 \u2502 \u2502 \u2502 \u2502 \u251C\u2500\u2500 page1.component.html
145
- \u2502 \u2502 \u2502 \u2502 \u2502 \u2502 \u2514\u2500\u2500 page1.component.ts
146
- \u2502 \u2502 \u2502 \u2502 \u2502 \u2514\u2500\u2500 page2/
147
- \u2502 \u2502 \u2502 \u2502 \u2502 \u251C\u2500\u2500 page2.component.html
148
- \u2502 \u2502 \u2502 \u2502 \u2502 \u2514\u2500\u2500 page2.component.ts
149
- \u2502 \u2502 \u2502 \u2502 \u251C\u2500\u2500 module1.component.html
150
- \u2502 \u2502 \u2502 \u2502 \u251C\u2500\u2500 module1.component.ts
151
- \u2502 \u2502 \u2502 \u2502 \u2514\u2500\u2500 module1.routes.ts
152
- \u2502 \u2502 \u2502 \u2514\u2500\u2500 module2/
153
- \u2502 \u2502 \u2502 \u251C\u2500\u2500 module2.component.html
154
- \u2502 \u2502 \u2502 \u251C\u2500\u2500 module2.component.ts
155
- \u2502 \u2502 \u2502 \u2514\u2500\u2500 module2.routes.ts
156
- \u2502 \u2502 \u251C\u2500\u2500 shared/
157
- \u2502 \u2502 \u2502 \u2514\u2500\u2500 testing/
158
- \u2502 \u2502 \u2502 \u2514\u2500\u2500 router.mock.ts
159
- \u2502 \u2502 \u251C\u2500\u2500 app-starter.service.ts
160
- \u2502 \u2502 \u251C\u2500\u2500 app-starter.service.spec.ts
161
- \u2502 \u2502 \u251C\u2500\u2500 app.component.html
162
- \u2502 \u2502 \u251C\u2500\u2500 app.component.ts
163
- \u2502 \u2502 \u251C\u2500\u2500 app.component.spec.ts
164
- \u2502 \u2502 \u251C\u2500\u2500 app.config.ts
165
- \u2502 \u2502 \u2514\u2500\u2500 app.routes.ts
166
- \u2502 \u251C\u2500\u2500 assets/
167
- \u2502 \u2502 \u251C\u2500\u2500 config/
168
- \u2502 \u2502 \u2502 \u251C\u2500\u2500 env-json-config-dev.json
169
- \u2502 \u2502 \u2502 \u251C\u2500\u2500 env-json-config-prod.json
170
- \u2502 \u2502 \u2502 \u2514\u2500\u2500 env-json-config.json
171
- \u2502 \u2502 \u2514\u2500\u2500 i18n/
172
- \u2502 \u2502 \u251C\u2500\u2500 en.json
173
- \u2502 \u2502 \u2514\u2500\u2500 fr.json
174
- \u2502 \u251C\u2500\u2500 config/
175
- \u2502 \u2502 \u251C\u2500\u2500 global.ts
176
- \u2502 \u2502 \u251C\u2500\u2500 index.ts
177
- \u2502 \u2502 \u2514\u2500\u2500 modules.ts
178
- \u2502 \u251C\u2500\u2500 environments/
179
- \u2502 \u2502 \u251C\u2500\u2500 environment.ts
180
- \u2502 \u2502 \u2514\u2500\u2500 environment.prod.ts
181
- \u2502 \u251C\u2500\u2500 index.html
182
- \u2502 \u251C\u2500\u2500 main.ts
183
- \u2502 \u251C\u2500\u2500 styles.scss
184
- \u2502 \u251C\u2500\u2500 favicon.ico
185
- \u2502 \u251C\u2500\u2500 dummy.spec.ts
186
- \u2502 \u251C\u2500\u2500 tsconfig.app.json
187
- \u2502 \u2514\u2500\u2500 tsconfig.spec.json
188
- \u251C\u2500\u2500 mock/
189
- \u2502 \u251C\u2500\u2500 app/
190
- \u2502 \u2502 \u251C\u2500\u2500 models/
191
- \u2502 \u2502 \u2502 \u2514\u2500\u2500 user.js
192
- \u2502 \u2502 \u2514\u2500\u2500 routes/
193
- \u2502 \u251C\u2500\u2500 db/
194
- \u2502 \u2502 \u2514\u2500\u2500 db.json
195
- \u2502 \u2514\u2500\u2500 server.js
196
- \`\`\`
197
-
198
- The application will be available at \`http://localhost:4200\`
199
- `;var R=class{execute(e={}){return Promise.resolve({content:De,format:"markdown"})}static getToolDefinition(){return{name:"get-eui-cli-instructions",description:"Returns complete EUI CLI instructions including all commands, options, headless mode configuration, CI/CD usage, and best practices for automated scaffolding and building.",inputSchema:{type:"object",properties:{}}}}},De=`# eUI CLI - Complete Options Report
200
-
201
- ## Overview
202
-
203
- The @eui/cli is a command-line tool for scaffolding and managing eUI Angular applications. It supports both interactive and headless (automated) modes for CI/CD pipelines and scripting.
204
-
205
- ## Installation
206
-
207
- \`\`\`bash
208
- npm install -g @eui/cli@latest
209
- \`\`\`
210
-
211
- ## Available Commands
212
-
213
- ### 1. new (default command)
214
-
215
- Generates a new eUI application with interactive prompts or automated configuration.
216
-
217
- **Usage:**
218
-
219
- \`\`\`bash
220
- eui-cli new [options]
221
- eui-cli [options] # 'new' is default
222
- \`\`\`
223
-
224
- **Interactive Options:**
225
-
226
- **Application Type:**
227
- - \`angular\` - eUI Angular Desktop
228
- - \`mobile\` - eUI Angular Mobile (Ionic)
229
- - \`web-spring-boot\` - eUI Angular + Spring Boot (requires JDK + Maven)
230
- - \`web-maven\` - eUI Angular + Maven web module (requires JDK + Maven)
231
-
232
- **Additional Configuration:**
233
- - \`ecl\` - ECL app-shell template for ec.europa.eu apps
234
- - ECL Theme: \`ecl-ec\` or \`ecl-eu\`
235
-
236
- **Package Manager:**
237
- - \`yarn\` (default)
238
- - \`pnpm\` (experimental)
239
-
240
- **Maven Options (for web-spring-boot):**
241
- - \`groupId\` - Default: ec.europa.digit
242
- - \`artifactId\` - Default: myapp
243
-
244
- ### 2. build-app
245
-
246
- Builds the Angular application with linting, testing, and compilation.
247
-
248
- **Usage:**
249
-
250
- \`\`\`bash
251
- eui-cli build-app [options]
252
- \`\`\`
253
-
254
- **Options:**
255
-
256
- | Option | Type | Description |
257
- |--------|------|-------------|
258
- | \`--skipLint\` | boolean | Skip linting phase |
259
- | \`--skipTest\` | boolean | Skip unit testing phase |
260
- | \`--skipCompile\` | boolean | Skip compilation phase |
261
- | \`--configuration\` | string | Build configuration (e.g., production, development) |
262
- | \`--baseHref\` | string | Base URL for the application |
263
- | \`--servePath\` | string | Path where files are served |
264
- | \`--deployUrl\` | string | URL where files will be deployed |
265
- | \`--watch\` | boolean | Enable watch mode for tests |
266
- | \`--dryRun\` | boolean | Run without executing build |
267
- | \`--maxSpaceSize\` | boolean | Increase Node memory (8096MB) |
268
- | \`--statsJson\` | boolean | Generate stats.json for bundle analysis |
269
- | \`--ci\` | boolean | CI mode (disables progress output) |
270
- | \`--sourceMap\` | boolean | Generate source maps |
271
- | \`--configEnvTarget\` | string | Inject environment-specific config |
272
- | \`--project\` | string | Project name (default: 'app') |
273
-
274
- **Example:**
275
-
276
- \`\`\`bash
277
- eui-cli build-app --configuration=production --baseHref=/myapp/ --skipTest
278
- \`\`\`
279
-
280
- ### 3. serve-app
281
-
282
- Serves the Angular application locally with development server.
283
-
284
- **Usage:**
285
-
286
- \`\`\`bash
287
- eui-cli serve-app [options]
288
- \`\`\`
289
-
290
- **Options:**
291
-
292
- | Option | Type | Description |
293
- |--------|------|-------------|
294
- | \`--configuration\` | string | Serve configuration |
295
- | \`--baseHref\` | string | Base URL for the application |
296
- | \`--servePath\` | string | Path where files are served |
297
- | \`--host\` | string | Host to listen on (default: localhost) |
298
- | \`--port\` | number | Port to listen on (default: 4200) |
299
- | \`--proxyConfig\` | string | Proxy configuration file |
300
- | \`--disableHostCheck\` | boolean | Disable host check |
301
- | \`--open\` | string | Open browser (default: true, use 'false' to disable) |
302
- | \`--maxSpaceSize\` | boolean | Increase Node memory (8192MB) |
303
- | \`--noLiveReload\` | boolean | Disable live reload |
304
- | \`--configEnvTarget\` | string | Inject environment-specific config |
305
- | \`--project\` | string | Project name (default: 'app') |
306
- | \`--debug\` | boolean | Enable debug logging |
307
-
308
- **Example:**
309
-
310
- \`\`\`bash
311
- eui-cli serve-app --port=4300 --host=0.0.0.0 --proxyConfig=proxy.conf.json
312
- \`\`\`
313
-
314
- ### 4. lint-app
315
-
316
- Runs linting on the application.
317
-
318
- **Usage:**
319
-
320
- \`\`\`bash
321
- eui-cli lint-app
322
- \`\`\`
323
-
324
- ### 5. inject-config-app
325
-
326
- Injects environment-specific configuration into the application.
327
-
328
- **Usage:**
329
-
330
- \`\`\`bash
331
- eui-cli inject-config-app --configEnvTarget=<env>
332
- \`\`\`
333
-
334
- **Options:**
335
-
336
- | Option | Type | Description |
337
- |--------|------|-------------|
338
- | \`--configEnvTarget\` | string | Target environment (dev, tst, acc, prd) |
339
-
340
- **How it works:**
341
- - Copies \`src/assets/config/env-json-config-<env>.json\` to \`src/assets/env-json-config.json\`
342
- - Used for environment-specific OpenID/configuration injection
343
-
344
- **Example:**
345
-
346
- \`\`\`bash
347
- eui-cli inject-config-app --configEnvTarget=production
348
- \`\`\`
349
-
350
- ### 6. generate-sprite
351
-
352
- Generates SVG sprite from individual SVG files.
353
-
354
- **Usage:**
355
-
356
- \`\`\`bash
357
- eui-cli generate-sprite --inFolder=<path> --outFile=<filename.svg>
358
- \`\`\`
359
-
360
- **Options:**
361
-
362
- | Option | Type | Description |
363
- |--------|------|-------------|
364
- | \`--inFolder\` | string | Input folder containing SVG files (required) |
365
- | \`--outFile\` | string | Output sprite filename (required, must end with .svg) |
366
-
367
- **Features:**
368
- - Optimizes SVG files using imagemin-svgo
369
- - Generates sprite file and JSON list of icons
370
- - Cleans up IDs, removes styles and titles
371
-
372
- **Example:**
373
-
374
- \`\`\`bash
375
- eui-cli generate-sprite --inFolder=src/assets/icons --outFile=sprite.svg
376
- \`\`\`
377
-
378
- ## Headless Mode (Automated/CI Usage)
379
-
380
- ### Using --config Parameter
381
-
382
- The CLI supports headless operation via the \`--config\` parameter for automated scaffolding without interactive prompts.
383
-
384
- **Syntax:**
385
-
386
- \`\`\`bash
387
- eui-cli --config <key1>:<value1>,<key2>:<value2> --targetPath <path>
388
- \`\`\`
389
-
390
- ### Configuration Options
391
-
392
- | Key | Type | Values | Description |
393
- |-----|------|--------|-------------|
394
- | \`appType\` | string | angular, mobile, web-maven, web-spring-boot | Application type |
395
- | \`appName\` | string | any | Application name (default: 'my-app') |
396
- | \`appScope\` | string | any | NPM scope (default: '@app') |
397
- | \`appOptions\` | array | ecl | Additional options (use underscore for multiple: ecl_option2) |
398
- | \`appOptionsEclTheme\` | string | ecl-ec, ecl-eu | ECL theme flavor |
399
- | \`groupId\` | string | any | Maven groupId (default: 'ec.europa.digit') |
400
- | \`artifactId\` | string | any | Maven artifactId (default: 'myapp') |
401
- | \`packageManager\` | string | yarn, pnpm | Package manager |
402
- | \`npmInstall\` | boolean | true, false | Install dependencies |
403
- | \`appStart\` | boolean | true, false | Start app after generation |
404
-
405
- ### Headless Examples
406
-
407
- **1. Basic Angular App (no installation):**
408
-
409
- \`\`\`bash
410
- eui-cli --config appType:angular,npmInstall:false --targetPath my-angular-app
411
- \`\`\`
412
-
413
- **2. Angular App with ECL EC Theme:**
414
-
415
- \`\`\`bash
416
- eui-cli --config appType:angular,appOptions:ecl,appOptionsEclTheme:ecl-ec,npmInstall:true,packageManager:yarn --targetPath my-ecl-app
417
- \`\`\`
418
-
419
- **3. Mobile Ionic App:**
420
-
421
- \`\`\`bash
422
- eui-cli --config appType:mobile,npmInstall:true --targetPath my-mobile-app
423
- \`\`\`
424
-
425
- **4. Spring Boot Web App:**
426
-
427
- \`\`\`bash
428
- eui-cli --config appType:web-spring-boot,groupId:com.mycompany,artifactId:myproject,npmInstall:false --targetPath my-spring-app
429
- \`\`\`
430
-
431
- **5. CI/CD Pipeline Example:**
432
-
433
- \`\`\`bash
434
- # Generate app without installation
435
- eui-cli --config appType:angular,appOptions:ecl,npmInstall:false --targetPath ./build/app
436
-
437
- # Build for production
438
- cd ./build/app
439
- eui-cli build-app --configuration=production --ci --skipTest --baseHref=/app/
440
- \`\`\`
441
-
442
- ## Environment Variables
443
-
444
- ### _CSDR_ARGS
445
-
446
- Alternative method for passing arguments (used in CSDR pipelines).
447
-
448
- **Format:**
449
-
450
- \`\`\`bash
451
- export _CSDR_ARGS="key1:value1,key2:value2"
452
- eui-cli
453
- \`\`\`
454
-
455
- **Array Format:**
456
-
457
- \`\`\`bash
458
- export _CSDR_ARGS="itemsArray:key1=value1|key2=value2"
459
- \`\`\`
460
-
461
- ## Advanced Usage
462
-
463
- ### Version Check
464
-
465
- \`\`\`bash
466
- eui-cli -v
467
- eui-cli --version
468
- \`\`\`
469
-
470
- ### Debug Mode
471
-
472
- Enable verbose logging for troubleshooting:
473
-
474
- \`\`\`bash
475
- eui-cli serve-app --debug
476
- eui-cli build-app --debug
477
- \`\`\`
478
-
479
- ### CI/CD Build Pipeline
480
-
481
- \`\`\`bash
482
- # 1. Inject environment config
483
- eui-cli inject-config-app --configEnvTarget=production
484
-
485
- # 2. Build with optimizations
486
- eui-cli build-app \\
487
- --configuration=production \\
488
- --baseHref=/myapp/ \\
489
- --deployUrl=https://cdn.example.com/ \\
490
- --ci \\
491
- --statsJson \\
492
- --skipTest
493
-
494
- # 3. Output in dist/ folder
495
- \`\`\`
496
-
497
- ### Memory-Intensive Builds
498
-
499
- \`\`\`bash
500
- eui-cli build-app --maxSpaceSize --configuration=production
501
- eui-cli serve-app --maxSpaceSize
502
- \`\`\`
503
-
504
- ## Default Configuration Values
505
-
506
- \`\`\`javascript
507
- {
508
- appName: 'my-app',
509
- appScope: '@app',
510
- appType: 'angular',
511
- appOptions: [],
512
- appOptionsEclTheme: 'ecl-ec',
513
- appFeatures: [],
514
- groupId: 'ec.europa.digit',
515
- artifactId: 'myapp',
516
- packageManager: 'yarn',
517
- npmInstall: true,
518
- appStart: true
519
- }
520
- \`\`\`
521
-
522
- ## Exit Codes
523
-
524
- - \`0\` - Success
525
- - \`1\` - Error (build failure, missing arguments, etc.)
526
-
527
- ## Best Practices
528
-
529
- 1. **Headless Generation**: Always use \`--config\` with \`npmInstall:false\` in CI, then install separately
530
- 2. **Build Optimization**: Use \`--ci\` flag in pipelines to disable progress output
531
- 3. **Memory Management**: Use \`--maxSpaceSize\` for large applications
532
- 4. **Environment Config**: Use \`inject-config-app\` before builds for environment-specific settings
533
- 5. **Testing**: Skip tests in CI with \`--skipTest\` if running separately
534
-
535
- ## Supported Node Versions
536
-
537
- - **Node.js**: >=24.0.0
538
- - **Yarn**: >=1.22.4 <2
539
- `;var j=class{server;index;query;searchEngine;formatter;tools;isRunning=!1;constructor(e,t){this.index=t,this.query=new N(t),this.searchEngine=new F(t),this.formatter=new J,this.tools=new Map,this.server=new Se({name:e.name,version:e.version},{capabilities:{tools:{}}}),this.registerTools(),this.setupHandlers()}registerTools(){let e=new h(this.query,this.formatter),t=new y(this.query,this.formatter),r=new v(this.searchEngine,this.formatter),n=new C(this.query,this.formatter),o=new x(this.query,this.formatter),s=new b(this.query,this.formatter),a=new w,p=new D(this.index,this.formatter),u=new S(this.index,this.formatter),m=new I,f=new R;this.tools.set("list-components",e),this.tools.set("get-component-docs",t),this.tools.set("search-components",r),this.tools.set("get-component-inputs",n),this.tools.set("get-component-outputs",o),this.tools.set("get-component-examples",s),this.tools.set("get-library-version",a),this.tools.set("list-deprecated",p),this.tools.set("get-deprecation-info",u),this.tools.set("get-eui-cli-guide",m),this.tools.set("get-eui-cli-instructions",f)}setupHandlers(){this.server.setRequestHandler(Te,()=>({tools:[h.getToolDefinition(),y.getToolDefinition(),v.getToolDefinition(),C.getToolDefinition(),x.getToolDefinition(),b.getToolDefinition(),w.getToolDefinition(),D.getToolDefinition(),S.getToolDefinition(),I.getToolDefinition(),R.getToolDefinition()]})),this.server.setRequestHandler(Re,async e=>{let{name:t,arguments:r}=e.params;try{let n=this.tools.get(t);if(!n)return{content:[{type:"text",text:JSON.stringify({error:{code:"TOOL_NOT_FOUND",message:`Tool '${t}' does not exist. Available tools: ${Array.from(this.tools.keys()).join(", ")}`}})}],isError:!0};if(r==null)return{content:[{type:"text",text:JSON.stringify({error:{code:"INVALID_PARAMETERS",message:"Tool parameters are required"}})}],isError:!0};let o=await n.execute(r??{});return{content:[{type:"text",text:JSON.stringify(o,null,2)}]}}catch(n){let o=n instanceof Error?n.message:"Unknown error occurred",s=this.categorizeError(n);return{content:[{type:"text",text:JSON.stringify({error:{code:s,message:o}})}],isError:!0}}})}categorizeError(e){if(e instanceof Error){let t=e.message.toLowerCase();if(t.includes("not found")||t.includes("does not exist"))return"NOT_FOUND";if(t.includes("invalid")||t.includes("must be")||t.includes("required")||t.includes("limit")||t.includes("offset"))return"INVALID_PARAMETERS"}return"INTERNAL_ERROR"}async start(){if(this.isRunning)throw new Error("Server is already running");let e=new Ie;await this.server.connect(e),this.isRunning=!0}async stop(){this.isRunning&&(await this.server.close(),this.isRunning=!1)}isHealthy(){return this.isRunning}getStats(){return{isRunning:this.isRunning,toolCount:this.tools.size,indexStats:{totalComponents:this.index.totalCount,lastUpdated:this.index.lastUpdated}}}updateIndex(e){this.index=e,this.query=new N(e),this.searchEngine=new F(e),this.registerTools()}};var d=null,Y=null,le=!1;async function Pe(){try{let i=te();(!i.success||!i.config)&&(process.stderr.write(`Failed to load configuration
540
- `),i.errors&&i.errors.forEach(a=>process.stderr.write(` - ${a}
541
- `)),process.exit(1));let e=i.config,t=re({level:e.logging.level,format:e.logging.format});t.info("Starting EUI Compodoc MCP Server",{version:e.server.version,documentationPath:e.documentation.path}),t.info("Loading documentation...",{path:e.documentation.path}),Y=new M({path:e.documentation.path,watchForChanges:e.documentation.watchForChanges,reloadDebounce:e.documentation.reloadDebounce,onReload:Oe,onError:ke});let r=await Y.load();(!r.success||!r.data)&&(t.error("Failed to load documentation",void 0,{error:r.error}),process.exit(1)),t.info("Documentation loaded successfully",{path:e.documentation.path}),t.info("Building component index...");let n=new A,o;try{o=n.build(r.data);let a=n.getStatistics(o);t.info("Index built successfully",{totalCount:a.totalCount,components:a.componentCount,directives:a.directiveCount,pipes:a.pipeCount,services:a.serviceCount})}catch(a){t.error("Failed to build index",a instanceof Error?a:new Error(String(a))),process.exit(1)}t.info("Initializing MCP server..."),d=new j({name:e.server.name,version:e.server.version},o),t.info("Starting MCP server..."),await d.start(),t.info("MCP server started successfully",{name:e.server.name,version:e.server.version,watchForChanges:e.documentation.watchForChanges}),d.isHealthy()?t.info("Health check passed"):t.warn("Health check failed - server may not be fully operational");let s=d.getStats();t.debug("Server statistics",s),t.info("Server is ready to accept requests")}catch(i){c().error("Fatal error during startup",i instanceof Error?i:new Error(String(i))),process.exit(1)}}function Oe(i){let e=c();e.info("Documentation file changed, reloading...");try{let t=new A,r=t.build(i);if(d){d.updateIndex(r);let n=t.getStatistics(r);e.info("Index updated successfully",{totalCount:n.totalCount,components:n.componentCount,directives:n.directiveCount,pipes:n.pipeCount,services:n.serviceCount})}}catch(t){e.error("Failed to reload documentation",t instanceof Error?t:new Error(String(t)))}}function ke(i){c().error("Documentation loader error",i)}async function Z(i){if(le)return;le=!0;let e=c();e.info(`Received ${i}, shutting down gracefully...`);try{d&&(e.info("Stopping MCP server..."),await d.stop(),e.info("MCP server stopped")),Y&&(e.info("Stopping documentation loader..."),await Y.dispose(),e.info("Documentation loader stopped")),e.info("Shutdown complete"),process.exit(0)}catch(t){e.error("Error during shutdown",t instanceof Error?t:new Error(String(t))),process.exit(1)}}function Le(){process.on("SIGINT",()=>{Z("SIGINT")}),process.on("SIGTERM",()=>{Z("SIGTERM")}),process.on("uncaughtException",i=>{c().error("Uncaught exception",i),Z("uncaughtException")}),process.on("unhandledRejection",i=>{c().error("Unhandled promise rejection",i instanceof Error?i:new Error(String(i))),Z("unhandledRejection")})}Le();Pe().catch(i=>{process.stderr.write(`Fatal error: ${i}
542
- `),process.exit(1)});