marmot-logger 1.0.1 → 1.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marmot-logger",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "Activity monitoring tool for developer workflows - tracks file changes, terminal commands, git operations, and Claude Code hooks",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/cli/status.js CHANGED
@@ -46,7 +46,7 @@ module.exports = async function status() {
46
46
  // Plugins
47
47
  console.log('');
48
48
  console.log(chalk.bold('Plugins:'));
49
- const plugins = ['file-monitor', 'terminal', 'git-hooks', 'makefile', 'claude-hooks'];
49
+ const plugins = ['file-monitor', 'terminal', 'git-hooks', 'makefile', 'claude-hooks', 'process-monitor'];
50
50
 
51
51
  for (const plugin of plugins) {
52
52
  const enabled = config.isPluginEnabled(projectConfig, plugin);
@@ -27,7 +27,8 @@ const DEFAULT_CONFIG = {
27
27
  events: ['PreToolUse', 'PostToolUse', 'Stop', 'SubagentStop', 'UserPromptSubmit', 'SessionStart', 'SessionEnd']
28
28
  },
29
29
  'process-monitor': {
30
- enabled: false
30
+ enabled: false,
31
+ intervalSeconds: 15
31
32
  }
32
33
  }
33
34
  };
@@ -8,6 +8,15 @@ const logger = require('../core/logger');
8
8
  const MARMOT_CRON_MARKER = '# marmot-process-monitor';
9
9
  const SNAPSHOT_FILENAME = 'process-snapshot.json';
10
10
 
11
+ // Skip marmot's own processes to avoid noise
12
+ function isMarmotProcess(cmdline) {
13
+ if (!cmdline) return false;
14
+ return cmdline.includes('marmot monitor') ||
15
+ cmdline.includes('marmot process-monitor') ||
16
+ cmdline.includes('marmot log') ||
17
+ cmdline.includes('# marmot-');
18
+ }
19
+
11
20
  function getCrontab() {
12
21
  try {
13
22
  return execSync('crontab -l 2>/dev/null', { encoding: 'utf8' });
@@ -102,6 +111,9 @@ function getProjectProcesses(projectDir) {
102
111
  // Check if cwd is within project directory
103
112
  if (info.cwd === resolvedProjectDir ||
104
113
  info.cwd.startsWith(resolvedProjectDir + '/')) {
114
+ // Skip marmot's own processes
115
+ if (isMarmotProcess(info.cmdline)) continue;
116
+
105
117
  processes[info.key] = {
106
118
  pid: info.pid,
107
119
  cwd: info.cwd,
@@ -146,7 +158,8 @@ function saveSnapshot(snapshot, projectDir) {
146
158
  fs.writeFileSync(snapshotPath, JSON.stringify(snapshot, null, 2));
147
159
  }
148
160
 
149
- async function run(projectConfig, projectDir = process.cwd()) {
161
+ // Single poll iteration
162
+ async function poll(projectConfig, projectDir) {
150
163
  const logDir = config.getLogDir(projectConfig, projectDir);
151
164
 
152
165
  // Ensure log directory exists
@@ -221,16 +234,42 @@ async function run(projectConfig, projectDir = process.cwd()) {
221
234
  return changesFound;
222
235
  }
223
236
 
237
+ // Helper to sleep for given milliseconds
238
+ function sleep(ms) {
239
+ return new Promise(resolve => setTimeout(resolve, ms));
240
+ }
241
+
242
+ // Run polls for the duration of a cron minute (called by cron every minute)
243
+ async function run(projectConfig, projectDir = process.cwd()) {
244
+ const intervalSeconds = projectConfig.plugins?.['process-monitor']?.intervalSeconds || 15;
245
+ const pollsPerMinute = Math.floor(60 / intervalSeconds);
246
+ let totalChanges = 0;
247
+
248
+ for (let i = 0; i < pollsPerMinute; i++) {
249
+ const changes = await poll(projectConfig, projectDir);
250
+ totalChanges += changes;
251
+
252
+ // Sleep until next poll (except after last iteration)
253
+ if (i < pollsPerMinute - 1) {
254
+ await sleep(intervalSeconds * 1000);
255
+ }
256
+ }
257
+
258
+ return totalChanges;
259
+ }
260
+
224
261
  async function enable(projectConfig) {
225
262
  const projectDir = process.cwd();
226
263
  const marmotDir = config.getMarmotDir(projectDir);
227
264
  const logDir = config.getLogDir(projectConfig, projectDir);
228
265
  const snapshotPath = getProcessSnapshotPath(projectDir);
266
+ const intervalSeconds = projectConfig.plugins?.['process-monitor']?.intervalSeconds || 15;
229
267
 
230
268
  console.log('');
231
269
  console.log(chalk.bold('Process Monitor Plugin Setup:'));
232
270
  console.log(` Marmot directory: ${chalk.cyan(marmotDir)}`);
233
271
  console.log(` Snapshot file: ${chalk.cyan(snapshotPath)}`);
272
+ console.log(` Poll interval: ${chalk.cyan(intervalSeconds + ' seconds')}`);
234
273
  console.log(` Tracking: ${chalk.cyan('Processes with cwd in project directory')}`);
235
274
 
236
275
  // Install cron job