@lensmcp/nx-plugin 1.24.5 → 1.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,20 @@
1
1
  import { type Tree } from '@nx/devkit';
2
2
  import type { InitGeneratorSchema } from './schema';
3
+ /**
4
+ * The parts of `.lensmcp/` that are the team's and committed — each analyzer's instruction folder. Lock-step with
5
+ * `@lensmcp/core/lens-dir` LENS_SHARED_DIRS (init.spec.ts compares them); this package depends on no other.
6
+ */
7
+ export declare const LENS_SHARED_DIRS: readonly string[];
8
+ /**
9
+ * A .gitignore with its `.lensmcp` lines made right: the runtime ignored and each shared folder let back in under it.
10
+ * A `.lensmcp/` line becomes `**\/.lensmcp/*` — git never looks inside an ignored folder for a `!` line, and a bare
11
+ * `.lensmcp/*` (a slash in the middle) would hold at the root only; `/.lensmcp/` (the root's) becomes `/.lensmcp/*`.
12
+ * Lines it does not own are left as they are.
13
+ */
14
+ export declare function fixLensGitignore(text: string): {
15
+ text: string;
16
+ changed: boolean;
17
+ };
3
18
  export declare function initGenerator(tree: Tree, rawOptions?: InitGeneratorSchema): Promise<void>;
4
19
  /**
5
20
  * The stdio MCP server entry a host agent uses to launch LensMCP.
@@ -1,10 +1,13 @@
1
- "use strict";var f=Object.defineProperty;var p=(e,s)=>f(e,"name",{value:s,configurable:!0});var d=Object.defineProperty,c=p((e,s)=>d(e,"name",{value:s,configurable:!0}),"c");Object.defineProperty(exports,"__esModule",{value:!0}),exports.initGenerator=initGenerator,exports.mcpServerEntry=mcpServerEntry,exports.pluginVersion=pluginVersion,exports.isGeneratedMcpEntry=isGeneratedMcpEntry,exports.refreshedMcpEntry=refreshedMcpEntry;const node_fs_1=require("node:fs"),node_path_1=require("node:path"),devkit_1=require("@nx/devkit"),DEFAULT_LENSMCP_CONFIG={schemaVersion:1,storage:"memory",transport:"stdio",retention:{sessions:5,events:5e3,screenshots:50,buildReports:20,visualFrames:200,heapSnapshots:3,tracesWithErrors:20,verifications:10},redaction:{headers:["authorization","cookie","set-cookie","x-api-key"],paths:["password","token","secret","apiKey","api_key"]},channels:{blockingStatusChanged:{enabled:!0,minSeverity:"error"},memoryLeakSuspected:{enabled:!0,minSeverity:"warning"},bundleRegression:{enabled:!0,minSeverity:"warning"},visualViolationBlocking:{enabled:!0,minSeverity:"error"},verificationCompleted:{enabled:!0,minSeverity:"info"}},thresholds:{dbInLoop:5,nPlusOne:3,renderStorm:5,slowRouteMs:500,slowRenderMs:16}},LENSMCP_GITIGNORE_MARKER="# LensMCP runtime artifacts (per-session storage)",LENSMCP_GITIGNORE_ENTRY=".lensmcp/";async function initGenerator(e,s={}){const r={skipFormat:s.skipFormat??!1,registerHostConfig:s.registerHostConfig??"auto"},n=[];if(e.exists("nx.json"))(0,devkit_1.updateJson)(e,"nx.json",o=>{o.plugins=Array.isArray(o.plugins)?o.plugins:[],o.plugins.some(l=>typeof l=="string"?l==="@lensmcp/nx-plugin":l&&typeof l=="object"&&"plugin"in l?l.plugin==="@lensmcp/nx-plugin":!1)||(o.plugins.push("@lensmcp/nx-plugin"),n.push("nx.json: registered @lensmcp/nx-plugin"));const g=o.lensmcp??{};return o.lensmcp=mergeDeep(DEFAULT_LENSMCP_CONFIG,g),(!("lensmcp"in o)||Object.keys(g).length===0)&&n.push("nx.json: added workspace-wide `lensmcp` config block"),o});else throw new Error("No nx.json found at the workspace root. Are you in a Nx workspace?");const t=".gitignore",i=e.exists(t)?e.read(t,"utf-8")??"":"";if(!i.split(`
2
- `).some(o=>o.trim()===LENSMCP_GITIGNORE_ENTRY)){const o=i.endsWith(`
3
- `)?"":`
4
- `;e.write(t,`${i}${o}
5
- ${LENSMCP_GITIGNORE_MARKER}
6
- ${LENSMCP_GITIGNORE_ENTRY}
7
- `),n.push(`${t}: added \`${LENSMCP_GITIGNORE_ENTRY}\``)}const a=(0,devkit_1.joinPathFragments)(".lensmcp",".keep");e.exists(a)||(e.write(a,""),n.push(`${a}: created`));const m=(0,devkit_1.joinPathFragments)(".lensmcp","install-trail.json"),u=(e.exists(m)?JSON.parse(e.read(m,"utf-8")??"{}"):void 0)??{schemaVersion:1,installedAt:new Date().toISOString(),steps:[]};u.steps.push(...n),e.write(m,JSON.stringify(u,null,2)+`
8
- `),r.registerHostConfig!=="never"&&registerWorkspaceMcpConfig(e,n),r.skipFormat||await(0,devkit_1.formatFiles)(e)}p(initGenerator,"initGenerator"),c(initGenerator,"initGenerator");function mcpServerEntry(e,s={}){if((s.exists??node_fs_1.existsSync)((0,node_path_1.join)(e,"node_modules",".bin","lensmcp")))return{command:"npx",args:["--no","lensmcp","mcp"]};const r="version"in s?s.version:pluginVersion();return{command:"npx",args:["--yes",r?`lensmcp@${r}`:"lensmcp","mcp"]}}p(mcpServerEntry,"mcpServerEntry"),c(mcpServerEntry,"mcpServerEntry");function pluginVersion(e=__dirname){let s=e;for(let r=0;r<6;r++){const n=(0,node_path_1.join)(s,"package.json");try{if((0,node_fs_1.existsSync)(n)){const i=JSON.parse((0,node_fs_1.readFileSync)(n,"utf-8"));if(i.name==="@lensmcp/nx-plugin"&&typeof i.version=="string")return i.version}}catch{}const t=(0,node_path_1.dirname)(s);if(t===s)break;s=t}}p(pluginVersion,"pluginVersion"),c(pluginVersion,"pluginVersion");const PINNED_SPECIFIER=/^lensmcp@\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;function isGeneratedMcpEntry(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const{command:s,args:r,...n}=e;if(s!=="npx"||Object.keys(n).length>0||!Array.isArray(r)||r.length!==3)return!1;const[t,i,a]=r;return a!=="mcp"||typeof i!="string"?!1:t==="--no"?i==="lensmcp":t==="-y"||t==="--yes"?i==="lensmcp"||PINNED_SPECIFIER.test(i):!1}p(isGeneratedMcpEntry,"isGeneratedMcpEntry"),c(isGeneratedMcpEntry,"isGeneratedMcpEntry");function refreshedMcpEntry(e,s){if(!isGeneratedMcpEntry(e)||e.args.join(" ")===s.args.join(" "))return;const r=e.args[0]!=="--no"&&e.args[1]==="lensmcp";return s.args[0]==="--no"||r?s:void 0}p(refreshedMcpEntry,"refreshedMcpEntry"),c(refreshedMcpEntry,"refreshedMcpEntry");function registerWorkspaceMcpConfig(e,s){const r=".mcp.json";let n={};if(e.exists(r))try{n=JSON.parse(e.read(r,"utf-8")??"{}")}catch{n={}}(!n||typeof n!="object")&&(n={}),(!n.mcpServers||typeof n.mcpServers!="object")&&(n.mcpServers={});const t=n.mcpServers.lensmcp,i=mcpServerEntry(e.root);if(t){const a=refreshedMcpEntry(t,i);if(!a)return;n.mcpServers.lensmcp=a,e.write(r,JSON.stringify(n,null,2)+`
9
- `),s.push(`.mcp.json: refreshed the generated lensmcp MCP entry (${t.args.join(" ")} \u2192 ${a.args.join(" ")})`);return}n.mcpServers.lensmcp=i,e.write(r,JSON.stringify(n,null,2)+`
10
- `),s.push(`.mcp.json: registered lensmcp MCP server (stdio, ${i.args.join(" ")})`)}p(registerWorkspaceMcpConfig,"registerWorkspaceMcpConfig"),c(registerWorkspaceMcpConfig,"registerWorkspaceMcpConfig"),exports.default=initGenerator;function mergeDeep(e,s){const r={...e};for(const[n,t]of Object.entries(s))t!==null&&typeof t=="object"&&!Array.isArray(t)&&r[n]!==null&&typeof r[n]=="object"&&!Array.isArray(r[n])?r[n]=mergeDeep(r[n],t):r[n]=t;return r}p(mergeDeep,"mergeDeep"),c(mergeDeep,"mergeDeep");
1
+ "use strict";var y=Object.defineProperty;var a=(e,r)=>y(e,"name",{value:r,configurable:!0});var d=Object.defineProperty,p=a((e,r)=>d(e,"name",{value:r,configurable:!0}),"p");Object.defineProperty(exports,"__esModule",{value:!0}),exports.LENS_SHARED_DIRS=void 0,exports.fixLensGitignore=fixLensGitignore,exports.initGenerator=initGenerator,exports.mcpServerEntry=mcpServerEntry,exports.pluginVersion=pluginVersion,exports.isGeneratedMcpEntry=isGeneratedMcpEntry,exports.refreshedMcpEntry=refreshedMcpEntry;const node_fs_1=require("node:fs"),node_path_1=require("node:path"),devkit_1=require("@nx/devkit"),DEFAULT_LENSMCP_CONFIG={schemaVersion:1,storage:"memory",transport:"stdio",retention:{sessions:5,events:5e3,screenshots:50,buildReports:20,visualFrames:200,heapSnapshots:3,tracesWithErrors:20,verifications:10},redaction:{headers:["authorization","cookie","set-cookie","x-api-key"],paths:["password","token","secret","apiKey","api_key"]},channels:{blockingStatusChanged:{enabled:!0,minSeverity:"error"},memoryLeakSuspected:{enabled:!0,minSeverity:"warning"},bundleRegression:{enabled:!0,minSeverity:"warning"},visualViolationBlocking:{enabled:!0,minSeverity:"error"},verificationCompleted:{enabled:!0,minSeverity:"info"}},thresholds:{dbInLoop:5,nPlusOne:3,renderStorm:5,slowRouteMs:500,slowRenderMs:16}},LENSMCP_GITIGNORE_MARKER="# LensMCP: this machine's runtime state is ignored; the team's analyzer instructions are kept";exports.LENS_SHARED_DIRS=["sql-review","route-review","flow-review","ui-review","cache-review","queue-review"];function fixLensGitignore(e){const r=e.split(`
2
+ `),s=/^(\/|\*\*\/)?\.lensmcp\/?(\*)?$/;let n=r.findIndex(o=>s.test(o.trim())),t=!1;if(n<0){const o=e.length&&!e.endsWith(`
3
+ `)?`${e}
4
+ `:e;return{text:`${o}${o.trim()?`
5
+ `:""}${LENSMCP_GITIGNORE_MARKER}
6
+ **/.lensmcp/*
7
+ ${exports.LENS_SHARED_DIRS.map(l=>`!**/.lensmcp/${l}/`).join(`
8
+ `)}
9
+ `,changed:!0}}const i=s.exec(r[n].trim())[1]==="/"?"/":"**/";r[n].trim()!==`${i}.lensmcp/*`&&(r[n]=`${i}.lensmcp/*`,t=!0);for(const o of exports.LENS_SHARED_DIRS){const l=`!${i}.lensmcp/${o}/`;r.some(m=>m.trim()===l||m.trim()===l.slice(0,-1))||(r.splice(++n,0,l),t=!0)}return{text:r.join(`
10
+ `),changed:t}}a(fixLensGitignore,"fixLensGitignore"),p(fixLensGitignore,"fixLensGitignore");async function initGenerator(e,r={}){const s={skipFormat:r.skipFormat??!1,registerHostConfig:r.registerHostConfig??"auto"},n=[];if(e.exists("nx.json"))(0,devkit_1.updateJson)(e,"nx.json",c=>{c.plugins=Array.isArray(c.plugins)?c.plugins:[],c.plugins.some(u=>typeof u=="string"?u==="@lensmcp/nx-plugin":u&&typeof u=="object"&&"plugin"in u?u.plugin==="@lensmcp/nx-plugin":!1)||(c.plugins.push("@lensmcp/nx-plugin"),n.push("nx.json: registered @lensmcp/nx-plugin"));const f=c.lensmcp??{};return c.lensmcp=mergeDeep(DEFAULT_LENSMCP_CONFIG,f),(!("lensmcp"in c)||Object.keys(f).length===0)&&n.push("nx.json: added workspace-wide `lensmcp` config block"),c});else throw new Error("No nx.json found at the workspace root. Are you in a Nx workspace?");const t=".gitignore",i=e.exists(t)?e.read(t,"utf-8")??"":"",o=fixLensGitignore(i);o.changed&&(e.write(t,o.text),n.push(`${t}: ignores **/.lensmcp/* and keeps ${exports.LENS_SHARED_DIRS.map(c=>`.lensmcp/${c}/`).join(", ")}`));const l=(0,devkit_1.joinPathFragments)(".lensmcp",".keep");e.exists(l)||(e.write(l,""),n.push(`${l}: created`));const m=(0,devkit_1.joinPathFragments)(".lensmcp","install-trail.json"),g=(e.exists(m)?JSON.parse(e.read(m,"utf-8")??"{}"):void 0)??{schemaVersion:1,installedAt:new Date().toISOString(),steps:[]};g.steps.push(...n),e.write(m,JSON.stringify(g,null,2)+`
11
+ `),s.registerHostConfig!=="never"&&registerWorkspaceMcpConfig(e,n),s.skipFormat||await(0,devkit_1.formatFiles)(e)}a(initGenerator,"initGenerator"),p(initGenerator,"initGenerator");function mcpServerEntry(e,r={}){if((r.exists??node_fs_1.existsSync)((0,node_path_1.join)(e,"node_modules",".bin","lensmcp")))return{command:"npx",args:["--no","lensmcp","mcp"]};const s="version"in r?r.version:pluginVersion();return{command:"npx",args:["--yes",s?`lensmcp@${s}`:"lensmcp","mcp"]}}a(mcpServerEntry,"mcpServerEntry"),p(mcpServerEntry,"mcpServerEntry");function pluginVersion(e=__dirname){let r=e;for(let s=0;s<6;s++){const n=(0,node_path_1.join)(r,"package.json");try{if((0,node_fs_1.existsSync)(n)){const i=JSON.parse((0,node_fs_1.readFileSync)(n,"utf-8"));if(i.name==="@lensmcp/nx-plugin"&&typeof i.version=="string")return i.version}}catch{}const t=(0,node_path_1.dirname)(r);if(t===r)break;r=t}}a(pluginVersion,"pluginVersion"),p(pluginVersion,"pluginVersion");const PINNED_SPECIFIER=/^lensmcp@\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;function isGeneratedMcpEntry(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const{command:r,args:s,...n}=e;if(r!=="npx"||Object.keys(n).length>0||!Array.isArray(s)||s.length!==3)return!1;const[t,i,o]=s;return o!=="mcp"||typeof i!="string"?!1:t==="--no"?i==="lensmcp":t==="-y"||t==="--yes"?i==="lensmcp"||PINNED_SPECIFIER.test(i):!1}a(isGeneratedMcpEntry,"isGeneratedMcpEntry"),p(isGeneratedMcpEntry,"isGeneratedMcpEntry");function refreshedMcpEntry(e,r){if(!isGeneratedMcpEntry(e)||e.args.join(" ")===r.args.join(" "))return;const s=e.args[0]!=="--no"&&e.args[1]==="lensmcp";return r.args[0]==="--no"||s?r:void 0}a(refreshedMcpEntry,"refreshedMcpEntry"),p(refreshedMcpEntry,"refreshedMcpEntry");function registerWorkspaceMcpConfig(e,r){const s=".mcp.json";let n={};if(e.exists(s))try{n=JSON.parse(e.read(s,"utf-8")??"{}")}catch{n={}}(!n||typeof n!="object")&&(n={}),(!n.mcpServers||typeof n.mcpServers!="object")&&(n.mcpServers={});const t=n.mcpServers.lensmcp,i=mcpServerEntry(e.root);if(t){const o=refreshedMcpEntry(t,i);if(!o)return;n.mcpServers.lensmcp=o,e.write(s,JSON.stringify(n,null,2)+`
12
+ `),r.push(`.mcp.json: refreshed the generated lensmcp MCP entry (${t.args.join(" ")} \u2192 ${o.args.join(" ")})`);return}n.mcpServers.lensmcp=i,e.write(s,JSON.stringify(n,null,2)+`
13
+ `),r.push(`.mcp.json: registered lensmcp MCP server (stdio, ${i.args.join(" ")})`)}a(registerWorkspaceMcpConfig,"registerWorkspaceMcpConfig"),p(registerWorkspaceMcpConfig,"registerWorkspaceMcpConfig"),exports.default=initGenerator;function mergeDeep(e,r){const s={...e};for(const[n,t]of Object.entries(r))t!==null&&typeof t=="object"&&!Array.isArray(t)&&s[n]!==null&&typeof s[n]=="object"&&!Array.isArray(s[n])?s[n]=mergeDeep(s[n],t):s[n]=t;return s}a(mergeDeep,"mergeDeep"),p(mergeDeep,"mergeDeep");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/nx-plugin",
3
- "version": "1.24.5",
3
+ "version": "1.25.0",
4
4
  "main": "./index.js",
5
5
  "module": "./index.js",
6
6
  "types": "./index.d.ts",