@gowelle/stint-agent 1.0.5 → 1.0.6

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/README.md CHANGED
@@ -53,6 +53,7 @@ stint daemon status
53
53
  |---------|-------------|
54
54
  | `stint --version`, `stint -V` | Show current agent version |
55
55
  | `stint --help`, `stint -h` | Show help information |
56
+ | `stint update` | Update agent to the latest version |
56
57
 
57
58
  ### Authentication
58
59
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  apiService
3
- } from "./chunk-BSBIB3MX.js";
3
+ } from "./chunk-NCWEPWZN.js";
4
4
  export {
5
5
  apiService
6
6
  };
@@ -254,7 +254,7 @@ var AuthServiceImpl = class {
254
254
  return null;
255
255
  }
256
256
  try {
257
- const { apiService: apiService2 } = await import("./api-OUZE76VQ.js");
257
+ const { apiService: apiService2 } = await import("./api-N3FEQDDP.js");
258
258
  const user = await apiService2.getCurrentUser();
259
259
  logger.info("auth", `Token validated for user: ${user.email}`);
260
260
  return user;
@@ -274,7 +274,7 @@ var AuthServiceImpl = class {
274
274
  var authService = new AuthServiceImpl();
275
275
 
276
276
  // src/services/api.ts
277
- var AGENT_VERSION = "1.0.5";
277
+ var AGENT_VERSION = "1.0.6";
278
278
  var ApiServiceImpl = class {
279
279
  sessionId = null;
280
280
  async getHeaders() {
@@ -2,7 +2,7 @@ import {
2
2
  apiService,
3
3
  config,
4
4
  logger
5
- } from "./chunk-BSBIB3MX.js";
5
+ } from "./chunk-NCWEPWZN.js";
6
6
 
7
7
  // src/utils/process.ts
8
8
  import fs from "fs";
@@ -5,13 +5,13 @@ import {
5
5
  projectService,
6
6
  removePidFile,
7
7
  writePidFile
8
- } from "../chunk-5PC3XTZ7.js";
8
+ } from "../chunk-RWHZ5ULY.js";
9
9
  import {
10
10
  apiService,
11
11
  authService,
12
12
  config,
13
13
  logger
14
- } from "../chunk-BSBIB3MX.js";
14
+ } from "../chunk-NCWEPWZN.js";
15
15
 
16
16
  // src/daemon/runner.ts
17
17
  import "dotenv/config";
package/dist/index.js CHANGED
@@ -8,18 +8,18 @@ import {
8
8
  projectService,
9
9
  spawnDetached,
10
10
  validatePidFile
11
- } from "./chunk-5PC3XTZ7.js";
11
+ } from "./chunk-RWHZ5ULY.js";
12
12
  import {
13
13
  apiService,
14
14
  authService,
15
15
  config,
16
16
  logger
17
- } from "./chunk-BSBIB3MX.js";
17
+ } from "./chunk-NCWEPWZN.js";
18
18
 
19
19
  // src/index.ts
20
20
  import "dotenv/config";
21
21
  import { Command } from "commander";
22
- import chalk11 from "chalk";
22
+ import chalk12 from "chalk";
23
23
 
24
24
  // src/commands/login.ts
25
25
  import open from "open";
@@ -1266,20 +1266,81 @@ function registerUninstallCommand(program2) {
1266
1266
  });
1267
1267
  }
1268
1268
 
1269
+ // src/commands/update.ts
1270
+ import ora11 from "ora";
1271
+ import chalk11 from "chalk";
1272
+ import { exec as exec2 } from "child_process";
1273
+ import { promisify as promisify2 } from "util";
1274
+ var execAsync2 = promisify2(exec2);
1275
+ function registerUpdateCommand(program2) {
1276
+ program2.command("update").description("Update stint agent to the latest version").action(async () => {
1277
+ const spinner = ora11("Checking for updates...").start();
1278
+ try {
1279
+ const currentVersion = program2.version();
1280
+ const { stdout: latestVersion } = await execAsync2("npm view @gowelle/stint-agent version");
1281
+ const cleanLatestVersion = latestVersion.trim();
1282
+ if (currentVersion === cleanLatestVersion) {
1283
+ spinner.succeed("Already up to date");
1284
+ console.log(chalk11.gray(`
1285
+ Current version: ${currentVersion}`));
1286
+ console.log(chalk11.gray(`Latest version: ${cleanLatestVersion}
1287
+ `));
1288
+ return;
1289
+ }
1290
+ spinner.info(`Update available: ${currentVersion} \u2192 ${cleanLatestVersion}`);
1291
+ spinner.text = "Installing update...";
1292
+ await execAsync2("npm install -g @gowelle/stint-agent@latest");
1293
+ spinner.succeed(`Updated to version ${cleanLatestVersion}`);
1294
+ const { valid, pid } = validatePidFile();
1295
+ if (valid && pid) {
1296
+ console.log(chalk11.blue("\n\u{1F504} Restarting daemon with new version..."));
1297
+ const restartSpinner = ora11("Restarting daemon...").start();
1298
+ try {
1299
+ killProcess(pid, "SIGTERM");
1300
+ let attempts = 0;
1301
+ while (attempts < 10 && isProcessRunning(pid)) {
1302
+ await new Promise((resolve) => setTimeout(resolve, 500));
1303
+ attempts++;
1304
+ }
1305
+ if (isProcessRunning(pid)) {
1306
+ killProcess(pid, "SIGKILL");
1307
+ }
1308
+ await new Promise((resolve) => setTimeout(resolve, 1e3));
1309
+ await execAsync2("stint daemon start");
1310
+ restartSpinner.succeed("Daemon restarted successfully");
1311
+ logger.success("update", `Daemon restarted after update`);
1312
+ } catch (error) {
1313
+ restartSpinner.fail("Failed to restart daemon");
1314
+ logger.error("update", "Daemon restart failed", error);
1315
+ console.log(chalk11.yellow('\nPlease run "stint daemon start" manually.\n'));
1316
+ }
1317
+ }
1318
+ logger.success("update", `Updated to version ${cleanLatestVersion}`);
1319
+ } catch (error) {
1320
+ spinner.fail("Update failed");
1321
+ logger.error("update", "Update command failed", error);
1322
+ console.error(chalk11.red(`
1323
+ \u2716 Error: ${error.message}
1324
+ `));
1325
+ process.exit(1);
1326
+ }
1327
+ });
1328
+ }
1329
+
1269
1330
  // src/index.ts
1270
- var AGENT_VERSION = "1.0.5";
1331
+ var AGENT_VERSION = "1.0.6";
1271
1332
  var program = new Command();
1272
- program.name("stint").description("Stint Agent - Local daemon for Stint Project Assistant").version(AGENT_VERSION, "-V, --version", "output the current version").addHelpText("after", `
1273
- ${chalk11.bold("Examples:")}
1274
- ${chalk11.cyan("$")} stint login ${chalk11.gray("# Authenticate with Stint")}
1275
- ${chalk11.cyan("$")} stint install ${chalk11.gray("# Install agent to run on startup")}
1276
- ${chalk11.cyan("$")} stint link ${chalk11.gray("# Link current directory to a project")}
1277
- ${chalk11.cyan("$")} stint daemon start ${chalk11.gray("# Start background daemon")}
1278
- ${chalk11.cyan("$")} stint status ${chalk11.gray("# Check status")}
1279
- ${chalk11.cyan("$")} stint commits ${chalk11.gray("# List pending commits")}
1333
+ program.name("stint").description("Stint Agent - Local daemon for Stint Project Assistant").version(AGENT_VERSION, "-v, -V, --version", "output the current version").addHelpText("after", `
1334
+ ${chalk12.bold("Examples:")}
1335
+ ${chalk12.cyan("$")} stint login ${chalk12.gray("# Authenticate with Stint")}
1336
+ ${chalk12.cyan("$")} stint install ${chalk12.gray("# Install agent to run on startup")}
1337
+ ${chalk12.cyan("$")} stint link ${chalk12.gray("# Link current directory to a project")}
1338
+ ${chalk12.cyan("$")} stint daemon start ${chalk12.gray("# Start background daemon")}
1339
+ ${chalk12.cyan("$")} stint status ${chalk12.gray("# Check status")}
1340
+ ${chalk12.cyan("$")} stint commits ${chalk12.gray("# List pending commits")}
1280
1341
 
1281
- ${chalk11.bold("Documentation:")}
1282
- For more information, visit: ${chalk11.blue("https://stint.codes/docs")}
1342
+ ${chalk12.bold("Documentation:")}
1343
+ For more information, visit: ${chalk12.blue("https://stint.codes/docs")}
1283
1344
  `);
1284
1345
  registerLoginCommand(program);
1285
1346
  registerLogoutCommand(program);
@@ -1292,14 +1353,15 @@ registerDaemonCommands(program);
1292
1353
  registerCommitCommands(program);
1293
1354
  registerInstallCommand(program);
1294
1355
  registerUninstallCommand(program);
1356
+ registerUpdateCommand(program);
1295
1357
  program.exitOverride();
1296
1358
  try {
1297
1359
  await program.parseAsync(process.argv);
1298
1360
  } catch (error) {
1299
1361
  const commanderError = error;
1300
- if (commanderError.code !== "commander.help" && commanderError.code !== "commander.version") {
1362
+ if (commanderError.code !== "commander.help" && commanderError.code !== "commander.version" && commanderError.code !== "commander.helpDisplayed") {
1301
1363
  logger.error("cli", "Command execution failed", error);
1302
- console.error(chalk11.red(`
1364
+ console.error(chalk12.red(`
1303
1365
  \u2716 Error: ${error.message}
1304
1366
  `));
1305
1367
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gowelle/stint-agent",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Local agent for Stint - Project Assistant",
5
5
  "author": "Gowelle John <gowelle.john@icloud.com>",
6
6
  "license": "MIT",