@lensmcp/core 1.25.46 → 1.25.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/capture-off.d.ts +50 -0
- package/lib/capture-off.js +1 -0
- package/lib/flow-shape.d.ts +6 -6
- package/lib/lens-dir.d.ts +10 -0
- package/lib/lens-dir.js +9 -1
- package/package.json +7 -2
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the project records no longer (planning/modules/01-split.md S3), as every writer to the bus reads it:
|
|
3
|
+
* `.lensmcp/capture.json` → `off`, beside the bus file, written by the lens from `lensmcp.json` and the feature cards
|
|
4
|
+
* (servers/lensmcp-mcp project/capture-sync.ts). Each entry is an event `source` (`db`) or `source:kind`
|
|
5
|
+
* (`lens:db-dropped`): an event that matches one is not written, and the lens's own ingest drops it too.
|
|
6
|
+
*
|
|
7
|
+
* Read at most every two seconds — a stat, and the file only when it changed — so turning a feature off reaches every
|
|
8
|
+
* running service within seconds, with no restart. No file, or one it cannot read: nothing is off, as before.
|
|
9
|
+
*
|
|
10
|
+
* `parts` (the Map, 02-settings ST3): each part's capabilities its exceptions turn off, by the part's name — the Nx
|
|
11
|
+
* project a service or a dev server runs as (`LENSMCP_PROJECT`). A process asks of its own: `off.part(PROJECT, 'observe')`.
|
|
12
|
+
*
|
|
13
|
+
* Node-only and dependency-free: the caller injects the fs primitives, so the fs-tap-safe pristine references in
|
|
14
|
+
* `node-instrumentation/emit.ts` keep working. The same arrangement as `./bus-rotation`.
|
|
15
|
+
*/
|
|
16
|
+
export interface CaptureFs {
|
|
17
|
+
statSync(path: string): {
|
|
18
|
+
mtimeMs: number;
|
|
19
|
+
};
|
|
20
|
+
readFileSync(path: string, encoding: 'utf8'): string;
|
|
21
|
+
}
|
|
22
|
+
/** The file beside the bus: `<dir of events.jsonl>/capture.json`. */
|
|
23
|
+
export declare const CAPTURE_FILE_NAME = "capture.json";
|
|
24
|
+
/** How long a read holds. */
|
|
25
|
+
export declare const CAPTURE_OFF_EVERY_MS = 2000;
|
|
26
|
+
/** The `off` list of a capture file's text: the strings in it, nothing when it says none. */
|
|
27
|
+
export declare function readCaptureOff(text: string): Set<string>;
|
|
28
|
+
/** The `off` list and the `parts` of a capture file's text — nothing of either it cannot read. */
|
|
29
|
+
export declare function readCapture(text: string): {
|
|
30
|
+
off: Set<string>;
|
|
31
|
+
parts: Map<string, Set<string>>;
|
|
32
|
+
};
|
|
33
|
+
/** Whether an event is one of `off`'s: its source, or its source and `raw.kind`. */
|
|
34
|
+
export declare function isRecordOff(off: ReadonlySet<string>, source: unknown, kind: unknown): boolean;
|
|
35
|
+
export interface CaptureOff {
|
|
36
|
+
/** Whether an event of this source and kind is off now (as of at most two seconds ago). */
|
|
37
|
+
(source: unknown, kind?: unknown): boolean;
|
|
38
|
+
/** Whether a capability is off on one part (`observe` on the project this process runs as). */
|
|
39
|
+
part(name: string | undefined, capability: string): boolean;
|
|
40
|
+
/** Forget the last read: the next ask reads the file. */
|
|
41
|
+
reset(): void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A reader of one capture file. `file` is asked on each read, so a writer whose bus file is resolved late (from the
|
|
45
|
+
* environment) still finds it.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createCaptureOff(file: () => string | undefined, fs: CaptureFs, opts?: {
|
|
48
|
+
everyMs?: number;
|
|
49
|
+
now?: () => number;
|
|
50
|
+
}): CaptureOff;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var d=Object.defineProperty;var s=(r,t)=>d(r,"name",{value:t,configurable:!0});var S=Object.defineProperty,a=s((r,t)=>S(r,"name",{value:t,configurable:!0}),"s");export const CAPTURE_FILE_NAME="capture.json",CAPTURE_OFF_EVERY_MS=2e3;export function readCaptureOff(r){return readCapture(r).off}s(readCaptureOff,"readCaptureOff"),a(readCaptureOff,"readCaptureOff");export function readCapture(r){const t=new Map;try{const e=JSON.parse(r);if(e.parts&&typeof e.parts=="object"&&!Array.isArray(e.parts))for(const[o,p]of Object.entries(e.parts))Array.isArray(p)&&t.set(o,new Set(p.filter(c=>typeof c=="string")));return{off:new Set(Array.isArray(e.off)?e.off.filter(o=>typeof o=="string"&&o.length>0):[]),parts:t}}catch{return{off:new Set,parts:t}}}s(readCapture,"readCapture"),a(readCapture,"readCapture");export function isRecordOff(r,t,e){return!r.size||typeof t!="string"?!1:r.has(t)||typeof e=="string"&&r.has(`${t}:${e}`)}s(isRecordOff,"isRecordOff"),a(isRecordOff,"isRecordOff");export function createCaptureOff(r,t,e={}){const o=e.everyMs??2e3,p=e.now??(()=>Date.now());let c=-1/0,u,y=new Set,h=new Map;const i=a(()=>{u=void 0,y=new Set,h=new Map},"none"),O=a(n=>{c=n;const f=r();if(!f)return i();let l;try{l=t.statSync(f).mtimeMs}catch{return i()}if(l!==u)try{({off:y,parts:h}=readCapture(t.readFileSync(f,"utf8"))),u=l}catch{i()}},"refresh"),A=a(()=>{const n=p();n-c>=o&&O(n)},"look"),w=a(((n,f)=>{try{return A(),isRecordOff(y,n,f)}catch{return!1}}),"ask");return w.part=(n,f)=>{try{return A(),!!n&&h.get(n)?.has(f)===!0}catch{return!1}},w.reset=()=>{c=-1/0,i()},w}s(createCaptureOff,"createCaptureOff"),a(createCaptureOff,"createCaptureOff");
|
package/lib/flow-shape.d.ts
CHANGED
|
@@ -74,9 +74,9 @@ export declare function trimFlowEvent(event: BaseEvent, opts?: FlowShapeOptions)
|
|
|
74
74
|
outcome?: "returned" | "threw" | undefined;
|
|
75
75
|
calleeRequestId?: string | undefined;
|
|
76
76
|
hop?: true | undefined;
|
|
77
|
-
source: "
|
|
78
|
-
category: "
|
|
79
|
-
severity: "error" | "
|
|
77
|
+
source: "nx" | "vite" | "typescript" | "eslint" | "rollup" | "client-runtime" | "chrome" | "react" | "valtio" | "nestjs" | "nextjs" | "db" | "redis" | "queue" | "memory" | "visual" | "perf" | "security" | "gateway" | "external" | "ai" | "lens" | "custom";
|
|
78
|
+
category: "db" | "memory" | "visual" | "security" | "ai" | "build" | "lint" | "typecheck" | "test" | "runtime" | "render" | "trace" | "state" | "network" | "backend" | "performance" | "deps" | "cluster" | "agent";
|
|
79
|
+
severity: "error" | "debug" | "info" | "warning" | "fatal";
|
|
80
80
|
title: string;
|
|
81
81
|
kind: string | undefined;
|
|
82
82
|
area: FlowArea;
|
|
@@ -148,9 +148,9 @@ export declare function buildFlowDetail(rawEvents: BaseEvent[], opts?: FlowShape
|
|
|
148
148
|
outcome?: "returned" | "threw" | undefined;
|
|
149
149
|
calleeRequestId?: string | undefined;
|
|
150
150
|
hop?: true | undefined;
|
|
151
|
-
source: "
|
|
152
|
-
category: "
|
|
153
|
-
severity: "error" | "
|
|
151
|
+
source: "nx" | "vite" | "typescript" | "eslint" | "rollup" | "client-runtime" | "chrome" | "react" | "valtio" | "nestjs" | "nextjs" | "db" | "redis" | "queue" | "memory" | "visual" | "perf" | "security" | "gateway" | "external" | "ai" | "lens" | "custom";
|
|
152
|
+
category: "db" | "memory" | "visual" | "security" | "ai" | "build" | "lint" | "typecheck" | "test" | "runtime" | "render" | "trace" | "state" | "network" | "backend" | "performance" | "deps" | "cluster" | "agent";
|
|
153
|
+
severity: "error" | "debug" | "info" | "warning" | "fatal";
|
|
154
154
|
title: string;
|
|
155
155
|
kind: string | undefined;
|
|
156
156
|
area: FlowArea;
|
package/lib/lens-dir.d.ts
CHANGED
|
@@ -26,3 +26,13 @@
|
|
|
26
26
|
export declare const LENS_SHARED_DIRS: readonly string[];
|
|
27
27
|
/** The .gitignore lines for `.lensmcp/`: at any depth (prefix `**\/`), or at the root only (`/`). */
|
|
28
28
|
export declare function lensGitignoreLines(prefix?: '**/' | '/'): string[];
|
|
29
|
+
/**
|
|
30
|
+
* A .gitignore with its `.lensmcp` lines made right: the runtime ignored and each shared folder let back in under it.
|
|
31
|
+
* A `.lensmcp/` line becomes `**\/.lensmcp/*`; `/.lensmcp/` (the root's) becomes `/.lensmcp/*`. Lines it does not own
|
|
32
|
+
* are left as they are. Lock-step with `@lensmcp/nx-plugin` init `fixLensGitignore` (that package depends on no other):
|
|
33
|
+
* what `lensmcp install` writes and what Settings › Project › Setup's Run writes are the same lines.
|
|
34
|
+
*/
|
|
35
|
+
export declare function fixLensGitignore(text: string): {
|
|
36
|
+
text: string;
|
|
37
|
+
changed: boolean;
|
|
38
|
+
};
|
package/lib/lens-dir.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var u=Object.defineProperty;var r=(t,e)=>u(t,"name",{value:e,configurable:!0});var p=Object.defineProperty,l=r((t,e)=>p(t,"name",{value:e,configurable:!0}),"c");export const LENS_SHARED_DIRS=["sql-review","route-review","flow-review","ui-review","cache-review","queue-review","ai-review","ai-names","team","team-design"];export function lensGitignoreLines(t="**/"){return[`${t}.lensmcp/*`,...LENS_SHARED_DIRS.map(e=>`!${t}.lensmcp/${e}/`)]}r(lensGitignoreLines,"lensGitignoreLines"),l(lensGitignoreLines,"lensGitignoreLines");const $="# LensMCP: this machine's runtime state is ignored; the team's analyzer instructions are kept";export function fixLensGitignore(t){const e=t.split(`
|
|
2
|
+
`),m=/^(\/|\*\*\/)?\.lensmcp\/?(\*)?$/;let n=e.findIndex(i=>m.test(i.trim())),s=!1;if(n<0){const i=t.length&&!t.endsWith(`
|
|
3
|
+
`)?`${t}
|
|
4
|
+
`:t;return{text:`${i}${i.trim()?`
|
|
5
|
+
`:""}${$}
|
|
6
|
+
${lensGitignoreLines().join(`
|
|
7
|
+
`)}
|
|
8
|
+
`,changed:!0}}const c=m.exec(e[n].trim())[1]==="/"?"/":"**/";e[n].trim()!==`${c}.lensmcp/*`&&(e[n]=`${c}.lensmcp/*`,s=!0);for(const i of LENS_SHARED_DIRS){const o=`!${c}.lensmcp/${i}/`;e.some(a=>a.trim()===o||a.trim()===o.slice(0,-1))||(e.splice(++n,0,o),s=!0)}return{text:e.join(`
|
|
9
|
+
`),changed:s}}r(fixLensGitignore,"fixLensGitignore"),l(fixLensGitignore,"fixLensGitignore");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lensmcp/core",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.48",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -47,6 +47,11 @@
|
|
|
47
47
|
"import": "./lib/bus-rotation.js",
|
|
48
48
|
"default": "./lib/bus-rotation.js"
|
|
49
49
|
},
|
|
50
|
+
"./capture-off": {
|
|
51
|
+
"types": "./lib/capture-off.d.ts",
|
|
52
|
+
"import": "./lib/capture-off.js",
|
|
53
|
+
"default": "./lib/capture-off.js"
|
|
54
|
+
},
|
|
50
55
|
"./lens-events": {
|
|
51
56
|
"types": "./lib/lens-events.d.ts",
|
|
52
57
|
"import": "./lib/lens-events.js",
|
|
@@ -84,7 +89,7 @@
|
|
|
84
89
|
}
|
|
85
90
|
},
|
|
86
91
|
"dependencies": {
|
|
87
|
-
"@lensmcp/protocol-types": "1.25.
|
|
92
|
+
"@lensmcp/protocol-types": "1.25.48",
|
|
88
93
|
"tslib": "^2.3.0"
|
|
89
94
|
},
|
|
90
95
|
"license": "Apache-2.0",
|