ccsniff 1.1.22 → 1.1.24

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": "ccsniff",
3
- "version": "1.1.22",
3
+ "version": "1.1.24",
4
4
  "description": "Watch Claude Code JSONL output files and emit structured events as a Node.js EventEmitter",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/cli.js CHANGED
@@ -257,6 +257,17 @@ if (opts['list-projects']) {
257
257
  process.exit(0);
258
258
  }
259
259
 
260
+ // Each --*-discipline below is its own one-shot report ending in process.exit(0), so only the
261
+ // first requested discipline in source order would ever run. Combining flags (e.g.
262
+ // `--git-discipline --search-discipline`) would silently drop every discipline but the first and
263
+ // yield a false-clean audit. Fail loud instead of running one and dropping the rest.
264
+ const DISCIPLINE_FLAGS = ['bash-discipline', 'git-discipline', 'verb-bypass-discipline', 'spool-discipline', 'search-discipline', 'glyph-discipline', 'continuation-discipline'];
265
+ const requestedDisciplines = DISCIPLINE_FLAGS.filter(d => opts[d]);
266
+ if (requestedDisciplines.length > 1) {
267
+ process.stderr.write(`ccsniff: ${requestedDisciplines.length} discipline flags given (${requestedDisciplines.map(d => '--' + d).join(' ')}); each is a separate one-shot report and only the first would run. Invoke one discipline per call.\n`);
268
+ process.exit(2);
269
+ }
270
+
260
271
  // ---------- bash-discipline (flag Bash calls that should have been Read/Glob/Grep/dispatch)
261
272
  if (opts['bash-discipline']) {
262
273
  // discipline is about MY tool routing, not subagents — they have separate prompts/contexts.
@@ -7,7 +7,7 @@ const isAbs = (d) => d.startsWith('/') || /^[a-z]:/.test(d);
7
7
  export function targetsOutsideCwd(line, cwd) {
8
8
  const cwdN = normPath(cwd);
9
9
  if (!cwdN) return false;
10
- const stripped = stripQuoted(line);
10
+ const stripped = stripQuoted(line).replace(/\\/g, '/');
11
11
  const ctxM = stripped.match(/(?:^|[|&;]\s*)(?:cd|pushd)\s+([^\s|&;]+)/i) || stripped.match(/\bgit\s+-C\s+([^\s|&;]+)/i);
12
12
  if (ctxM) { const d = normPath(ctxM[1]); if (isAbs(d) && !d.startsWith(cwdN)) return true; }
13
13
  const absArgs = stripped.match(/(?:^|\s)((?:[a-z]:)?\/[^\s|&;"']+)/gi) || [];
package/src/index.cjs CHANGED
@@ -199,7 +199,11 @@ class JsonlReplayer extends JsonlWatcher {
199
199
  } catch {}
200
200
  };
201
201
  if (fs.existsSync(this._dir)) collect(this._dir, 0);
202
- const chosen = fileFilter ? all.filter(fileFilter) : all;
202
+ let chosen = fileFilter ? all.filter(fileFilter) : all;
203
+ if (since > 0) {
204
+ const cutoff = since - 300000;
205
+ chosen = chosen.filter(fp => { try { return fs.statSync(fp).mtimeMs >= cutoff; } catch { return true; } });
206
+ }
203
207
  let emitted = 0;
204
208
  for (const fp of chosen) {
205
209
  const fallbackSid = path.basename(fp, '.jsonl');
@@ -245,7 +249,7 @@ function vault({ projectsDir = DEFAULT_DIR, destDir = path.join(os.homedir(), '.
245
249
  try { srcStat = fs.statSync(srcPath); } catch { continue; }
246
250
  try {
247
251
  const dstStat = fs.statSync(dstPath);
248
- if (dstStat.size === srcStat.size && dstStat.mtimeMs >= srcStat.mtimeMs) { skipped++; continue; }
252
+ if (dstStat.size === srcStat.size && dstStat.mtimeMs >= srcStat.mtimeMs - 2000) { skipped++; continue; }
249
253
  } catch {}
250
254
  try {
251
255
  fs.mkdirSync(path.dirname(dstPath), { recursive: true });
package/src/index.js CHANGED
@@ -209,6 +209,10 @@ export class JsonlReplayer extends JsonlWatcher {
209
209
  };
210
210
  if (fs.existsSync(this._dir)) collect(this._dir, 0);
211
211
  let chosen = fileFilter ? all.filter(fileFilter) : all;
212
+ if (since > 0) {
213
+ const cutoff = since - 300000;
214
+ chosen = chosen.filter(fp => { try { return fs.statSync(fp).mtimeMs >= cutoff; } catch { return true; } });
215
+ }
212
216
  // When a maxEvents budget is set, read newest files first and stop once the
213
217
  // budget is met — so a huge projects tree never has its full backlog parsed
214
218
  // into the heap at once (the load-time memory peak this guards against).
@@ -264,7 +268,7 @@ export function vault({ projectsDir = DEFAULT_DIR, destDir = path.join(os.homedi
264
268
  try { srcStat = fs.statSync(srcPath); } catch { continue; }
265
269
  try {
266
270
  const dstStat = fs.statSync(dstPath);
267
- if (dstStat.size === srcStat.size && dstStat.mtimeMs >= srcStat.mtimeMs) { skipped++; continue; }
271
+ if (dstStat.size === srcStat.size && dstStat.mtimeMs >= srcStat.mtimeMs - 2000) { skipped++; continue; }
268
272
  } catch {}
269
273
  try {
270
274
  fs.mkdirSync(path.dirname(dstPath), { recursive: true });