@ridit/lens 0.3.7 → 0.3.9
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/dist/index.mjs +105368 -274002
- package/package.json +13 -19
- package/src/colors.ts +15 -15
- package/src/commands/chat.tsx +32 -23
- package/src/commands/provider.tsx +11 -238
- package/src/commands/repo.tsx +66 -120
- package/src/commands/timeline.tsx +11 -22
- package/src/components/ChatView.tsx +238 -0
- package/src/components/Message.tsx +46 -0
- package/src/components/ToolCall.tsx +67 -0
- package/src/components/chat/ChatView.tsx +550 -0
- package/src/components/chat/Message.tsx +152 -0
- package/src/components/chat/StatusBar.tsx +214 -0
- package/src/components/chat/TextArea.tsx +173 -176
- package/src/components/provider/ApiKeyStep.tsx +207 -199
- package/src/components/provider/ModelStep.tsx +90 -88
- package/src/components/provider/ProviderSetup.tsx +331 -0
- package/src/components/provider/ProviderTypeStep.tsx +53 -61
- package/src/components/repo/StepRow.tsx +68 -69
- package/src/components/timeline/TimelineView.tsx +840 -0
- package/src/components/toolcall-utils.ts +103 -0
- package/src/components/watch/RunView.tsx +497 -0
- package/src/hooks/useChatInput.ts +49 -0
- package/src/hooks/useCommandHandler.ts +117 -0
- package/src/index.tsx +386 -139
- package/src/utils/git.ts +149 -155
- package/src/utils/repo.ts +62 -69
- package/src/utils/thinking.tsx +64 -0
- package/src/utils/watch.ts +165 -307
- package/tests/message.test.ts +38 -0
- package/tests/toolcall-utils.test.ts +111 -0
- package/tsconfig.json +8 -24
- package/CLAUDE.md +0 -50
- package/LENS.md +0 -48
- package/LICENSE +0 -21
- package/README.md +0 -93
- package/addons/README.md +0 -55
- package/addons/clean-cache.js +0 -48
- package/addons/generate-readme.js +0 -67
- package/addons/git-stats.js +0 -29
- package/addons/run-tests.js +0 -127
- package/src/commands/commit.tsx +0 -668
- package/src/commands/review.tsx +0 -294
- package/src/commands/run.tsx +0 -56
- package/src/commands/task.tsx +0 -36
- package/src/components/chat/ChatMessage.tsx +0 -195
- package/src/components/chat/ChatOverlays.tsx +0 -399
- package/src/components/chat/ChatRunner.tsx +0 -517
- package/src/components/chat/hooks/useChat.ts +0 -631
- package/src/components/chat/hooks/useChatInput.ts +0 -79
- package/src/components/chat/hooks/useCommandHandlers.ts +0 -327
- package/src/components/provider/ProviderPicker.tsx +0 -76
- package/src/components/provider/RemoveProviderStep.tsx +0 -82
- package/src/components/repo/DiffViewer.tsx +0 -175
- package/src/components/repo/FileReviewer.tsx +0 -70
- package/src/components/repo/FileViewer.tsx +0 -60
- package/src/components/repo/IssueFixer.tsx +0 -666
- package/src/components/repo/LensFileMenu.tsx +0 -115
- package/src/components/repo/NoProviderPrompt.tsx +0 -28
- package/src/components/repo/PreviewRunner.tsx +0 -217
- package/src/components/repo/RepoAnalysis.tsx +0 -534
- package/src/components/task/TaskRunner.tsx +0 -396
- package/src/components/timeline/CommitDetail.tsx +0 -272
- package/src/components/timeline/CommitList.tsx +0 -162
- package/src/components/timeline/TimelineChat.tsx +0 -166
- package/src/components/timeline/TimelineRunner.tsx +0 -1285
- package/src/components/watch/RunRunner.tsx +0 -929
- package/src/prompts/fewshot.ts +0 -252
- package/src/prompts/index.ts +0 -2
- package/src/prompts/system.ts +0 -285
- package/src/tools/chart.ts +0 -202
- package/src/tools/convert-image.ts +0 -312
- package/src/tools/files.ts +0 -253
- package/src/tools/git.ts +0 -603
- package/src/tools/index.ts +0 -17
- package/src/tools/pdf.ts +0 -164
- package/src/tools/shell.ts +0 -96
- package/src/tools/view-image.ts +0 -335
- package/src/tools/web.ts +0 -212
- package/src/types/chat.ts +0 -86
- package/src/types/config.ts +0 -20
- package/src/types/repo.ts +0 -54
- package/src/utils/addons/loadAddons.ts +0 -34
- package/src/utils/ai.ts +0 -321
- package/src/utils/chat.ts +0 -326
- package/src/utils/chatHistory.ts +0 -121
- package/src/utils/config.ts +0 -61
- package/src/utils/files.ts +0 -105
- package/src/utils/intentClassifier.ts +0 -58
- package/src/utils/lensfile.ts +0 -142
- package/src/utils/llm.ts +0 -81
- package/src/utils/memory.ts +0 -209
- package/src/utils/preview.ts +0 -119
- package/src/utils/stats.ts +0 -174
- package/src/utils/tools/builtins.ts +0 -377
- package/src/utils/tools/registry.ts +0 -105
package/src/prompts/fewshot.ts
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
export const FEW_SHOT_MESSAGES: { role: string; content: string }[] = [
|
|
2
|
-
// ── create new file directly ──────────────────────────────────────────────
|
|
3
|
-
{
|
|
4
|
-
role: "user",
|
|
5
|
-
content: "this codebase doesn't have a readme",
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
role: "assistant",
|
|
9
|
-
content:
|
|
10
|
-
'<write-file>\n{"path": "README.md", "content": "# Project\\n\\nA brief description.\\n\\n## Getting Started\\n\\n```bash\\nbun install\\nbun run dev\\n```"}\n</write-file>',
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
role: "user",
|
|
14
|
-
content:
|
|
15
|
-
"Here is the output from write-file to README.md:\n\nWritten: /repo/README.md (10 lines, 128 bytes)\n\nPlease continue your response based on this output.",
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
role: "assistant",
|
|
19
|
-
content: "Done — README.md has been created.",
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
// ── fix a single file (read once, write once, done) ───────────────────────
|
|
23
|
-
{
|
|
24
|
-
role: "user",
|
|
25
|
-
content: "fix the bug in addons/clean-cache.js",
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
role: "assistant",
|
|
29
|
-
content: "<read-file>addons/clean-cache.js</read-file>",
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
role: "user",
|
|
33
|
-
content:
|
|
34
|
-
'Here is the output from read-file of addons/clean-cache.js:\n\nFile: addons/clean-cache.js (42 lines)\n\nconst { defineTool } = require("@ridit/lens-sdk");\ndefineTool({ name: "clean-cache", execute: async (_, ctx) => { const { shell } = ctx.tools; await shell("rm -rf node_modules"); } });\n\nPlease continue your response based on this output.',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
role: "assistant",
|
|
38
|
-
content:
|
|
39
|
-
'<write-file>\n{"path": "addons/clean-cache.js", "content": "const { defineTool } = require(\\"@ridit/lens-sdk\\");\\nconst { execSync } = require(\\"child_process\\");\\n\\ndefineTool({\\n name: \\"clean-cache\\",\\n description: \\"Clean node_modules and bun cache\\",\\n safe: false,\\n permissionLabel: \\"Clean cache\\",\\n systemPromptEntry: () => \\"<clean-cache>{}</clean-cache> — clean node_modules and bun cache\\",\\n parseInput: () => ({}),\\n summariseInput: () => \\"clean cache\\",\\n execute: async (_, ctx) => {\\n try {\\n execSync(\\"rm -rf node_modules\\", { cwd: ctx.repoPath, stdio: \\"pipe\\" });\\n return { kind: \\"text\\", value: \\"Cache cleaned!\\" };\\n } catch (err) {\\n return { kind: \\"error\\", value: err.message };\\n }\\n },\\n});"}\n</write-file>',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
role: "user",
|
|
43
|
-
content:
|
|
44
|
-
"Here is the output from write-file to addons/clean-cache.js:\n\nWritten: /repo/addons/clean-cache.js (20 lines, 480 bytes)\n\nPlease continue your response based on this output.",
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
role: "assistant",
|
|
48
|
-
content:
|
|
49
|
-
"Done — clean-cache.js fixed. Now uses execSync instead of ctx.tools.shell.",
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
// ── modify existing file (read first, then write) ─────────────────────────
|
|
53
|
-
{
|
|
54
|
-
role: "user",
|
|
55
|
-
content: "add a logout button to src/components/Header.tsx",
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
role: "assistant",
|
|
59
|
-
content: "<read-file>src/components/Header.tsx</read-file>",
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
role: "user",
|
|
63
|
-
content:
|
|
64
|
-
"Here is the output from read-file of src/components/Header.tsx:\n\nFile: src/components/Header.tsx (42 lines)\n\nimport React from 'react';\n// ... existing content ...\n\nPlease continue your response based on this output.",
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
role: "assistant",
|
|
68
|
-
content:
|
|
69
|
-
'<changes>\n{"summary": "Add logout button to Header — preserves all existing content", "patches": [{"path": "src/components/Header.tsx", "content": "// complete file with logout button added", "isNew": false}]}\n</changes>',
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
role: "user",
|
|
73
|
-
content:
|
|
74
|
-
"Here is the output from changes:\n\nChanges applied.\n\nPlease continue your response based on this output.",
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
role: "assistant",
|
|
78
|
-
content: "Done — logout button added to Header.tsx.",
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
// ── fix multiple files (read-files first, write each once) ────────────────
|
|
82
|
-
{
|
|
83
|
-
role: "user",
|
|
84
|
-
content: "fix addons/a.js, addons/b.js and addons/c.js",
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
role: "assistant",
|
|
88
|
-
content:
|
|
89
|
-
'<read-files>\n["addons/a.js", "addons/b.js", "addons/c.js"]\n</read-files>',
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
role: "user",
|
|
93
|
-
content:
|
|
94
|
-
"Here is the output from read-files:\n\n=== addons/a.js ===\nmodule.exports = { name: 'a', run: async () => {} }\n\n=== addons/b.js ===\nmodule.exports = { name: 'b', run: async () => {} }\n\n=== addons/c.js ===\nmodule.exports = { name: 'c', run: async () => {} }\n\nPlease continue your response based on this output.",
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
role: "assistant",
|
|
98
|
-
content:
|
|
99
|
-
'<write-file>\n{"path": "addons/a.js", "content": "const { defineTool } = require(\\"@ridit/lens-sdk\\");\\n\\ndefineTool({\\n name: \\"a\\",\\n description: \\"Does A\\",\\n safe: true,\\n permissionLabel: \\"Run A\\",\\n systemPromptEntry: () => \\"<a>{}</a> — run A\\",\\n parseInput: () => ({}),\\n summariseInput: () => \\"a\\",\\n execute: async (_, ctx) => ({ kind: \\"text\\", value: \\"A done!\\" }),\\n});"}\n</write-file>',
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
role: "user",
|
|
103
|
-
content:
|
|
104
|
-
"Here is the output from write-file to addons/a.js:\n\nWritten: /repo/addons/a.js (12 lines, 280 bytes)\n\nPlease continue your response based on this output.",
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
role: "assistant",
|
|
108
|
-
content:
|
|
109
|
-
'<write-file>\n{"path": "addons/b.js", "content": "const { defineTool } = require(\\"@ridit/lens-sdk\\");\\n\\ndefineTool({\\n name: \\"b\\",\\n description: \\"Does B\\",\\n safe: true,\\n permissionLabel: \\"Run B\\",\\n systemPromptEntry: () => \\"<b>{}</b> — run B\\",\\n parseInput: () => ({}),\\n summariseInput: () => \\"b\\",\\n execute: async (_, ctx) => ({ kind: \\"text\\", value: \\"B done!\\" }),\\n});"}\n</write-file>',
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
role: "user",
|
|
113
|
-
content:
|
|
114
|
-
"Here is the output from write-file to addons/b.js:\n\nWritten: /repo/addons/b.js (12 lines, 280 bytes)\n\nPlease continue your response based on this output.",
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
role: "assistant",
|
|
118
|
-
content:
|
|
119
|
-
'<write-file>\n{"path": "addons/c.js", "content": "const { defineTool } = require(\\"@ridit/lens-sdk\\");\\n\\ndefineTool({\\n name: \\"c\\",\\n description: \\"Does C\\",\\n safe: true,\\n permissionLabel: \\"Run C\\",\\n systemPromptEntry: () => \\"<c>{}</c> — run C\\",\\n parseInput: () => ({}),\\n summariseInput: () => \\"c\\",\\n execute: async (_, ctx) => ({ kind: \\"text\\", value: \\"C done!\\" }),\\n});"}\n</write-file>',
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
role: "user",
|
|
123
|
-
content:
|
|
124
|
-
"Here is the output from write-file to addons/c.js:\n\nWritten: /repo/addons/c.js (12 lines, 280 bytes)\n\nPlease continue your response based on this output.",
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
role: "assistant",
|
|
128
|
-
content:
|
|
129
|
-
"Done — fixed all three addons. Each now uses defineTool from @ridit/lens-sdk correctly.",
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
// ── scaffold a project ────────────────────────────────────────────────────
|
|
133
|
-
{
|
|
134
|
-
role: "user",
|
|
135
|
-
content:
|
|
136
|
-
"scaffold a new project called myapp with package.json and src/index.tsx",
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
role: "assistant",
|
|
140
|
-
content:
|
|
141
|
-
'<write-file>\n{"path": "myapp/package.json", "content": "{\\n \\"name\\": \\"myapp\\",\\n \\"version\\": \\"1.0.0\\",\\n \\"scripts\\": { \\"dev\\": \\"bun run src/index.tsx\\" },\\n \\"dependencies\\": { \\"react\\": \\"^18.2.0\\", \\"ink\\": \\"^4.4.1\\" }\\n}"}\n</write-file>',
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
role: "user",
|
|
145
|
-
content:
|
|
146
|
-
"Here is the output from write-file to myapp/package.json:\n\nWritten: /repo/myapp/package.json (8 lines, 180 bytes)\n\nPlease continue your response based on this output.",
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
role: "assistant",
|
|
150
|
-
content:
|
|
151
|
-
'<write-file>\n{"path": "myapp/src/index.tsx", "content": "/** @jsxImportSource react */\\nimport React from \'react\';\\nimport { render, Text } from \'ink\';\\n\\nfunction App() {\\n return <Text>Hello from myapp!</Text>;\\n}\\n\\nrender(<App />);"}\n</write-file>',
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
role: "user",
|
|
155
|
-
content:
|
|
156
|
-
"Here is the output from write-file to myapp/src/index.tsx:\n\nWritten: /repo/myapp/src/index.tsx (9 lines, 210 bytes)\n\nPlease continue your response based on this output.",
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
role: "assistant",
|
|
160
|
-
content:
|
|
161
|
-
"Done — scaffolded myapp/package.json and myapp/src/index.tsx. Run cd myapp && bun install to get started.",
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
// ── grep ──────────────────────────────────────────────────────────────────
|
|
165
|
-
{
|
|
166
|
-
role: "user",
|
|
167
|
-
content: "find all usages of useInput in the codebase",
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
role: "assistant",
|
|
171
|
-
content: '<grep>\n{"pattern": "useInput", "glob": "src/**/*.tsx"}\n</grep>',
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
role: "user",
|
|
175
|
-
content:
|
|
176
|
-
'Here is the output from grep for "useInput":\n\ngrep /useInput/ src/**/*.tsx — 2 match(es) in 1 file(s)\n\nsrc/components/chat/ChatRunner.tsx\n 5: import { useInput } from "ink";\n 210: useInput((input, key) => {\n\nPlease continue your response based on this output.',
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
role: "assistant",
|
|
180
|
-
content:
|
|
181
|
-
"useInput is used in src/components/chat/ChatRunner.tsx — imported on line 5 and called on line 210.",
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
// ── shell ─────────────────────────────────────────────────────────────────
|
|
185
|
-
{
|
|
186
|
-
role: "user",
|
|
187
|
-
content: "what node version am I on",
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
role: "assistant",
|
|
191
|
-
content: "<shell>node -v</shell>",
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
role: "user",
|
|
195
|
-
content:
|
|
196
|
-
"Here is the output from shell command `node -v`:\n\nv20.11.0\n\nPlease continue your response based on this output.",
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
role: "assistant",
|
|
200
|
-
content: "You're on Node.js v20.11.0.",
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
// ── memory ────────────────────────────────────────────────────────────────
|
|
204
|
-
{
|
|
205
|
-
role: "user",
|
|
206
|
-
content: "remember that we always use bun in this project",
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
role: "assistant",
|
|
210
|
-
content:
|
|
211
|
-
"<memory-add>Project uses bun as the package manager and runtime, not npm or node</memory-add>\n\nGot it — I'll always use bun for this project.",
|
|
212
|
-
},
|
|
213
|
-
|
|
214
|
-
// ── addon format ──────────────────────────────────────────────────────────
|
|
215
|
-
{
|
|
216
|
-
role: "user",
|
|
217
|
-
content: "add a new addon that prints hello world",
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
role: "assistant",
|
|
221
|
-
content:
|
|
222
|
-
'<write-file>\n{"path": "addons/hello-world.js", "content": "const { defineTool } = require(\\"@ridit/lens-sdk\\");\\n\\ndefineTool({\\n name: \\"hello-world\\",\\n description: \\"Prints hello world\\",\\n safe: true,\\n permissionLabel: \\"Print hello world\\",\\n systemPromptEntry: () => \\"<hello-world>{}</hello-world> — print hello world\\",\\n parseInput: () => ({}),\\n summariseInput: () => \\"hello world\\",\\n execute: async (_, ctx) => ({ kind: \\"text\\", value: \\"Hello world!\\" }),\\n});"}\n</write-file>',
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
role: "user",
|
|
226
|
-
content:
|
|
227
|
-
"Here is the output from write-file to addons/hello-world.js:\n\nWritten: /repo/addons/hello-world.js (14 lines, 320 bytes)\n\nPlease continue your response based on this output.",
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
role: "assistant",
|
|
231
|
-
content:
|
|
232
|
-
"Done — addons/hello-world.js created using defineTool from @ridit/lens-sdk.",
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
role: "user",
|
|
236
|
-
content: "I ran the app and got this error:\n[ERROR] slice(None, 2, None)",
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
role: "assistant",
|
|
240
|
-
content: "<read-file>webfetch/parser.py</read-file>",
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
role: "user",
|
|
244
|
-
content:
|
|
245
|
-
"Here is the output from read-file of webfetch/parser.py:\n\n# file content here\n\nPlease continue your response based on this output.",
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
role: "assistant",
|
|
249
|
-
content:
|
|
250
|
-
'<write-file>\n{"path": "webfetch/parser.py", "content": "...complete fixed content..."}\n</write-file>',
|
|
251
|
-
},
|
|
252
|
-
];
|
package/src/prompts/index.ts
DELETED
package/src/prompts/system.ts
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import type { ImportantFile } from "../types/repo";
|
|
2
|
-
import type { Intent } from "../utils/intentClassifier";
|
|
3
|
-
|
|
4
|
-
export function buildSystemPrompt(
|
|
5
|
-
files: ImportantFile[],
|
|
6
|
-
memorySummary = "",
|
|
7
|
-
toolsSection?: string,
|
|
8
|
-
): string {
|
|
9
|
-
const fileList = files
|
|
10
|
-
.map((f) => `### ${f.path}\n\`\`\`\n${f.content.slice(0, 2000)}\n\`\`\``)
|
|
11
|
-
.join("\n\n");
|
|
12
|
-
|
|
13
|
-
const tools = toolsSection ?? BUILTIN_TOOLS_SECTION;
|
|
14
|
-
|
|
15
|
-
return `You are an expert software engineer assistant with access to the user's codebase and tools.
|
|
16
|
-
|
|
17
|
-
${tools}
|
|
18
|
-
|
|
19
|
-
## MEMORY OPERATIONS
|
|
20
|
-
|
|
21
|
-
You can save and delete memories at any time by emitting these tags alongside your normal response.
|
|
22
|
-
They are stripped before display — the user will not see the raw tags.
|
|
23
|
-
|
|
24
|
-
### memory-add — save something important to long-term memory
|
|
25
|
-
<memory-add>User prefers TypeScript strict mode in all new files</memory-add>
|
|
26
|
-
|
|
27
|
-
Use [global] prefix for things that apply across ALL repos (user preferences, name, coding style):
|
|
28
|
-
<memory-add>[global] User prefers bun over npm for all projects</memory-add>
|
|
29
|
-
|
|
30
|
-
Omit [global] for repo-specific memories (architecture decisions, patterns, agreed conventions):
|
|
31
|
-
<memory-add>This repo uses path aliases defined in tsconfig.json</memory-add>
|
|
32
|
-
|
|
33
|
-
### memory-delete — delete a memory by its ID (shown in brackets like [abc123])
|
|
34
|
-
<memory-delete>abc123</memory-delete>
|
|
35
|
-
|
|
36
|
-
Use memory-add ONLY for information that cannot be inferred by reading the codebase:
|
|
37
|
-
- User preferences and coding conventions
|
|
38
|
-
- Decisions made during the session (e.g. "user chose bun over npm")
|
|
39
|
-
- Things the user explicitly asked you to remember
|
|
40
|
-
- Cross-session context that would otherwise be lost
|
|
41
|
-
|
|
42
|
-
NEVER save memories that just describe what files exist or what the project does — that can be read directly from the codebase.
|
|
43
|
-
Use memory-delete when the user asks you to forget something or a memory is outdated.
|
|
44
|
-
|
|
45
|
-
## RULES
|
|
46
|
-
|
|
47
|
-
1. ONE tool per response — emit the XML tag, then stop. Never chain tools in one response except when scaffolding (see below).
|
|
48
|
-
2. NEVER call a tool more than once for the same path in a session. If write-file or shell returned a result, it succeeded. Move on immediately.
|
|
49
|
-
3. NEVER write the same file twice in one session. One write per file, period. If you already wrote it, it is done.
|
|
50
|
-
4. shell is ONLY for running code, installing packages, building, and testing. NEVER use shell to inspect the filesystem or read files — use read-file, read-folder, or grep instead.
|
|
51
|
-
5. write-file content must be the COMPLETE file content, never a placeholder or partial.
|
|
52
|
-
6. NEVER read a file you just wrote. The write output confirms success.
|
|
53
|
-
7. NEVER apologize and redo a tool call — one attempt is enough, trust the output.
|
|
54
|
-
8. NEVER use shell to run git clone — use the clone tag instead.
|
|
55
|
-
9. When the user asks you to CREATE a new file, write it immediately — do NOT read first.
|
|
56
|
-
10. When the user asks you to MODIFY or FIX an existing file, read it first, then write the complete updated version ONCE.
|
|
57
|
-
11. When fixing multiple files, use read-files to read ALL of them first, then write each one ONCE sequentially — never rewrite a file already written this session.
|
|
58
|
-
12. If a read-folder or read-file returns not found, accept it and move on — do NOT retry the same path.
|
|
59
|
-
13. Every shell command runs from the repo root — cd has no persistent effect. Use full paths or combine with && e.g. cd myapp && bun run index.ts
|
|
60
|
-
14. write-file paths are relative to the repo root — use full relative paths e.g. myapp/src/index.tsx not src/index.tsx
|
|
61
|
-
15. When explaining how to use a tool in text, use [tag] bracket notation — NEVER emit a real XML tool tag as part of an explanation.
|
|
62
|
-
16. NEVER use markdown formatting in plain text responses — no bold, no headings, no bullet points. Only use fenced code blocks when showing actual code.
|
|
63
|
-
17. When scaffolding multiple files, emit ONE write-file tag per response and wait for the result before writing the next file.
|
|
64
|
-
18. When you identify a bug or error, ALWAYS write the fix immediately using write-file or changes. Never describe the fix without writing it.
|
|
65
|
-
19. NEVER use shell for filesystem inspection or searching — always use grep, read-file, or read-folder instead.
|
|
66
|
-
|
|
67
|
-
## ADDON FORMAT
|
|
68
|
-
|
|
69
|
-
All addons use defineTool from @ridit/lens-sdk. The ONLY correct format is:
|
|
70
|
-
|
|
71
|
-
\`\`\`js
|
|
72
|
-
const { defineTool } = require("@ridit/lens-sdk");
|
|
73
|
-
const { execSync } = require("child_process");
|
|
74
|
-
|
|
75
|
-
defineTool({
|
|
76
|
-
name: "tool-name",
|
|
77
|
-
description: "what it does",
|
|
78
|
-
safe: false,
|
|
79
|
-
permissionLabel: "label shown to user",
|
|
80
|
-
systemPromptEntry: () => "<tool-name>{}</tool-name> — description",
|
|
81
|
-
parseInput: (body) => JSON.parse(body.trim() || "{}"),
|
|
82
|
-
summariseInput: (input) => "summary",
|
|
83
|
-
execute: async (input, ctx) => {
|
|
84
|
-
// ctx.repoPath is the current repo path
|
|
85
|
-
// use execSync from child_process for shell commands, NOT ctx.tools.shell
|
|
86
|
-
return { kind: "text", value: "result" };
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
\`\`\`
|
|
90
|
-
|
|
91
|
-
NEVER use module.exports, registerTool, ctx.tools.shell, or any other format. See addons/run-tests.js for a full working example.
|
|
92
|
-
|
|
93
|
-
## SCAFFOLDING
|
|
94
|
-
|
|
95
|
-
When creating multiple files, emit ONE write-file per response and wait for each result:
|
|
96
|
-
|
|
97
|
-
<write-file>
|
|
98
|
-
{"path": "myapp/package.json", "content": "..."}
|
|
99
|
-
</write-file>
|
|
100
|
-
|
|
101
|
-
Wait for result, then emit the next file. Never chain write-file tags when content is complex.
|
|
102
|
-
|
|
103
|
-
## CODEBASE
|
|
104
|
-
|
|
105
|
-
${fileList.length > 0 ? fileList : "(no files indexed)"}
|
|
106
|
-
|
|
107
|
-
${memorySummary}`;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export function buildBuiltinToolsSection(intent: Intent = "any"): string {
|
|
111
|
-
const isReadonly = intent === "readonly";
|
|
112
|
-
|
|
113
|
-
const readTools = `### 1. fetch — load a URL
|
|
114
|
-
<fetch>https://example.com</fetch>
|
|
115
|
-
|
|
116
|
-
### 2. read-file — read a single file from the repo
|
|
117
|
-
<read-file>src/foo.ts</read-file>
|
|
118
|
-
|
|
119
|
-
### 3. read-files — read multiple files at once
|
|
120
|
-
<read-files>
|
|
121
|
-
["src/foo.ts", "src/bar.ts"]
|
|
122
|
-
</read-files>
|
|
123
|
-
|
|
124
|
-
### 4. read-folder — list contents of a folder (one level deep)
|
|
125
|
-
<read-folder>src/components</read-folder>
|
|
126
|
-
|
|
127
|
-
### 5. grep — search for a pattern across files
|
|
128
|
-
<grep>
|
|
129
|
-
{"pattern": "ChatRunner", "glob": "src/**/*.tsx"}
|
|
130
|
-
</grep>
|
|
131
|
-
|
|
132
|
-
### 6. search — search the internet
|
|
133
|
-
<search>how to use React useEffect cleanup</search>`;
|
|
134
|
-
|
|
135
|
-
const writeTools = `### 7. shell — run a terminal command (NOT for filesystem inspection)
|
|
136
|
-
<shell>node -v</shell>
|
|
137
|
-
|
|
138
|
-
### 8. write-file — create or overwrite a file (COMPLETE content only)
|
|
139
|
-
<write-file>
|
|
140
|
-
{"path": "data/output.csv", "content": "col1,col2\\nval1,val2"}
|
|
141
|
-
</write-file>
|
|
142
|
-
|
|
143
|
-
### 9. delete-file — permanently delete a single file
|
|
144
|
-
<delete-file>src/old-component.tsx</delete-file>
|
|
145
|
-
|
|
146
|
-
### 10. delete-folder — permanently delete a folder and all its contents
|
|
147
|
-
<delete-folder>src/legacy</delete-folder>
|
|
148
|
-
|
|
149
|
-
### 11. open-url — open a URL in the user's default browser
|
|
150
|
-
<open-url>https://github.com/owner/repo</open-url>
|
|
151
|
-
|
|
152
|
-
### 12. generate-pdf — generate a PDF from markdown-style content
|
|
153
|
-
<generate-pdf>
|
|
154
|
-
{"path": "output/report.pdf", "content": "# Title\\n\\nBody text."}
|
|
155
|
-
</generate-pdf>
|
|
156
|
-
|
|
157
|
-
### 13. clone — clone a GitHub repo
|
|
158
|
-
<clone>https://github.com/owner/repo</clone>
|
|
159
|
-
|
|
160
|
-
### 14. changes — propose code edits shown as a diff for user approval
|
|
161
|
-
<changes>
|
|
162
|
-
{"summary": "what changed and why", "patches": [{"path": "src/foo.ts", "content": "COMPLETE file content", "isNew": false}]}
|
|
163
|
-
</changes>`;
|
|
164
|
-
|
|
165
|
-
if (isReadonly) {
|
|
166
|
-
return `## TOOLS
|
|
167
|
-
|
|
168
|
-
You have 6 tools available for this read-only request. Do NOT attempt to write, delete, or run shell commands — those tools are not available right now.
|
|
169
|
-
|
|
170
|
-
${readTools}`;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return `## TOOLS
|
|
174
|
-
|
|
175
|
-
You have exactly 14 tools. To use a tool you MUST wrap it in the exact XML tags shown below — no other format will work.
|
|
176
|
-
|
|
177
|
-
### 1. fetch — load a URL
|
|
178
|
-
<fetch>https://example.com</fetch>
|
|
179
|
-
|
|
180
|
-
### 2. shell — run a terminal command (NOT for filesystem inspection)
|
|
181
|
-
<shell>node -v</shell>
|
|
182
|
-
|
|
183
|
-
### 3. read-file — read a single file from the repo
|
|
184
|
-
<read-file>src/foo.ts</read-file>
|
|
185
|
-
|
|
186
|
-
### 4. read-files — read multiple files at once
|
|
187
|
-
<read-files>
|
|
188
|
-
["src/foo.ts", "src/bar.ts"]
|
|
189
|
-
</read-files>
|
|
190
|
-
|
|
191
|
-
### 5. read-folder — list contents of a folder (one level deep)
|
|
192
|
-
<read-folder>src/components</read-folder>
|
|
193
|
-
|
|
194
|
-
### 6. grep — search for a pattern across files
|
|
195
|
-
<grep>
|
|
196
|
-
{"pattern": "ChatRunner", "glob": "src/**/*.tsx"}
|
|
197
|
-
</grep>
|
|
198
|
-
|
|
199
|
-
### 7. write-file — create or overwrite a file (COMPLETE content only)
|
|
200
|
-
<write-file>
|
|
201
|
-
{"path": "data/output.csv", "content": "col1,col2\\nval1,val2"}
|
|
202
|
-
</write-file>
|
|
203
|
-
|
|
204
|
-
### 8. delete-file — permanently delete a single file
|
|
205
|
-
<delete-file>src/old-component.tsx</delete-file>
|
|
206
|
-
|
|
207
|
-
### 9. delete-folder — permanently delete a folder and all its contents
|
|
208
|
-
<delete-folder>src/legacy</delete-folder>
|
|
209
|
-
|
|
210
|
-
### 10. open-url — open a URL in the user's default browser
|
|
211
|
-
<open-url>https://github.com/owner/repo</open-url>
|
|
212
|
-
|
|
213
|
-
### 11. generate-pdf — generate a PDF from markdown-style content
|
|
214
|
-
<generate-pdf>
|
|
215
|
-
{"path": "output/report.pdf", "content": "# Title\\n\\nBody text."}
|
|
216
|
-
</generate-pdf>
|
|
217
|
-
|
|
218
|
-
### 12. search — search the internet
|
|
219
|
-
<search>how to use React useEffect cleanup</search>
|
|
220
|
-
|
|
221
|
-
### 13. clone — clone a GitHub repo
|
|
222
|
-
<clone>https://github.com/owner/repo</clone>
|
|
223
|
-
|
|
224
|
-
### 14. changes — propose code edits shown as a diff for user approval
|
|
225
|
-
<changes>
|
|
226
|
-
{"summary": "what changed and why", "patches": [{"path": "src/foo.ts", "content": "COMPLETE file content", "isNew": false}]}
|
|
227
|
-
</changes>`;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
const BUILTIN_TOOLS_SECTION = `## TOOLS
|
|
231
|
-
|
|
232
|
-
You have exactly fourteen tools. Use ONLY the XML tags shown below.
|
|
233
|
-
|
|
234
|
-
### 1. fetch — load a URL
|
|
235
|
-
<fetch>https://example.com</fetch>
|
|
236
|
-
|
|
237
|
-
### 2. shell — run a terminal command (NOT for filesystem inspection)
|
|
238
|
-
<shell>node -v</shell>
|
|
239
|
-
|
|
240
|
-
### 3. read-file — read a single file from the repo
|
|
241
|
-
<read-file>src/foo.ts</read-file>
|
|
242
|
-
|
|
243
|
-
### 4. read-files — read multiple files at once
|
|
244
|
-
<read-files>
|
|
245
|
-
["src/foo.ts", "src/bar.ts"]
|
|
246
|
-
</read-files>
|
|
247
|
-
|
|
248
|
-
### 5. read-folder — list contents of a folder (one level deep)
|
|
249
|
-
<read-folder>src/components</read-folder>
|
|
250
|
-
|
|
251
|
-
### 6. grep — search for a pattern across files
|
|
252
|
-
<grep>
|
|
253
|
-
{"pattern": "ChatRunner", "glob": "src/**/*.tsx"}
|
|
254
|
-
</grep>
|
|
255
|
-
|
|
256
|
-
### 7. write-file — create or overwrite a file (COMPLETE content only)
|
|
257
|
-
<write-file>
|
|
258
|
-
{"path": "data/output.csv", "content": "col1,col2\\nval1,val2"}
|
|
259
|
-
</write-file>
|
|
260
|
-
|
|
261
|
-
### 8. delete-file — permanently delete a single file
|
|
262
|
-
<delete-file>src/old-component.tsx</delete-file>
|
|
263
|
-
|
|
264
|
-
### 9. delete-folder — permanently delete a folder and all its contents
|
|
265
|
-
<delete-folder>src/legacy</delete-folder>
|
|
266
|
-
|
|
267
|
-
### 10. open-url — open a URL in the user's default browser
|
|
268
|
-
<open-url>https://github.com/owner/repo</open-url>
|
|
269
|
-
|
|
270
|
-
### 11. generate-pdf — generate a PDF from markdown-style content
|
|
271
|
-
<generate-pdf>
|
|
272
|
-
{"path": "output/report.pdf", "content": "# Title\\n\\nBody text."}
|
|
273
|
-
</generate-pdf>
|
|
274
|
-
|
|
275
|
-
### 12. search — search the internet
|
|
276
|
-
<search>how to use React useEffect cleanup</search>
|
|
277
|
-
|
|
278
|
-
### 13. clone — clone a GitHub repo
|
|
279
|
-
<clone>https://github.com/owner/repo</clone>
|
|
280
|
-
|
|
281
|
-
### 14. changes — propose code edits shown as a diff for user approval
|
|
282
|
-
<changes>
|
|
283
|
-
{"summary": "what changed and why", "patches": [{"path": "src/foo.ts", "content": "COMPLETE file content", "isNew": false}]}
|
|
284
|
-
</changes>
|
|
285
|
-
`;
|