@ridit/lens 0.3.0 → 0.3.2
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/addons/README.md +55 -3
- package/addons/clean-cache.js +48 -0
- package/addons/generate-readme.js +67 -0
- package/addons/git-stats.js +29 -0
- package/dist/index.mjs +157 -486
- package/package.json +1 -1
- package/src/commands/commit.tsx +21 -47
- package/src/prompts/fewshot.ts +46 -286
- package/src/prompts/system.ts +71 -92
- package/src/utils/addons/loadAddons.ts +3 -1
- package/src/utils/tools/builtins.ts +14 -9
- package/LENS.md +0 -32
package/addons/README.md
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
-
# Sample addons for Lens
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# Sample addons for Lens
|
|
2
|
+
|
|
3
|
+
## These addons are generated by lens.
|
|
4
|
+
|
|
5
|
+
Paste them inside ~/.lens/addons or C:/Users/UserName/.lens/addons
|
|
6
|
+
|
|
7
|
+
## Addon Format
|
|
8
|
+
|
|
9
|
+
Addons use `defineTool` from `@ridit/lens-sdk`:
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
const { defineTool } = require("@ridit/lens-sdk");
|
|
13
|
+
|
|
14
|
+
defineTool({
|
|
15
|
+
name: "tool-name",
|
|
16
|
+
description: "what it does",
|
|
17
|
+
safe: false,
|
|
18
|
+
permissionLabel: "label shown to user",
|
|
19
|
+
systemPromptEntry: () => `<tool-name>{}</tool-name> — description`,
|
|
20
|
+
parseInput: (body) => JSON.parse(body.trim() || "{}"),
|
|
21
|
+
summariseInput: (input) => "summary",
|
|
22
|
+
execute: async (input, ctx) => {
|
|
23
|
+
// ctx.repoPath is the current repo
|
|
24
|
+
return { kind: "text", value: "result" };
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Available Addons
|
|
30
|
+
|
|
31
|
+
### clean-cache
|
|
32
|
+
Clears node_modules and bun install cache
|
|
33
|
+
```xml
|
|
34
|
+
<clean-cache>{}</clean-cache>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### generate-readme
|
|
38
|
+
Creates a README.md file for the project
|
|
39
|
+
```xml
|
|
40
|
+
<generate-readme>{}</generate-readme>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### git-stats
|
|
44
|
+
Shows git contributor commit counts
|
|
45
|
+
```xml
|
|
46
|
+
<git-stats></git-stats>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### run-tests
|
|
50
|
+
Runs test suite or specific test files
|
|
51
|
+
```xml
|
|
52
|
+
<run-tests>{}</run-tests> — full suite
|
|
53
|
+
<run-tests>{"file": "src/utils.test.js"}</run-tests> — specific file
|
|
54
|
+
<run-tests>{"command": "node script.js"}</run-tests> — custom command
|
|
55
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const { defineTool } = require("@ridit/lens-sdk");
|
|
2
|
+
const { execSync } = require("child_process");
|
|
3
|
+
|
|
4
|
+
const isWindows = process.platform === "win32";
|
|
5
|
+
|
|
6
|
+
defineTool({
|
|
7
|
+
name: "clean-cache",
|
|
8
|
+
description: "Clean node_modules and bun install cache",
|
|
9
|
+
safe: false,
|
|
10
|
+
permissionLabel: "Clean cache and node_modules",
|
|
11
|
+
|
|
12
|
+
systemPromptEntry: () =>
|
|
13
|
+
`<clean-cache>{}</clean-cache> — clean node_modules and bun cache`,
|
|
14
|
+
|
|
15
|
+
parseInput: (body) => {
|
|
16
|
+
const trimmed = body.trim();
|
|
17
|
+
if (!trimmed || trimmed === "{}") return {};
|
|
18
|
+
return JSON.parse(trimmed);
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
summariseInput: () => "clean cache",
|
|
22
|
+
|
|
23
|
+
execute: async (input, ctx) => {
|
|
24
|
+
const repoPath = ctx.repoPath;
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
// Remove node_modules
|
|
28
|
+
if (isWindows) {
|
|
29
|
+
execSync("rmdir /s /q node_modules", { cwd: repoPath, stdio: "pipe" });
|
|
30
|
+
} else {
|
|
31
|
+
execSync("rm -rf node_modules", { cwd: repoPath, stdio: "pipe" });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Clean bun cache
|
|
35
|
+
execSync("bun clean", { cwd: repoPath, stdio: "pipe" });
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
kind: "text",
|
|
39
|
+
value: "Cache cleaned successfully! node_modules removed and bun cache cleared.",
|
|
40
|
+
};
|
|
41
|
+
} catch (err) {
|
|
42
|
+
return {
|
|
43
|
+
kind: "error",
|
|
44
|
+
value: `Failed to clean cache: ${err.message}`,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const { defineTool } = require("@ridit/lens-sdk");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
|
|
4
|
+
const readmeTemplate = `# {name}
|
|
5
|
+
|
|
6
|
+
{description}
|
|
7
|
+
|
|
8
|
+
## Getting Started
|
|
9
|
+
|
|
10
|
+
\`\`\`bash
|
|
11
|
+
bun install
|
|
12
|
+
bun run dev
|
|
13
|
+
\`\`\`
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- Feature one
|
|
18
|
+
- Feature two
|
|
19
|
+
|
|
20
|
+
## Contributing
|
|
21
|
+
|
|
22
|
+
Pull requests welcome.`;
|
|
23
|
+
|
|
24
|
+
defineTool({
|
|
25
|
+
name: "generate-readme",
|
|
26
|
+
description: "Generate a README.md file for the project",
|
|
27
|
+
safe: true,
|
|
28
|
+
permissionLabel: "Generate README",
|
|
29
|
+
|
|
30
|
+
systemPromptEntry: () =>
|
|
31
|
+
`<generate-readme>{}</generate-readme> — generate a README.md`,
|
|
32
|
+
|
|
33
|
+
parseInput: (body) => {
|
|
34
|
+
const trimmed = body.trim();
|
|
35
|
+
if (!trimmed || trimmed === "{}") return {};
|
|
36
|
+
return JSON.parse(trimmed);
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
summariseInput: () => "generate README",
|
|
40
|
+
|
|
41
|
+
execute: async (input, ctx) => {
|
|
42
|
+
const repoPath = ctx.repoPath;
|
|
43
|
+
const pkgPath = `${repoPath}/package.json`;
|
|
44
|
+
|
|
45
|
+
let name = "Project";
|
|
46
|
+
let description = "A brief description.";
|
|
47
|
+
|
|
48
|
+
if (fs.existsSync(pkgPath)) {
|
|
49
|
+
try {
|
|
50
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
51
|
+
name = pkg.name || name;
|
|
52
|
+
description = pkg.description || description;
|
|
53
|
+
} catch {}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const content = readmeTemplate
|
|
57
|
+
.replace("{name}", name)
|
|
58
|
+
.replace("{description}", description);
|
|
59
|
+
|
|
60
|
+
fs.writeFileSync(`${repoPath}/README.md`, content);
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
kind: "text",
|
|
64
|
+
value: "README.md generated successfully!"
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { defineTool } = require("@ridit/lens-sdk");
|
|
2
|
+
const { execSync } = require("child_process");
|
|
3
|
+
|
|
4
|
+
defineTool({
|
|
5
|
+
name: "git-stats",
|
|
6
|
+
description: "Show git contributor stats",
|
|
7
|
+
safe: true,
|
|
8
|
+
permissionLabel: "View git stats",
|
|
9
|
+
systemPromptEntry: () => "<git-stats>{}</git-stats> — show contributor commit counts",
|
|
10
|
+
parseInput: (body) => JSON.parse(body.trim() || "{}"),
|
|
11
|
+
summariseInput: () => "git contributor stats",
|
|
12
|
+
execute: async (input, ctx) => {
|
|
13
|
+
try {
|
|
14
|
+
const output = execSync("git shortlog -sn --all", {
|
|
15
|
+
cwd: ctx.repoPath,
|
|
16
|
+
stdio: "pipe",
|
|
17
|
+
}).toString();
|
|
18
|
+
return {
|
|
19
|
+
kind: "text",
|
|
20
|
+
value: output || "No commits found",
|
|
21
|
+
};
|
|
22
|
+
} catch (err) {
|
|
23
|
+
return {
|
|
24
|
+
kind: "error",
|
|
25
|
+
value: `Failed to get git stats: ${err.message}`,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
});
|