@moneko/core 4.8.0-beta.0 → 4.8.0-beta.1

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.
@@ -0,0 +1 @@
1
+ import './module-federation/index.mjs';
@@ -0,0 +1 @@
1
+ import"./module-federation/index.mjs";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 获取当前项目所有 moduleFederation 远端,生成指定文件名的 URL 映射
3
+ * @param {string} filename - 文件名,如 'LLMs.md' 或 'module-federation.d.ts'
4
+ * @returns {Record<string, string>} - 返回 { ['mf:<name>']: 'host/<filename>' } 格式
5
+ */ export declare function getRemoteUrls(filename: string): Record<string, string>;
6
+ export declare function fetchRemoteText(url: string): Promise<string>;
@@ -0,0 +1 @@
1
+ import{getConfigWithTypescript as e,paths as t}from"@moneko/core";export function getRemoteUrls(o){let r=e(t.configPath).default;return Object.fromEntries((r?.moduleFederation??[]).flatMap(e=>e.remotes??[]).filter(e=>e?.name&&e?.host).map(e=>[`mf:${e.name}`,new URL(o,e.host).toString()]))}export async function fetchRemoteText(e){let{request:t}=await import("@moneko/request");return t(e,{responseType:"text",rejectUnauthorized:!1})}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export { };
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{McpServer as e}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as t}from"@modelcontextprotocol/sdk/server/stdio.js";import o from"zod";import{fetchRemoteText as n,getRemoteUrls as r}from"./common.mjs";function i(e){let t=[],o=e.split("\n"),n=null,r=0;for(let e of o)if(0===r&&/^(export\s+)?(declare\s+)?(module|namespace|interface|type|class|function|const|enum|var)\s/.test(e)){n&&t.push(n);let o=e.match(/module\s+['"]([^'"]+)['"]/)||e.match(/(?:namespace|interface|type|class|function|const|enum|var)\s+(\w+)/);n={name:o?o[1]:e.trim().slice(0,60),content:e},r+=(e.match(/\{/g)||[]).length-(e.match(/\}/g)||[]).length}else n&&(n.content+=`
3
+ ${e}`,(r+=(e.match(/\{/g)||[]).length-(e.match(/\}/g)||[]).length)<=0&&(r=0));return n&&t.push(n),t}let s=new e({name:"module-federation",version:"1.0.0"},{capabilities:{tools:{}}}),a=o.string().optional().describe("项目根目录路径,默认使用当前工作目录");function l(e){return async t=>{try{return{content:[{type:"text",text:JSON.stringify(await e(t),null,2)}]}}catch(e){return{content:[{type:"text",text:`错误:${e.message}`}],isError:!0}}}}s.registerTool("get_module_federation_dts",{title:"获取 Module Federation dts 文件地址",description:"获取各 Module Federation 远端对应的 module-federation.d.ts 文件 URL,可用于下获取完整类型声明。",inputSchema:{project_root:a}},l(()=>r("module-federation.d.ts"))),s.registerTool("search_module_federation_dts",{title:"搜索 Module Federation dts",description:"从指定 Module Federation 远端拉取 module-federation.d.ts,仅返回与查询关键词匹配的顶级类型声明块(declare module / interface / type 等)。",inputSchema:{query:o.string().describe("要搜索的类型名或关键词(大小写不敏感)"),remote:o.string().optional().describe('远端名称,例如 "mf:lexicon_admin",不填则搜索所有远端。'),project_root:a}},l(async e=>{let{query:t,remote:o}=e||{},s=r("module-federation.d.ts"),a=o?{[o]:s[o]??(()=>{throw Error(`远端 "${o}" 不存在`)})()}:s;return(await Promise.allSettled(Object.entries(a).map(async([e,o])=>{let r=await n(o),s=t?.toLowerCase()??"",a=s?i(r).filter(e=>e.content.toLowerCase().includes(s)):i(r);return{remote:e,matched:a.length,sections:a.map(e=>e.content)}}))).map(e=>"fulfilled"===e.status&&e.value?.matched>0?e.value:null).filter(Boolean)})),await s.connect(new t);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "4.8.0-beta.0",
3
+ "version": "4.8.0-beta.1",
4
4
  "description": "@moneko/core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
@@ -116,7 +116,8 @@
116
116
  }
117
117
  },
118
118
  "./package.json": "./package.json",
119
- "./lib/polyfills/public-path.mjs": "./lib/polyfills/public-path.mjs"
119
+ "./lib/polyfills/public-path.mjs": "./lib/polyfills/public-path.mjs",
120
+ "./mcp": "./lib/mcp/index.mjs"
120
121
  },
121
122
  "keywords": [
122
123
  "moneko",
@@ -147,7 +148,7 @@
147
148
  "less-loader": "12.3.2",
148
149
  "lightningcss": "1.32.0",
149
150
  "swc-loader": "0.2.7",
150
- "typescript": "6.0.2",
151
+ "typescript": "5.9.3",
151
152
  "webpack": "5.105.4",
152
153
  "webpack-hot-middleware": "2.26.1",
153
154
  "webpack-merge": "6.0.1"