@gowelle/stint-agent 1.2.57 → 1.2.58

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-3MQX6TV5.js";
5
+ } from "./chunk-KTMQKNBV.js";
6
6
  import {
7
7
  authService
8
- } from "./chunk-46ZVI2XN.js";
8
+ } from "./chunk-WHQU5Y4G.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-I5BUGWPT.js";
4
+ import "./chunk-WHQU5Y4G.js";
5
+ export {
6
+ apiService
7
+ };
@@ -2,7 +2,7 @@ import {
2
2
  authService,
3
3
  config,
4
4
  logger
5
- } from "./chunk-46ZVI2XN.js";
5
+ } from "./chunk-WHQU5Y4G.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.57";
103
+ var AGENT_VERSION = "1.2.58";
104
104
  var ApiServiceImpl = class {
105
105
  sessionId = null;
106
106
  circuitBreaker = new CircuitBreaker({
@@ -158,9 +158,7 @@ var ApiServiceImpl = class {
158
158
  });
159
159
  if (!response.ok) {
160
160
  const errorText = await response.text();
161
- throw new Error(
162
- `API request failed: ${response.status} ${errorText}`
163
- );
161
+ throw new Error(`API request failed: ${response.status} ${errorText}`);
164
162
  }
165
163
  return await response.json();
166
164
  } catch (error) {
@@ -535,6 +533,25 @@ var ApiServiceImpl = class {
535
533
  );
536
534
  }
537
535
  }
536
+ /**
537
+ * Report commit processing progress.
538
+ * @param commitId - Commit ID
539
+ * @param stage - Current processing stage
540
+ */
541
+ async reportCommitProgress(commitId, stage) {
542
+ if (!stage) return;
543
+ try {
544
+ await this.executeRequest(`/api/agent/commits/${commitId}/progress`, {
545
+ method: "POST",
546
+ body: JSON.stringify({ stage })
547
+ });
548
+ } catch (error) {
549
+ logger.debug(
550
+ "api",
551
+ `Progress report failed for ${commitId}: ${error.message}`
552
+ );
553
+ }
554
+ }
538
555
  /**
539
556
  * Get tasks for a project, optionally filtered by branch
540
557
  * @param projectId - Project ID
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  config,
3
3
  logger
4
- } from "./chunk-46ZVI2XN.js";
4
+ } from "./chunk-WHQU5Y4G.js";
5
5
 
6
6
  // src/services/git.ts
7
7
  import simpleGit from "simple-git";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  apiService
3
- } from "./chunk-HPJT3JQ7.js";
3
+ } from "./chunk-I5BUGWPT.js";
4
4
  import {
5
5
  gitService,
6
6
  projectService
7
- } from "./chunk-3MQX6TV5.js";
7
+ } from "./chunk-KTMQKNBV.js";
8
8
  import {
9
9
  authService,
10
10
  config,
11
11
  logger
12
- } from "./chunk-46ZVI2XN.js";
12
+ } from "./chunk-WHQU5Y4G.js";
13
13
 
14
14
  // src/services/package-detector.ts
15
15
  import fs from "fs";
@@ -541,87 +541,6 @@ function notify(options) {
541
541
  }
542
542
  }
543
543
 
544
- // src/utils/streamer.ts
545
- var OutputBuffer = class {
546
- buffer = "";
547
- commitId;
548
- lastSendTime = 0;
549
- timer = null;
550
- MAX_BUFFER_SIZE = 50 * 1024;
551
- // 50KB safety limit
552
- FLUSH_INTERVAL = 500;
553
- // 500ms
554
- isClosed = false;
555
- constructor(commitId) {
556
- this.commitId = commitId;
557
- }
558
- /**
559
- * Add output to the buffer
560
- * @param data String data to append
561
- */
562
- append(data) {
563
- if (this.isClosed) return;
564
- const text = typeof data === "string" ? data : String(data);
565
- if (!text) return;
566
- this.buffer += text;
567
- if (this.buffer.length > this.MAX_BUFFER_SIZE) {
568
- this.flush();
569
- return;
570
- }
571
- this.scheduleFlush();
572
- }
573
- /**
574
- * Schedule a flush operation
575
- */
576
- scheduleFlush() {
577
- const now = Date.now();
578
- const timeSinceLastSend = now - this.lastSendTime;
579
- if (this.timer) {
580
- return;
581
- }
582
- if (timeSinceLastSend >= this.FLUSH_INTERVAL) {
583
- this.flush();
584
- } else {
585
- const delay = this.FLUSH_INTERVAL - timeSinceLastSend;
586
- this.timer = setTimeout(() => this.flush(), delay);
587
- }
588
- }
589
- /**
590
- * Flush current buffer to API
591
- */
592
- async flush() {
593
- if (this.timer) {
594
- clearTimeout(this.timer);
595
- this.timer = null;
596
- }
597
- if (!this.buffer) {
598
- return;
599
- }
600
- if (!this.buffer.trim()) {
601
- this.buffer = "";
602
- return;
603
- }
604
- const chunk = this.buffer;
605
- this.buffer = "";
606
- this.lastSendTime = Date.now();
607
- try {
608
- await apiService.streamCommitOutput(this.commitId, chunk);
609
- } catch (error) {
610
- logger.debug(
611
- "stream",
612
- `Failed to stream output for ${this.commitId}: ${error.message}`
613
- );
614
- }
615
- }
616
- /**
617
- * Close the buffer and flush remaining data
618
- */
619
- async close() {
620
- this.isClosed = true;
621
- await this.flush();
622
- }
623
- };
624
-
625
544
  // src/services/hook.ts
626
545
  import { spawn } from "child_process";
627
546
  var HookService = class {
@@ -767,7 +686,10 @@ var CommitQueueProcessor = class {
767
686
  * @param commitId - Commit ID to cancel
768
687
  */
769
688
  cancel(commitId) {
770
- logger.info("queue", `Received cancellation request for commit ${commitId}`);
689
+ logger.info(
690
+ "queue",
691
+ `Received cancellation request for commit ${commitId}`
692
+ );
771
693
  if (this.currentCommitId === commitId) {
772
694
  logger.info(
773
695
  "queue",
@@ -821,7 +743,10 @@ var CommitQueueProcessor = class {
821
743
  this.currentCommitId = item.commit.id;
822
744
  this.abortedCommitId = null;
823
745
  try {
824
- await this.executeCommit(item.commit, item.project);
746
+ await this.executeCommit(item.commit, item.project, (stage) => {
747
+ apiService.reportCommitProgress(item.commit.id, stage);
748
+ logger.info("queue", stage);
749
+ });
825
750
  } catch (error) {
826
751
  if (error.message === "Commit canceled") {
827
752
  logger.info("queue", `Commit ${item.commit.id} processing canceled.`);
@@ -852,14 +777,8 @@ var CommitQueueProcessor = class {
852
777
  */
853
778
  async executeCommit(commit, project, onProgress, options) {
854
779
  logger.info("queue", `Processing commit: ${commit.id} - ${commit.message}`);
855
- const streamer = new OutputBuffer(commit.id);
856
- const streamOutput = (text) => {
857
- streamer.append(text);
858
- };
859
780
  try {
860
781
  this.checkAborted(commit.id);
861
- streamer.append(`Processing commit: ${commit.message}
862
- `);
863
782
  onProgress?.("Finding project directory...");
864
783
  const projectPath = this.findProjectPath(project.id);
865
784
  if (!projectPath) {
@@ -869,8 +788,6 @@ var CommitQueueProcessor = class {
869
788
  }
870
789
  this.checkAborted(commit.id);
871
790
  logger.info("queue", `Executing in directory: ${projectPath}`);
872
- streamer.append(`> Project directory: ${projectPath}
873
- `);
874
791
  onProgress?.("Validating repository...");
875
792
  const isRepo = await gitService.isRepo(projectPath);
876
793
  if (!isRepo) {
@@ -888,11 +805,9 @@ var CommitQueueProcessor = class {
888
805
  this.checkAborted(commit.id);
889
806
  onProgress?.("Running pre-commit hooks...");
890
807
  logger.info("queue", "Executing pre-commit hooks...");
891
- streamer.append("\n> Executing pre-commit hooks...\n");
892
808
  const hookResults = await hookService.executeHooks(
893
809
  project.commitSettings.hooks,
894
- projectPath,
895
- streamOutput
810
+ projectPath
896
811
  );
897
812
  this.checkAborted(commit.id);
898
813
  const failedBlockingHook = hookResults.find(
@@ -904,11 +819,6 @@ var CommitQueueProcessor = class {
904
819
  "queue",
905
820
  `Blocking hook "${failedBlockingHook.hookName}" failed: ${errorMsg}`
906
821
  );
907
- streamer.append(
908
- `
909
- Error: Blocking hook "${failedBlockingHook.hookName}" failed: ${errorMsg}
910
- `
911
- );
912
822
  if (failedBlockingHook.output) {
913
823
  logger.warn("queue", `Hook output:
914
824
  ${failedBlockingHook.output}`);
@@ -923,11 +833,6 @@ ${failedBlockingHook.output}`);
923
833
  "queue",
924
834
  `${failedNonBlockingHooks.length} hooks failed but were not blocking: ${failedNonBlockingHooks.map((h) => h.hookName).join(", ")}`
925
835
  );
926
- streamer.append(
927
- `
928
- Warning: ${failedNonBlockingHooks.length} non-blocking hooks failed.
929
- `
930
- );
931
836
  }
932
837
  const statusAfterHooks = await gitService.getStatus(projectPath);
933
838
  hookModifiedFiles = [
@@ -939,11 +844,6 @@ Warning: ${failedNonBlockingHooks.length} non-blocking hooks failed.
939
844
  "queue",
940
845
  `Hooks modified ${hookModifiedFiles.length} additional files: ${hookModifiedFiles.join(", ")}`
941
846
  );
942
- streamer.append(
943
- `
944
- > Hooks modified ${hookModifiedFiles.length} additional files: ${hookModifiedFiles.join(", ")}
945
- `
946
- );
947
847
  }
948
848
  }
949
849
  this.checkAborted(commit.id);
@@ -957,24 +857,16 @@ Warning: ${failedNonBlockingHooks.length} non-blocking hooks failed.
957
857
  const extraFiles = filesToStage.length - commit.files.length;
958
858
  const extraMsg = extraFiles > 0 ? ` (+${extraFiles} from hooks)` : "";
959
859
  onProgress?.(`Staging ${filesToStage.length} files${extraMsg}...`);
960
- streamer.append(
961
- `
962
- > Staging ${filesToStage.length} files${extraMsg}...
963
- `
964
- );
965
860
  this.checkAborted(commit.id);
966
- await gitService.stageFiles(projectPath, filesToStage, streamOutput);
861
+ await gitService.stageFiles(projectPath, filesToStage);
967
862
  status = await gitService.getStatus(projectPath);
968
863
  logger.info("queue", `Auto-staged files: ${filesToStage.join(", ")}`);
969
864
  } else if (status.staged.length === 0) {
970
865
  const hasChanges = status.unstaged.length > 0 || status.untracked.length > 0;
971
866
  if (hasChanges) {
972
867
  onProgress?.("Staging all changes...");
973
- streamer.append(`
974
- > Auto-staging all changes...
975
- `);
976
868
  this.checkAborted(commit.id);
977
- await gitService.stageAll(projectPath, streamOutput);
869
+ await gitService.stageAll(projectPath);
978
870
  status = await gitService.getStatus(projectPath);
979
871
  logger.info("queue", `Auto-staged all changes`);
980
872
  }
@@ -986,24 +878,16 @@ Warning: ${failedNonBlockingHooks.length} non-blocking hooks failed.
986
878
  );
987
879
  }
988
880
  logger.info("queue", `Committing ${status.staged.length} staged files.`);
989
- streamer.append(
990
- `
991
- > Committing ${status.staged.length} staged files...
992
- `
993
- );
994
881
  this.checkAborted(commit.id);
995
882
  onProgress?.("Creating commit...");
996
883
  logger.info("queue", `Creating commit with message: "${commit.message}"`);
997
884
  const sha = await gitService.commit(
998
885
  projectPath,
999
886
  commit.message,
1000
- streamOutput,
887
+ void 0,
1001
888
  commit.body
1002
889
  );
1003
890
  logger.success("queue", `Commit created successfully: ${sha}`);
1004
- streamer.append(`
1005
- > Commit created: ${sha}
1006
- `);
1007
891
  this.checkAborted(commit.id);
1008
892
  let pushed = false;
1009
893
  let pushError;
@@ -1011,33 +895,20 @@ Warning: ${failedNonBlockingHooks.length} non-blocking hooks failed.
1011
895
  if (shouldPush) {
1012
896
  try {
1013
897
  onProgress?.("Pushing to remote...");
1014
- streamer.append(`
1015
- > Pushing to remote...
1016
- `);
1017
898
  this.checkAborted(commit.id);
1018
- await gitService.push(
1019
- projectPath,
1020
- void 0,
1021
- void 0,
1022
- streamOutput
1023
- );
899
+ await gitService.push(projectPath, void 0, void 0);
1024
900
  pushed = true;
1025
901
  logger.success("queue", `Pushed commit ${sha} to remote`);
1026
- streamer.append(`
1027
- > Implementation sent to remote successfully.
1028
- `);
1029
902
  notify({
1030
903
  title: `Commit Pushed - ${project.name}`,
1031
904
  message: `Commit "${commit.message}" successfully pushed.`,
1032
905
  category: "commits"
1033
906
  });
1034
907
  } catch (error) {
1035
- if (this.abortedCommitId === commit.id) throw new Error("Commit canceled");
908
+ if (this.abortedCommitId === commit.id)
909
+ throw new Error("Commit canceled");
1036
910
  pushError = error.message;
1037
911
  const isConflict = pushError.includes("rejected") || pushError.includes("non-fast-forward") || pushError.includes("failed to push") || pushError.includes("Updates were rejected");
1038
- streamer.append(`
1039
- > Push failed: ${pushError}
1040
- `);
1041
912
  if (isConflict) {
1042
913
  logger.warn(
1043
914
  "queue",
@@ -1062,10 +933,6 @@ Run "git pull --rebase" to resolve.`,
1062
933
  this.checkAborted(commit.id);
1063
934
  onProgress?.("Reporting to server...");
1064
935
  await this.reportSuccess(commit.id, sha, pushed, pushError);
1065
- streamer.append(`
1066
- > Execution completed.
1067
- `);
1068
- await streamer.close();
1069
936
  if (!pushed && !pushError) {
1070
937
  notify({
1071
938
  title: `Commit Created - ${project.name}`,
@@ -1078,10 +945,6 @@ Run "git pull --rebase" to resolve.`,
1078
945
  const msg = error.message;
1079
946
  if (msg === "Commit canceled") {
1080
947
  logger.info("queue", `Commit execution aborted: ${commit.id}`);
1081
- streamer.append(`
1082
- > Execution canceled by user.
1083
- `);
1084
- await streamer.close();
1085
948
  notify({
1086
949
  title: `Commit Canceled - ${project.name}`,
1087
950
  message: `Commit processing canceled.`,
@@ -1090,10 +953,6 @@ Run "git pull --rebase" to resolve.`,
1090
953
  throw error;
1091
954
  }
1092
955
  logger.error("queue", `Commit execution failed: ${msg}`);
1093
- streamer.append(`
1094
- > Execution failed: ${msg}
1095
- `);
1096
- await streamer.close();
1097
956
  notify({
1098
957
  title: `Commit Failed - ${project.name}`,
1099
958
  message: `Failed to execute commit "${commit.message}": ${msg}`,
@@ -1165,6 +1024,15 @@ Run "git pull --rebase" to resolve.`,
1165
1024
  getQueueLength() {
1166
1025
  return this.queue.length;
1167
1026
  }
1027
+ /**
1028
+ * Clear the queue and reset processing state (for testing)
1029
+ */
1030
+ clear() {
1031
+ this.queue = [];
1032
+ this.isProcessing = false;
1033
+ this.currentCommitId = null;
1034
+ this.abortedCommitId = null;
1035
+ }
1168
1036
  };
1169
1037
  var commitQueue = new CommitQueueProcessor();
1170
1038
 
@@ -1502,7 +1370,7 @@ var WebSocketServiceImpl = class {
1502
1370
  "websocket",
1503
1371
  `Commit ${commit.id} marked as large, fetching full details...`
1504
1372
  );
1505
- const { apiService: apiService2 } = await import("./api-NBOMNUU6.js");
1373
+ const { apiService: apiService2 } = await import("./api-PWWFTHZJ.js");
1506
1374
  const fullCommit = await apiService2.getCommit(commit.id);
1507
1375
  commit = {
1508
1376
  ...commit,
@@ -358,7 +358,7 @@ var AuthServiceImpl = class {
358
358
  return null;
359
359
  }
360
360
  try {
361
- const { apiService } = await import("./api-NBOMNUU6.js");
361
+ const { apiService } = await import("./api-PWWFTHZJ.js");
362
362
  const user = await apiService.getCurrentUser();
363
363
  logger.info("auth", `Token validated for user: ${user.email}`);
364
364
  return user;
@@ -4,21 +4,21 @@ import {
4
4
  notify,
5
5
  packageDetector,
6
6
  websocketService
7
- } from "../chunk-R26LSZF3.js";
7
+ } from "../chunk-UGPSA4OM.js";
8
8
  import {
9
9
  apiService
10
- } from "../chunk-HPJT3JQ7.js";
10
+ } from "../chunk-I5BUGWPT.js";
11
11
  import {
12
12
  gitService,
13
13
  projectService,
14
14
  removePidFile,
15
15
  writePidFile
16
- } from "../chunk-3MQX6TV5.js";
16
+ } from "../chunk-KTMQKNBV.js";
17
17
  import {
18
18
  authService,
19
19
  config,
20
20
  logger
21
- } from "../chunk-46ZVI2XN.js";
21
+ } from "../chunk-WHQU5Y4G.js";
22
22
 
23
23
  // src/daemon/runner.ts
24
24
  import "dotenv/config";
package/dist/index.js CHANGED
@@ -3,10 +3,10 @@ import {
3
3
  commitQueue,
4
4
  packageDetector,
5
5
  websocketService
6
- } from "./chunk-R26LSZF3.js";
6
+ } from "./chunk-UGPSA4OM.js";
7
7
  import {
8
8
  apiService
9
- } from "./chunk-HPJT3JQ7.js";
9
+ } from "./chunk-I5BUGWPT.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-3MQX6TV5.js";
18
+ } from "./chunk-KTMQKNBV.js";
19
19
  import {
20
20
  __commonJS,
21
21
  __toESM,
22
22
  authService,
23
23
  config,
24
24
  logger
25
- } from "./chunk-46ZVI2XN.js";
25
+ } from "./chunk-WHQU5Y4G.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-VRS5ISJB.js");
2661
+ const { StatusDashboard } = await import("./StatusDashboard-5CQMAIYN.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.57";
5059
+ var AGENT_VERSION = "1.2.58";
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.57";
5100
+ var AGENT_VERSION2 = "1.2.58";
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.57",
3
+ "version": "1.2.58",
4
4
  "description": "Local agent for Stint - Project Assistant",
5
5
  "author": "Gowelle John <gowelle.john@icloud.com>",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "typecheck": "tsc --noEmit",
37
37
  "format": "prettier --write src",
38
38
  "format:check": "prettier --check src",
39
- "test": "vitest",
39
+ "test": "npx vitest run",
40
40
  "test:update": "node --loader ts-node/esm scripts/test-update.ts",
41
41
  "prepublishOnly": "npm run build"
42
42
  },
@@ -1,7 +0,0 @@
1
- import {
2
- apiService
3
- } from "./chunk-HPJT3JQ7.js";
4
- import "./chunk-46ZVI2XN.js";
5
- export {
6
- apiService
7
- };