agenttop 0.11.3 → 0.11.4
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/index.js +42 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -612,6 +612,7 @@ var deriveSeverityColors = (c) => ({
|
|
|
612
612
|
// src/updates.ts
|
|
613
613
|
import { execFile, spawn } from "child_process";
|
|
614
614
|
import { readFile } from "fs/promises";
|
|
615
|
+
import { existsSync } from "fs";
|
|
615
616
|
import { join, dirname } from "path";
|
|
616
617
|
import { fileURLToPath } from "url";
|
|
617
618
|
var getPackageVersion = async () => {
|
|
@@ -628,6 +629,17 @@ var getNpmPath = () => {
|
|
|
628
629
|
const nodeDir = dirname(process.execPath);
|
|
629
630
|
return join(nodeDir, process.platform === "win32" ? "npm.cmd" : "npm");
|
|
630
631
|
};
|
|
632
|
+
var detectInstallMethod = () => {
|
|
633
|
+
const execPath = process.execPath;
|
|
634
|
+
const thisFile = fileURLToPath(import.meta.url);
|
|
635
|
+
if (thisFile.includes("/Cellar/") || thisFile.includes("/homebrew/") || existsSync("/usr/local/Cellar/agenttop") || existsSync("/opt/homebrew/Cellar/agenttop")) {
|
|
636
|
+
return "homebrew";
|
|
637
|
+
}
|
|
638
|
+
if (process.platform === "win32" && (execPath.includes("\\scoop\\") || thisFile.includes("\\scoop\\"))) {
|
|
639
|
+
return "scoop";
|
|
640
|
+
}
|
|
641
|
+
return "npm";
|
|
642
|
+
};
|
|
631
643
|
var checkForUpdate = () => new Promise((resolve) => {
|
|
632
644
|
const npm = getNpmPath();
|
|
633
645
|
getPackageVersion().then((current) => {
|
|
@@ -646,14 +658,34 @@ var checkForUpdate = () => new Promise((resolve) => {
|
|
|
646
658
|
});
|
|
647
659
|
});
|
|
648
660
|
var installUpdate = () => {
|
|
661
|
+
const method = detectInstallMethod();
|
|
662
|
+
if (method === "homebrew") {
|
|
663
|
+
return new Promise((resolve, reject) => {
|
|
664
|
+
execFile("brew", ["upgrade", "agenttop"], { timeout: 12e4 }, (err, stdout) => {
|
|
665
|
+
if (err) {
|
|
666
|
+
execFile("brew", ["reinstall", "agenttop"], { timeout: 12e4 }, (err2, stdout2) => {
|
|
667
|
+
if (err2) reject(err2);
|
|
668
|
+
else resolve(stdout2.trim());
|
|
669
|
+
});
|
|
670
|
+
} else {
|
|
671
|
+
resolve(stdout.trim());
|
|
672
|
+
}
|
|
673
|
+
});
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
if (method === "scoop") {
|
|
677
|
+
return new Promise((resolve, reject) => {
|
|
678
|
+
execFile("scoop", ["update", "agenttop"], { timeout: 12e4, shell: true }, (err, stdout) => {
|
|
679
|
+
if (err) reject(err);
|
|
680
|
+
else resolve(stdout.trim());
|
|
681
|
+
});
|
|
682
|
+
});
|
|
683
|
+
}
|
|
649
684
|
const npm = getNpmPath();
|
|
650
685
|
return new Promise((resolve, reject) => {
|
|
651
|
-
execFile(npm, ["install", "-g", "
|
|
652
|
-
if (err)
|
|
653
|
-
|
|
654
|
-
} else {
|
|
655
|
-
resolve(stdout.trim());
|
|
656
|
-
}
|
|
686
|
+
execFile(npm, ["install", "-g", "agenttop@latest"], { timeout: 6e4 }, (err, stdout) => {
|
|
687
|
+
if (err) reject(err);
|
|
688
|
+
else resolve(stdout.trim());
|
|
657
689
|
});
|
|
658
690
|
});
|
|
659
691
|
};
|
|
@@ -4193,7 +4225,7 @@ var useUpdateChecker = (disabled, checkOnLaunch, checkInterval) => {
|
|
|
4193
4225
|
import { useState as useState16, useCallback as useCallback6 } from "react";
|
|
4194
4226
|
|
|
4195
4227
|
// src/hooks/installer.ts
|
|
4196
|
-
import { existsSync, readFileSync, writeFileSync, copyFileSync, mkdirSync as mkdirSync2, chmodSync } from "fs";
|
|
4228
|
+
import { existsSync as existsSync2, readFileSync, writeFileSync, copyFileSync, mkdirSync as mkdirSync2, chmodSync } from "fs";
|
|
4197
4229
|
import { join as join3, dirname as dirname3 } from "path";
|
|
4198
4230
|
import { homedir } from "os";
|
|
4199
4231
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
@@ -4205,10 +4237,10 @@ var getHookSource = () => {
|
|
|
4205
4237
|
const distHooksDir = join3(dirname3(thisFile), "hooks");
|
|
4206
4238
|
for (const dir of [distHooksDir, srcHooksDir]) {
|
|
4207
4239
|
const path = join3(dir, HOOK_FILENAME);
|
|
4208
|
-
if (
|
|
4240
|
+
if (existsSync2(path)) return path;
|
|
4209
4241
|
}
|
|
4210
4242
|
const npmGlobalPath = join3(dirname3(thisFile), "..", "hooks", HOOK_FILENAME);
|
|
4211
|
-
if (
|
|
4243
|
+
if (existsSync2(npmGlobalPath)) return npmGlobalPath;
|
|
4212
4244
|
throw new Error(`cannot find ${HOOK_FILENAME} \u2014 is agenttop installed correctly?`);
|
|
4213
4245
|
};
|
|
4214
4246
|
var getHookTarget = () => {
|
|
@@ -4217,7 +4249,7 @@ var getHookTarget = () => {
|
|
|
4217
4249
|
return join3(claudeHooksDir, HOOK_FILENAME);
|
|
4218
4250
|
};
|
|
4219
4251
|
var readSettings = () => {
|
|
4220
|
-
if (!
|
|
4252
|
+
if (!existsSync2(SETTINGS_PATH)) {
|
|
4221
4253
|
return {};
|
|
4222
4254
|
}
|
|
4223
4255
|
try {
|