@swestash/agent-lens 0.8.2 → 0.8.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/dist/agent-lens.js +21 -16
- package/dist/agent-lens.js.map +1 -1
- package/package.json +1 -1
package/dist/agent-lens.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { existsSync as existsSync9, readFileSync as readFileSync8, writeFileSync as writeFileSync3 } from "fs";
|
|
5
|
-
import { dirname as dirname6, join as
|
|
5
|
+
import { dirname as dirname6, join as join12 } from "path";
|
|
6
6
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
7
7
|
|
|
8
8
|
// ../../node_modules/.pnpm/cac@6.7.14/node_modules/cac/dist/index.mjs
|
|
@@ -1315,6 +1315,12 @@ function resolveDataDir(repoRoot = findRepoRoot()) {
|
|
|
1315
1315
|
return join(repoRoot, "data");
|
|
1316
1316
|
return userDataDir();
|
|
1317
1317
|
}
|
|
1318
|
+
function resolveArchiveDir(repoRoot = findRepoRoot()) {
|
|
1319
|
+
return join(resolveDataDir(repoRoot), "archive");
|
|
1320
|
+
}
|
|
1321
|
+
function triageDbFor(dbPath) {
|
|
1322
|
+
return join(dirname(dbPath), "triage.db");
|
|
1323
|
+
}
|
|
1318
1324
|
function resolveConfigFile(repoRoot, dataDir) {
|
|
1319
1325
|
const candidates = [
|
|
1320
1326
|
process.env.AGENT_LENS_CONFIG,
|
|
@@ -1662,7 +1668,7 @@ function collectSource(source, archiveBase, excludedDirs, runTs, stats, log) {
|
|
|
1662
1668
|
}
|
|
1663
1669
|
function collectAll(opts = {}) {
|
|
1664
1670
|
const log = opts.log ?? ((m) => console.log(m));
|
|
1665
|
-
const archiveBase = opts.archiveBase ??
|
|
1671
|
+
const archiveBase = opts.archiveBase ?? resolveArchiveDir();
|
|
1666
1672
|
const sources = opts.sources ?? loadSources();
|
|
1667
1673
|
const excludedDirs = (opts.excludes ?? loadExcludes()).map(encodeProjectPath);
|
|
1668
1674
|
const runTs = opts.runTimestamp ?? collectTimestamp();
|
|
@@ -4050,8 +4056,7 @@ function parseIngestArgs(argv) {
|
|
|
4050
4056
|
}
|
|
4051
4057
|
function runIngest(argv = process.argv.slice(2)) {
|
|
4052
4058
|
const args = parseIngestArgs(argv);
|
|
4053
|
-
const
|
|
4054
|
-
const archiveRoot = args.archive || process.env.AGENT_LENS_ARCHIVE || join9(dataDir, "archive");
|
|
4059
|
+
const archiveRoot = args.archive || resolveArchiveDir();
|
|
4055
4060
|
const { path: dbPath } = resolveDbPath(args.db);
|
|
4056
4061
|
if (!existsSync4(archiveRoot)) {
|
|
4057
4062
|
console.error(`agent-lens-ingest: archive not found: ${archiveRoot} (run 'agent-lens collect' first)`);
|
|
@@ -4177,7 +4182,7 @@ function runMetrics(argv = process.argv.slice(2)) {
|
|
|
4177
4182
|
|
|
4178
4183
|
// ../server/dist/run.js
|
|
4179
4184
|
import { existsSync as existsSync7 } from "fs";
|
|
4180
|
-
import { dirname as dirname5
|
|
4185
|
+
import { dirname as dirname5 } from "path";
|
|
4181
4186
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
4182
4187
|
|
|
4183
4188
|
// ../server/dist/db.js
|
|
@@ -5059,7 +5064,7 @@ function runRefresh() {
|
|
|
5059
5064
|
return null;
|
|
5060
5065
|
try {
|
|
5061
5066
|
const collected = collectAll();
|
|
5062
|
-
const archiveRoot =
|
|
5067
|
+
const archiveRoot = resolveArchiveDir();
|
|
5063
5068
|
if (!existsSync5(archiveRoot))
|
|
5064
5069
|
mkdirSync5(archiveRoot, { recursive: true });
|
|
5065
5070
|
runIngest([]);
|
|
@@ -5389,7 +5394,7 @@ async function startServer(overrides = {}) {
|
|
|
5389
5394
|
console.error(`agent-lens-server: db not found: ${dbPath} (run ingest first)`);
|
|
5390
5395
|
process.exit(1);
|
|
5391
5396
|
}
|
|
5392
|
-
const triageDbPath =
|
|
5397
|
+
const triageDbPath = triageDbFor(dbPath);
|
|
5393
5398
|
const db = openReadonly(dbPath);
|
|
5394
5399
|
const enforceLoopbackHost = host === "127.0.0.1" || host === "localhost";
|
|
5395
5400
|
const app = await createApp(db, { webDist, triageDbPath, enforceLoopbackHost });
|
|
@@ -5406,11 +5411,11 @@ async function startServer(overrides = {}) {
|
|
|
5406
5411
|
|
|
5407
5412
|
// src/watch.ts
|
|
5408
5413
|
import { existsSync as existsSync8 } from "fs";
|
|
5409
|
-
import { join as
|
|
5414
|
+
import { join as join11 } from "path";
|
|
5410
5415
|
import chokidar from "chokidar";
|
|
5411
5416
|
async function runWatch(opts = {}) {
|
|
5412
5417
|
const sources = loadSources();
|
|
5413
|
-
const lockPath =
|
|
5418
|
+
const lockPath = join11(resolveDataDir(findRepoRoot()), ".agent-lens.lock");
|
|
5414
5419
|
let running = false;
|
|
5415
5420
|
let pending = false;
|
|
5416
5421
|
const cycle = () => {
|
|
@@ -5443,7 +5448,7 @@ async function runWatch(opts = {}) {
|
|
|
5443
5448
|
}
|
|
5444
5449
|
};
|
|
5445
5450
|
cycle();
|
|
5446
|
-
const watchPaths = sources.map((s) =>
|
|
5451
|
+
const watchPaths = sources.map((s) => join11(s.configDir, "projects")).filter((p) => existsSync8(p));
|
|
5447
5452
|
if (watchPaths.length === 0) {
|
|
5448
5453
|
console.error("agent-lens watch: no source 'projects' directories found \u2014 nothing to watch");
|
|
5449
5454
|
}
|
|
@@ -5471,14 +5476,14 @@ async function runWatch(opts = {}) {
|
|
|
5471
5476
|
// src/index.ts
|
|
5472
5477
|
function version() {
|
|
5473
5478
|
try {
|
|
5474
|
-
const pkg = JSON.parse(readFileSync8(
|
|
5479
|
+
const pkg = JSON.parse(readFileSync8(join12(dirname6(fileURLToPath3(import.meta.url)), "../package.json"), "utf8"));
|
|
5475
5480
|
return pkg.version ?? "0.0.0";
|
|
5476
5481
|
} catch {
|
|
5477
5482
|
return "0.0.0";
|
|
5478
5483
|
}
|
|
5479
5484
|
}
|
|
5480
5485
|
function withLock(fn) {
|
|
5481
|
-
const lockPath =
|
|
5486
|
+
const lockPath = join12(resolveDataDir(findRepoRoot()), ".agent-lens.lock");
|
|
5482
5487
|
const lock = acquireLock(lockPath);
|
|
5483
5488
|
if (!lock) {
|
|
5484
5489
|
console.error("agent-lens: another collect/ingest run is in progress \u2014 skipping");
|
|
@@ -5561,17 +5566,17 @@ cli.command("config", "Show the effective configuration (sources, paths, server)
|
|
|
5561
5566
|
}
|
|
5562
5567
|
const { port, host, portOrigin, hostOrigin } = server;
|
|
5563
5568
|
const { path: dbPath, origin: dbOrigin } = resolveDbPath();
|
|
5564
|
-
const archive =
|
|
5565
|
-
const triageDb =
|
|
5569
|
+
const archive = resolveArchiveDir(repoRoot);
|
|
5570
|
+
const triageDb = triageDbFor(dbPath);
|
|
5566
5571
|
const keepDays = process.env.AGENT_LENS_VERSIONS_KEEP_DAYS || "90";
|
|
5567
5572
|
const keepOrigin = process.env.AGENT_LENS_VERSIONS_KEEP_DAYS ? "env" : "default";
|
|
5568
5573
|
console.log("agent-lens config (precedence: flag > env > config file > default)\n");
|
|
5569
5574
|
console.log("Paths");
|
|
5570
5575
|
console.log(` config file ${configFile ?? "(none \u2014 using built-in default source)"}`);
|
|
5571
5576
|
console.log(` data dir ${dataDir}${process.env.AGENT_LENS_DATA ? " [env]" : ""}`);
|
|
5572
|
-
console.log(` archive ${archive}
|
|
5577
|
+
console.log(` archive ${archive} [fixed: <data dir>/archive]`);
|
|
5573
5578
|
console.log(` db ${dbPath} [${dbOrigin}]`);
|
|
5574
|
-
console.log(` triage db ${triageDb}
|
|
5579
|
+
console.log(` triage db ${triageDb} [fixed: beside the db]`);
|
|
5575
5580
|
console.log("\nServer");
|
|
5576
5581
|
console.log(` host ${host} [${hostOrigin}]`);
|
|
5577
5582
|
console.log(` port ${port} [${portOrigin}]`);
|