@ridit/lens 0.3.4 → 0.3.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 +27 -20
- package/README.md +16 -14
- package/dist/index.mjs +946 -784
- package/package.json +2 -2
- package/src/commands/{watch.tsx → run.tsx} +3 -3
- package/src/components/chat/ChatRunner.tsx +131 -877
- package/src/components/chat/hooks/useChat.ts +540 -0
- package/src/components/chat/hooks/useChatInput.ts +79 -0
- package/src/components/chat/hooks/useCommandHandlers.ts +327 -0
- package/src/components/watch/{WatchRunner.tsx → RunRunner.tsx} +1 -2
- package/src/index.tsx +12 -17
- package/src/prompts/system.ts +141 -20
- package/src/tools/chart.ts +0 -8
- package/src/tools/git.ts +26 -0
- package/src/utils/intentClassifier.ts +58 -0
- package/src/utils/tools/builtins.ts +15 -0
- package/src/utils/tools/registry.ts +65 -9
package/LENS.md
CHANGED
|
@@ -1,41 +1,48 @@
|
|
|
1
1
|
# Lens
|
|
2
|
-
> Generated: 2026-03-
|
|
2
|
+
> Generated: 2026-03-24T15:21:42.840Z
|
|
3
3
|
|
|
4
4
|
## Overview
|
|
5
|
-
Lens is an AI-powered CLI tool built with React and Ink that
|
|
5
|
+
Lens is an AI-powered CLI tool built with React and Ink that enables natural language interaction with codebases. It provides chat-based exploration, code modification, repository analysis, timeline viewing, and smart commit generation. The tool connects to multiple LLM providers (Anthropic, OpenAI, Gemini, Ollama) and gives AI access to filesystem operations, shell commands, and web tools through a plugin system.
|
|
6
6
|
|
|
7
7
|
## Architecture
|
|
8
|
-
The
|
|
8
|
+
The architecture follows a command-based structure with Ink components for terminal UI rendering. Each CLI command (chat, commit, review, task, timeline) has a corresponding React component in src/commands/ that handles the specific workflow. The system uses discriminated union types for state management across multi-step processes. Tool execution is managed through a centralized registry system that supports plugins via @ridit/lens-sdk.
|
|
9
9
|
|
|
10
10
|
## Tooling & Conventions
|
|
11
11
|
- **packageManager**: bun
|
|
12
12
|
- **language**: TypeScript
|
|
13
13
|
- **runtime**: Node.js
|
|
14
|
-
- **bundler**:
|
|
15
|
-
- **framework**:
|
|
14
|
+
- **bundler**: bun build
|
|
15
|
+
- **framework**: Ink + React
|
|
16
|
+
- **testRunner**: jest (configured but not actively used)
|
|
17
|
+
- **linter**: TypeScript compiler with strict settings
|
|
16
18
|
|
|
17
19
|
## Important Folders
|
|
18
|
-
- src/commands: Contains chat.tsx, commit.tsx, review.tsx, timeline.tsx
|
|
19
|
-
- src/
|
|
20
|
-
- src/
|
|
20
|
+
- src/commands: Contains CLI command entry points (chat.tsx, commit.tsx, review.tsx, task.tsx, timeline.tsx) that render Ink components
|
|
21
|
+
- src/components: Houses reusable UI components organized by feature (chat/, repo/, timeline/, task/) with associated hooks
|
|
22
|
+
- src/utils: Core utilities including AI integration (ai.ts), configuration management (config.ts), git operations (git.ts), and tool registry (tools/)
|
|
23
|
+
- src/tools: Filesystem, shell, web, and PDF tools that the AI can call through the tool registry system
|
|
21
24
|
|
|
22
25
|
## Key Files
|
|
23
|
-
- src/
|
|
24
|
-
- src/
|
|
25
|
-
- src/
|
|
26
|
-
- src/
|
|
27
|
-
- src/
|
|
26
|
+
- src/index.tsx: Main CLI entry point that sets up Commander.js with all command handlers and loads built-in tools
|
|
27
|
+
- src/utils/tools/registry.ts: Central tool registry implementing the @ridit/lens-sdk interface for tool management and system prompt generation
|
|
28
|
+
- src/utils/ai.ts: Provider-agnostic AI integration with support for Anthropic, OpenAI, Ollama, and custom providers through unified interfaces
|
|
29
|
+
- src/types/chat.ts: Core type definitions for chat messages, tool calls, and state management using discriminated unions
|
|
30
|
+
- src/components/chat/ChatRunner.tsx: Main chat interface component handling tool execution, permission prompts, and clone operations
|
|
28
31
|
|
|
29
32
|
## Patterns & Idioms
|
|
30
|
-
- Discriminated union state machines (type + stage fields) for multi-step UI flows in every command component
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
+
- Discriminated union state machines (type + stage fields) for multi-step UI flows in every command component (ChatStage, AnalysisStage, etc)
|
|
34
|
+
- Centralized tool registry pattern with plugin system support through @ridit/lens-sdk interface
|
|
35
|
+
- Provider abstraction layer that supports multiple LLM backends with consistent interfaces
|
|
36
|
+
- File-based memory system that persists chat history and context across sessions per repository
|
|
37
|
+
- Ink component composition with hooks for input handling and state management
|
|
33
38
|
|
|
34
39
|
## Suggestions
|
|
35
|
-
- In src/utils/ai.ts, callModel has no retry logic
|
|
36
|
-
- The
|
|
37
|
-
-
|
|
40
|
+
- In src/utils/ai.ts, callModel has no retry logic — adding exponential backoff would improve reliability for ollama which can be slow to start
|
|
41
|
+
- The tool registry in src/utils/tools/registry.ts lacks validation for tool name conflicts during registration
|
|
42
|
+
- src/utils/git.ts uses simple execSync for git operations which could benefit from proper error handling and timeout management
|
|
43
|
+
- The discriminated union types in src/types/chat.ts could use branded types for better type safety
|
|
44
|
+
- The build process in package.json uses a postbuild script to add node shebang which could be replaced with bun's native --target=binary option
|
|
38
45
|
|
|
39
46
|
<!--lens-json
|
|
40
|
-
{"overview":"Lens is an AI-powered CLI tool built with React and Ink that
|
|
47
|
+
{"overview":"Lens is an AI-powered CLI tool built with React and Ink that enables natural language interaction with codebases. It provides chat-based exploration, code modification, repository analysis, timeline viewing, and smart commit generation. The tool connects to multiple LLM providers (Anthropic, OpenAI, Gemini, Ollama) and gives AI access to filesystem operations, shell commands, and web tools through a plugin system.","importantFolders":["src/commands: Contains CLI command entry points (chat.tsx, commit.tsx, review.tsx, task.tsx, timeline.tsx) that render Ink components","src/components: Houses reusable UI components organized by feature (chat/, repo/, timeline/, task/) with associated hooks","src/utils: Core utilities including AI integration (ai.ts), configuration management (config.ts), git operations (git.ts), and tool registry (tools/)","src/tools: Filesystem, shell, web, and PDF tools that the AI can call through the tool registry system"],"tooling":{"packageManager":"bun","language":"TypeScript","runtime":"Node.js","bundler":"bun build","framework":"Ink + React","testRunner":"jest (configured but not actively used)","linter":"TypeScript compiler with strict settings"},"keyFiles":["src/index.tsx: Main CLI entry point that sets up Commander.js with all command handlers and loads built-in tools","src/utils/tools/registry.ts: Central tool registry implementing the @ridit/lens-sdk interface for tool management and system prompt generation","src/utils/ai.ts: Provider-agnostic AI integration with support for Anthropic, OpenAI, Ollama, and custom providers through unified interfaces","src/types/chat.ts: Core type definitions for chat messages, tool calls, and state management using discriminated unions","src/components/chat/ChatRunner.tsx: Main chat interface component handling tool execution, permission prompts, and clone operations"],"patterns":["Discriminated union state machines (type + stage fields) for multi-step UI flows in every command component (ChatStage, AnalysisStage, etc)","Centralized tool registry pattern with plugin system support through @ridit/lens-sdk interface","Provider abstraction layer that supports multiple LLM backends with consistent interfaces","File-based memory system that persists chat history and context across sessions per repository","Ink component composition with hooks for input handling and state management"],"architecture":"The architecture follows a command-based structure with Ink components for terminal UI rendering. Each CLI command (chat, commit, review, task, timeline) has a corresponding React component in src/commands/ that handles the specific workflow. The system uses discriminated union types for state management across multi-step processes. Tool execution is managed through a centralized registry system that supports plugins via @ridit/lens-sdk.","suggestions":["In src/utils/ai.ts, callModel has no retry logic — adding exponential backoff would improve reliability for ollama which can be slow to start","The tool registry in src/utils/tools/registry.ts lacks validation for tool name conflicts during registration","src/utils/git.ts uses simple execSync for git operations which could benefit from proper error handling and timeout management","The discriminated union types in src/types/chat.ts could use branded types for better type safety","The build process in package.json uses a postbuild script to add node shebang which could be replaced with bun's native --target=binary option"],"generatedAt":"2026-03-24T15:21:42.840Z","lastUpdated":"2026-03-24T15:21:42.840Z"}
|
|
41
48
|
lens-json-->
|
package/README.md
CHANGED
|
@@ -30,26 +30,28 @@ npm install -g @ridit/lens
|
|
|
30
30
|
## CLI Commands
|
|
31
31
|
|
|
32
32
|
```
|
|
33
|
-
lens chat
|
|
33
|
+
lens chat chat with your codebase
|
|
34
34
|
lens chat -p /path/to/repo chat in a specific repo
|
|
35
35
|
|
|
36
|
-
lens review
|
|
36
|
+
lens review AI review of the current directory
|
|
37
37
|
lens review /path/to/repo AI review of a specific repo
|
|
38
38
|
|
|
39
|
-
lens repo
|
|
39
|
+
lens repo <url> analyze a remote GitHub repository
|
|
40
40
|
|
|
41
|
-
lens task
|
|
42
|
-
lens task
|
|
41
|
+
lens task <text> apply a natural language change to the codebase
|
|
42
|
+
lens task <text> -p /path apply change to a specific repo
|
|
43
43
|
|
|
44
|
-
lens commit
|
|
45
|
-
lens commit
|
|
46
|
-
lens commit
|
|
47
|
-
lens commit
|
|
48
|
-
lens commit
|
|
49
|
-
lens commit
|
|
44
|
+
lens commit generate a smart commit message from staged changes
|
|
45
|
+
lens commit [files...] stage specific files and generate a commit message
|
|
46
|
+
lens commit --auto stage all changes and commit without confirmation
|
|
47
|
+
lens commit --confirm show preview before committing when using --auto
|
|
48
|
+
lens commit --preview show the generated message without committing
|
|
49
|
+
lens commit --push push to remote after committing
|
|
50
50
|
|
|
51
|
-
lens timeline
|
|
52
|
-
lens timeline
|
|
51
|
+
lens timeline explore commit history
|
|
52
|
+
lens timeline -p /path explore history of a specific repo
|
|
53
|
+
|
|
54
|
+
lens run Run your dev server. Lens detects and fixes errors automatically
|
|
53
55
|
|
|
54
56
|
lens provider configure AI providers
|
|
55
57
|
```
|
|
@@ -88,4 +90,4 @@ Custom tools can be built and registered using `[@ridit/lens-sdk](https://www.np
|
|
|
88
90
|
|
|
89
91
|
## License
|
|
90
92
|
|
|
91
|
-
MIT
|
|
93
|
+
MIT
|