ai-lens 0.8.108 → 0.8.109
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/.commithash +1 -1
- package/CHANGELOG.md +3 -0
- package/cli/init.js +47 -8
- package/package.json +1 -1
package/.commithash
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
99dee20
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
History of changes to the `ai-lens` CLI package on npm. New entries go on top. Format: `## X.Y.Z — YYYY-MM-DD`, followed by user-facing bullets.
|
|
4
4
|
|
|
5
|
+
## 0.8.109 — 2026-06-22
|
|
6
|
+
- fix: `init --yes` no longer captures every project or silently imports your local Claude history. It now scopes capture to the git root of the current folder (still `--projects all` for everything), and imports past history only when you pass `--import`.
|
|
7
|
+
|
|
5
8
|
## 0.8.108 — 2026-06-22
|
|
6
9
|
- feat: `ai-lens init --mcp-only` registers just the MCP server in Claude Code and Cursor — for when you only need to read sessions from Claude, not capture hooks. It skips hook setup, authentication, and history import. The MCP scope now mirrors how AI Lens is installed: a local/project install registers the MCP at project scope, a global install at user scope (local wins if both are present); pass `--mcp-scope` to override.
|
|
7
10
|
- change: `init --project-hooks` now also registers the MCP at project scope (Claude `local` + the project `.cursor/mcp.json`) to match where it writes hooks, instead of always registering globally. Pass `--mcp-scope` to override.
|
package/cli/init.js
CHANGED
|
@@ -35,6 +35,37 @@ function ask(question) {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
// Default `projects` scope for `init --yes` on a FRESH config: the git root of
|
|
39
|
+
// cwd (the dev's work tree — the workspace when init is run there). Returns null
|
|
40
|
+
// when cwd isn't inside a git repo (e.g. bot containers under /app) → capture-all,
|
|
41
|
+
// which stays safe because the 90-day history import is separately gated to
|
|
42
|
+
// opt-in (importMode).
|
|
43
|
+
//
|
|
44
|
+
// Uses the INNERMOST git root (`git rev-parse --show-toplevel`), NOT an outermost
|
|
45
|
+
// walk-up: a `~/.git` dotfiles repo must never escalate the scope to $HOME (that
|
|
46
|
+
// would re-introduce capture-all + a personal-history import). Without this,
|
|
47
|
+
// `init --yes` left projects=null (= capture ALL).
|
|
48
|
+
export function defaultProjectsScope(cwd = process.cwd()) {
|
|
49
|
+
try {
|
|
50
|
+
const root = execSync('git rev-parse --show-toplevel', {
|
|
51
|
+
cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'],
|
|
52
|
+
}).trim();
|
|
53
|
+
return root || null;
|
|
54
|
+
} catch {
|
|
55
|
+
return null; // not a git repo (or git unavailable) → keep capture-all
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// History-import decision for `init`. Opt-in by design: `--import` runs it,
|
|
60
|
+
// interactive prompts, and `--yes` SKIPS (it used to auto-run, which silently
|
|
61
|
+
// imported the full 90-day ~/.claude history including personal projects).
|
|
62
|
+
// `--no-import` is handled earlier (skips outright before the preview).
|
|
63
|
+
export function importMode(flags = {}) {
|
|
64
|
+
if (flags.importHistory) return 'run'; // explicit opt-in (highest priority)
|
|
65
|
+
if (flags.yes) return 'skip'; // non-interactive: never auto-import
|
|
66
|
+
return 'prompt'; // interactive: ask
|
|
67
|
+
}
|
|
68
|
+
|
|
38
69
|
function getJson(url) {
|
|
39
70
|
return new Promise((resolve, reject) => {
|
|
40
71
|
const parsed = new URL(url);
|
|
@@ -743,7 +774,11 @@ export default async function init() {
|
|
|
743
774
|
if (flags.projects) {
|
|
744
775
|
projects = flags.projects;
|
|
745
776
|
} else if (auto) {
|
|
746
|
-
|
|
777
|
+
// Fresh config under --yes: default to the git root of cwd (the work tree),
|
|
778
|
+
// not null. null = capture ALL projects. Stays null only when cwd isn't a
|
|
779
|
+
// git repo (bots/containers) — safe because the import is separately gated.
|
|
780
|
+
// `--projects all` is the explicit opt-in for capture-everything.
|
|
781
|
+
projects = currentProjects || projectHooksDefault || defaultProjectsScope();
|
|
747
782
|
} else {
|
|
748
783
|
const projectsDefault = currentProjects || projectHooksDefault || 'all';
|
|
749
784
|
const projectsInput = await ask(
|
|
@@ -1406,7 +1441,8 @@ export default async function init() {
|
|
|
1406
1441
|
|
|
1407
1442
|
/**
|
|
1408
1443
|
* After a successful init, offer to import the developer's local Claude Code
|
|
1409
|
-
* history. `--no-import` skips; `--import`
|
|
1444
|
+
* history. `--no-import` skips; `--import` runs it without prompting; `--yes`
|
|
1445
|
+
* does NOT import (opt-in only — avoids silently pulling personal history);
|
|
1410
1446
|
* otherwise asks interactively. No-op if there's no `~/.claude/projects`.
|
|
1411
1447
|
*/
|
|
1412
1448
|
async function maybeOfferImportHistory(flags) {
|
|
@@ -1429,18 +1465,21 @@ async function maybeOfferImportHistory(flags) {
|
|
|
1429
1465
|
? `Found ${preview.count} Claude Code session${preview.count === 1 ? '' : 's'} from ${day(preview.earliest)} to ${day(preview.latest)} (last 90d).`
|
|
1430
1466
|
: 'Local Claude Code history found.';
|
|
1431
1467
|
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1468
|
+
info(` ${previewLine}`);
|
|
1469
|
+
// History import is opt-IN (importMode): `--import` runs, interactive asks,
|
|
1470
|
+
// `--yes` SKIPS. `--yes` used to auto-import (`|| flags.yes`), silently pulling
|
|
1471
|
+
// the full 90-day ~/.claude history (incl. personal projects) on a fresh config.
|
|
1472
|
+
const mode = importMode(flags);
|
|
1473
|
+
let run = mode === 'run';
|
|
1474
|
+
if (mode === 'prompt') {
|
|
1436
1475
|
try {
|
|
1437
|
-
const answer = (await ask(
|
|
1476
|
+
const answer = (await ask(' Import now? (Y/n) ')).toLowerCase();
|
|
1438
1477
|
run = answer === '' || answer === 'y' || answer === 'yes';
|
|
1439
1478
|
} catch { run = false; }
|
|
1440
1479
|
}
|
|
1441
1480
|
if (!run) {
|
|
1442
1481
|
blank();
|
|
1443
|
-
info(' Skipped import. Run `npx -y ai-lens import claude-code`
|
|
1482
|
+
info(' Skipped local history import. Run `npx -y ai-lens import claude-code` (or pass `--import`) to bring it in.');
|
|
1444
1483
|
return;
|
|
1445
1484
|
}
|
|
1446
1485
|
|