@ridit/lens 0.3.1 → 0.3.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ridit/lens",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Know Your Codebase.",
5
5
  "author": "Ridit Jangra <riditjangra09@gmail.com> (https://ridit.space)",
6
6
  "license": "MIT",
@@ -144,7 +144,7 @@ Rules:
144
144
  - Skip bullets that just restate the subject line or describe trivial version bumps
145
145
  - Be specific — mention file names, feature names, component names
146
146
  - No markdown, no backticks, no code blocks
147
- - Output ONLY the commit message, nothing else
147
+ - Output ONLY the commit message, nothing else — no preamble, no explanation, no thinking
148
148
 
149
149
  Examples of good short commits:
150
150
  chore: bump version to 0.1.6
@@ -158,6 +158,13 @@ feat(chat): add persistent memory across sessions
158
158
  - inject memory summary into system prompt on load
159
159
  - expose /memory commands for manual management`;
160
160
 
161
+ function stripThinking(raw: string): string {
162
+ return raw
163
+ .replace(/<thinking>[\s\S]*?<\/thinking>/g, "")
164
+ .replace(/^[\s\n]+/, "")
165
+ .trim();
166
+ }
167
+
161
168
  async function generateCommitMessage(
162
169
  provider: Provider,
163
170
  diff: string,
@@ -170,7 +177,8 @@ async function generateCommitMessage(
170
177
  },
171
178
  ];
172
179
  const raw = await callChat(provider, SYSTEM_PROMPT, msgs);
173
- return typeof raw === "string" ? raw.trim() : "chore: update files";
180
+ if (typeof raw !== "string") return "chore: update files";
181
+ return stripThinking(raw) || "chore: update files";
174
182
  }
175
183
 
176
184
  function trunc(s: string, n: number) {
@@ -369,11 +377,9 @@ function CommitRunner({
369
377
  <Text color={ACCENT} bold>
370
378
  ◈ COMMIT
371
379
  </Text>
372
- <Text color="gray" dimColor>
373
- {cwd}
374
- </Text>
380
+ <Text color="gray">{cwd}</Text>
375
381
  {files.length > 0 && (
376
- <Text color={CYAN} dimColor>
382
+ <Text color={CYAN}>
377
383
  {files.length} file{files.length !== 1 ? "s" : ""}
378
384
  </Text>
379
385
  )}
@@ -383,32 +389,26 @@ function CommitRunner({
383
389
  <Box flexDirection="column" marginBottom={1}>
384
390
  {files.map((f, i) => (
385
391
  <Box key={i} gap={1}>
386
- <Text color="gray" dimColor>
387
- {" ·"}
388
- </Text>
392
+ <Text color="gray">{" ·"}</Text>
389
393
  <Text color="white">{f}</Text>
390
394
  </Box>
391
395
  ))}
392
396
  </Box>
393
397
  )}
394
398
 
395
- <Text color="gray" dimColor>
396
- {div}
397
- </Text>
399
+ <Text color="gray">{div}</Text>
398
400
 
399
401
  {phase.type === "checking" && (
400
402
  <Box gap={1} marginTop={1}>
401
403
  <Text color={ACCENT}>*</Text>
402
- <Text color="gray" dimColor>
403
- checking changes…
404
- </Text>
404
+ <Text color="gray">checking changes…</Text>
405
405
  </Box>
406
406
  )}
407
407
 
408
408
  {phase.type === "staging" && (
409
409
  <Box gap={1} marginTop={1}>
410
410
  <Text color={ACCENT}>*</Text>
411
- <Text color="gray" dimColor>
411
+ <Text color="gray">
412
412
  {phase.files.length > 0
413
413
  ? `staging ${phase.files.length} file${phase.files.length !== 1 ? "s" : ""}…`
414
414
  : "staging all changes…"}
@@ -433,11 +433,9 @@ function CommitRunner({
433
433
  </Box>
434
434
  {phase.hasUnstaged && (
435
435
  <Box flexDirection="column" marginLeft={2} gap={1}>
436
- <Text color="gray" dimColor>
437
- you have unstaged changes. try:
438
- </Text>
436
+ <Text color="gray">you have unstaged changes. try:</Text>
439
437
  {phase.files.length > 0 ? (
440
- <Text color="gray" dimColor>
438
+ <Text color="gray">
441
439
  {" "}
442
440
  <Text color={ACCENT}>
443
441
  lens commit {phase.files.join(" ")}
@@ -445,7 +443,7 @@ function CommitRunner({
445
443
  {" "}(stages and commits those files)
446
444
  </Text>
447
445
  ) : (
448
- <Text color="gray" dimColor>
446
+ <Text color="gray">
449
447
  {" "}
450
448
  <Text color={ACCENT}>git add {"<files>"}</Text>
451
449
  {" "}or{" "}
@@ -483,27 +481,23 @@ function CommitRunner({
483
481
  </Box>
484
482
  {phase.splitGroups.length > 0 && (
485
483
  <Box flexDirection="column" marginLeft={2} marginBottom={1}>
486
- <Text color="yellow" dimColor>
484
+ <Text color="yellow">
487
485
  ⚡ large diff — consider splitting into{" "}
488
486
  {phase.splitGroups.length} commits:
489
487
  </Text>
490
488
  {phase.splitGroups.map((g, i) => (
491
- <Text key={i} color="gray" dimColor>
489
+ <Text key={i} color="gray">
492
490
  {" · "}
493
491
  {g}
494
492
  </Text>
495
493
  ))}
496
494
  </Box>
497
495
  )}
498
- <Text color="gray" dimColor>
499
- {div}
500
- </Text>
496
+ <Text color="gray">{div}</Text>
501
497
  <Box gap={3} marginTop={1}>
502
498
  <Text color={GREEN}>y/enter commit</Text>
503
499
  <Text color={CYAN}>e edit</Text>
504
- <Text color="gray" dimColor>
505
- n/esc cancel
506
- </Text>
500
+ <Text color="gray">n/esc cancel</Text>
507
501
  </Box>
508
502
  </Box>
509
503
  )}
@@ -534,9 +528,7 @@ function CommitRunner({
534
528
  )
535
529
  }
536
530
  />
537
- <Text color="gray" dimColor>
538
- enter confirm · esc back
539
- </Text>
531
+ <Text color="gray">enter confirm · esc back</Text>
540
532
  </Box>
541
533
  </Box>
542
534
  )}
@@ -544,9 +536,7 @@ function CommitRunner({
544
536
  {phase.type === "committing" && (
545
537
  <Box gap={1} marginTop={1}>
546
538
  <Text color={ACCENT}>*</Text>
547
- <Text color="gray" dimColor>
548
- committing…
549
- </Text>
539
+ <Text color="gray">committing…</Text>
550
540
  </Box>
551
541
  )}
552
542
 
@@ -561,9 +551,7 @@ function CommitRunner({
561
551
  </Box>
562
552
  <Box gap={1} marginLeft={2}>
563
553
  <Text color={ACCENT}>*</Text>
564
- <Text color="gray" dimColor>
565
- pushing…
566
- </Text>
554
+ <Text color="gray">pushing…</Text>
567
555
  </Box>
568
556
  </Box>
569
557
  )}
@@ -582,21 +570,17 @@ function CommitRunner({
582
570
  .slice(2)
583
571
  .filter(Boolean)
584
572
  .map((line, i) => (
585
- <Text key={i} color="gray" dimColor>
573
+ <Text key={i} color="gray">
586
574
  {line}
587
575
  </Text>
588
576
  ))}
589
577
  {phase.pushed && (
590
578
  <Box gap={2} marginTop={1}>
591
579
  <Text color={GREEN}>{figures.tick}</Text>
592
- <Text color="gray" dimColor>
593
- pushed to remote
594
- </Text>
580
+ <Text color="gray">pushed to remote</Text>
595
581
  </Box>
596
582
  )}
597
- <Text color="gray" dimColor>
598
- press any key to exit
599
- </Text>
583
+ <Text color="gray">press any key to exit</Text>
600
584
  </Box>
601
585
  )}
602
586
 
@@ -612,9 +596,7 @@ function CommitRunner({
612
596
  </Text>
613
597
  ))}
614
598
  </Box>
615
- <Text color="gray" dimColor>
616
- (preview only — not committed)
617
- </Text>
599
+ <Text color="gray">(preview only — not committed)</Text>
618
600
  </Box>
619
601
  )}
620
602
 
@@ -628,7 +610,7 @@ function CommitRunner({
628
610
  .split("\n")
629
611
  .slice(1)
630
612
  .map((line, i) => (
631
- <Text key={i} color="gray" dimColor>
613
+ <Text key={i} color="gray">
632
614
  {line}
633
615
  </Text>
634
616
  ))}
@@ -0,0 +1,56 @@
1
+ import React from "react";
2
+ import { Box, Text } from "ink";
3
+ import figures from "figures";
4
+ import path from "path";
5
+ import { existsSync } from "fs";
6
+ import { WatchRunner } from "../components/watch/WatchRunner";
7
+ import { RED } from "../colors";
8
+
9
+ interface Props {
10
+ cmd: string;
11
+ path: string;
12
+ clean: boolean;
13
+ fixAll: boolean;
14
+ autoRestart: boolean;
15
+ prompt?: string;
16
+ }
17
+
18
+ export function WatchCommand({
19
+ cmd,
20
+ path: inputPath,
21
+ clean,
22
+ fixAll,
23
+ autoRestart,
24
+ prompt,
25
+ }: Props) {
26
+ const repoPath = path.resolve(inputPath);
27
+
28
+ if (!cmd.trim()) {
29
+ return (
30
+ <Box marginTop={1}>
31
+ <Text color={RED}>{figures.cross} Usage: lens watch "bun dev"</Text>
32
+ </Box>
33
+ );
34
+ }
35
+
36
+ if (!existsSync(repoPath)) {
37
+ return (
38
+ <Box marginTop={1}>
39
+ <Text color={RED}>
40
+ {figures.cross} Path not found: {repoPath}
41
+ </Text>
42
+ </Box>
43
+ );
44
+ }
45
+
46
+ return (
47
+ <WatchRunner
48
+ cmd={cmd}
49
+ repoPath={repoPath}
50
+ clean={clean}
51
+ fixAll={fixAll}
52
+ autoRestart={autoRestart}
53
+ extraPrompt={prompt}
54
+ />
55
+ );
56
+ }
@@ -1179,7 +1179,6 @@ export function TimelineRunner({
1179
1179
 
1180
1180
  return (
1181
1181
  <Box flexDirection="column">
1182
- {/* header */}
1183
1182
  <Box gap={2} marginBottom={1}>
1184
1183
  <Text color={ACCENT} bold>
1185
1184
  ◈ TIMELINE
@@ -1195,7 +1194,6 @@ export function TimelineRunner({
1195
1194
  )}
1196
1195
  </Box>
1197
1196
 
1198
- {/* status messages */}
1199
1197
  <Static items={statusMsgs}>
1200
1198
  {(msg) => (
1201
1199
  <Box key={msg.id} paddingX={1} gap={1}>
@@ -1205,7 +1203,6 @@ export function TimelineRunner({
1205
1203
  )}
1206
1204
  </Static>
1207
1205
 
1208
- {/* search bar */}
1209
1206
  {isSearching && (
1210
1207
  <Box gap={1} marginBottom={1}>
1211
1208
  <Text color={ACCENT}>{"/"}</Text>
@@ -1218,7 +1215,6 @@ export function TimelineRunner({
1218
1215
  </Box>
1219
1216
  )}
1220
1217
 
1221
- {/* commit list */}
1222
1218
  {visible.map((commit, i) => {
1223
1219
  const absIdx = scrollOffset + i;
1224
1220
  const isSel = absIdx === selectedIdx;
@@ -1251,7 +1247,6 @@ export function TimelineRunner({
1251
1247
  </Box>
1252
1248
  )}
1253
1249
 
1254
- {/* revert overlay */}
1255
1250
  {isReverting && mode.type === "revert" && (
1256
1251
  <RevertConfirm
1257
1252
  commit={mode.commit}
@@ -1268,7 +1263,6 @@ export function TimelineRunner({
1268
1263
  />
1269
1264
  )}
1270
1265
 
1271
- {/* ask panel */}
1272
1266
  {isAsking && provider && (
1273
1267
  <AskPanel
1274
1268
  commits={commits}
@@ -1281,7 +1275,6 @@ export function TimelineRunner({
1281
1275
  />
1282
1276
  )}
1283
1277
 
1284
- {/* shortcut bar */}
1285
1278
  <Box marginTop={1}>
1286
1279
  <Text color="gray" dimColor>
1287
1280
  {shortcutHint}