@ridit/lens 0.2.2 → 0.2.5
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 +18 -11
- package/README.md +91 -0
- package/dist/index.mjs +69273 -2244
- package/package.json +7 -3
- package/src/commands/commit.tsx +713 -0
- package/src/components/chat/ChatOverlays.tsx +14 -4
- package/src/components/chat/ChatRunner.tsx +197 -30
- 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 +505 -422
- package/src/index.tsx +41 -0
- package/src/prompts/fewshot.ts +100 -3
- package/src/prompts/system.ts +16 -20
- 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/view-image.ts +335 -0
- package/src/tools/web.ts +0 -4
- package/src/utils/addons/loadAddons.ts +29 -0
- package/src/utils/chat.ts +8 -18
- package/src/utils/memory.ts +7 -12
- package/src/utils/thinking.tsx +275 -162
- package/src/utils/tools/builtins.ts +9 -32
- package/src/utils/tools/registry.ts +3 -59
- package/hello.py +0 -51
|
@@ -10,65 +10,7 @@
|
|
|
10
10
|
// import { registry } from "lens/tools/registry";
|
|
11
11
|
// registry.register({ name: "my-tool", ... });
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
repoPath: string;
|
|
15
|
-
/** All messages in the current conversation so far */
|
|
16
|
-
messages: unknown[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type ToolResult =
|
|
20
|
-
| { kind: "text"; value: string }
|
|
21
|
-
| { kind: "error"; value: string };
|
|
22
|
-
|
|
23
|
-
export interface Tool<TInput = string> {
|
|
24
|
-
/**
|
|
25
|
-
* Tag name used in XML: <name>...</name>
|
|
26
|
-
* Must be lowercase, hyphens allowed. Must be unique.
|
|
27
|
-
*/
|
|
28
|
-
name: string;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Short description shown in system prompt and /help.
|
|
32
|
-
*/
|
|
33
|
-
description: string;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* System prompt snippet explaining how to invoke this tool.
|
|
37
|
-
* Return the full ### N. name — description block.
|
|
38
|
-
*/
|
|
39
|
-
systemPromptEntry(index: number): string;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Parse the raw inner text of the XML tag into a typed input.
|
|
43
|
-
* Throw or return null to signal a parse failure (tool will be skipped).
|
|
44
|
-
*/
|
|
45
|
-
parseInput(body: string): TInput | null;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Execute the tool. May be async.
|
|
49
|
-
* Return a ToolResult — the value is fed back to the model as the tool result.
|
|
50
|
-
*/
|
|
51
|
-
execute(input: TInput, ctx: ToolContext): Promise<ToolResult> | ToolResult;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Whether this tool is safe to auto-approve (read-only, no side effects).
|
|
55
|
-
* Defaults to false.
|
|
56
|
-
*/
|
|
57
|
-
safe?: boolean;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Optional: permission prompt label shown to the user before execution.
|
|
61
|
-
* e.g. "run", "read", "write", "delete"
|
|
62
|
-
* Defaults to the tool name.
|
|
63
|
-
*/
|
|
64
|
-
permissionLabel?: string;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Optional: summarise the input for display in the chat history.
|
|
68
|
-
* Defaults to showing the raw input string.
|
|
69
|
-
*/
|
|
70
|
-
summariseInput?(input: TInput): string;
|
|
71
|
-
}
|
|
13
|
+
import type { Tool } from "@ridit/lens-sdk";
|
|
72
14
|
|
|
73
15
|
// ── Registry ──────────────────────────────────────────────────────────────────
|
|
74
16
|
|
|
@@ -117,3 +59,5 @@ class ToolRegistry {
|
|
|
117
59
|
}
|
|
118
60
|
|
|
119
61
|
export const registry = new ToolRegistry();
|
|
62
|
+
|
|
63
|
+
(globalThis as any).__lens_registry = registry;
|
package/hello.py
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# hello.py
|
|
2
|
-
# A simple script that reads a text file, makes an HTTP request,
|
|
3
|
-
# and prints the result in a friendly way.
|
|
4
|
-
|
|
5
|
-
import json
|
|
6
|
-
import pathlib
|
|
7
|
-
import sys
|
|
8
|
-
from urllib.request import urlopen
|
|
9
|
-
|
|
10
|
-
def read_local_file(path: str) -> str:
|
|
11
|
-
"""Read the contents of a file and return it as a string."""
|
|
12
|
-
file_path = pathlib.Path(path)
|
|
13
|
-
if not file_path.is_file():
|
|
14
|
-
raise FileNotFoundError(f"❌ File not found: {path}")
|
|
15
|
-
return file_path.read_text(encoding="utf-8")
|
|
16
|
-
|
|
17
|
-
def fetch_json(url: str) -> dict:
|
|
18
|
-
"""Fetch JSON from a URL and decode it into a Python dict."""
|
|
19
|
-
with urlopen(url) as response:
|
|
20
|
-
if response.status != 200:
|
|
21
|
-
raise RuntimeError(f"❌ HTTP {response.status} from {url}")
|
|
22
|
-
data = response.read()
|
|
23
|
-
return json.loads(data)
|
|
24
|
-
|
|
25
|
-
def main():
|
|
26
|
-
# 1️⃣ Read a local file (optional – you can comment this out)
|
|
27
|
-
try:
|
|
28
|
-
local_content = read_local_file("example.txt")
|
|
29
|
-
print("📄 Contents of example.txt:")
|
|
30
|
-
print(local_content)
|
|
31
|
-
except FileNotFoundError:
|
|
32
|
-
print("⚠️ example.txt not found – skipping that step.")
|
|
33
|
-
|
|
34
|
-
# 2️⃣ Fetch some JSON data from a public API
|
|
35
|
-
url = "https://api.github.com/repos/python/cpython"
|
|
36
|
-
print(f"\n🌐 Fetching data from {url} …")
|
|
37
|
-
repo_info = fetch_json(url)
|
|
38
|
-
|
|
39
|
-
# 3️⃣ Extract a couple of useful fields and display them
|
|
40
|
-
name = repo_info.get("name")
|
|
41
|
-
stars = repo_info.get("stargazers_count")
|
|
42
|
-
description = repo_info.get("description")
|
|
43
|
-
print("\n🔎 Repository info:")
|
|
44
|
-
print(f"• Name: {name}")
|
|
45
|
-
print(f"• Stars: {stars:,}") # adds commas for readability
|
|
46
|
-
print(f"• Description: {description}")
|
|
47
|
-
|
|
48
|
-
return 0
|
|
49
|
-
|
|
50
|
-
if __name__ == "__main__":
|
|
51
|
-
sys.exit(main())
|