@moshi-labs/snitch 1.0.2 → 1.0.3

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/cli/collector.js CHANGED
@@ -3,6 +3,7 @@ import { readFileSync, statSync, existsSync } from 'fs';
3
3
  import { join, basename, dirname } from 'path';
4
4
  import { execSync } from 'child_process';
5
5
  import { homedir } from 'os';
6
+ import { load } from './config.js';
6
7
 
7
8
  const CLAUDE_PROJECTS_DIR = join(homedir(), '.claude', 'projects');
8
9
 
@@ -16,8 +17,13 @@ export class ActivityCollector {
16
17
  this.watcher = null;
17
18
  this.filePositions = new Map(); // Track read position per file
18
19
  this.activeThresholdMs = 5 * 60 * 1000; // 5 minutes = active
19
- // Only track these repos
20
- this.allowedRepos = ['moshi-api', 'moshi-frontend', 'moshi-e2e', 'terraform', 'browser-use', 'claude-team-viewer', 'snitch'];
20
+ // Load allowed repos from config
21
+ const config = load();
22
+ this.allowedRepos = config.allowedRepos || [];
23
+ // Build regex pattern from allowed repos
24
+ this.repoPattern = this.allowedRepos.length > 0
25
+ ? new RegExp(this.allowedRepos.map(r => r.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|'))
26
+ : null;
21
27
  }
22
28
 
23
29
  start() {
@@ -137,9 +143,9 @@ export class ActivityCollector {
137
143
  }
138
144
  // Detect cd into repos
139
145
  const cdMatch = cmd.match(/cd\s+['"]*([^'"&|;\s]+)/);
140
- if (cdMatch) {
146
+ if (cdMatch && this.repoPattern) {
141
147
  const path = cdMatch[1];
142
- const repoMatch = path.match(/moshi-(api|frontend|e2e)|terraform|browser-use|claude-team-viewer|snitch/);
148
+ const repoMatch = path.match(this.repoPattern);
143
149
  if (repoMatch) {
144
150
  activity.repo = repoMatch[0];
145
151
  }
@@ -150,9 +156,11 @@ export class ActivityCollector {
150
156
  // Extract repo hints from file operations
151
157
  if (['Read', 'Edit', 'Write'].includes(block.name) && block.input?.file_path) {
152
158
  const path = block.input.file_path;
153
- const repoMatch = path.match(/moshi-(api|frontend|e2e)|terraform|browser-use|claude-team-viewer|snitch/);
154
- if (repoMatch) {
155
- activity.repo = repoMatch[0];
159
+ if (this.repoPattern) {
160
+ const repoMatch = path.match(this.repoPattern);
161
+ if (repoMatch) {
162
+ activity.repo = repoMatch[0];
163
+ }
156
164
  }
157
165
  toolEvent.hint = path;
158
166
  }
@@ -166,8 +174,8 @@ export class ActivityCollector {
166
174
  if (event.gitBranch) {
167
175
  activity.branch = event.gitBranch;
168
176
  }
169
- if (event.cwd) {
170
- const repoMatch = event.cwd.match(/moshi-(api|frontend|e2e)|terraform|browser-use|claude-team-viewer|snitch/);
177
+ if (event.cwd && this.repoPattern) {
178
+ const repoMatch = event.cwd.match(this.repoPattern);
171
179
  if (repoMatch) {
172
180
  activity.repo = repoMatch[0];
173
181
  }
package/cli/config.js CHANGED
@@ -14,6 +14,7 @@ const DEFAULT_CONFIG = {
14
14
  serverUrl: '',
15
15
  apiKey: '',
16
16
  userName: '',
17
+ allowedRepos: ['moshi-api', 'moshi-frontend', 'moshi-e2e', 'terraform', 'claude-team-viewer', 'snitch'],
17
18
  };
18
19
 
19
20
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moshi-labs/snitch",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "CLI daemon that reports Claude Code activity to a team server",
5
5
  "type": "module",
6
6
  "bin": {