lens-engine 0.1.15 → 0.1.17
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/cli.js +284 -24
- package/daemon.js +964 -324
- package/dashboard/assets/index-B-FwfnUH.css +1 -0
- package/dashboard/assets/index-Bgjp5TLX.js +341 -0
- package/dashboard/index.html +2 -2
- package/package.json +1 -1
- package/dashboard/assets/index-DDXq5eat.js +0 -232
- package/dashboard/assets/index-UUQ9jgzS.css +0 -1
package/cli.js
CHANGED
|
@@ -3402,9 +3402,11 @@ async function request(method, path4, body, retries = 3) {
|
|
|
3402
3402
|
for (let i = 0; i < retries; i++) {
|
|
3403
3403
|
let res;
|
|
3404
3404
|
try {
|
|
3405
|
+
const headers = { "User-Agent": "lens-cli" };
|
|
3406
|
+
if (body) headers["Content-Type"] = "application/json";
|
|
3405
3407
|
res = await fetch(url, {
|
|
3406
3408
|
method,
|
|
3407
|
-
headers
|
|
3409
|
+
headers,
|
|
3408
3410
|
body: body ? JSON.stringify(body) : void 0,
|
|
3409
3411
|
signal: AbortSignal.timeout(6e4)
|
|
3410
3412
|
// 60s timeout
|
|
@@ -4237,21 +4239,261 @@ function chooserPage(port) {
|
|
|
4237
4239
|
}
|
|
4238
4240
|
function callbackPage() {
|
|
4239
4241
|
return `<!DOCTYPE html>
|
|
4240
|
-
<html><head><meta charset="utf-8"><title>LENS Login</title>
|
|
4242
|
+
<html lang="en" class="dark"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>LENS Dashboard Login</title>
|
|
4241
4243
|
<style>
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4244
|
+
:root {
|
|
4245
|
+
--background: #171717;
|
|
4246
|
+
--foreground: #fafafa;
|
|
4247
|
+
--card: #212121;
|
|
4248
|
+
--card-foreground: #f5f5f5;
|
|
4249
|
+
--muted: #2d2d2d;
|
|
4250
|
+
--muted-foreground: #a1a1aa;
|
|
4251
|
+
--border: rgba(255, 255, 255, 0.1);
|
|
4252
|
+
--ring: rgba(255, 255, 255, 0.2);
|
|
4253
|
+
--primary: #ebebeb;
|
|
4254
|
+
--primary-foreground: #222222;
|
|
4255
|
+
--success: #55d6a5;
|
|
4256
|
+
--destructive: #ff8c8c;
|
|
4257
|
+
--network-line: 125, 211, 252;
|
|
4258
|
+
--network-node: 207, 239, 255;
|
|
4259
|
+
}
|
|
4260
|
+
* { box-sizing: border-box; }
|
|
4261
|
+
html, body { width: 100%; height: 100%; margin: 0; }
|
|
4262
|
+
body {
|
|
4263
|
+
position: relative;
|
|
4264
|
+
overflow: hidden;
|
|
4265
|
+
display: grid;
|
|
4266
|
+
place-items: center;
|
|
4267
|
+
background: radial-gradient(circle at 20% 0%, #222222 0%, transparent 40%), var(--background);
|
|
4268
|
+
color: var(--foreground);
|
|
4269
|
+
font-family: "Inter Variable", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
4270
|
+
letter-spacing: -0.01em;
|
|
4271
|
+
}
|
|
4272
|
+
#network {
|
|
4273
|
+
position: absolute;
|
|
4274
|
+
inset: 0;
|
|
4275
|
+
width: 100%;
|
|
4276
|
+
height: 100%;
|
|
4277
|
+
opacity: 0.74;
|
|
4278
|
+
}
|
|
4279
|
+
.overlay {
|
|
4280
|
+
position: absolute;
|
|
4281
|
+
inset: 0;
|
|
4282
|
+
background:
|
|
4283
|
+
radial-gradient(circle at center, transparent 20%, rgba(0, 0, 0, 0.44) 82%),
|
|
4284
|
+
linear-gradient(180deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.26));
|
|
4285
|
+
pointer-events: none;
|
|
4286
|
+
}
|
|
4287
|
+
.inner {
|
|
4288
|
+
position: relative;
|
|
4289
|
+
z-index: 1;
|
|
4290
|
+
width: min(500px, calc(100vw - 2rem));
|
|
4291
|
+
border-radius: 0.75rem;
|
|
4292
|
+
border: 1px solid var(--border);
|
|
4293
|
+
background: color-mix(in srgb, var(--card) 88%, transparent);
|
|
4294
|
+
color: var(--card-foreground);
|
|
4295
|
+
padding: 1.25rem 1.25rem 1.15rem;
|
|
4296
|
+
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.42);
|
|
4297
|
+
backdrop-filter: blur(5px);
|
|
4298
|
+
}
|
|
4299
|
+
.brand {
|
|
4300
|
+
display: flex;
|
|
4301
|
+
align-items: center;
|
|
4302
|
+
gap: 0.7rem;
|
|
4303
|
+
text-align: left;
|
|
4304
|
+
}
|
|
4305
|
+
.brand-mark {
|
|
4306
|
+
display: inline-flex;
|
|
4307
|
+
align-items: center;
|
|
4308
|
+
justify-content: center;
|
|
4309
|
+
width: 2rem;
|
|
4310
|
+
height: 2rem;
|
|
4311
|
+
border-radius: 0.5rem;
|
|
4312
|
+
font-size: 0.82rem;
|
|
4313
|
+
font-weight: 700;
|
|
4314
|
+
background: var(--primary);
|
|
4315
|
+
color: var(--primary-foreground);
|
|
4316
|
+
}
|
|
4317
|
+
.brand-copy {
|
|
4318
|
+
display: grid;
|
|
4319
|
+
gap: 0.08rem;
|
|
4320
|
+
}
|
|
4321
|
+
.brand-copy strong {
|
|
4322
|
+
font-size: 0.9rem;
|
|
4323
|
+
line-height: 1;
|
|
4324
|
+
}
|
|
4325
|
+
.brand-copy span {
|
|
4326
|
+
color: var(--muted-foreground);
|
|
4327
|
+
font-size: 0.72rem;
|
|
4328
|
+
}
|
|
4329
|
+
h1 {
|
|
4330
|
+
margin: 1.05rem 0 0;
|
|
4331
|
+
font-size: clamp(1.2rem, 2.1vw, 1.55rem);
|
|
4332
|
+
letter-spacing: -0.02em;
|
|
4333
|
+
font-weight: 600;
|
|
4334
|
+
text-align: left;
|
|
4335
|
+
}
|
|
4336
|
+
p {
|
|
4337
|
+
margin: 0.55rem 0 0;
|
|
4338
|
+
color: var(--muted-foreground);
|
|
4339
|
+
font-size: 0.9rem;
|
|
4340
|
+
line-height: 1.5;
|
|
4341
|
+
text-align: left;
|
|
4342
|
+
}
|
|
4343
|
+
.status-chip {
|
|
4344
|
+
margin-top: 0.95rem;
|
|
4345
|
+
display: inline-flex;
|
|
4346
|
+
align-items: center;
|
|
4347
|
+
gap: 0.5rem;
|
|
4348
|
+
border: 1px solid var(--border);
|
|
4349
|
+
background: var(--muted);
|
|
4350
|
+
border-radius: 999px;
|
|
4351
|
+
padding: 0.26rem 0.6rem;
|
|
4352
|
+
color: #d4d4d8;
|
|
4353
|
+
font-size: 0.74rem;
|
|
4354
|
+
line-height: 1;
|
|
4355
|
+
}
|
|
4356
|
+
.status-dot {
|
|
4357
|
+
width: 0.5rem;
|
|
4358
|
+
height: 0.5rem;
|
|
4359
|
+
border-radius: 999px;
|
|
4360
|
+
background: #d4d4d8;
|
|
4361
|
+
color: rgba(212, 212, 216, 0.5);
|
|
4362
|
+
box-shadow: 0 0 0 0 currentColor;
|
|
4363
|
+
animation: ping 1.6s ease-out infinite;
|
|
4364
|
+
}
|
|
4365
|
+
.status-dot.ok {
|
|
4366
|
+
background: var(--success);
|
|
4367
|
+
color: rgba(85, 214, 165, 0.55);
|
|
4368
|
+
}
|
|
4369
|
+
.status-dot.err {
|
|
4370
|
+
background: var(--destructive);
|
|
4371
|
+
color: rgba(255, 140, 140, 0.58);
|
|
4372
|
+
}
|
|
4373
|
+
@keyframes ping {
|
|
4374
|
+
0% { box-shadow: 0 0 0 0 currentColor; }
|
|
4375
|
+
70% { box-shadow: 0 0 0 11px rgba(0, 0, 0, 0); }
|
|
4376
|
+
100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); }
|
|
4377
|
+
}
|
|
4378
|
+
@media (max-width: 560px) {
|
|
4379
|
+
.inner { padding: 1rem; }
|
|
4380
|
+
.brand-mark { width: 1.8rem; height: 1.8rem; }
|
|
4381
|
+
h1 { font-size: 1.08rem; }
|
|
4382
|
+
p { font-size: 0.84rem; }
|
|
4383
|
+
}
|
|
4246
4384
|
</style></head><body>
|
|
4247
|
-
<
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4385
|
+
<canvas id="network" aria-hidden="true"></canvas>
|
|
4386
|
+
<div class="overlay" aria-hidden="true"></div>
|
|
4387
|
+
<main class="inner" role="status" aria-live="polite">
|
|
4388
|
+
<div class="brand">
|
|
4389
|
+
<div class="brand-mark">L</div>
|
|
4390
|
+
<div class="brand-copy"><strong>LENS</strong><span>Workspace</span></div>
|
|
4391
|
+
</div>
|
|
4392
|
+
<h1 id="title">Authenticating...</h1>
|
|
4393
|
+
<p id="msg">Processing OAuth callback tokens.</p>
|
|
4394
|
+
<div class="status-chip"><span class="status-dot" id="pulse"></span><span id="submsg">Securing local session</span></div>
|
|
4395
|
+
</main>
|
|
4251
4396
|
<script>
|
|
4397
|
+
(() => {
|
|
4398
|
+
const canvas = document.getElementById("network");
|
|
4399
|
+
if (!canvas || !canvas.getContext) return;
|
|
4400
|
+
|
|
4401
|
+
const ctx = canvas.getContext("2d");
|
|
4402
|
+
if (!ctx) return;
|
|
4403
|
+
|
|
4404
|
+
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
|
4405
|
+
let width = 0;
|
|
4406
|
+
let height = 0;
|
|
4407
|
+
let nodes = [];
|
|
4408
|
+
let maxDist = 150;
|
|
4409
|
+
const lineColor = "125, 211, 252";
|
|
4410
|
+
const nodeColor = "207, 239, 255";
|
|
4411
|
+
|
|
4412
|
+
function seedNodes() {
|
|
4413
|
+
const count = Math.max(34, Math.min(84, Math.floor((width * height) / 18000)));
|
|
4414
|
+
nodes = Array.from({ length: count }, () => ({
|
|
4415
|
+
x: Math.random() * width,
|
|
4416
|
+
y: Math.random() * height,
|
|
4417
|
+
vx: (Math.random() - 0.5) * 0.32,
|
|
4418
|
+
vy: (Math.random() - 0.5) * 0.32,
|
|
4419
|
+
r: 1 + Math.random() * 1.25,
|
|
4420
|
+
}));
|
|
4421
|
+
}
|
|
4422
|
+
|
|
4423
|
+
function resize() {
|
|
4424
|
+
width = window.innerWidth;
|
|
4425
|
+
height = window.innerHeight;
|
|
4426
|
+
canvas.width = Math.floor(width * dpr);
|
|
4427
|
+
canvas.height = Math.floor(height * dpr);
|
|
4428
|
+
canvas.style.width = width + "px";
|
|
4429
|
+
canvas.style.height = height + "px";
|
|
4430
|
+
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
4431
|
+
maxDist = Math.max(130, Math.min(210, Math.min(width, height) * 0.26));
|
|
4432
|
+
seedNodes();
|
|
4433
|
+
}
|
|
4434
|
+
|
|
4435
|
+
function animate() {
|
|
4436
|
+
ctx.clearRect(0, 0, width, height);
|
|
4437
|
+
|
|
4438
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
4439
|
+
const a = nodes[i];
|
|
4440
|
+
a.x += a.vx;
|
|
4441
|
+
a.y += a.vy;
|
|
4442
|
+
|
|
4443
|
+
if (a.x <= 0 || a.x >= width) a.vx *= -1;
|
|
4444
|
+
if (a.y <= 0 || a.y >= height) a.vy *= -1;
|
|
4445
|
+
|
|
4446
|
+
for (let j = i + 1; j < nodes.length; j++) {
|
|
4447
|
+
const b = nodes[j];
|
|
4448
|
+
const dx = a.x - b.x;
|
|
4449
|
+
const dy = a.y - b.y;
|
|
4450
|
+
const dist = Math.hypot(dx, dy);
|
|
4451
|
+
if (dist > maxDist) continue;
|
|
4452
|
+
|
|
4453
|
+
const alpha = Math.pow(1 - dist / maxDist, 2) * 0.62;
|
|
4454
|
+
ctx.strokeStyle = "rgba(" + lineColor + ", " + alpha.toFixed(3) + ")";
|
|
4455
|
+
ctx.lineWidth = 0.78;
|
|
4456
|
+
ctx.beginPath();
|
|
4457
|
+
ctx.moveTo(a.x, a.y);
|
|
4458
|
+
ctx.lineTo(b.x, b.y);
|
|
4459
|
+
ctx.stroke();
|
|
4460
|
+
}
|
|
4461
|
+
}
|
|
4462
|
+
|
|
4463
|
+
for (const n of nodes) {
|
|
4464
|
+
ctx.beginPath();
|
|
4465
|
+
ctx.arc(n.x, n.y, n.r, 0, Math.PI * 2);
|
|
4466
|
+
ctx.fillStyle = "rgba(" + nodeColor + ", 0.93)";
|
|
4467
|
+
ctx.fill();
|
|
4468
|
+
}
|
|
4469
|
+
|
|
4470
|
+
requestAnimationFrame(animate);
|
|
4471
|
+
}
|
|
4472
|
+
|
|
4473
|
+
resize();
|
|
4474
|
+
window.addEventListener("resize", resize);
|
|
4475
|
+
requestAnimationFrame(animate);
|
|
4476
|
+
})();
|
|
4477
|
+
|
|
4252
4478
|
(async () => {
|
|
4479
|
+
const title = document.getElementById("title");
|
|
4253
4480
|
const msg = document.getElementById("msg");
|
|
4481
|
+
const submsg = document.getElementById("submsg");
|
|
4482
|
+
const pulse = document.getElementById("pulse");
|
|
4483
|
+
|
|
4484
|
+
function setState(headline, detail, subDetail, tone) {
|
|
4485
|
+
if (title) title.textContent = headline;
|
|
4486
|
+
if (msg) msg.textContent = detail;
|
|
4487
|
+
if (submsg) submsg.textContent = subDetail || "";
|
|
4488
|
+
if (pulse) {
|
|
4489
|
+
pulse.classList.remove("ok", "err");
|
|
4490
|
+
if (tone) pulse.classList.add(tone);
|
|
4491
|
+
}
|
|
4492
|
+
}
|
|
4493
|
+
|
|
4254
4494
|
try {
|
|
4495
|
+
setState("Authenticating...", "Validating callback token payload.", "Contacting identity service");
|
|
4496
|
+
|
|
4255
4497
|
const hash = window.location.hash.substring(1);
|
|
4256
4498
|
const params = new URLSearchParams(hash);
|
|
4257
4499
|
const access_token = params.get("access_token");
|
|
@@ -4259,19 +4501,25 @@ function callbackPage() {
|
|
|
4259
4501
|
const expires_in = params.get("expires_in");
|
|
4260
4502
|
|
|
4261
4503
|
if (!access_token) {
|
|
4262
|
-
|
|
4504
|
+
setState("Authentication failed", "No access token received. Please try login again.", "Missing OAuth token", "err");
|
|
4263
4505
|
return;
|
|
4264
4506
|
}
|
|
4265
4507
|
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4508
|
+
let user_email = "unknown";
|
|
4509
|
+
try {
|
|
4510
|
+
const res = await fetch("${SUPABASE_URL}/auth/v1/user", {
|
|
4511
|
+
headers: {
|
|
4512
|
+
"Authorization": "Bearer " + access_token,
|
|
4513
|
+
"apikey": "${SUPABASE_ANON_KEY}"
|
|
4514
|
+
}
|
|
4515
|
+
});
|
|
4516
|
+
if (res.ok) {
|
|
4517
|
+
const user = await res.json();
|
|
4518
|
+
user_email = user && user.email ? user.email : "unknown";
|
|
4271
4519
|
}
|
|
4272
|
-
}
|
|
4273
|
-
|
|
4274
|
-
|
|
4520
|
+
} catch {}
|
|
4521
|
+
|
|
4522
|
+
setState("Initializing workspace...", "Saving secure credentials to local daemon.", "Provisioning CLI session");
|
|
4275
4523
|
|
|
4276
4524
|
const r = await fetch("/token", {
|
|
4277
4525
|
method: "POST",
|
|
@@ -4280,13 +4528,17 @@ function callbackPage() {
|
|
|
4280
4528
|
});
|
|
4281
4529
|
|
|
4282
4530
|
if (r.ok) {
|
|
4283
|
-
|
|
4531
|
+
setState("Success", "Session established. Redirecting to dashboard...", "Opening local dashboard", "ok");
|
|
4532
|
+
setTimeout(() => {
|
|
4533
|
+
window.location.href = "http://127.0.0.1:4111/dashboard/";
|
|
4534
|
+
}, 280);
|
|
4284
4535
|
return;
|
|
4285
|
-
} else {
|
|
4286
|
-
msg.textContent = "Failed to save tokens. Please try again.";
|
|
4287
4536
|
}
|
|
4537
|
+
|
|
4538
|
+
setState("Authentication failed", "Failed to save tokens. Please close this tab and try again.", "Token persistence failed", "err");
|
|
4288
4539
|
} catch (e) {
|
|
4289
|
-
|
|
4540
|
+
const detail = e && typeof e.message === "string" ? e.message : "Unknown error";
|
|
4541
|
+
setState("Authentication failed", "Error: " + detail, "Unexpected callback exception", "err");
|
|
4290
4542
|
}
|
|
4291
4543
|
})();
|
|
4292
4544
|
</script></body></html>`;
|
|
@@ -4328,6 +4580,10 @@ async function loginCommand(opts) {
|
|
|
4328
4580
|
error(`Cloud unreachable: ${e?.message ?? "unknown"}. Daemon will retry on next start.`);
|
|
4329
4581
|
}
|
|
4330
4582
|
await writeAuth(tokens);
|
|
4583
|
+
try {
|
|
4584
|
+
await post("/api/auth/notify");
|
|
4585
|
+
} catch {
|
|
4586
|
+
}
|
|
4331
4587
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
4332
4588
|
res.end(JSON.stringify({ ok: true }));
|
|
4333
4589
|
output(`Logged in as ${user_email}`, false);
|
|
@@ -4375,11 +4631,15 @@ async function loginCommand(opts) {
|
|
|
4375
4631
|
// packages/cli/src/commands/logout.ts
|
|
4376
4632
|
async function logoutCommand() {
|
|
4377
4633
|
await clearAuth();
|
|
4634
|
+
try {
|
|
4635
|
+
await post("/api/auth/notify");
|
|
4636
|
+
} catch {
|
|
4637
|
+
}
|
|
4378
4638
|
output("Logged out of LENS cloud.", false);
|
|
4379
4639
|
}
|
|
4380
4640
|
|
|
4381
4641
|
// packages/cli/src/index.ts
|
|
4382
|
-
var program2 = new Command().name("lens").description("LENS \u2014 Local-first repo context engine").version("0.1.
|
|
4642
|
+
var program2 = new Command().name("lens").description("LENS \u2014 Local-first repo context engine").version("0.1.17");
|
|
4383
4643
|
function trackCommand(name) {
|
|
4384
4644
|
if (!isTelemetryEnabled()) return;
|
|
4385
4645
|
const BASE_URL2 = process.env.LENS_HOST ?? "http://127.0.0.1:4111";
|