Skip to content

Commit 4f60aaa

Browse files
committed
docs: add CLI README and improve VSCode extension onboarding
Create comprehensive README for CLI package with installation and usage instructions. Enhance VSCode extension with welcome views that guide users to connect agents when sidebar is empty. Add context-aware welcome messages based on agent connection status.
1 parent efa1f66 commit 4f60aaa

File tree

4 files changed

+366
-11
lines changed

4 files changed

+366
-11
lines changed

packages/cli/README.md

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
# @vibe-x/agentlens-cli
2+
3+
> Command-line interface for Agent Lens - Track and identify AI agent contributions in code
4+
5+
![Agent Lens](https://s17-def.ap4r.com/kos/s101/nlav112218/mengshou/agentlens.96a74eebe90f8cc4.png)
6+
7+
## Overview
8+
9+
Agent Lens CLI is a command-line tool that helps you track which code in your repository was written by AI agents (like Cursor, Claude Code) versus humans. It integrates with AI coding assistants via hooks to capture code changes in real-time.
10+
11+
**For a visual experience**, we recommend using the CLI together with the [Agent Lens VS Code Extension](https://marketplace.visualstudio.com/items?itemName=vibe-x-ai.agentlens), which provides GitLens-style inline blame annotations and a sidebar for browsing AI activity.
12+
13+
## Installation
14+
15+
```bash
16+
# Install globally via npm
17+
npm install -g @vibe-x/agentlens-cli
18+
19+
# Or use npx
20+
npx @vibe-x/agentlens-cli --help
21+
```
22+
23+
## Quick Start
24+
25+
```bash
26+
# 1. Initialize Agent Lens in your project
27+
cd your-project
28+
agentlens config --init
29+
30+
# 2. Connect to an AI Agent
31+
agentlens hook connect cursor # For Cursor
32+
agentlens hook connect claude-code # For Claude Code
33+
34+
# 3. Use your AI Agent normally - changes are tracked automatically
35+
36+
# 4. View annotated diff with contributor information
37+
agentlens diff --annotated
38+
```
39+
40+
## Commands
41+
42+
### `agentlens config`
43+
44+
Configure Agent Lens settings in your project.
45+
46+
```bash
47+
# Initialize Agent Lens in the current project
48+
agentlens config --init
49+
50+
# Show current configuration
51+
agentlens config --show
52+
53+
# Set a configuration value
54+
agentlens config --set key=value
55+
56+
# Reset configuration to defaults
57+
agentlens config --reset
58+
```
59+
60+
**After initialization**, a `.agentlens/` directory is created with:
61+
- `data/sessions/` - Session data from AI agents
62+
- `data/hooks/` - Hook captured code changes (sharded by date)
63+
- `data/todos.json` - TODO items from agent sessions
64+
- `config/` - Configuration files
65+
66+
### `agentlens hook`
67+
68+
Manage AI Agent hooks for data collection.
69+
70+
```bash
71+
# Connect to an AI Agent
72+
agentlens hook connect <agent> # cursor, claude-code
73+
74+
# Disconnect from an AI Agent
75+
agentlens hook disconnect <agent>
76+
77+
# Show connection status for all agents
78+
agentlens hook status
79+
80+
# List supported AI Agents
81+
agentlens hook list
82+
```
83+
84+
**Supported Agents:**
85+
| Agent | ID | Config Location |
86+
|-------|------|----------------|
87+
| Cursor | `cursor` | `~/.cursor/hooks.json` |
88+
| Claude Code | `claude-code` | `~/.claude/settings.json` |
89+
90+
**Note for Cursor users:** You need to enable "Third-party skills" in Cursor Settings for hooks to work.
91+
92+
### `agentlens diff`
93+
94+
Show annotated diff with AI/human contributor information.
95+
96+
```bash
97+
# Show working tree changes with contributor info (default)
98+
agentlens diff --annotated
99+
100+
# Show staged changes only
101+
agentlens diff --staged
102+
103+
# Diff against a specific git reference
104+
agentlens diff --ref HEAD~3
105+
106+
# Output formats
107+
agentlens diff --format terminal # Default, colored terminal output
108+
agentlens diff --format markdown # Markdown format
109+
agentlens diff --format json # JSON format
110+
111+
# Write output to file
112+
agentlens diff --format markdown -o report.md
113+
114+
# Disable colored output
115+
agentlens diff --no-color
116+
```
117+
118+
**Options:**
119+
| Option | Description |
120+
|--------|-------------|
121+
| `-a, --annotated` | Show annotated diff with contributor info (default: true) |
122+
| `-f, --format <format>` | Output format: terminal, markdown, json |
123+
| `-r, --ref <ref>` | Git reference to diff against |
124+
| `--staged` | Show staged changes only |
125+
| `-o, --output <file>` | Write output to file |
126+
| `--no-color` | Disable colored output |
127+
128+
### `agentlens review`
129+
130+
Start an interactive code review session.
131+
132+
```bash
133+
# Start review session
134+
agentlens review
135+
136+
# Filter by session ID
137+
agentlens review --session abc123
138+
139+
# Show changes since a specific date
140+
agentlens review --since "2024-01-01"
141+
142+
# Export to markdown
143+
agentlens review --format markdown -o review-report.md
144+
```
145+
146+
**Options:**
147+
| Option | Description |
148+
|--------|-------------|
149+
| `-f, --format <format>` | Output format: terminal, markdown |
150+
| `--session <id>` | Filter by session ID |
151+
| `--since <date>` | Show changes since date |
152+
| `-o, --output <file>` | Write report to file |
153+
154+
### `agentlens todos`
155+
156+
Manage TODO items from Agent sessions.
157+
158+
```bash
159+
# List all TODOs
160+
agentlens todos
161+
162+
# Filter by status
163+
agentlens todos --status pending
164+
agentlens todos --status in_progress
165+
agentlens todos --status completed
166+
167+
# Filter by session
168+
agentlens todos --session abc123
169+
170+
# Output as JSON
171+
agentlens todos --format json
172+
```
173+
174+
**Options:**
175+
| Option | Description |
176+
|--------|-------------|
177+
| `-l, --list` | List all TODOs (default) |
178+
| `-s, --status <status>` | Filter by status: pending, in_progress, completed |
179+
| `--session <id>` | Filter by session ID |
180+
| `-f, --format <format>` | Output format: terminal, json |
181+
182+
## How It Works
183+
184+
### Hook System
185+
186+
Agent Lens uses a hook system to capture code changes from AI agents:
187+
188+
1. **For Cursor**: Uses the [Third-party Hooks](https://cursor.com/cn/docs/agent/hooks) feature
189+
2. **For Claude Code**: Uses the [Hooks](https://docs.anthropic.com/en/docs/claude-code/hooks) feature
190+
191+
When you run `agentlens hook connect <agent>`, the CLI:
192+
1. Detects if the agent is installed on your system
193+
2. Creates/updates the agent's hook configuration file
194+
3. Points the hooks to the `agentlens` CLI commands
195+
196+
### Data Storage
197+
198+
All captured data is stored in `.agentlens/data/hooks/`:
199+
200+
```
201+
.agentlens/data/hooks/
202+
├── changes/ # Code change records (sharded by date)
203+
│ ├── 2024-01-10.jsonl
204+
│ ├── 2024-01-11.jsonl
205+
│ └── ...
206+
├── prompts/ # User prompts (sharded by date)
207+
│ └── 2024-01-10.jsonl
208+
└── sessions.json # Session metadata
209+
```
210+
211+
### Contributor Detection
212+
213+
Agent Lens uses **4-level filtering with Levenshtein similarity matching** to determine code authorship:
214+
215+
```
216+
Level 1: File Path Filter (100 records → 30 records)
217+
218+
Level 2: Time Window Filter (30 records → 15 records)
219+
220+
Level 3: Content Length Filter (15 records → 5 records)
221+
222+
Level 4: Levenshtein Matching (5 candidates → best match)
223+
```
224+
225+
**Classification Thresholds:**
226+
- ≥ 90% similarity → **AI Generated**
227+
- 70-90% similarity → **AI Generated (Human Modified)**
228+
- < 70% similarity → **Human Contribution**
229+
230+
## VS Code Extension
231+
232+
For the best experience, use the CLI together with the [Agent Lens VS Code Extension](https://marketplace.visualstudio.com/items?itemName=vibe-x-ai.agentlens).
233+
234+
![Agent Lens Inline Blame](https://v17-def.ap4r.com/kos/s101/nlav112218/mengshou/inline-blame.3916d683ae836108.png)
235+
236+
The extension provides:
237+
238+
- **GitLens-style inline blame** - Hover over any line to see if it was written by AI or human
239+
- **Sidebar views** - Browse connected agents and recent AI-generated code changes
240+
- **One-click issue reporting** - Report matching problems directly from VS Code
241+
- **Auto cleanup** - Automatic cleanup of old data files
242+
243+
### Installation
244+
245+
```bash
246+
# Install from VS Code Marketplace
247+
code --install-extension vibe-x-ai.agentlens
248+
```
249+
250+
Or search for "Agent Lens" in VS Code Extensions (`Cmd+Shift+X` / `Ctrl+Shift+X`).
251+
252+
**Note:** The VS Code extension works independently and does not require the CLI to be installed. Both tools can connect to AI agents directly.
253+
254+
## Requirements
255+
256+
- Node.js >= 22.15.1
257+
- Git repository
258+
- Supported AI Agent (Cursor or Claude Code)
259+
260+
## Related
261+
262+
- [Agent Lens](https://github.com/vibe-x-ai/agent-blame) - Main repository
263+
- [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=vibe-x-ai.agentlens)
264+
265+
## License
266+
267+
MIT

packages/vscode/README.md

Lines changed: 71 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,32 @@ Agent Lens helps you understand **who wrote what** in your codebase — AI or hu
1111

1212
![Agent Lens](https://s17-def.ap4r.com/kos/s101/nlav112218/mengshou/agentlens.96a74eebe90f8cc4.png)
1313

14+
## Getting Started
15+
16+
### Step 1: Install the Extension
17+
18+
Install Agent Lens from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=vibe-x-ai.agentlens), or search for "Agent Lens" in VS Code Extensions.
19+
20+
### Step 2: Connect to an AI Agent
21+
22+
**This step is required** to enable code tracking. Agent Lens needs to connect to your AI coding assistant to capture code changes.
23+
24+
1. Open Command Palette (`Cmd+Shift+P` / `Ctrl+Shift+P`)
25+
2. Run `Agent Lens: Connect Agent`
26+
3. Select your AI Agent (Cursor or Claude Code)
27+
28+
![Connect Agent](https://v17-def.ap4r.com/kos/s101/nlav112218/mengshou/connect-agent.png)
29+
30+
**For Cursor users:** Make sure to enable **"Third-party skills"** in Cursor Settings > Features for hooks to work.
31+
32+
### Step 3: Start Coding with Your AI Agent
33+
34+
Once connected, Agent Lens automatically tracks all code changes made by your AI agent. You can:
35+
36+
- **Hover over any line** to see if it was written by AI or human
37+
- **Check the sidebar** to see connected agents and recent AI activity
38+
- **Use the diff view** to review AI-generated changes
39+
1440
## Features
1541

1642
### 🎯 GitLens-Style Blame
@@ -24,14 +50,31 @@ Hover over any line to see contributor information:
2450

2551
### 📊 Sidebar Views
2652

27-
- **Connected Agents**: View all detected AI agents and their connection status
28-
- **Recent Activity**: Browse recent AI-generated code changes with quick file navigation
53+
The sidebar provides two views to help you understand AI contributions:
54+
55+
#### Connected Agents
56+
57+
Shows all supported AI agents and their connection status:
58+
-**Connected**: Agent is connected and tracking code changes
59+
- ⚠️ **Detected**: Agent is installed but not connected
60+
-**Not Detected**: Agent is not installed on your system
61+
62+
> **Tip:** Click on an agent to connect or disconnect.
63+
64+
#### Recent Activity
65+
66+
Displays recent code changes made by AI agents:
67+
- Browse changes grouped by time
68+
- Click to open the changed file
69+
- Use the diff icon to view before/after changes
70+
71+
> **Note:** This view requires at least one agent to be connected. If empty, use `Agent Lens: Connect Agent` command first.
2972
3073
### 🔌 Multi-Agent Support
3174

3275
Works with popular AI coding assistants:
33-
- Cursor
34-
- Claude Code
76+
- **Cursor** - via Third-party Hooks
77+
- **Claude Code** - via Hooks system
3578
- More coming soon...
3679

3780
### ⚙️ Configuration
@@ -77,28 +120,45 @@ Level 4: Levenshtein Matching (5 candidates → best match)
77120

78121
| Command | Description |
79122
|---------|-------------|
80-
| `Agent Lens: Show Blame` | Show contributor info for current line |
81-
| `Agent Lens: Connect Agent` | Connect to an AI agent |
123+
| `Agent Lens: Connect Agent` | Connect to an AI agent (required for tracking) |
82124
| `Agent Lens: Disconnect Agent` | Disconnect from an AI agent |
83125
| `Agent Lens: Show Agent Status` | Display agent connection status |
126+
| `Agent Lens: Show Blame` | Show contributor info for current line |
84127
| `Agent Lens: Report Matching Issue` | Report a matching problem |
85128
| `Agent Lens: Cleanup Old Data` | Manually clean up old data files |
86129

87130
## Requirements
88131

89132
- VS Code 1.85.0 or higher
90133
- Git repository
134+
- AI coding assistant (Cursor or Claude Code)
91135

92-
## Getting Started
136+
## Troubleshooting
137+
138+
### Sidebar shows no activity
139+
140+
Make sure you have connected to an AI agent:
141+
1. Run `Agent Lens: Connect Agent` from Command Palette
142+
2. Select your AI agent
143+
3. Start using your AI agent to generate code
144+
145+
### Cursor hooks not working
146+
147+
Ensure "Third-party skills" is enabled in Cursor:
148+
1. Open Cursor Settings
149+
2. Go to Features
150+
3. Enable "Third-party skills"
151+
152+
### Blame shows "Human Contribution" for AI code
93153

94-
1. Install the extension from VS Code Marketplace
95-
2. Open a project with a `.git` folder
96-
3. Agent Lens will automatically detect AI agents and start tracking
154+
This can happen when:
155+
- The agent was not connected when the code was written
156+
- The code was heavily modified after AI generation
157+
- The time window has expired (default: 3 days)
97158

98159
## Links
99160

100161
- [GitHub Repository](https://github.com/alienzhou/agentlens)
101-
- [Documentation](https://github.com/alienzhou/agentlens/tree/main/docs)
102162
- [Issue Tracker](https://github.com/alienzhou/agentlens/issues)
103163
- [Changelog](https://github.com/alienzhou/agentlens/blob/main/CHANGELOG.md)
104164

0 commit comments

Comments
 (0)