@gowelle/stint-agent 1.2.40 → 1.2.42

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
@@ -91,6 +91,19 @@ stint daemon status
91
91
  | `stint status [--dashboard]` | Show status (use `-d` for interactive dashboard) |
92
92
  | `stint sync` | Manually sync repository information to server |
93
93
 
94
+ ### Task Operations
95
+
96
+ | Command | Description |
97
+ | ------------- | ---------------------------------- |
98
+ | `stint tasks` | List tasks for the current project |
99
+
100
+ **`stint tasks` Options:**
101
+
102
+ | Option | Description |
103
+ | ----------------------- | ---------------------------------------------- |
104
+ | `-b, --branch <branch>` | Filter tasks by specific branch |
105
+ | `-a, --all` | Show all tasks (ignore current branch context) |
106
+
94
107
  ### Commit Operations
95
108
 
96
109
  | Command | Description |
@@ -2,10 +2,10 @@ import {
2
2
  gitService,
3
3
  projectService,
4
4
  validatePidFile
5
- } from "./chunk-UBNAWBEL.js";
5
+ } from "./chunk-TCRZ7UWW.js";
6
6
  import {
7
7
  authService
8
- } from "./chunk-XH2UAPVA.js";
8
+ } from "./chunk-GOT6DVWZ.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-XJKYVUDT.js";
4
+ import "./chunk-GOT6DVWZ.js";
5
+ export {
6
+ apiService
7
+ };
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  apiService
3
- } from "./chunk-3AS45O54.js";
3
+ } from "./chunk-XJKYVUDT.js";
4
4
  import {
5
5
  gitService,
6
6
  projectService
7
- } from "./chunk-UBNAWBEL.js";
7
+ } from "./chunk-TCRZ7UWW.js";
8
8
  import {
9
9
  authService,
10
10
  config,
11
11
  logger
12
- } from "./chunk-XH2UAPVA.js";
12
+ } from "./chunk-GOT6DVWZ.js";
13
13
 
14
14
  // src/utils/notify.ts
15
15
  import notifier from "node-notifier";
@@ -911,7 +911,7 @@ var WebSocketServiceImpl = class {
911
911
  "websocket",
912
912
  `Commit ${commit.id} marked as large, fetching full details...`
913
913
  );
914
- const { apiService: apiService2 } = await import("./api-QIIGJ7R2.js");
914
+ const { apiService: apiService2 } = await import("./api-3OZXM443.js");
915
915
  const fullCommit = await apiService2.getCommit(commit.id);
916
916
  commit = {
917
917
  ...commit,
@@ -346,7 +346,7 @@ var AuthServiceImpl = class {
346
346
  return null;
347
347
  }
348
348
  try {
349
- const { apiService } = await import("./api-QIIGJ7R2.js");
349
+ const { apiService } = await import("./api-3OZXM443.js");
350
350
  const user = await apiService.getCurrentUser();
351
351
  logger.info("auth", `Token validated for user: ${user.email}`);
352
352
  return user;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  config,
3
3
  logger
4
- } from "./chunk-XH2UAPVA.js";
4
+ } from "./chunk-GOT6DVWZ.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-XH2UAPVA.js";
5
+ } from "./chunk-GOT6DVWZ.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.40";
103
+ var AGENT_VERSION = "1.2.42";
104
104
  var ApiServiceImpl = class {
105
105
  sessionId = null;
106
106
  circuitBreaker = new CircuitBreaker({
@@ -254,9 +254,8 @@ var ApiServiceImpl = class {
254
254
  }
255
255
  /**
256
256
  * Send heartbeat to keep session alive
257
- * @throws Error if no active session
258
257
  */
259
- async heartbeat() {
258
+ async heartbeat(stats) {
260
259
  if (!this.sessionId) {
261
260
  throw new Error("No active session");
262
261
  }
@@ -264,7 +263,8 @@ var ApiServiceImpl = class {
264
263
  const response = await this.request("/api/agent/heartbeat", {
265
264
  method: "POST",
266
265
  body: JSON.stringify({
267
- session_id: this.sessionId
266
+ session_id: this.sessionId,
267
+ ...stats
268
268
  })
269
269
  });
270
270
  if (response.notification_preferences) {
@@ -3,20 +3,20 @@ import {
3
3
  commitQueue,
4
4
  notify,
5
5
  websocketService
6
- } from "../chunk-RZM4P35S.js";
6
+ } from "../chunk-CTT3PVE2.js";
7
7
  import {
8
8
  apiService
9
- } from "../chunk-3AS45O54.js";
9
+ } from "../chunk-XJKYVUDT.js";
10
10
  import {
11
11
  gitService,
12
12
  projectService,
13
13
  removePidFile,
14
14
  writePidFile
15
- } from "../chunk-UBNAWBEL.js";
15
+ } from "../chunk-TCRZ7UWW.js";
16
16
  import {
17
17
  authService,
18
18
  logger
19
- } from "../chunk-XH2UAPVA.js";
19
+ } from "../chunk-GOT6DVWZ.js";
20
20
 
21
21
  // src/daemon/runner.ts
22
22
  import "dotenv/config";
@@ -288,6 +288,12 @@ var FileWatcher = class {
288
288
  }
289
289
  }
290
290
  }
291
+ /**
292
+ * Get the number of watched projects
293
+ */
294
+ getWatchedCount() {
295
+ return this.watchers.size;
296
+ }
291
297
  };
292
298
 
293
299
  // src/daemon/sync.ts
@@ -478,6 +484,135 @@ var HealthMonitor = class {
478
484
  };
479
485
  var healthMonitor = new HealthMonitor();
480
486
 
487
+ // src/daemon/memory-trend.ts
488
+ var MAX_SAMPLES = 120;
489
+ var MIN_SAMPLES_FOR_ANALYSIS = 10;
490
+ var RSS_SLOPE_CAUTION_THRESHOLD = 20;
491
+ var RSS_SLOPE_WARNING_THRESHOLD = 50;
492
+ var R2_CONFIDENCE_THRESHOLD = 0.7;
493
+ var MemoryTrendTracker = class {
494
+ samples = [];
495
+ baselineRss = 0;
496
+ /**
497
+ * Add a new memory sample
498
+ */
499
+ addSample(memoryUsage, uptime) {
500
+ const sample = {
501
+ timestamp: Date.now(),
502
+ rss: Math.round(memoryUsage.rss / 1024 / 1024),
503
+ heapUsed: Math.round(memoryUsage.heapUsed / 1024 / 1024),
504
+ uptime
505
+ };
506
+ if (this.samples.length === 0) {
507
+ this.baselineRss = sample.rss;
508
+ }
509
+ this.samples.push(sample);
510
+ if (this.samples.length > MAX_SAMPLES) {
511
+ this.samples.shift();
512
+ }
513
+ }
514
+ /**
515
+ * Calculate linear regression for a dataset
516
+ * Returns { slope, intercept, r2 }
517
+ */
518
+ linearRegression(points) {
519
+ const n = points.length;
520
+ if (n < 2) return { slope: 0, intercept: 0, r2: 0 };
521
+ let sumX = 0;
522
+ let sumY = 0;
523
+ let sumXY = 0;
524
+ let sumXX = 0;
525
+ for (const { x, y } of points) {
526
+ sumX += x;
527
+ sumY += y;
528
+ sumXY += x * y;
529
+ sumXX += x * x;
530
+ }
531
+ const denominator = n * sumXX - sumX * sumX;
532
+ if (denominator === 0) return { slope: 0, intercept: 0, r2: 0 };
533
+ const slope = (n * sumXY - sumX * sumY) / denominator;
534
+ const intercept = (sumY - slope * sumX) / n;
535
+ const yMean = sumY / n;
536
+ let ssTotal = 0;
537
+ let ssResidual = 0;
538
+ for (const { x, y } of points) {
539
+ const yPredicted = slope * x + intercept;
540
+ ssTotal += (y - yMean) ** 2;
541
+ ssResidual += (y - yPredicted) ** 2;
542
+ }
543
+ const r2 = ssTotal === 0 ? 0 : 1 - ssResidual / ssTotal;
544
+ return { slope, intercept, r2 };
545
+ }
546
+ /**
547
+ * Get current memory trend analysis
548
+ */
549
+ getTrend() {
550
+ if (this.samples.length < MIN_SAMPLES_FOR_ANALYSIS) {
551
+ return {
552
+ rssSlope: 0,
553
+ heapSlope: 0,
554
+ rssR2: 0,
555
+ heapR2: 0,
556
+ sampleCount: this.samples.length,
557
+ timeSpanMinutes: 0,
558
+ status: "unknown",
559
+ message: `Collecting data... (${this.samples.length}/${MIN_SAMPLES_FOR_ANALYSIS} samples)`,
560
+ baselineRss: this.baselineRss,
561
+ currentRss: this.samples.length > 0 ? this.samples[this.samples.length - 1].rss : 0
562
+ };
563
+ }
564
+ const firstTimestamp = this.samples[0].timestamp;
565
+ const rssPoints = this.samples.map((s) => ({
566
+ x: (s.timestamp - firstTimestamp) / 1e3 / 3600,
567
+ // hours
568
+ y: s.rss
569
+ }));
570
+ const heapPoints = this.samples.map((s) => ({
571
+ x: (s.timestamp - firstTimestamp) / 1e3 / 3600,
572
+ y: s.heapUsed
573
+ }));
574
+ const rssRegression = this.linearRegression(rssPoints);
575
+ const heapRegression = this.linearRegression(heapPoints);
576
+ const lastTimestamp = this.samples[this.samples.length - 1].timestamp;
577
+ const timeSpanMinutes = (lastTimestamp - firstTimestamp) / 1e3 / 60;
578
+ const currentRss = this.samples[this.samples.length - 1].rss;
579
+ let status = "healthy";
580
+ let message = "Memory usage is stable";
581
+ const isConfidentTrend = rssRegression.r2 >= R2_CONFIDENCE_THRESHOLD;
582
+ if (isConfidentTrend && rssRegression.slope >= RSS_SLOPE_WARNING_THRESHOLD) {
583
+ status = "warning";
584
+ message = `Memory leak detected: +${rssRegression.slope.toFixed(1)} MB/hr (R\xB2=${rssRegression.r2.toFixed(2)})`;
585
+ } else if (isConfidentTrend && rssRegression.slope >= RSS_SLOPE_CAUTION_THRESHOLD) {
586
+ status = "caution";
587
+ message = `Memory trending up: +${rssRegression.slope.toFixed(1)} MB/hr`;
588
+ } else if (rssRegression.slope < 0 && rssRegression.r2 >= 0.5) {
589
+ message = `Memory stable/decreasing: ${rssRegression.slope.toFixed(1)} MB/hr`;
590
+ } else if (!isConfidentTrend && Math.abs(rssRegression.slope) > 10) {
591
+ message = `Memory fluctuating (low confidence: R\xB2=${rssRegression.r2.toFixed(2)})`;
592
+ }
593
+ return {
594
+ rssSlope: rssRegression.slope,
595
+ heapSlope: heapRegression.slope,
596
+ rssR2: rssRegression.r2,
597
+ heapR2: heapRegression.r2,
598
+ sampleCount: this.samples.length,
599
+ timeSpanMinutes,
600
+ status,
601
+ message,
602
+ baselineRss: this.baselineRss,
603
+ currentRss
604
+ };
605
+ }
606
+ /**
607
+ * Reset all samples (e.g., after restart)
608
+ */
609
+ reset() {
610
+ this.samples = [];
611
+ this.baselineRss = 0;
612
+ }
613
+ };
614
+ var memoryTrendTracker = new MemoryTrendTracker();
615
+
481
616
  // src/daemon/index.ts
482
617
  var heartbeatInterval = null;
483
618
  var isShuttingDown = false;
@@ -638,7 +773,35 @@ function startHeartbeat() {
638
773
  heartbeatInterval = setInterval(async () => {
639
774
  if (isShuttingDown) return;
640
775
  try {
641
- await apiService.heartbeat();
776
+ const memoryUsage = process.memoryUsage();
777
+ const uptime = Math.floor(process.uptime());
778
+ memoryTrendTracker.addSample(memoryUsage, uptime);
779
+ const memoryTrend = memoryTrendTracker.getTrend();
780
+ await apiService.heartbeat({
781
+ websocket_connected: websocketService.isConnected(),
782
+ queue_size: commitQueue.getQueueLength(),
783
+ watched_projects_count: fileWatcher.getWatchedCount ? fileWatcher.getWatchedCount() : 0,
784
+ memory_usage: {
785
+ rss: Math.round(memoryUsage.rss / 1024 / 1024),
786
+ // MB
787
+ heapTotal: Math.round(memoryUsage.heapTotal / 1024 / 1024),
788
+ heapUsed: Math.round(memoryUsage.heapUsed / 1024 / 1024),
789
+ external: Math.round(memoryUsage.external / 1024 / 1024)
790
+ },
791
+ memory_trend: {
792
+ rss_slope: memoryTrend.rssSlope,
793
+ heap_slope: memoryTrend.heapSlope,
794
+ rss_r2: memoryTrend.rssR2,
795
+ heap_r2: memoryTrend.heapR2,
796
+ sample_count: memoryTrend.sampleCount,
797
+ time_span_minutes: memoryTrend.timeSpanMinutes,
798
+ status: memoryTrend.status,
799
+ message: memoryTrend.message,
800
+ baseline_rss: memoryTrend.baselineRss,
801
+ current_rss: memoryTrend.currentRss
802
+ },
803
+ uptime
804
+ });
642
805
  healthMonitor.recordHeartbeat();
643
806
  logger.debug("daemon", "Heartbeat sent successfully");
644
807
  } catch (error) {
package/dist/index.js CHANGED
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  commitQueue,
4
4
  websocketService
5
- } from "./chunk-RZM4P35S.js";
5
+ } from "./chunk-CTT3PVE2.js";
6
6
  import {
7
7
  apiService
8
- } from "./chunk-3AS45O54.js";
8
+ } from "./chunk-XJKYVUDT.js";
9
9
  import {
10
10
  getPidFilePath,
11
11
  gitService,
@@ -14,14 +14,14 @@ import {
14
14
  projectService,
15
15
  spawnDetached,
16
16
  validatePidFile
17
- } from "./chunk-UBNAWBEL.js";
17
+ } from "./chunk-TCRZ7UWW.js";
18
18
  import {
19
19
  __commonJS,
20
20
  __toESM,
21
21
  authService,
22
22
  config,
23
23
  logger
24
- } from "./chunk-XH2UAPVA.js";
24
+ } from "./chunk-GOT6DVWZ.js";
25
25
 
26
26
  // node_modules/semver/internal/constants.js
27
27
  var require_constants = __commonJS({
@@ -2657,7 +2657,7 @@ function registerStatusCommand(program2) {
2657
2657
  try {
2658
2658
  const { render } = await import("ink");
2659
2659
  const { createElement } = await import("react");
2660
- const { StatusDashboard } = await import("./StatusDashboard-NGRPLDM7.js");
2660
+ const { StatusDashboard } = await import("./StatusDashboard-A4AGVOHI.js");
2661
2661
  render(createElement(StatusDashboard, { cwd }));
2662
2662
  return;
2663
2663
  } catch (error) {
@@ -4928,7 +4928,7 @@ Tasks for project ${chalk15.cyan(linkedProject.projectId)}`
4928
4928
  });
4929
4929
 
4930
4930
  // src/index.ts
4931
- var AGENT_VERSION = "1.2.40";
4931
+ var AGENT_VERSION = "1.2.42";
4932
4932
  var program = new Command2();
4933
4933
  program.name("stint").description("Stint Agent - Local daemon for Stint Project Assistant").version(AGENT_VERSION, "-v, --version", "output the current version").addHelpText(
4934
4934
  "after",
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@gowelle/stint-agent",
3
- "version": "1.2.40",
3
+ "version": "1.2.42",
4
4
  "description": "Local agent for Stint - Project Assistant",
5
5
  "author": "Gowelle John <gowelle.john@icloud.com>",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "bin": {
9
- "stint": "./dist/index.js"
9
+ "stint": "dist/index.js"
10
10
  },
11
11
  "files": [
12
12
  "dist",
@@ -1,7 +0,0 @@
1
- import {
2
- apiService
3
- } from "./chunk-3AS45O54.js";
4
- import "./chunk-XH2UAPVA.js";
5
- export {
6
- apiService
7
- };