@arvoretech/runtime-lens-mcp 1.0.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.
Files changed (42) hide show
  1. package/.vscodeignore +21 -0
  2. package/README.md +136 -0
  3. package/agent/index.ts +263 -0
  4. package/agent/tsconfig.json +17 -0
  5. package/dist/index.d.ts +7 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +17 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/log-collector.d.ts +73 -0
  10. package/dist/log-collector.d.ts.map +1 -0
  11. package/dist/log-collector.js +349 -0
  12. package/dist/log-collector.js.map +1 -0
  13. package/dist/process-inspector.d.ts +44 -0
  14. package/dist/process-inspector.d.ts.map +1 -0
  15. package/dist/process-inspector.js +190 -0
  16. package/dist/process-inspector.js.map +1 -0
  17. package/dist/runtime-interceptor.d.ts +18 -0
  18. package/dist/runtime-interceptor.d.ts.map +1 -0
  19. package/dist/runtime-interceptor.js +133 -0
  20. package/dist/runtime-interceptor.js.map +1 -0
  21. package/dist/server.d.ts +26 -0
  22. package/dist/server.d.ts.map +1 -0
  23. package/dist/server.js +301 -0
  24. package/dist/server.js.map +1 -0
  25. package/dist/types.d.ts +280 -0
  26. package/dist/types.d.ts.map +1 -0
  27. package/dist/types.js +102 -0
  28. package/dist/types.js.map +1 -0
  29. package/eslint.config.js +41 -0
  30. package/extension/decorator.ts +144 -0
  31. package/extension/extension.ts +98 -0
  32. package/extension/runtime-bridge.ts +206 -0
  33. package/extension/tsconfig.json +17 -0
  34. package/package.json +134 -0
  35. package/src/index.ts +18 -0
  36. package/src/log-collector.ts +441 -0
  37. package/src/process-inspector.ts +235 -0
  38. package/src/runtime-interceptor.ts +152 -0
  39. package/src/server.ts +387 -0
  40. package/src/types.ts +128 -0
  41. package/tsconfig.json +20 -0
  42. package/vitest.config.ts +13 -0
@@ -0,0 +1,280 @@
1
+ import { z } from "zod";
2
+ export declare const LogLevel: z.ZodEnum<["debug", "info", "warn", "error", "fatal"]>;
3
+ export type LogLevel = z.infer<typeof LogLevel>;
4
+ export declare const Framework: z.ZodEnum<["react", "nextjs", "nestjs", "unknown"]>;
5
+ export type Framework = z.infer<typeof Framework>;
6
+ export declare const LogEntrySchema: z.ZodObject<{
7
+ id: z.ZodString;
8
+ timestamp: z.ZodString;
9
+ level: z.ZodEnum<["debug", "info", "warn", "error", "fatal"]>;
10
+ message: z.ZodString;
11
+ source: z.ZodOptional<z.ZodString>;
12
+ framework: z.ZodOptional<z.ZodEnum<["react", "nextjs", "nestjs", "unknown"]>>;
13
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
14
+ stackTrace: z.ZodOptional<z.ZodString>;
15
+ }, "strip", z.ZodTypeAny, {
16
+ message: string;
17
+ id: string;
18
+ timestamp: string;
19
+ level: "debug" | "info" | "warn" | "error" | "fatal";
20
+ source?: string | undefined;
21
+ framework?: "react" | "nextjs" | "nestjs" | "unknown" | undefined;
22
+ metadata?: Record<string, unknown> | undefined;
23
+ stackTrace?: string | undefined;
24
+ }, {
25
+ message: string;
26
+ id: string;
27
+ timestamp: string;
28
+ level: "debug" | "info" | "warn" | "error" | "fatal";
29
+ source?: string | undefined;
30
+ framework?: "react" | "nextjs" | "nestjs" | "unknown" | undefined;
31
+ metadata?: Record<string, unknown> | undefined;
32
+ stackTrace?: string | undefined;
33
+ }>;
34
+ export type LogEntry = z.infer<typeof LogEntrySchema>;
35
+ export declare const HttpRequestSchema: z.ZodObject<{
36
+ id: z.ZodString;
37
+ timestamp: z.ZodString;
38
+ method: z.ZodString;
39
+ url: z.ZodString;
40
+ statusCode: z.ZodOptional<z.ZodNumber>;
41
+ duration: z.ZodOptional<z.ZodNumber>;
42
+ requestHeaders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
43
+ responseHeaders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
44
+ requestBody: z.ZodOptional<z.ZodUnknown>;
45
+ responseBody: z.ZodOptional<z.ZodUnknown>;
46
+ framework: z.ZodOptional<z.ZodEnum<["react", "nextjs", "nestjs", "unknown"]>>;
47
+ error: z.ZodOptional<z.ZodString>;
48
+ }, "strip", z.ZodTypeAny, {
49
+ id: string;
50
+ timestamp: string;
51
+ method: string;
52
+ url: string;
53
+ error?: string | undefined;
54
+ framework?: "react" | "nextjs" | "nestjs" | "unknown" | undefined;
55
+ statusCode?: number | undefined;
56
+ duration?: number | undefined;
57
+ requestHeaders?: Record<string, string> | undefined;
58
+ responseHeaders?: Record<string, string> | undefined;
59
+ requestBody?: unknown;
60
+ responseBody?: unknown;
61
+ }, {
62
+ id: string;
63
+ timestamp: string;
64
+ method: string;
65
+ url: string;
66
+ error?: string | undefined;
67
+ framework?: "react" | "nextjs" | "nestjs" | "unknown" | undefined;
68
+ statusCode?: number | undefined;
69
+ duration?: number | undefined;
70
+ requestHeaders?: Record<string, string> | undefined;
71
+ responseHeaders?: Record<string, string> | undefined;
72
+ requestBody?: unknown;
73
+ responseBody?: unknown;
74
+ }>;
75
+ export type HttpRequest = z.infer<typeof HttpRequestSchema>;
76
+ export declare const PerformanceMetricSchema: z.ZodObject<{
77
+ name: z.ZodString;
78
+ value: z.ZodNumber;
79
+ unit: z.ZodString;
80
+ timestamp: z.ZodString;
81
+ tags: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
82
+ }, "strip", z.ZodTypeAny, {
83
+ value: number;
84
+ timestamp: string;
85
+ name: string;
86
+ unit: string;
87
+ tags?: Record<string, string> | undefined;
88
+ }, {
89
+ value: number;
90
+ timestamp: string;
91
+ name: string;
92
+ unit: string;
93
+ tags?: Record<string, string> | undefined;
94
+ }>;
95
+ export type PerformanceMetric = z.infer<typeof PerformanceMetricSchema>;
96
+ export declare const ProcessInfoSchema: z.ZodObject<{
97
+ pid: z.ZodNumber;
98
+ uptime: z.ZodNumber;
99
+ memoryUsage: z.ZodObject<{
100
+ rss: z.ZodNumber;
101
+ heapTotal: z.ZodNumber;
102
+ heapUsed: z.ZodNumber;
103
+ external: z.ZodNumber;
104
+ }, "strip", z.ZodTypeAny, {
105
+ rss: number;
106
+ heapTotal: number;
107
+ heapUsed: number;
108
+ external: number;
109
+ }, {
110
+ rss: number;
111
+ heapTotal: number;
112
+ heapUsed: number;
113
+ external: number;
114
+ }>;
115
+ cpuUsage: z.ZodObject<{
116
+ user: z.ZodNumber;
117
+ system: z.ZodNumber;
118
+ }, "strip", z.ZodTypeAny, {
119
+ user: number;
120
+ system: number;
121
+ }, {
122
+ user: number;
123
+ system: number;
124
+ }>;
125
+ nodeVersion: z.ZodString;
126
+ platform: z.ZodString;
127
+ arch: z.ZodString;
128
+ cwd: z.ZodString;
129
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
130
+ }, "strip", z.ZodTypeAny, {
131
+ pid: number;
132
+ uptime: number;
133
+ memoryUsage: {
134
+ rss: number;
135
+ heapTotal: number;
136
+ heapUsed: number;
137
+ external: number;
138
+ };
139
+ cpuUsage: {
140
+ user: number;
141
+ system: number;
142
+ };
143
+ nodeVersion: string;
144
+ platform: string;
145
+ arch: string;
146
+ cwd: string;
147
+ env?: Record<string, string> | undefined;
148
+ }, {
149
+ pid: number;
150
+ uptime: number;
151
+ memoryUsage: {
152
+ rss: number;
153
+ heapTotal: number;
154
+ heapUsed: number;
155
+ external: number;
156
+ };
157
+ cpuUsage: {
158
+ user: number;
159
+ system: number;
160
+ };
161
+ nodeVersion: string;
162
+ platform: string;
163
+ arch: string;
164
+ cwd: string;
165
+ env?: Record<string, string> | undefined;
166
+ }>;
167
+ export type ProcessInfo = z.infer<typeof ProcessInfoSchema>;
168
+ export declare const TailLogsParamsSchema: z.ZodObject<{
169
+ lines: z.ZodDefault<z.ZodNumber>;
170
+ level: z.ZodOptional<z.ZodEnum<["debug", "info", "warn", "error", "fatal"]>>;
171
+ framework: z.ZodOptional<z.ZodEnum<["react", "nextjs", "nestjs", "unknown"]>>;
172
+ source: z.ZodOptional<z.ZodString>;
173
+ }, "strip", z.ZodTypeAny, {
174
+ lines: number;
175
+ level?: "debug" | "info" | "warn" | "error" | "fatal" | undefined;
176
+ source?: string | undefined;
177
+ framework?: "react" | "nextjs" | "nestjs" | "unknown" | undefined;
178
+ }, {
179
+ level?: "debug" | "info" | "warn" | "error" | "fatal" | undefined;
180
+ source?: string | undefined;
181
+ framework?: "react" | "nextjs" | "nestjs" | "unknown" | undefined;
182
+ lines?: number | undefined;
183
+ }>;
184
+ export type TailLogsParams = z.infer<typeof TailLogsParamsSchema>;
185
+ export declare const SearchLogsParamsSchema: z.ZodObject<{
186
+ query: z.ZodString;
187
+ level: z.ZodOptional<z.ZodEnum<["debug", "info", "warn", "error", "fatal"]>>;
188
+ framework: z.ZodOptional<z.ZodEnum<["react", "nextjs", "nestjs", "unknown"]>>;
189
+ limit: z.ZodDefault<z.ZodNumber>;
190
+ since: z.ZodOptional<z.ZodString>;
191
+ }, "strip", z.ZodTypeAny, {
192
+ query: string;
193
+ limit: number;
194
+ level?: "debug" | "info" | "warn" | "error" | "fatal" | undefined;
195
+ framework?: "react" | "nextjs" | "nestjs" | "unknown" | undefined;
196
+ since?: string | undefined;
197
+ }, {
198
+ query: string;
199
+ level?: "debug" | "info" | "warn" | "error" | "fatal" | undefined;
200
+ framework?: "react" | "nextjs" | "nestjs" | "unknown" | undefined;
201
+ limit?: number | undefined;
202
+ since?: string | undefined;
203
+ }>;
204
+ export type SearchLogsParams = z.infer<typeof SearchLogsParamsSchema>;
205
+ export declare const GetErrorsParamsSchema: z.ZodObject<{
206
+ limit: z.ZodDefault<z.ZodNumber>;
207
+ framework: z.ZodOptional<z.ZodEnum<["react", "nextjs", "nestjs", "unknown"]>>;
208
+ grouped: z.ZodDefault<z.ZodBoolean>;
209
+ }, "strip", z.ZodTypeAny, {
210
+ limit: number;
211
+ grouped: boolean;
212
+ framework?: "react" | "nextjs" | "nestjs" | "unknown" | undefined;
213
+ }, {
214
+ framework?: "react" | "nextjs" | "nestjs" | "unknown" | undefined;
215
+ limit?: number | undefined;
216
+ grouped?: boolean | undefined;
217
+ }>;
218
+ export type GetErrorsParams = z.infer<typeof GetErrorsParamsSchema>;
219
+ export declare const InspectRequestParamsSchema: z.ZodObject<{
220
+ id: z.ZodOptional<z.ZodString>;
221
+ method: z.ZodOptional<z.ZodString>;
222
+ urlPattern: z.ZodOptional<z.ZodString>;
223
+ statusCode: z.ZodOptional<z.ZodNumber>;
224
+ limit: z.ZodDefault<z.ZodNumber>;
225
+ }, "strip", z.ZodTypeAny, {
226
+ limit: number;
227
+ id?: string | undefined;
228
+ method?: string | undefined;
229
+ statusCode?: number | undefined;
230
+ urlPattern?: string | undefined;
231
+ }, {
232
+ id?: string | undefined;
233
+ method?: string | undefined;
234
+ statusCode?: number | undefined;
235
+ limit?: number | undefined;
236
+ urlPattern?: string | undefined;
237
+ }>;
238
+ export type InspectRequestParams = z.infer<typeof InspectRequestParamsSchema>;
239
+ export declare const GetPerformanceParamsSchema: z.ZodObject<{
240
+ metric: z.ZodOptional<z.ZodString>;
241
+ since: z.ZodOptional<z.ZodString>;
242
+ limit: z.ZodDefault<z.ZodNumber>;
243
+ }, "strip", z.ZodTypeAny, {
244
+ limit: number;
245
+ since?: string | undefined;
246
+ metric?: string | undefined;
247
+ }, {
248
+ limit?: number | undefined;
249
+ since?: string | undefined;
250
+ metric?: string | undefined;
251
+ }>;
252
+ export type GetPerformanceParams = z.infer<typeof GetPerformanceParamsSchema>;
253
+ export declare const ExecuteInContextParamsSchema: z.ZodObject<{
254
+ expression: z.ZodString;
255
+ framework: z.ZodOptional<z.ZodEnum<["react", "nextjs", "nestjs", "unknown"]>>;
256
+ }, "strip", z.ZodTypeAny, {
257
+ expression: string;
258
+ framework?: "react" | "nextjs" | "nestjs" | "unknown" | undefined;
259
+ }, {
260
+ expression: string;
261
+ framework?: "react" | "nextjs" | "nestjs" | "unknown" | undefined;
262
+ }>;
263
+ export type ExecuteInContextParams = z.infer<typeof ExecuteInContextParamsSchema>;
264
+ export declare const WatchParamsSchema: z.ZodObject<{
265
+ pattern: z.ZodString;
266
+ duration: z.ZodDefault<z.ZodNumber>;
267
+ }, "strip", z.ZodTypeAny, {
268
+ duration: number;
269
+ pattern: string;
270
+ }, {
271
+ pattern: string;
272
+ duration?: number | undefined;
273
+ }>;
274
+ export type WatchParams = z.infer<typeof WatchParamsSchema>;
275
+ export declare class RuntimeLensError extends Error {
276
+ code: string;
277
+ details?: unknown | undefined;
278
+ constructor(message: string, code: string, details?: unknown | undefined);
279
+ }
280
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,QAAQ,wDAAsD,CAAC;AAC5E,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD,eAAO,MAAM,SAAS,qDAAmD,CAAC;AAC1E,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;EASzB,CAAC;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAa5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;EAMlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;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,MAAM,EACZ,OAAO,CAAC,EAAE,OAAO,YAAA;CAK3B"}
package/dist/types.js ADDED
@@ -0,0 +1,102 @@
1
+ import { z } from "zod";
2
+ export const LogLevel = z.enum(["debug", "info", "warn", "error", "fatal"]);
3
+ export const Framework = z.enum(["react", "nextjs", "nestjs", "unknown"]);
4
+ export const LogEntrySchema = z.object({
5
+ id: z.string(),
6
+ timestamp: z.string(),
7
+ level: LogLevel,
8
+ message: z.string(),
9
+ source: z.string().optional(),
10
+ framework: Framework.optional(),
11
+ metadata: z.record(z.unknown()).optional(),
12
+ stackTrace: z.string().optional(),
13
+ });
14
+ export const HttpRequestSchema = z.object({
15
+ id: z.string(),
16
+ timestamp: z.string(),
17
+ method: z.string(),
18
+ url: z.string(),
19
+ statusCode: z.number().optional(),
20
+ duration: z.number().optional(),
21
+ requestHeaders: z.record(z.string()).optional(),
22
+ responseHeaders: z.record(z.string()).optional(),
23
+ requestBody: z.unknown().optional(),
24
+ responseBody: z.unknown().optional(),
25
+ framework: Framework.optional(),
26
+ error: z.string().optional(),
27
+ });
28
+ export const PerformanceMetricSchema = z.object({
29
+ name: z.string(),
30
+ value: z.number(),
31
+ unit: z.string(),
32
+ timestamp: z.string(),
33
+ tags: z.record(z.string()).optional(),
34
+ });
35
+ export const ProcessInfoSchema = z.object({
36
+ pid: z.number(),
37
+ uptime: z.number(),
38
+ memoryUsage: z.object({
39
+ rss: z.number(),
40
+ heapTotal: z.number(),
41
+ heapUsed: z.number(),
42
+ external: z.number(),
43
+ }),
44
+ cpuUsage: z.object({
45
+ user: z.number(),
46
+ system: z.number(),
47
+ }),
48
+ nodeVersion: z.string(),
49
+ platform: z.string(),
50
+ arch: z.string(),
51
+ cwd: z.string(),
52
+ env: z.record(z.string()).optional(),
53
+ });
54
+ export const TailLogsParamsSchema = z.object({
55
+ lines: z.number().min(1).max(1000).default(50).describe("Number of recent log lines to retrieve"),
56
+ level: LogLevel.optional().describe("Filter by log level"),
57
+ framework: Framework.optional().describe("Filter by framework"),
58
+ source: z.string().optional().describe("Filter by source file or module"),
59
+ });
60
+ export const SearchLogsParamsSchema = z.object({
61
+ query: z.string().min(1).describe("Search pattern (supports regex)"),
62
+ level: LogLevel.optional().describe("Filter by log level"),
63
+ framework: Framework.optional().describe("Filter by framework"),
64
+ limit: z.number().min(1).max(500).default(50).describe("Maximum results to return"),
65
+ since: z.string().optional().describe("ISO timestamp to search from"),
66
+ });
67
+ export const GetErrorsParamsSchema = z.object({
68
+ limit: z.number().min(1).max(100).default(20).describe("Maximum errors to return"),
69
+ framework: Framework.optional().describe("Filter by framework"),
70
+ grouped: z.boolean().default(false).describe("Group similar errors together"),
71
+ });
72
+ export const InspectRequestParamsSchema = z.object({
73
+ id: z.string().optional().describe("Specific request ID to inspect"),
74
+ method: z.string().optional().describe("Filter by HTTP method"),
75
+ urlPattern: z.string().optional().describe("Filter by URL pattern (supports regex)"),
76
+ statusCode: z.number().optional().describe("Filter by status code"),
77
+ limit: z.number().min(1).max(100).default(20).describe("Maximum requests to return"),
78
+ });
79
+ export const GetPerformanceParamsSchema = z.object({
80
+ metric: z.string().optional().describe("Specific metric name to retrieve"),
81
+ since: z.string().optional().describe("ISO timestamp to get metrics from"),
82
+ limit: z.number().min(1).max(100).default(20).describe("Maximum metrics to return"),
83
+ });
84
+ export const ExecuteInContextParamsSchema = z.object({
85
+ expression: z.string().min(1).describe("JavaScript expression to evaluate"),
86
+ framework: Framework.optional().describe("Target framework context"),
87
+ });
88
+ export const WatchParamsSchema = z.object({
89
+ pattern: z.string().min(1).describe("File glob pattern or log pattern to watch"),
90
+ duration: z.number().min(1).max(300).default(30).describe("Watch duration in seconds"),
91
+ });
92
+ export class RuntimeLensError extends Error {
93
+ code;
94
+ details;
95
+ constructor(message, code, details) {
96
+ super(message);
97
+ this.code = code;
98
+ this.details = details;
99
+ this.name = "RuntimeLensError";
100
+ }
101
+ }
102
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRo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OAAO,CAAU;QAGxB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF"}
@@ -0,0 +1,41 @@
1
+ import eslint from '@eslint/js';
2
+ import tseslint from '@typescript-eslint/eslint-plugin';
3
+ import tsparser from '@typescript-eslint/parser';
4
+
5
+ export default [
6
+ eslint.configs.recommended,
7
+ {
8
+ files: ['src/**/*.ts'],
9
+ languageOptions: {
10
+ parser: tsparser,
11
+ parserOptions: {
12
+ ecmaVersion: 2022,
13
+ sourceType: 'module',
14
+ },
15
+ globals: {
16
+ console: 'readonly',
17
+ process: 'readonly',
18
+ Buffer: 'readonly',
19
+ BufferEncoding: 'readonly',
20
+ __dirname: 'readonly',
21
+ __filename: 'readonly',
22
+ global: 'readonly',
23
+ setTimeout: 'readonly',
24
+ clearTimeout: 'readonly',
25
+ setInterval: 'readonly',
26
+ clearInterval: 'readonly',
27
+ require: 'readonly',
28
+ },
29
+ },
30
+ plugins: {
31
+ '@typescript-eslint': tseslint,
32
+ },
33
+ rules: {
34
+ ...tseslint.configs.recommended.rules,
35
+ 'no-redeclare': 'off',
36
+ '@typescript-eslint/no-unused-vars': 'error',
37
+ '@typescript-eslint/explicit-function-return-type': 'warn',
38
+ '@typescript-eslint/no-explicit-any': 'warn',
39
+ },
40
+ },
41
+ ];
@@ -0,0 +1,144 @@
1
+ import * as vscode from "vscode";
2
+
3
+ interface InlineValue {
4
+ file: string;
5
+ line: number;
6
+ column: number;
7
+ text: string;
8
+ type: "log" | "error" | "warn" | "info" | "debug" | "result";
9
+ timestamp: number;
10
+ }
11
+
12
+ const TYPE_COLORS: Record<string, string> = {
13
+ log: "#6A9955",
14
+ info: "#569CD6",
15
+ warn: "#CE9178",
16
+ error: "#F44747",
17
+ debug: "#9CDCFE",
18
+ result: "#DCDCAA",
19
+ };
20
+
21
+ export class InlineDecorator {
22
+ private decorationTypes: Map<string, vscode.TextEditorDecorationType> = new Map();
23
+ private values: Map<string, InlineValue[]> = new Map();
24
+ private disposables: vscode.Disposable[] = [];
25
+
26
+ activate(context: vscode.ExtensionContext): void {
27
+ this.disposables.push(
28
+ vscode.window.onDidChangeActiveTextEditor(() => this.refresh()),
29
+ vscode.workspace.onDidChangeTextDocument((e) => {
30
+ if (e.document === vscode.window.activeTextEditor?.document) {
31
+ this.refresh();
32
+ }
33
+ })
34
+ );
35
+ context.subscriptions.push(...this.disposables);
36
+ }
37
+
38
+ addValue(value: InlineValue): void {
39
+ const key = value.file;
40
+ if (!this.values.has(key)) {
41
+ this.values.set(key, []);
42
+ }
43
+
44
+ const existing = this.values.get(key)!;
45
+ const idx = existing.findIndex((v) => v.line === value.line);
46
+ if (idx >= 0) {
47
+ existing[idx] = value;
48
+ } else {
49
+ existing.push(value);
50
+ }
51
+
52
+ if (existing.length > 1000) {
53
+ existing.splice(0, existing.length - 1000);
54
+ }
55
+
56
+ this.refresh();
57
+ }
58
+
59
+ clearFile(file: string): void {
60
+ this.values.delete(file);
61
+ this.refresh();
62
+ }
63
+
64
+ clearAll(): void {
65
+ this.values.clear();
66
+ this.clearDecorations();
67
+ }
68
+
69
+ refresh(): void {
70
+ const editor = vscode.window.activeTextEditor;
71
+ if (!editor) return;
72
+
73
+ this.clearDecorations();
74
+
75
+ const filePath = editor.document.uri.fsPath;
76
+ const fileValues = this.values.get(filePath);
77
+ if (!fileValues || fileValues.length === 0) return;
78
+
79
+ const decorationsByType = new Map<string, vscode.DecorationOptions[]>();
80
+
81
+ for (const value of fileValues) {
82
+ const lineIndex = value.line - 1;
83
+ if (lineIndex < 0 || lineIndex >= editor.document.lineCount) continue;
84
+
85
+ const lineText = editor.document.lineAt(lineIndex).text;
86
+ const range = new vscode.Range(
87
+ new vscode.Position(lineIndex, lineText.length),
88
+ new vscode.Position(lineIndex, lineText.length)
89
+ );
90
+
91
+ const truncated = value.text.length > 80
92
+ ? value.text.slice(0, 80) + "…"
93
+ : value.text;
94
+
95
+ const decoration: vscode.DecorationOptions = {
96
+ range,
97
+ hoverMessage: new vscode.MarkdownString(
98
+ `**Runtime Lens** (${value.type})\n\n\`\`\`\n${value.text}\n\`\`\`\n\n*${new Date(value.timestamp).toLocaleTimeString()}*`
99
+ ),
100
+ renderOptions: {
101
+ after: {
102
+ contentText: ` // → ${truncated}`,
103
+ color: TYPE_COLORS[value.type] || "#6A9955",
104
+ fontStyle: "italic",
105
+ margin: "0 0 0 1em",
106
+ },
107
+ },
108
+ };
109
+
110
+ const typeKey = value.type;
111
+ if (!decorationsByType.has(typeKey)) {
112
+ decorationsByType.set(typeKey, []);
113
+ }
114
+ decorationsByType.get(typeKey)!.push(decoration);
115
+ }
116
+
117
+ for (const [typeKey, decorations] of decorationsByType) {
118
+ const decorationType = vscode.window.createTextEditorDecorationType({
119
+ after: {
120
+ color: TYPE_COLORS[typeKey] || "#6A9955",
121
+ fontStyle: "italic",
122
+ },
123
+ isWholeLine: false,
124
+ });
125
+
126
+ this.decorationTypes.set(typeKey, decorationType);
127
+ editor.setDecorations(decorationType, decorations);
128
+ }
129
+ }
130
+
131
+ private clearDecorations(): void {
132
+ for (const decorationType of this.decorationTypes.values()) {
133
+ decorationType.dispose();
134
+ }
135
+ this.decorationTypes.clear();
136
+ }
137
+
138
+ dispose(): void {
139
+ this.clearDecorations();
140
+ for (const d of this.disposables) {
141
+ d.dispose();
142
+ }
143
+ }
144
+ }
@@ -0,0 +1,98 @@
1
+ import * as vscode from "vscode";
2
+ import { join } from "node:path";
3
+ import { InlineDecorator } from "./decorator.js";
4
+ import { RuntimeBridge } from "./runtime-bridge.js";
5
+
6
+ let decorator: InlineDecorator;
7
+ let bridge: RuntimeBridge;
8
+ let statusBarItem: vscode.StatusBarItem;
9
+
10
+ export function activate(context: vscode.ExtensionContext): void {
11
+ const outputChannel = vscode.window.createOutputChannel("Runtime Lens");
12
+ const agentPath = join(context.extensionPath, "dist", "agent", "index.js");
13
+
14
+ decorator = new InlineDecorator();
15
+ decorator.activate(context);
16
+
17
+ bridge = new RuntimeBridge(decorator, outputChannel);
18
+
19
+ statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100);
20
+ statusBarItem.text = "$(eye) Lens";
21
+ statusBarItem.tooltip = "Runtime Lens - Click to toggle";
22
+ statusBarItem.command = "runtimeLens.toggle";
23
+ statusBarItem.show();
24
+ context.subscriptions.push(statusBarItem);
25
+
26
+ const port = vscode.workspace.getConfiguration("runtimeLens").get("port", 9500);
27
+
28
+ context.subscriptions.push(
29
+ vscode.commands.registerCommand("runtimeLens.start", () => {
30
+ bridge.connect();
31
+ updateStatusBar(true);
32
+ vscode.window.showInformationMessage("Runtime Lens: Listening for logs...");
33
+ }),
34
+
35
+ vscode.commands.registerCommand("runtimeLens.stop", () => {
36
+ bridge.disconnect();
37
+ decorator.clearAll();
38
+ updateStatusBar(false);
39
+ vscode.window.showInformationMessage("Runtime Lens: Stopped");
40
+ }),
41
+
42
+ vscode.commands.registerCommand("runtimeLens.toggle", () => {
43
+ if (bridge.isConnected()) {
44
+ vscode.commands.executeCommand("runtimeLens.stop");
45
+ } else {
46
+ vscode.commands.executeCommand("runtimeLens.start");
47
+ }
48
+ }),
49
+
50
+ vscode.commands.registerCommand("runtimeLens.clear", () => {
51
+ decorator.clearAll();
52
+ vscode.window.showInformationMessage("Runtime Lens: Cleared");
53
+ }),
54
+
55
+ vscode.commands.registerCommand("runtimeLens.connect", () => {
56
+ bridge.connect();
57
+ updateStatusBar(true);
58
+ }),
59
+
60
+ vscode.commands.registerCommand("runtimeLens.showOutput", () => {
61
+ outputChannel.show();
62
+ }),
63
+
64
+ vscode.commands.registerCommand("runtimeLens.injectEnv", () => {
65
+ const terminal = vscode.window.activeTerminal;
66
+ if (!terminal) {
67
+ vscode.window.showWarningMessage("Runtime Lens: No active terminal");
68
+ return;
69
+ }
70
+ terminal.sendText(`export NODE_OPTIONS="--require ${agentPath}"`, true);
71
+ terminal.sendText(`export RUNTIME_LENS_PORT="${port}"`, true);
72
+ vscode.window.showInformationMessage("Runtime Lens: Environment injected. Run your app now.");
73
+ })
74
+ );
75
+
76
+ const autoStart = vscode.workspace.getConfiguration("runtimeLens").get("autoStart", false);
77
+ if (autoStart) {
78
+ vscode.commands.executeCommand("runtimeLens.start");
79
+ }
80
+
81
+ outputChannel.appendLine(`[runtime-lens] Extension activated`);
82
+ outputChannel.appendLine(`[runtime-lens] Agent path: ${agentPath}`);
83
+ }
84
+
85
+ function updateStatusBar(active: boolean): void {
86
+ if (active) {
87
+ statusBarItem.text = "$(eye) Lens ●";
88
+ statusBarItem.backgroundColor = new vscode.ThemeColor("statusBarItem.warningBackground");
89
+ } else {
90
+ statusBarItem.text = "$(eye) Lens";
91
+ statusBarItem.backgroundColor = undefined;
92
+ }
93
+ }
94
+
95
+ export function deactivate(): void {
96
+ bridge?.disconnect();
97
+ decorator?.dispose();
98
+ }