agent-insights 0.0.19 → 0.0.20
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/cli.js +54 -9
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1255,11 +1255,18 @@ var adapterList = Object.values(adapters);
|
|
|
1255
1255
|
|
|
1256
1256
|
// src/commands/disable.ts
|
|
1257
1257
|
init_paths();
|
|
1258
|
+
var CONFIG_KEY_BY_ID = {
|
|
1259
|
+
"claude-code": "claudeCode",
|
|
1260
|
+
cursor: "cursor",
|
|
1261
|
+
codex: "codex",
|
|
1262
|
+
pi: "pi"
|
|
1263
|
+
};
|
|
1258
1264
|
async function runDisable(opts) {
|
|
1259
1265
|
const repoRoot = process.cwd();
|
|
1266
|
+
const knownIds = new Set(adapterList.map((a) => a.id));
|
|
1260
1267
|
const targets = opts.agent ? [opts.agent] : adapterList.map((a) => a.id);
|
|
1261
1268
|
for (const id of targets) {
|
|
1262
|
-
if (id
|
|
1269
|
+
if (!knownIds.has(id)) {
|
|
1263
1270
|
log.warn(`Unknown agent id "${id}"`);
|
|
1264
1271
|
continue;
|
|
1265
1272
|
}
|
|
@@ -1271,11 +1278,9 @@ async function runDisable(opts) {
|
|
|
1271
1278
|
}
|
|
1272
1279
|
const cfg = await loadConfig();
|
|
1273
1280
|
if (cfg) {
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
if (!opts.agent || opts.agent === "cursor") {
|
|
1278
|
-
cfg.agents.cursor.enabled = false;
|
|
1281
|
+
for (const id of targets) {
|
|
1282
|
+
const key = CONFIG_KEY_BY_ID[id];
|
|
1283
|
+
if (key) cfg.agents[key].enabled = false;
|
|
1279
1284
|
}
|
|
1280
1285
|
if (!opts.agent) cfg.enabled = false;
|
|
1281
1286
|
await saveConfig(cfg);
|
|
@@ -1391,7 +1396,10 @@ var AnalyzerTranscriptStore = class {
|
|
|
1391
1396
|
"x-session-id": input.sessionId,
|
|
1392
1397
|
"x-agent": input.agent,
|
|
1393
1398
|
"x-user-hash": input.userHash,
|
|
1394
|
-
...input.userEmail ? { "x-user-email": input.userEmail } : {}
|
|
1399
|
+
...input.userEmail ? { "x-user-email": input.userEmail } : {},
|
|
1400
|
+
...input.gitInfo?.repoName ? { "x-git-repo-name": input.gitInfo.repoName } : {},
|
|
1401
|
+
...input.gitInfo?.branch ? { "x-git-branch": input.gitInfo.branch } : {},
|
|
1402
|
+
...input.gitInfo?.commitSha ? { "x-git-commit-sha": input.gitInfo.commitSha } : {}
|
|
1395
1403
|
});
|
|
1396
1404
|
const res = await fetch(url, { method: "POST", headers, body });
|
|
1397
1405
|
if (!res.ok) {
|
|
@@ -1526,6 +1534,40 @@ async function runDoctor(opts) {
|
|
|
1526
1534
|
|
|
1527
1535
|
// src/commands/hook.ts
|
|
1528
1536
|
init_store();
|
|
1537
|
+
|
|
1538
|
+
// src/util/git-info.ts
|
|
1539
|
+
import { execSync as execSync2 } from "child_process";
|
|
1540
|
+
import { basename } from "path";
|
|
1541
|
+
function readGitInfo(cwd) {
|
|
1542
|
+
let raw;
|
|
1543
|
+
try {
|
|
1544
|
+
raw = execSync2("git rev-parse HEAD --show-toplevel", {
|
|
1545
|
+
cwd,
|
|
1546
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
1547
|
+
timeout: 1500
|
|
1548
|
+
}).toString("utf8");
|
|
1549
|
+
} catch {
|
|
1550
|
+
return void 0;
|
|
1551
|
+
}
|
|
1552
|
+
const [commitSha, top] = raw.split("\n").map((s) => s.trim());
|
|
1553
|
+
if (!top) return void 0;
|
|
1554
|
+
let branch;
|
|
1555
|
+
try {
|
|
1556
|
+
const out = execSync2("git rev-parse --abbrev-ref HEAD", {
|
|
1557
|
+
cwd,
|
|
1558
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
1559
|
+
timeout: 1500
|
|
1560
|
+
}).toString("utf8").trim();
|
|
1561
|
+
if (out && out !== "HEAD") branch = out;
|
|
1562
|
+
} catch {
|
|
1563
|
+
}
|
|
1564
|
+
const info = { repoName: basename(top) };
|
|
1565
|
+
if (branch) info.branch = branch;
|
|
1566
|
+
if (commitSha) info.commitSha = commitSha;
|
|
1567
|
+
return info;
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
// src/commands/hook.ts
|
|
1529
1571
|
async function runHook(eventName, opts) {
|
|
1530
1572
|
const cfg = await loadConfig();
|
|
1531
1573
|
if (!cfg || !cfg.enabled) {
|
|
@@ -1555,12 +1597,15 @@ async function runHook(eventName, opts) {
|
|
|
1555
1597
|
try {
|
|
1556
1598
|
const store = createTranscriptStore(cfg.transcriptStore);
|
|
1557
1599
|
const userEmail = await loadEmail();
|
|
1600
|
+
const cwd = (typeof data?.["cwd"] === "string" ? data["cwd"] : void 0) ?? process.cwd();
|
|
1601
|
+
const gitInfo = readGitInfo(cwd);
|
|
1558
1602
|
const result = await store.upload({
|
|
1559
1603
|
transcriptPath: mapped.transcriptPath,
|
|
1560
1604
|
userHash: event.userHash ?? userHash(),
|
|
1561
1605
|
sessionId: mapped.sessionId ?? "unknown",
|
|
1562
1606
|
agent: adapter.id,
|
|
1563
|
-
...userEmail ? { userEmail } : {}
|
|
1607
|
+
...userEmail ? { userEmail } : {},
|
|
1608
|
+
...gitInfo ? { gitInfo } : {}
|
|
1564
1609
|
});
|
|
1565
1610
|
debug("transcript uploaded", {
|
|
1566
1611
|
size: result.size,
|
|
@@ -1997,7 +2042,7 @@ function yn(v) {
|
|
|
1997
2042
|
var program = new Command();
|
|
1998
2043
|
program.name("agent-insights").description(
|
|
1999
2044
|
"Internal CLI for AI coding agent observability (Claude Code, Cursor)."
|
|
2000
|
-
).version("0.0.
|
|
2045
|
+
).version("0.0.20");
|
|
2001
2046
|
program.command("login").description("Authenticate with Vercel (Sign in with Vercel).").action(async () => {
|
|
2002
2047
|
await runLogin();
|
|
2003
2048
|
});
|