lens-engine 0.1.12 → 0.1.14
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/README.md +140 -0
- package/cli.js +13 -1
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# LENS
|
|
2
|
+
|
|
3
|
+
Local-first repo context engine for AI agents.
|
|
4
|
+
|
|
5
|
+
LENS indexes your codebase — TF-IDF scoring, import graph traversal, co-change analysis — and delivers ranked files in one call. Fewer tokens wasted, smarter output.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install -g lens-engine
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Requires Node.js 20+.
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
# Start the background daemon
|
|
19
|
+
lens daemon start
|
|
20
|
+
|
|
21
|
+
# Register and auto-index a repo
|
|
22
|
+
cd my-project
|
|
23
|
+
lens repo register
|
|
24
|
+
|
|
25
|
+
# Query with intent
|
|
26
|
+
lens context "add auth middleware"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
Context pack: 12 files, 3.2KB
|
|
31
|
+
src/middleware/auth.ts
|
|
32
|
+
src/routes/login.ts
|
|
33
|
+
src/lib/tokens.ts
|
|
34
|
+
...
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## What It Does
|
|
38
|
+
|
|
39
|
+
1. **Diff scan** — detects changed files since last index
|
|
40
|
+
2. **TF-IDF keyword scoring** — code-domain stopwords, path tokens, exports, docstrings
|
|
41
|
+
3. **Concept expansion** — static synonyms + repo-specific vocab clusters
|
|
42
|
+
4. **Import graph traversal** — 2-hop dependency analysis, hub-file boosting
|
|
43
|
+
5. **Git co-change analysis** — files that change together get surfaced together
|
|
44
|
+
6. **Semantic boost** (Pro) — Voyage vector search for meaning-level matching
|
|
45
|
+
7. **Cache** — ~10ms cached, under 1s cold
|
|
46
|
+
|
|
47
|
+
Your code never leaves your machine. No cloud dependency for local usage.
|
|
48
|
+
|
|
49
|
+
## Daemon & Dashboard
|
|
50
|
+
|
|
51
|
+
The daemon runs on port 4111 — serves the REST API, MCP stdio, and a full local dashboard. Manage repos, watch indexing jobs, build context packs, and browse indexed data from the browser.
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
lens daemon start
|
|
55
|
+
lens dashboard # opens http://localhost:4111/dashboard/
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Dashboard pages: **Overview** (system stats, repo cards), **Context** (interactive query builder), **Repositories** (status table), **Jobs** (indexing progress), **Requests** (live log), **Data Browser**, **Usage**, **Billing**.
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
# REST API
|
|
62
|
+
curl http://localhost:4111/context \
|
|
63
|
+
-H "Content-Type: application/json" \
|
|
64
|
+
-d '{"goal": "add auth middleware"}'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## MCP Integration
|
|
68
|
+
|
|
69
|
+
`lens repo register` writes `.mcp.json` automatically. Claude Code, Cursor, and any MCP-compatible agent auto-discovers LENS. To re-create it manually: `lens repo mcp`.
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"mcpServers": {
|
|
74
|
+
"lens": {
|
|
75
|
+
"command": "lens-daemon",
|
|
76
|
+
"args": ["--stdio"]
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Pro
|
|
83
|
+
|
|
84
|
+
LENS is free for local use — TF-IDF, import graph, co-change, and caching all work without an account. Pro unlocks two additional pipeline stages that improve retrieval accuracy for larger or more complex codebases.
|
|
85
|
+
|
|
86
|
+
### Semantic Embeddings
|
|
87
|
+
|
|
88
|
+
Every file chunk is embedded for semantic search. LENS runs cosine similarity against all vectors to find files that are semantically relevant — even when they share zero keywords with your prompt.
|
|
89
|
+
|
|
90
|
+
> **Example:** Query `"handle expired sessions"` surfaces `tokenRefresh.ts` and `authMiddleware.ts`. Neither contains the word "session".
|
|
91
|
+
|
|
92
|
+
### Vocab Clusters
|
|
93
|
+
|
|
94
|
+
Export names across your repo are embedded and clustered by cosine similarity (threshold >0.75). When a query matches one term in a cluster, all related terms are pulled in — automatic query expansion tuned to your codebase.
|
|
95
|
+
|
|
96
|
+
> **Example:** Query `"auth"` expands to `verifyToken`, `sessionMiddleware`, `loginHandler`, `requireAuth`.
|
|
97
|
+
|
|
98
|
+
Together they add ~100-300ms per query. After logging in, run `lens index --force` to embed everything immediately, or leave it — LENS embeds new and changed files on each incremental index, so coverage grows automatically as you work.
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
lens login --github
|
|
102
|
+
# Authenticated as user@example.com
|
|
103
|
+
|
|
104
|
+
lens status
|
|
105
|
+
# Pro: active
|
|
106
|
+
# Embeddings: 847/847 files
|
|
107
|
+
# Vocab clusters: 42 clusters
|
|
108
|
+
|
|
109
|
+
# Optional: force full re-index to embed everything now
|
|
110
|
+
lens index --force
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## CLI Reference
|
|
114
|
+
|
|
115
|
+
All commands support `--json` for machine-readable output.
|
|
116
|
+
|
|
117
|
+
| Command | Description |
|
|
118
|
+
|---------|-------------|
|
|
119
|
+
| `lens daemon start` | Start the HTTP daemon on :4111 |
|
|
120
|
+
| `lens daemon stop` | Stop the running daemon |
|
|
121
|
+
| `lens daemon stats` | Show global statistics |
|
|
122
|
+
| `lens repo register` | Register current repo for indexing |
|
|
123
|
+
| `lens repo list` | List registered repos |
|
|
124
|
+
| `lens repo remove` | Remove current repo |
|
|
125
|
+
| `lens repo watch` | Start file watcher for current repo |
|
|
126
|
+
| `lens repo unwatch` | Stop file watcher for current repo |
|
|
127
|
+
| `lens repo watch-status` | Show watcher status |
|
|
128
|
+
| `lens repo mcp` | Write .mcp.json for agent integration |
|
|
129
|
+
| `lens index` | Index the current repo |
|
|
130
|
+
| `lens context "<goal>"` | Build a context pack for a goal |
|
|
131
|
+
| `lens status` | Show repo index/embedding status |
|
|
132
|
+
| `lens dashboard` | Open local dashboard in browser |
|
|
133
|
+
| `lens login` | Authenticate via OAuth (GitHub/Google) |
|
|
134
|
+
| `lens logout` | Clear cloud authentication |
|
|
135
|
+
| `lens config get <key>` | Get a config value |
|
|
136
|
+
| `lens config set <key> <val>` | Set a config value |
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
MIT
|
package/cli.js
CHANGED
|
@@ -4045,6 +4045,17 @@ async function watchStatusCommand(opts) {
|
|
|
4045
4045
|
}
|
|
4046
4046
|
}
|
|
4047
4047
|
|
|
4048
|
+
// packages/cli/src/commands/mcp.ts
|
|
4049
|
+
async function mcpCommand() {
|
|
4050
|
+
const { root_path } = await detectRepo();
|
|
4051
|
+
const result = injectMcp(root_path);
|
|
4052
|
+
if (result === "exists") {
|
|
4053
|
+
output("LENS MCP entry already present in .mcp.json", false);
|
|
4054
|
+
} else {
|
|
4055
|
+
output("Wrote .mcp.json \u2014 agents will auto-discover LENS", false);
|
|
4056
|
+
}
|
|
4057
|
+
}
|
|
4058
|
+
|
|
4048
4059
|
// packages/cli/src/commands/config.ts
|
|
4049
4060
|
async function configGetCommand(key) {
|
|
4050
4061
|
try {
|
|
@@ -4368,7 +4379,7 @@ async function logoutCommand() {
|
|
|
4368
4379
|
}
|
|
4369
4380
|
|
|
4370
4381
|
// packages/cli/src/index.ts
|
|
4371
|
-
var program2 = new Command().name("lens").description("LENS \u2014 Local-first repo context engine").version("0.1.
|
|
4382
|
+
var program2 = new Command().name("lens").description("LENS \u2014 Local-first repo context engine").version("0.1.14");
|
|
4372
4383
|
function trackCommand(name) {
|
|
4373
4384
|
if (!isTelemetryEnabled()) return;
|
|
4374
4385
|
const BASE_URL2 = process.env.LENS_HOST ?? "http://127.0.0.1:4111";
|
|
@@ -4387,6 +4398,7 @@ repo.command("remove").description("Remove current repo and all its data").optio
|
|
|
4387
4398
|
repo.command("watch").description("Start file watcher for current repo").option("--json", "Output as JSON", false).action((opts) => run(() => watchCommand(opts)));
|
|
4388
4399
|
repo.command("unwatch").description("Stop file watcher for current repo").option("--json", "Output as JSON", false).action((opts) => run(() => unwatchCommand(opts)));
|
|
4389
4400
|
repo.command("watch-status").description("Show file watcher status for current repo").option("--json", "Output as JSON", false).action((opts) => run(() => watchStatusCommand(opts)));
|
|
4401
|
+
repo.command("mcp").description("Write .mcp.json for MCP agent integration").action(() => run(() => mcpCommand()));
|
|
4390
4402
|
program2.command("context <goal>").description("Build an intelligent context pack for a goal").option("--json", "Output as JSON", false).action((goal, opts) => run(() => contextCommand(goal, opts), "context"));
|
|
4391
4403
|
program2.command("index").description("Index the current repo").option("--json", "Output as JSON", false).option("--force", "Full re-scan (default: diff scan, changed files only)", false).option("--status", "Show index status", false).action((opts) => run(() => indexCommand(opts), "index"));
|
|
4392
4404
|
program2.command("status").description("Show repo index/embedding status").option("--json", "Output as JSON", false).action((opts) => run(() => statusCommand(opts), "status"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lens-engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "LENS — Local-first repo context engine for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
"node": ">=20"
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
|
-
"homepage": "https://
|
|
18
|
+
"homepage": "https://lens-engine.com"
|
|
19
19
|
}
|