Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fix(collector): prevent memory leak in long-running processes
docs(readme): update installation instructions
refactor(renderer): simplify chart generation logic
test(metrics): add tests for drift compensation
chore(deps): update systeminformation to v5.22.0
refactor(metrics): replace systeminformation with native OS commands
ci(workflow): add Node.js 24 to test matrix
perf(post): optimize metrics file reading
```
Expand Down
9 changes: 5 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Examples:
- `feat(metrics): add memory pressure tracking`
- `fix(collector): prevent memory leak in long-running processes`
- `docs(readme): update installation instructions`
- `chore(deps): update systeminformation to v5.22.0`
- `refactor(metrics): replace systeminformation with native OS commands`

See `.github/copilot-instructions.md` for complete guidelines.

Expand Down Expand Up @@ -64,8 +64,9 @@ npm test # Run all tests
### Key Components

- **src/lib.ts**: Shared utilities and data schemas for metrics collection.
- **src/system-info.ts**: Native system information collector for CPU, memory, and disk metrics. All metrics use platform-specific commands for accuracy. CPU: Linux `/proc/stat`, macOS `top`, Windows PowerShell. Memory: Linux `/proc/meminfo`, macOS/Windows Node.js `os` module. Disk: Linux/macOS `df`, Windows PowerShell.
- **src/main/metrics.ts**: Collects CPU (user/system 0-100%) and memory (active/available in MB).
Uses `systeminformation`. Starts collection in constructor with drift-compensated `setTimeout`.
Uses native OS commands via `system-info.ts`. Starts collection in constructor with drift-compensated `setTimeout`.
Stores data in memory only; calls `saveState()` on stop.
- **src/main/collector.ts**: Simple background process that creates a Metrics instance and keeps running.
Ensures `stop()` is called on SIGTERM/SIGINT to save metrics state.
Expand Down Expand Up @@ -102,7 +103,7 @@ before(async () => {
mock.timers.enable({ apis: ['setTimeout', 'Date'] });

// Mock other modules
mockModule = mock.module("systeminformation", { /* ... */ });
mockModule = mock.module("../system-info.ts", { /* ... */ });

// Import after mocking
({ Metrics } = await import("./metrics.ts"));
Expand All @@ -119,7 +120,7 @@ for (let i = 0; i < 5; i++) {

```typescript
// Mock the module before importing
mock.module("systeminformation", {
mock.module("../system-info.ts", {
namedExports: {
currentLoad: async () =>
Promise.resolve({
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ src/

1. `src/main/index.ts` is executed
2. Node.js spawns `src/main/collector.ts` as a detached background process
3. `Metrics` class collects CPU/memory/disk information every 5 seconds using `systeminformation` library
3. `Metrics` class collects CPU/memory/disk information every 5 seconds using native OS commands
4. Metrics data is stored in memory only (no disk writes during collection)
5. On process termination (SIGTERM/SIGINT), metrics are saved to GitHub Actions state

Expand Down
Loading