pi-agent-toolkit 0.4.0 → 0.5.0

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.
Files changed (2) hide show
  1. package/dist/index.js +80 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1411,6 +1411,75 @@ async function runSync(options) {
1411
1411
  );
1412
1412
  }
1413
1413
 
1414
+ // src/commands/update.ts
1415
+ import { execSync as execSync2 } from "child_process";
1416
+ import pc5 from "picocolors";
1417
+ var PACKAGE_NAME = "pi-agent-toolkit";
1418
+ function fetchLatestVersion() {
1419
+ try {
1420
+ const result = execSync2(`npm view ${PACKAGE_NAME} version`, {
1421
+ stdio: "pipe",
1422
+ timeout: 15e3
1423
+ });
1424
+ return result.toString().trim();
1425
+ } catch {
1426
+ return null;
1427
+ }
1428
+ }
1429
+ function compareSemver(a, b) {
1430
+ const partsA = a.split(".").map(Number);
1431
+ const partsB = b.split(".").map(Number);
1432
+ for (let i = 0; i < 3; i++) {
1433
+ const diff = (partsA[i] ?? 0) - (partsB[i] ?? 0);
1434
+ if (diff !== 0) return diff > 0 ? 1 : -1;
1435
+ }
1436
+ return 0;
1437
+ }
1438
+ function runGlobalUpdate() {
1439
+ try {
1440
+ execSync2(`npm install -g ${PACKAGE_NAME}@latest`, {
1441
+ stdio: "inherit",
1442
+ timeout: 6e4
1443
+ });
1444
+ return true;
1445
+ } catch {
1446
+ return false;
1447
+ }
1448
+ }
1449
+ function runUpdate(currentVersion) {
1450
+ console.log();
1451
+ console.log(pc5.bold("pi-agent-toolkit update"));
1452
+ console.log();
1453
+ console.log(`${pc5.dim("Current version:")} ${currentVersion}`);
1454
+ const latest = fetchLatestVersion();
1455
+ if (!latest) {
1456
+ console.log(pc5.red("Could not reach the npm registry. Check your network connection."));
1457
+ console.log();
1458
+ return;
1459
+ }
1460
+ console.log(`${pc5.dim("Latest version:")} ${latest}`);
1461
+ console.log();
1462
+ const cmp = compareSemver(currentVersion, latest);
1463
+ if (cmp >= 0) {
1464
+ console.log(pc5.green("Already up to date."));
1465
+ console.log();
1466
+ return;
1467
+ }
1468
+ console.log(pc5.cyan(`Updating ${currentVersion} -> ${latest}...`));
1469
+ console.log();
1470
+ const success = runGlobalUpdate();
1471
+ if (success) {
1472
+ console.log();
1473
+ console.log(pc5.green(`Updated to ${latest}.`));
1474
+ console.log(pc5.dim('Run "pi-agent-toolkit install" to pick up any new or updated components.'));
1475
+ } else {
1476
+ console.log();
1477
+ console.log(pc5.red("Update failed. Try manually:"));
1478
+ console.log(pc5.dim(` npm install -g ${PACKAGE_NAME}@latest`));
1479
+ }
1480
+ console.log();
1481
+ }
1482
+
1414
1483
  // src/index.ts
1415
1484
  var __dirname2 = dirname3(fileURLToPath2(import.meta.url));
1416
1485
  var CLI_VERSION = JSON.parse(
@@ -1513,6 +1582,15 @@ var sync = defineCommand({
1513
1582
  });
1514
1583
  }
1515
1584
  });
1585
+ var update = defineCommand({
1586
+ meta: {
1587
+ name: "update",
1588
+ description: "Update pi-agent-toolkit to the latest version"
1589
+ },
1590
+ run() {
1591
+ runUpdate(CLI_VERSION);
1592
+ }
1593
+ });
1516
1594
  var main = defineCommand({
1517
1595
  meta: {
1518
1596
  name: "pi-agent-toolkit",
@@ -1523,7 +1601,8 @@ var main = defineCommand({
1523
1601
  install,
1524
1602
  list,
1525
1603
  status,
1526
- sync
1604
+ sync,
1605
+ update
1527
1606
  }
1528
1607
  });
1529
1608
  runMain(main);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-toolkit",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "CLI to selectively install curated extensions, skills, and configs for the pi coding agent",
5
5
  "keywords": [
6
6
  "pi",