pi-agent-toolkit 0.4.0 → 0.5.1
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 +104 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1173,7 +1173,20 @@ function runStatus() {
|
|
|
1173
1173
|
const entries = [];
|
|
1174
1174
|
for (const component of registry) {
|
|
1175
1175
|
const isInstalled = installedNames.has(component.name);
|
|
1176
|
+
const path = expectedPath(component);
|
|
1176
1177
|
if (!isInstalled) {
|
|
1178
|
+
if (path) {
|
|
1179
|
+
const check2 = checkFile(path);
|
|
1180
|
+
if (check2.exists) {
|
|
1181
|
+
entries.push({
|
|
1182
|
+
name: component.name,
|
|
1183
|
+
category: component.category,
|
|
1184
|
+
status: "untracked",
|
|
1185
|
+
detail: check2.detail
|
|
1186
|
+
});
|
|
1187
|
+
continue;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1177
1190
|
entries.push({
|
|
1178
1191
|
name: component.name,
|
|
1179
1192
|
category: component.category,
|
|
@@ -1181,7 +1194,6 @@ function runStatus() {
|
|
|
1181
1194
|
});
|
|
1182
1195
|
continue;
|
|
1183
1196
|
}
|
|
1184
|
-
const path = expectedPath(component);
|
|
1185
1197
|
if (!path) {
|
|
1186
1198
|
entries.push({
|
|
1187
1199
|
name: component.name,
|
|
@@ -1212,17 +1224,25 @@ function runStatus() {
|
|
|
1212
1224
|
for (const cat of categories) {
|
|
1213
1225
|
const catEntries = entries.filter((e) => e.category === cat.key);
|
|
1214
1226
|
if (catEntries.length === 0) continue;
|
|
1215
|
-
const
|
|
1227
|
+
const tracked = catEntries.filter((e) => e.status === "ok" || e.status === "missing");
|
|
1228
|
+
const untracked = catEntries.filter((e) => e.status === "untracked");
|
|
1216
1229
|
const available = catEntries.filter((e) => e.status === "not-installed");
|
|
1230
|
+
const totalInstalled = tracked.length + untracked.length;
|
|
1217
1231
|
console.log(
|
|
1218
|
-
pc3.bold(pc3.cyan(cat.label)) + pc3.dim(` (${
|
|
1232
|
+
pc3.bold(pc3.cyan(cat.label)) + pc3.dim(` (${totalInstalled}/${catEntries.length} installed)`)
|
|
1219
1233
|
);
|
|
1220
|
-
for (const entry of
|
|
1234
|
+
for (const entry of tracked) {
|
|
1221
1235
|
const icon = entry.status === "ok" ? pc3.green("*") : pc3.red("!");
|
|
1222
1236
|
const detail = entry.detail ? pc3.dim(` (${entry.detail})`) : "";
|
|
1223
1237
|
const statusLabel = entry.status === "missing" ? pc3.red(" MISSING") : "";
|
|
1224
1238
|
console.log(` ${icon} ${entry.name}${statusLabel}${detail}`);
|
|
1225
1239
|
}
|
|
1240
|
+
for (const entry of untracked) {
|
|
1241
|
+
const detail = entry.detail ? pc3.dim(` (${entry.detail})`) : "";
|
|
1242
|
+
console.log(
|
|
1243
|
+
` ${pc3.yellow("~")} ${entry.name}${detail} ${pc3.yellow("(not tracked by manifest)")}`
|
|
1244
|
+
);
|
|
1245
|
+
}
|
|
1226
1246
|
if (available.length > 0) {
|
|
1227
1247
|
console.log(
|
|
1228
1248
|
pc3.dim(` ${available.length} more available: ${available.map((e) => e.name).join(", ")}`)
|
|
@@ -1411,6 +1431,75 @@ async function runSync(options) {
|
|
|
1411
1431
|
);
|
|
1412
1432
|
}
|
|
1413
1433
|
|
|
1434
|
+
// src/commands/update.ts
|
|
1435
|
+
import { execSync as execSync2 } from "child_process";
|
|
1436
|
+
import pc5 from "picocolors";
|
|
1437
|
+
var PACKAGE_NAME = "pi-agent-toolkit";
|
|
1438
|
+
function fetchLatestVersion() {
|
|
1439
|
+
try {
|
|
1440
|
+
const result = execSync2(`npm view ${PACKAGE_NAME} version`, {
|
|
1441
|
+
stdio: "pipe",
|
|
1442
|
+
timeout: 15e3
|
|
1443
|
+
});
|
|
1444
|
+
return result.toString().trim();
|
|
1445
|
+
} catch {
|
|
1446
|
+
return null;
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
function compareSemver(a, b) {
|
|
1450
|
+
const partsA = a.split(".").map(Number);
|
|
1451
|
+
const partsB = b.split(".").map(Number);
|
|
1452
|
+
for (let i = 0; i < 3; i++) {
|
|
1453
|
+
const diff = (partsA[i] ?? 0) - (partsB[i] ?? 0);
|
|
1454
|
+
if (diff !== 0) return diff > 0 ? 1 : -1;
|
|
1455
|
+
}
|
|
1456
|
+
return 0;
|
|
1457
|
+
}
|
|
1458
|
+
function runGlobalUpdate() {
|
|
1459
|
+
try {
|
|
1460
|
+
execSync2(`npm install -g ${PACKAGE_NAME}@latest`, {
|
|
1461
|
+
stdio: "inherit",
|
|
1462
|
+
timeout: 6e4
|
|
1463
|
+
});
|
|
1464
|
+
return true;
|
|
1465
|
+
} catch {
|
|
1466
|
+
return false;
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
function runUpdate(currentVersion) {
|
|
1470
|
+
console.log();
|
|
1471
|
+
console.log(pc5.bold("pi-agent-toolkit update"));
|
|
1472
|
+
console.log();
|
|
1473
|
+
console.log(`${pc5.dim("Current version:")} ${currentVersion}`);
|
|
1474
|
+
const latest = fetchLatestVersion();
|
|
1475
|
+
if (!latest) {
|
|
1476
|
+
console.log(pc5.red("Could not reach the npm registry. Check your network connection."));
|
|
1477
|
+
console.log();
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
console.log(`${pc5.dim("Latest version:")} ${latest}`);
|
|
1481
|
+
console.log();
|
|
1482
|
+
const cmp = compareSemver(currentVersion, latest);
|
|
1483
|
+
if (cmp >= 0) {
|
|
1484
|
+
console.log(pc5.green("Already up to date."));
|
|
1485
|
+
console.log();
|
|
1486
|
+
return;
|
|
1487
|
+
}
|
|
1488
|
+
console.log(pc5.cyan(`Updating ${currentVersion} -> ${latest}...`));
|
|
1489
|
+
console.log();
|
|
1490
|
+
const success = runGlobalUpdate();
|
|
1491
|
+
if (success) {
|
|
1492
|
+
console.log();
|
|
1493
|
+
console.log(pc5.green(`Updated to ${latest}.`));
|
|
1494
|
+
console.log(pc5.dim('Run "pi-agent-toolkit install" to pick up any new or updated components.'));
|
|
1495
|
+
} else {
|
|
1496
|
+
console.log();
|
|
1497
|
+
console.log(pc5.red("Update failed. Try manually:"));
|
|
1498
|
+
console.log(pc5.dim(` npm install -g ${PACKAGE_NAME}@latest`));
|
|
1499
|
+
}
|
|
1500
|
+
console.log();
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1414
1503
|
// src/index.ts
|
|
1415
1504
|
var __dirname2 = dirname3(fileURLToPath2(import.meta.url));
|
|
1416
1505
|
var CLI_VERSION = JSON.parse(
|
|
@@ -1513,6 +1602,15 @@ var sync = defineCommand({
|
|
|
1513
1602
|
});
|
|
1514
1603
|
}
|
|
1515
1604
|
});
|
|
1605
|
+
var update = defineCommand({
|
|
1606
|
+
meta: {
|
|
1607
|
+
name: "update",
|
|
1608
|
+
description: "Update pi-agent-toolkit to the latest version"
|
|
1609
|
+
},
|
|
1610
|
+
run() {
|
|
1611
|
+
runUpdate(CLI_VERSION);
|
|
1612
|
+
}
|
|
1613
|
+
});
|
|
1516
1614
|
var main = defineCommand({
|
|
1517
1615
|
meta: {
|
|
1518
1616
|
name: "pi-agent-toolkit",
|
|
@@ -1523,7 +1621,8 @@ var main = defineCommand({
|
|
|
1523
1621
|
install,
|
|
1524
1622
|
list,
|
|
1525
1623
|
status,
|
|
1526
|
-
sync
|
|
1624
|
+
sync,
|
|
1625
|
+
update
|
|
1527
1626
|
}
|
|
1528
1627
|
});
|
|
1529
1628
|
runMain(main);
|