@gowelle/stint-agent 1.2.53 → 1.2.56

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.
@@ -2,10 +2,10 @@ import {
2
2
  gitService,
3
3
  projectService,
4
4
  validatePidFile
5
- } from "./chunk-ZGV7IQMJ.js";
5
+ } from "./chunk-7OSHGB4C.js";
6
6
  import {
7
7
  authService
8
- } from "./chunk-K3FOUU5A.js";
8
+ } from "./chunk-UHR52B56.js";
9
9
 
10
10
  // src/components/StatusDashboard.tsx
11
11
  import { useState, useEffect } from "react";
@@ -0,0 +1,7 @@
1
+ import {
2
+ apiService
3
+ } from "./chunk-GCWEUJWP.js";
4
+ import "./chunk-UHR52B56.js";
5
+ export {
6
+ apiService
7
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  config,
3
3
  logger
4
- } from "./chunk-K3FOUU5A.js";
4
+ } from "./chunk-UHR52B56.js";
5
5
 
6
6
  // src/services/git.ts
7
7
  import simpleGit from "simple-git";
@@ -2,7 +2,7 @@ import {
2
2
  authService,
3
3
  config,
4
4
  logger
5
- } from "./chunk-K3FOUU5A.js";
5
+ } from "./chunk-UHR52B56.js";
6
6
 
7
7
  // src/utils/circuit-breaker.ts
8
8
  var CircuitBreaker = class {
@@ -100,7 +100,7 @@ var CircuitBreaker = class {
100
100
  };
101
101
 
102
102
  // src/services/api.ts
103
- var AGENT_VERSION = "1.2.53";
103
+ var AGENT_VERSION = "1.2.56";
104
104
  var ApiServiceImpl = class {
105
105
  sessionId = null;
106
106
  circuitBreaker = new CircuitBreaker({
@@ -358,7 +358,7 @@ var AuthServiceImpl = class {
358
358
  return null;
359
359
  }
360
360
  try {
361
- const { apiService } = await import("./api-IFZZCDOY.js");
361
+ const { apiService } = await import("./api-FOWWYJSV.js");
362
362
  const user = await apiService.getCurrentUser();
363
363
  logger.info("auth", `Token validated for user: ${user.email}`);
364
364
  return user;
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  apiService
3
- } from "./chunk-BWH6PAAH.js";
3
+ } from "./chunk-GCWEUJWP.js";
4
4
  import {
5
5
  gitService,
6
6
  projectService
7
- } from "./chunk-ZGV7IQMJ.js";
7
+ } from "./chunk-7OSHGB4C.js";
8
8
  import {
9
9
  authService,
10
10
  config,
11
11
  logger
12
- } from "./chunk-K3FOUU5A.js";
12
+ } from "./chunk-UHR52B56.js";
13
13
 
14
14
  // src/services/package-detector.ts
15
15
  import fs from "fs";
@@ -750,6 +750,7 @@ var CommitQueueProcessor = class {
750
750
  queue = [];
751
751
  isProcessing = false;
752
752
  currentCommitId = null;
753
+ abortedCommitId = null;
753
754
  /**
754
755
  * Check if commit is already in queue or processing
755
756
  */
@@ -757,6 +758,31 @@ var CommitQueueProcessor = class {
757
758
  if (this.currentCommitId === commitId) return true;
758
759
  return this.queue.some((item) => item.commit.id === commitId);
759
760
  }
761
+ /**
762
+ * Cancel a commit
763
+ * @param commitId - Commit ID to cancel
764
+ */
765
+ cancel(commitId) {
766
+ logger.info("queue", `Received cancellation request for commit ${commitId}`);
767
+ if (this.currentCommitId === commitId) {
768
+ logger.info(
769
+ "queue",
770
+ `Commit ${commitId} is currently processing, flagging for abortion...`
771
+ );
772
+ this.abortedCommitId = commitId;
773
+ return;
774
+ }
775
+ const index = this.queue.findIndex((item) => item.commit.id === commitId);
776
+ if (index !== -1) {
777
+ this.queue.splice(index, 1);
778
+ logger.info("queue", `Removed commit ${commitId} from waiting queue`);
779
+ } else {
780
+ logger.info(
781
+ "queue",
782
+ `Commit ${commitId} not found in queue or currently processing`
783
+ );
784
+ }
785
+ }
760
786
  /**
761
787
  * Add commit to processing queue
762
788
  */
@@ -789,20 +815,34 @@ var CommitQueueProcessor = class {
789
815
  const item = this.queue.shift();
790
816
  if (!item) break;
791
817
  this.currentCommitId = item.commit.id;
818
+ this.abortedCommitId = null;
792
819
  try {
793
820
  await this.executeCommit(item.commit, item.project);
794
821
  } catch (error) {
795
- logger.error(
796
- "queue",
797
- `Failed to execute commit ${item.commit.id}`,
798
- error
799
- );
822
+ if (error.message === "Commit canceled") {
823
+ logger.info("queue", `Commit ${item.commit.id} processing canceled.`);
824
+ } else {
825
+ logger.error(
826
+ "queue",
827
+ `Failed to execute commit ${item.commit.id}`,
828
+ error
829
+ );
830
+ }
800
831
  } finally {
801
832
  this.currentCommitId = null;
833
+ this.abortedCommitId = null;
802
834
  }
803
835
  }
804
836
  this.isProcessing = false;
805
837
  }
838
+ /**
839
+ * Check if current commit is aborted
840
+ */
841
+ checkAborted(commitId) {
842
+ if (this.abortedCommitId === commitId) {
843
+ throw new Error("Commit canceled");
844
+ }
845
+ }
806
846
  /**
807
847
  * Execute a single commit
808
848
  */
@@ -813,6 +853,7 @@ var CommitQueueProcessor = class {
813
853
  streamer.append(text);
814
854
  };
815
855
  try {
856
+ this.checkAborted(commit.id);
816
857
  streamer.append(`Processing commit: ${commit.message}
817
858
  `);
818
859
  onProgress?.("Finding project directory...");
@@ -822,6 +863,7 @@ var CommitQueueProcessor = class {
822
863
  `Project ${project.id} is not linked to any local directory`
823
864
  );
824
865
  }
866
+ this.checkAborted(commit.id);
825
867
  logger.info("queue", `Executing in directory: ${projectPath}`);
826
868
  streamer.append(`> Project directory: ${projectPath}
827
869
  `);
@@ -830,6 +872,7 @@ var CommitQueueProcessor = class {
830
872
  if (!isRepo) {
831
873
  throw new Error(`Directory ${projectPath} is not a git repository`);
832
874
  }
875
+ this.checkAborted(commit.id);
833
876
  let hookModifiedFiles = [];
834
877
  if (project.commitSettings?.hooks?.length) {
835
878
  const statusBeforeHooks = await gitService.getStatus(projectPath);
@@ -838,6 +881,7 @@ var CommitQueueProcessor = class {
838
881
  ...statusBeforeHooks.unstaged,
839
882
  ...statusBeforeHooks.untracked
840
883
  ]);
884
+ this.checkAborted(commit.id);
841
885
  onProgress?.("Running pre-commit hooks...");
842
886
  logger.info("queue", "Executing pre-commit hooks...");
843
887
  streamer.append("\n> Executing pre-commit hooks...\n");
@@ -846,6 +890,7 @@ var CommitQueueProcessor = class {
846
890
  projectPath,
847
891
  streamOutput
848
892
  );
893
+ this.checkAborted(commit.id);
849
894
  const failedBlockingHook = hookResults.find(
850
895
  (r) => !r.success && project.commitSettings?.hooks.find((h) => h.id === r.hookId)?.blockOnFailure
851
896
  );
@@ -897,8 +942,10 @@ Warning: ${failedNonBlockingHooks.length} non-blocking hooks failed.
897
942
  );
898
943
  }
899
944
  }
945
+ this.checkAborted(commit.id);
900
946
  onProgress?.("Checking repository status...");
901
947
  let status = await gitService.getStatus(projectPath);
948
+ this.checkAborted(commit.id);
902
949
  if (commit.files && commit.files.length > 0) {
903
950
  const filesToStage = [
904
951
  .../* @__PURE__ */ new Set([...commit.files, ...hookModifiedFiles])
@@ -911,6 +958,7 @@ Warning: ${failedNonBlockingHooks.length} non-blocking hooks failed.
911
958
  > Staging ${filesToStage.length} files${extraMsg}...
912
959
  `
913
960
  );
961
+ this.checkAborted(commit.id);
914
962
  await gitService.stageFiles(projectPath, filesToStage, streamOutput);
915
963
  status = await gitService.getStatus(projectPath);
916
964
  logger.info("queue", `Auto-staged files: ${filesToStage.join(", ")}`);
@@ -921,11 +969,13 @@ Warning: ${failedNonBlockingHooks.length} non-blocking hooks failed.
921
969
  streamer.append(`
922
970
  > Auto-staging all changes...
923
971
  `);
972
+ this.checkAborted(commit.id);
924
973
  await gitService.stageAll(projectPath, streamOutput);
925
974
  status = await gitService.getStatus(projectPath);
926
975
  logger.info("queue", `Auto-staged all changes`);
927
976
  }
928
977
  }
978
+ this.checkAborted(commit.id);
929
979
  if (status.staged.length === 0) {
930
980
  throw new Error(
931
981
  "No changes to commit. The working directory is clean."
@@ -937,6 +987,7 @@ Warning: ${failedNonBlockingHooks.length} non-blocking hooks failed.
937
987
  > Committing ${status.staged.length} staged files...
938
988
  `
939
989
  );
990
+ this.checkAborted(commit.id);
940
991
  onProgress?.("Creating commit...");
941
992
  logger.info("queue", `Creating commit with message: "${commit.message}"`);
942
993
  const sha = await gitService.commit(
@@ -949,6 +1000,7 @@ Warning: ${failedNonBlockingHooks.length} non-blocking hooks failed.
949
1000
  streamer.append(`
950
1001
  > Commit created: ${sha}
951
1002
  `);
1003
+ this.checkAborted(commit.id);
952
1004
  let pushed = false;
953
1005
  let pushError;
954
1006
  const shouldPush = options?.push !== false;
@@ -958,6 +1010,7 @@ Warning: ${failedNonBlockingHooks.length} non-blocking hooks failed.
958
1010
  streamer.append(`
959
1011
  > Pushing to remote...
960
1012
  `);
1013
+ this.checkAborted(commit.id);
961
1014
  await gitService.push(
962
1015
  projectPath,
963
1016
  void 0,
@@ -975,6 +1028,7 @@ Warning: ${failedNonBlockingHooks.length} non-blocking hooks failed.
975
1028
  category: "commits"
976
1029
  });
977
1030
  } catch (error) {
1031
+ if (this.abortedCommitId === commit.id) throw new Error("Commit canceled");
978
1032
  pushError = error.message;
979
1033
  const isConflict = pushError.includes("rejected") || pushError.includes("non-fast-forward") || pushError.includes("failed to push") || pushError.includes("Updates were rejected");
980
1034
  streamer.append(`
@@ -1001,6 +1055,7 @@ Run "git pull --rebase" to resolve.`,
1001
1055
  }
1002
1056
  }
1003
1057
  }
1058
+ this.checkAborted(commit.id);
1004
1059
  onProgress?.("Reporting to server...");
1005
1060
  await this.reportSuccess(commit.id, sha, pushed, pushError);
1006
1061
  streamer.append(`
@@ -1017,6 +1072,19 @@ Run "git pull --rebase" to resolve.`,
1017
1072
  return sha;
1018
1073
  } catch (error) {
1019
1074
  const msg = error.message;
1075
+ if (msg === "Commit canceled") {
1076
+ logger.info("queue", `Commit execution aborted: ${commit.id}`);
1077
+ streamer.append(`
1078
+ > Execution canceled by user.
1079
+ `);
1080
+ await streamer.close();
1081
+ notify({
1082
+ title: `Commit Canceled - ${project.name}`,
1083
+ message: `Commit processing canceled.`,
1084
+ category: "commits"
1085
+ });
1086
+ throw error;
1087
+ }
1020
1088
  logger.error("queue", `Commit execution failed: ${msg}`);
1021
1089
  streamer.append(`
1022
1090
  > Execution failed: ${msg}
@@ -1144,6 +1212,7 @@ var WebSocketServiceImpl = class {
1144
1212
  disconnectHandlers = [];
1145
1213
  agentDisconnectedHandlers = [];
1146
1214
  syncRequestedHandlers = [];
1215
+ commitCanceledHandlers = [];
1147
1216
  /**
1148
1217
  * Connect to the WebSocket server using Laravel Echo
1149
1218
  * @throws Error if connection fails or no auth token available
@@ -1429,7 +1498,7 @@ var WebSocketServiceImpl = class {
1429
1498
  "websocket",
1430
1499
  `Commit ${commit.id} marked as large, fetching full details...`
1431
1500
  );
1432
- const { apiService: apiService2 } = await import("./api-IFZZCDOY.js");
1501
+ const { apiService: apiService2 } = await import("./api-FOWWYJSV.js");
1433
1502
  const fullCommit = await apiService2.getCommit(commit.id);
1434
1503
  commit = {
1435
1504
  ...commit,
@@ -1499,6 +1568,15 @@ var WebSocketServiceImpl = class {
1499
1568
  lastEventTime: (/* @__PURE__ */ new Date()).toISOString()
1500
1569
  });
1501
1570
  this.agentDisconnectedHandlers.forEach((handler) => handler(reason));
1571
+ }).listen(".commit.canceled", (data) => {
1572
+ logger.info("websocket", `Commit canceled: ${data.pendingCommit.id}`);
1573
+ writeStatus({
1574
+ lastEvent: "commit.canceled",
1575
+ lastEventTime: (/* @__PURE__ */ new Date()).toISOString()
1576
+ });
1577
+ this.commitCanceledHandlers.forEach(
1578
+ (handler) => handler(data.pendingCommit.id)
1579
+ );
1502
1580
  });
1503
1581
  logger.success("websocket", `Subscribed to private channel: ${channel}`);
1504
1582
  }
@@ -1527,6 +1605,9 @@ var WebSocketServiceImpl = class {
1527
1605
  onSyncRequested(handler) {
1528
1606
  this.syncRequestedHandlers.push(handler);
1529
1607
  }
1608
+ onCommitCanceled(handler) {
1609
+ this.commitCanceledHandlers.push(handler);
1610
+ }
1530
1611
  handleDisconnect() {
1531
1612
  this.disconnectHandlers.forEach((handler) => handler());
1532
1613
  if (this.isManualDisconnect) {
@@ -4,21 +4,21 @@ import {
4
4
  notify,
5
5
  packageDetector,
6
6
  websocketService
7
- } from "../chunk-LSBAWHMJ.js";
7
+ } from "../chunk-UQKCG3UM.js";
8
8
  import {
9
9
  apiService
10
- } from "../chunk-BWH6PAAH.js";
10
+ } from "../chunk-GCWEUJWP.js";
11
11
  import {
12
12
  gitService,
13
13
  projectService,
14
14
  removePidFile,
15
15
  writePidFile
16
- } from "../chunk-ZGV7IQMJ.js";
16
+ } from "../chunk-7OSHGB4C.js";
17
17
  import {
18
18
  authService,
19
19
  config,
20
20
  logger
21
- } from "../chunk-K3FOUU5A.js";
21
+ } from "../chunk-UHR52B56.js";
22
22
 
23
23
  // src/daemon/runner.ts
24
24
  import "dotenv/config";
@@ -196,7 +196,15 @@ var FileWatcher = class {
196
196
  const packageInfo = await Promise.all(
197
197
  rawPackageInfo.map((p) => packageDetector.checkPublicationStatus(p))
198
198
  );
199
- const diff = await gitService.getDiff(projectPath);
199
+ let diff = await gitService.getDiff(projectPath);
200
+ const MAX_DIFF_SIZE = 100 * 1024;
201
+ if (diff.length > MAX_DIFF_SIZE) {
202
+ logger.warn(
203
+ "watcher",
204
+ `Diff too large (${diff.length} bytes), truncating...`
205
+ );
206
+ diff = diff.substring(0, MAX_DIFF_SIZE) + "\n...diff truncated due to size limit...";
207
+ }
200
208
  const response = await apiService.syncProject(
201
209
  projectId,
202
210
  repoInfo,
@@ -664,6 +672,10 @@ Project: ${project.name}`,
664
672
  });
665
673
  commitQueue.addToQueue(commit, project);
666
674
  });
675
+ websocketService.onCommitCanceled((commitId) => {
676
+ logger.info("daemon", `Cancellation requested for commit: ${commitId}`);
677
+ commitQueue.cancel(commitId);
678
+ });
667
679
  websocketService.onCommitPending(async (data) => {
668
680
  const commit = data;
669
681
  logger.info("daemon", `Commit pending: ${commit.id}`);
package/dist/index.js CHANGED
@@ -3,10 +3,10 @@ import {
3
3
  commitQueue,
4
4
  packageDetector,
5
5
  websocketService
6
- } from "./chunk-LSBAWHMJ.js";
6
+ } from "./chunk-UQKCG3UM.js";
7
7
  import {
8
8
  apiService
9
- } from "./chunk-BWH6PAAH.js";
9
+ } from "./chunk-GCWEUJWP.js";
10
10
  import {
11
11
  getPidFilePath,
12
12
  gitService,
@@ -15,14 +15,14 @@ import {
15
15
  projectService,
16
16
  spawnDetached,
17
17
  validatePidFile
18
- } from "./chunk-ZGV7IQMJ.js";
18
+ } from "./chunk-7OSHGB4C.js";
19
19
  import {
20
20
  __commonJS,
21
21
  __toESM,
22
22
  authService,
23
23
  config,
24
24
  logger
25
- } from "./chunk-K3FOUU5A.js";
25
+ } from "./chunk-UHR52B56.js";
26
26
 
27
27
  // node_modules/semver/internal/constants.js
28
28
  var require_constants = __commonJS({
@@ -2658,7 +2658,7 @@ function registerStatusCommand(program2) {
2658
2658
  try {
2659
2659
  const { render } = await import("ink");
2660
2660
  const { createElement } = await import("react");
2661
- const { StatusDashboard } = await import("./StatusDashboard-2RKO3NNM.js");
2661
+ const { StatusDashboard } = await import("./StatusDashboard-SVQONIEE.js");
2662
2662
  render(createElement(StatusDashboard, { cwd }));
2663
2663
  return;
2664
2664
  } catch (error) {
@@ -5056,7 +5056,7 @@ function displayLocalProjects(entries) {
5056
5056
 
5057
5057
  // src/commands/about.ts
5058
5058
  import chalk17 from "chalk";
5059
- var AGENT_VERSION = "1.2.53";
5059
+ var AGENT_VERSION = "1.2.56";
5060
5060
  function registerAboutCommand(program2) {
5061
5061
  program2.command("about").description("Display information about Stint Agent").action(() => {
5062
5062
  console.log();
@@ -5097,7 +5097,7 @@ function registerAboutCommand(program2) {
5097
5097
  }
5098
5098
 
5099
5099
  // src/index.ts
5100
- var AGENT_VERSION2 = "1.2.53";
5100
+ var AGENT_VERSION2 = "1.2.56";
5101
5101
  var program = new Command3();
5102
5102
  program.name("stint").description("Stint Agent - Local daemon for Stint Project Assistant").version(AGENT_VERSION2, "-v, --version", "output the current version").addHelpText(
5103
5103
  "after",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gowelle/stint-agent",
3
- "version": "1.2.53",
3
+ "version": "1.2.56",
4
4
  "description": "Local agent for Stint - Project Assistant",
5
5
  "author": "Gowelle John <gowelle.john@icloud.com>",
6
6
  "license": "MIT",
@@ -1,7 +0,0 @@
1
- import {
2
- apiService
3
- } from "./chunk-BWH6PAAH.js";
4
- import "./chunk-K3FOUU5A.js";
5
- export {
6
- apiService
7
- };