@ridit/lens 0.2.4 → 0.2.6
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/LENS.md +32 -68
- package/README.md +91 -0
- package/addons/README.md +3 -0
- package/addons/run-tests.js +127 -0
- package/dist/index.mjs +226459 -2638
- package/package.json +13 -4
- package/src/colors.ts +5 -0
- package/src/commands/commit.tsx +686 -0
- package/src/commands/provider.tsx +36 -22
- package/src/components/__tests__/Header.test.tsx +9 -0
- package/src/components/chat/ChatMessage.tsx +6 -6
- package/src/components/chat/ChatOverlays.tsx +20 -10
- package/src/components/chat/ChatRunner.tsx +197 -31
- package/src/components/provider/ApiKeyStep.tsx +77 -121
- package/src/components/provider/ModelStep.tsx +35 -20
- package/src/components/{repo → provider}/ProviderPicker.tsx +1 -1
- package/src/components/provider/ProviderTypeStep.tsx +12 -5
- package/src/components/provider/RemoveProviderStep.tsx +7 -8
- package/src/components/repo/RepoAnalysis.tsx +1 -1
- package/src/components/task/TaskRunner.tsx +1 -1
- package/src/components/timeline/CommitDetail.tsx +2 -4
- package/src/components/timeline/CommitList.tsx +2 -14
- package/src/components/timeline/TimelineChat.tsx +1 -2
- package/src/components/timeline/TimelineRunner.tsx +506 -423
- package/src/index.tsx +38 -0
- package/src/prompts/fewshot.ts +144 -47
- package/src/prompts/system.ts +25 -21
- package/src/tools/chart.ts +210 -0
- package/src/tools/convert-image.ts +312 -0
- package/src/tools/files.ts +1 -9
- package/src/tools/git.ts +577 -0
- package/src/tools/index.ts +17 -13
- package/src/tools/pdf.ts +136 -78
- package/src/tools/view-image.ts +335 -0
- package/src/tools/web.ts +0 -4
- package/src/utils/addons/loadAddons.ts +6 -3
- package/src/utils/chat.ts +38 -23
- package/src/utils/thinking.tsx +275 -162
- package/src/utils/tools/builtins.ts +39 -32
- package/src/utils/tools/registry.ts +0 -14
- package/tsconfig.json +2 -2
|
@@ -11,10 +11,12 @@ import {
|
|
|
11
11
|
deleteFile,
|
|
12
12
|
deleteFolder,
|
|
13
13
|
generatePdf,
|
|
14
|
+
viewImageTool,
|
|
15
|
+
registerGitTools,
|
|
16
|
+
chartDataTool,
|
|
17
|
+
convertImageTool,
|
|
14
18
|
} from "../../tools";
|
|
15
19
|
|
|
16
|
-
// ── fetch ─────────────────────────────────────────────────────────────────────
|
|
17
|
-
|
|
18
20
|
export const fetchTool: Tool<string> = {
|
|
19
21
|
name: "fetch",
|
|
20
22
|
description: "load a URL",
|
|
@@ -37,8 +39,6 @@ export const fetchTool: Tool<string> = {
|
|
|
37
39
|
},
|
|
38
40
|
};
|
|
39
41
|
|
|
40
|
-
// ── shell ─────────────────────────────────────────────────────────────────────
|
|
41
|
-
|
|
42
42
|
export const shellTool: Tool<string> = {
|
|
43
43
|
name: "shell",
|
|
44
44
|
description: "run a terminal command",
|
|
@@ -54,8 +54,6 @@ export const shellTool: Tool<string> = {
|
|
|
54
54
|
},
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
// ── read-file ─────────────────────────────────────────────────────────────────
|
|
58
|
-
|
|
59
57
|
export const readFileTool: Tool<string> = {
|
|
60
58
|
name: "read-file",
|
|
61
59
|
description: "read a file from the repo",
|
|
@@ -71,8 +69,6 @@ export const readFileTool: Tool<string> = {
|
|
|
71
69
|
}),
|
|
72
70
|
};
|
|
73
71
|
|
|
74
|
-
// ── read-folder ───────────────────────────────────────────────────────────────
|
|
75
|
-
|
|
76
72
|
export const readFolderTool: Tool<string> = {
|
|
77
73
|
name: "read-folder",
|
|
78
74
|
description: "list contents of a folder (files + subfolders, one level deep)",
|
|
@@ -88,8 +84,6 @@ export const readFolderTool: Tool<string> = {
|
|
|
88
84
|
}),
|
|
89
85
|
};
|
|
90
86
|
|
|
91
|
-
// ── grep ──────────────────────────────────────────────────────────────────────
|
|
92
|
-
|
|
93
87
|
interface GrepInput {
|
|
94
88
|
pattern: string;
|
|
95
89
|
glob: string;
|
|
@@ -117,8 +111,6 @@ export const grepTool: Tool<GrepInput> = {
|
|
|
117
111
|
}),
|
|
118
112
|
};
|
|
119
113
|
|
|
120
|
-
// ── write-file ────────────────────────────────────────────────────────────────
|
|
121
|
-
|
|
122
114
|
interface WriteFileInput {
|
|
123
115
|
path: string;
|
|
124
116
|
content: string;
|
|
@@ -147,8 +139,6 @@ export const writeFileTool: Tool<WriteFileInput> = {
|
|
|
147
139
|
}),
|
|
148
140
|
};
|
|
149
141
|
|
|
150
|
-
// ── delete-file ───────────────────────────────────────────────────────────────
|
|
151
|
-
|
|
152
142
|
export const deleteFileTool: Tool<string> = {
|
|
153
143
|
name: "delete-file",
|
|
154
144
|
description: "permanently delete a single file",
|
|
@@ -164,8 +154,6 @@ export const deleteFileTool: Tool<string> = {
|
|
|
164
154
|
}),
|
|
165
155
|
};
|
|
166
156
|
|
|
167
|
-
// ── delete-folder ─────────────────────────────────────────────────────────────
|
|
168
|
-
|
|
169
157
|
export const deleteFolderTool: Tool<string> = {
|
|
170
158
|
name: "delete-folder",
|
|
171
159
|
description: "permanently delete a folder and all its contents",
|
|
@@ -181,8 +169,6 @@ export const deleteFolderTool: Tool<string> = {
|
|
|
181
169
|
}),
|
|
182
170
|
};
|
|
183
171
|
|
|
184
|
-
// ── open-url ──────────────────────────────────────────────────────────────────
|
|
185
|
-
|
|
186
172
|
export const openUrlTool: Tool<string> = {
|
|
187
173
|
name: "open-url",
|
|
188
174
|
description: "open a URL in the user's default browser",
|
|
@@ -195,8 +181,6 @@ export const openUrlTool: Tool<string> = {
|
|
|
195
181
|
execute: (url) => ({ kind: "text", value: openUrl(url) }),
|
|
196
182
|
};
|
|
197
183
|
|
|
198
|
-
// ── generate-pdf ──────────────────────────────────────────────────────────────
|
|
199
|
-
|
|
200
184
|
interface GeneratePdfInput {
|
|
201
185
|
filePath: string;
|
|
202
186
|
content: string;
|
|
@@ -225,14 +209,12 @@ export const generatePdfTool: Tool<GeneratePdfInput> = {
|
|
|
225
209
|
}
|
|
226
210
|
},
|
|
227
211
|
summariseInput: ({ filePath }) => filePath,
|
|
228
|
-
execute: ({ filePath, content }, ctx) => ({
|
|
212
|
+
execute: async ({ filePath, content }, ctx) => ({
|
|
229
213
|
kind: "text",
|
|
230
|
-
value: generatePdf(filePath, content, ctx.repoPath),
|
|
214
|
+
value: await generatePdf(filePath, content, ctx.repoPath),
|
|
231
215
|
}),
|
|
232
216
|
};
|
|
233
217
|
|
|
234
|
-
// ── search ────────────────────────────────────────────────────────────────────
|
|
235
|
-
|
|
236
218
|
export const searchTool: Tool<string> = {
|
|
237
219
|
name: "search",
|
|
238
220
|
description: "search the internet for anything you are unsure about",
|
|
@@ -255,8 +237,6 @@ export const searchTool: Tool<string> = {
|
|
|
255
237
|
},
|
|
256
238
|
};
|
|
257
239
|
|
|
258
|
-
// ── clone ─────────────────────────────────────────────────────────────────────
|
|
259
|
-
|
|
260
240
|
export const cloneTool: Tool<string> = {
|
|
261
241
|
name: "clone",
|
|
262
242
|
description: "clone a GitHub repo so you can explore and discuss it",
|
|
@@ -266,16 +246,12 @@ export const cloneTool: Tool<string> = {
|
|
|
266
246
|
`### ${i}. clone — clone a GitHub repo so you can explore and discuss it\n<clone>https://github.com/owner/repo</clone>`,
|
|
267
247
|
parseInput: (body) => body.replace(/^<|>$/g, "").trim() || null,
|
|
268
248
|
summariseInput: (url) => url,
|
|
269
|
-
// Clone is handled specially by ChatRunner (it triggers a UI flow),
|
|
270
|
-
// so execute here is just a fallback that should never run.
|
|
271
249
|
execute: (repoUrl) => ({
|
|
272
250
|
kind: "text",
|
|
273
251
|
value: `Clone of ${repoUrl} was handled by the UI.`,
|
|
274
252
|
}),
|
|
275
253
|
};
|
|
276
254
|
|
|
277
|
-
// ── changes ───────────────────────────────────────────────────────────────────
|
|
278
|
-
|
|
279
255
|
export interface ChangesInput {
|
|
280
256
|
summary: string;
|
|
281
257
|
patches: { path: string; content: string; isNew: boolean }[];
|
|
@@ -296,14 +272,40 @@ export const changesTool: Tool<ChangesInput> = {
|
|
|
296
272
|
}
|
|
297
273
|
},
|
|
298
274
|
summariseInput: ({ summary }) => summary,
|
|
299
|
-
// changes is handled specially by ChatRunner (diff preview UI).
|
|
300
275
|
execute: ({ summary }) => ({
|
|
301
276
|
kind: "text",
|
|
302
277
|
value: `Changes proposed: ${summary}`,
|
|
303
278
|
}),
|
|
304
279
|
};
|
|
305
280
|
|
|
306
|
-
|
|
281
|
+
interface ReadFilesInput {
|
|
282
|
+
paths: string[];
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export const readFilesTool: Tool<ReadFilesInput> = {
|
|
286
|
+
name: "read-files",
|
|
287
|
+
description: "read multiple files from the repo at once",
|
|
288
|
+
safe: true,
|
|
289
|
+
permissionLabel: "read",
|
|
290
|
+
systemPromptEntry: (i) =>
|
|
291
|
+
`### ${i}. read-files — read multiple files from the repo at once\n<read-files>\n["src/foo.ts", "src/bar.ts"]\n</read-files>`,
|
|
292
|
+
parseInput: (body) => {
|
|
293
|
+
try {
|
|
294
|
+
const parsed = JSON.parse(body) as string[];
|
|
295
|
+
if (!Array.isArray(parsed) || parsed.length === 0) return null;
|
|
296
|
+
return { paths: parsed };
|
|
297
|
+
} catch {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
summariseInput: ({ paths }) => paths.join(", "),
|
|
302
|
+
execute: ({ paths }, ctx) => ({
|
|
303
|
+
kind: "text",
|
|
304
|
+
value: paths
|
|
305
|
+
.map((p) => `=== ${p} ===\n${readFile(p, ctx.repoPath)}`)
|
|
306
|
+
.join("\n\n"),
|
|
307
|
+
}),
|
|
308
|
+
};
|
|
307
309
|
|
|
308
310
|
import { registry } from "./registry";
|
|
309
311
|
|
|
@@ -321,4 +323,9 @@ export function registerBuiltins(): void {
|
|
|
321
323
|
registry.register(searchTool);
|
|
322
324
|
registry.register(cloneTool);
|
|
323
325
|
registry.register(changesTool);
|
|
326
|
+
registry.register(viewImageTool);
|
|
327
|
+
registry.register(chartDataTool);
|
|
328
|
+
registry.register(convertImageTool);
|
|
329
|
+
registry.register(readFilesTool);
|
|
330
|
+
registerGitTools();
|
|
324
331
|
}
|
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
// ── Tool Plugin System ────────────────────────────────────────────────────────
|
|
2
|
-
//
|
|
3
|
-
// To create a new tool:
|
|
4
|
-
//
|
|
5
|
-
// 1. Implement the Tool interface
|
|
6
|
-
// 2. Call registry.register(myTool) before the app starts
|
|
7
|
-
//
|
|
8
|
-
// External addon example:
|
|
9
|
-
//
|
|
10
|
-
// import { registry } from "lens/tools/registry";
|
|
11
|
-
// registry.register({ name: "my-tool", ... });
|
|
12
|
-
|
|
13
1
|
import type { Tool } from "@ridit/lens-sdk";
|
|
14
2
|
|
|
15
|
-
// ── Registry ──────────────────────────────────────────────────────────────────
|
|
16
|
-
|
|
17
3
|
class ToolRegistry {
|
|
18
4
|
private tools = new Map<string, Tool<unknown>>();
|
|
19
5
|
|
package/tsconfig.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"jsx": "react-jsx",
|
|
8
8
|
"allowJs": true,
|
|
9
9
|
"outDir": "dist",
|
|
10
|
-
|
|
10
|
+
"esModuleInterop": true,
|
|
11
11
|
"verbatimModuleSyntax": true,
|
|
12
12
|
|
|
13
13
|
"strict": true,
|
|
@@ -21,4 +21,4 @@
|
|
|
21
21
|
"noPropertyAccessFromIndexSignature": false
|
|
22
22
|
},
|
|
23
23
|
"include": ["src"]
|
|
24
|
-
}
|
|
24
|
+
}
|