ccsniff 1.1.12 → 1.1.14

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +45 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccsniff",
3
- "version": "1.1.12",
3
+ "version": "1.1.14",
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
@@ -30,7 +30,7 @@ const FLAGS = {
30
30
  string: ['since', 'until', 'before', 'after', 'grep', 'igrep', 'cwd', 'project', 'role', 'type', 'tool', 'session', 'sid', 'sess', 'parent', 'rollup', 'format', 'sort', 'unsloth', 'unsloth-format', 'exclude-sess', 'exclude-sid', 'exclude-cwd', 'exclude-project'],
31
31
  multi: ['grep', 'igrep', 'role', 'type', 'tool', 'session', 'sid', 'project', 'cwd', 'exclude-sess', 'exclude-sid', 'exclude-cwd', 'exclude-project'],
32
32
  number: ['limit', 'head', 'tail-n', 'ctx', 'truncate', 'days'],
33
- bool: ['json', 'ndjson', 'tail', 'f', 'full', 'reverse', 'invert', 'no-subagents', 'only-subagents', 'no-meta', 'only-meta', 'list-sessions', 'list-projects', 'list-tools', 'bash-discipline', 'git-discipline', 'search-discipline', 'learning-xref', 'include-subagents', 'stats', 'count', 'help', 'h'],
33
+ bool: ['json', 'ndjson', 'tail', 'f', 'full', 'reverse', 'invert', 'no-subagents', 'only-subagents', 'no-meta', 'only-meta', 'list-sessions', 'list-projects', 'list-tools', 'bash-discipline', 'git-discipline', 'search-discipline', 'glyph-discipline', 'learning-xref', 'include-subagents', 'stats', 'count', 'help', 'h'],
34
34
  };
35
35
 
36
36
  function parseArgs(argv) {
@@ -67,6 +67,7 @@ USAGE
67
67
  ccsniff --learning-xref [--sess <id>] [--days N] join transcript turns to rs-learn recall/memorize
68
68
  ccsniff --git-discipline [--stats] git push from a dirty/unwitnessed tree
69
69
  ccsniff --search-discipline [--stats] native search (Grep/Glob/Explore/find) instead of codesearch/recall
70
+ ccsniff --glyph-discipline [--stats] decorative glyphs (arrows/box/star/dot/check/emoji) written into files
70
71
  (excludes subagents by default — --include-subagents to opt in;
71
72
  excludes 'echo > .gm/exec-spool/in/...' as canonical spool-write)
72
73
  ccsniff --stats [filters]
@@ -426,6 +427,49 @@ if (opts['search-discipline']) {
426
427
  process.exit(0);
427
428
  }
428
429
 
430
+ // ---------- glyph-discipline (flag decorative graphical symbols written into files)
431
+ // The gm SKILL.md rule forbids decorative glyphs (arrows, box/geometric glyphs, stars, dots,
432
+ // bullets, checkmarks, crosses, emojis) in output and source; they must convert to ASCII on sight.
433
+ // A glyph written into a file via Write/Edit is invisible to the spool ledger, so ccsniff reading
434
+ // the tool-call stream is the surface that catches it. Functional operators are ASCII and never match.
435
+ if (opts['glyph-discipline']) {
436
+ const includeSubagents = opts['include-subagents'];
437
+ const GLYPH = /[←-⇿⌀-⏿■-◿☀-➿⬀-⯿]|[\u{1F000}-\u{1FAFF}]/u;
438
+ const GLYPH_G = /[←-⇿⌀-⏿■-◿☀-➿⬀-⯿]|[\u{1F000}-\u{1FAFF}]/gu;
439
+ // Glyphs inside a regex char-class (e.g. /[←-⇿]/) are a detector/range DEFINITION, not decorative
440
+ // prose — blank those bracket bodies before testing so a glyph-rule definition does not flag itself.
441
+ const stripGlyphCharClass = (s) => s.replace(/\[[^\]\n]*\]/g, (m) => GLYPH.test(m) ? '[]' : m);
442
+ const violations = [];
443
+ for (const ev of all) {
444
+ if (!filter(ev)) continue;
445
+ if (ev.block?.type !== 'tool_use') continue;
446
+ if (!includeSubagents && ev.conversation?.isSubagent) continue;
447
+ const name = ev.block?.name || '';
448
+ if (name !== 'Write' && name !== 'Edit' && name !== 'NotebookEdit') continue;
449
+ const inp = ev.block?.input || {};
450
+ const filePath = inp.file_path || inp.notebook_path || '';
451
+ const rawContent = [inp.content, inp.new_string, inp.new_source].filter(s => typeof s === 'string').join('\n');
452
+ const content = stripGlyphCharClass(rawContent);
453
+ if (!content || !GLYPH.test(content)) continue;
454
+ const glyphs = [...new Set((content.match(GLYPH_G) || []))].slice(0, 10).join(' ');
455
+ violations.push({ ts: ev.timestamp, sid: ev.conversation?.id || '', project: path.basename(ev.conversation?.cwd || ''), kind: 'glyph-written', file: path.basename(filePath), glyphs });
456
+ }
457
+ if (opts.stats || opts.count) {
458
+ if (opts.count) { process.stdout.write(`${violations.length}\n`); process.exit(0); }
459
+ process.stdout.write(`# ${violations.length} glyph-discipline violations (decorative glyphs written to files)\n`);
460
+ const byProj = new Map();
461
+ for (const v of violations) byProj.set(v.project, (byProj.get(v.project) || 0) + 1);
462
+ process.stdout.write(`# by project\n`);
463
+ for (const [p, c] of [...byProj.entries()].sort((a, b) => b[1] - a[1])) process.stdout.write(` ${String(c).padStart(6)} ${p}\n`);
464
+ process.exit(0);
465
+ }
466
+ for (const v of violations) {
467
+ process.stdout.write(`${new Date(v.ts).toISOString().slice(0, 19)} ${v.sid.slice(0, 8)} ${v.kind.padEnd(14)} [${v.project}] ${v.file} ${v.glyphs}\n`);
468
+ }
469
+ process.stderr.write(`# ${violations.length} violations — convert decorative glyphs to ASCII (-> for arrow, - or * for bullet, [x]/[ ] for check/cross)\n`);
470
+ process.exit(0);
471
+ }
472
+
429
473
  // ---------- learning-xref (join transcript turns to gm-log rs_learn signals)
430
474
  if (opts['learning-xref']) {
431
475
  const days = opts.days || 1;