ccsniff 1.1.11 → 1.1.13
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 +1 -1
- package/src/cli.js +98 -1
package/package.json
CHANGED
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', '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) {
|
|
@@ -66,6 +66,8 @@ USAGE
|
|
|
66
66
|
ccsniff --bash-discipline [--stats] Bash calls that should have used Read/Glob/Grep
|
|
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
|
+
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
|
|
69
71
|
(excludes subagents by default — --include-subagents to opt in;
|
|
70
72
|
excludes 'echo > .gm/exec-spool/in/...' as canonical spool-write)
|
|
71
73
|
ccsniff --stats [filters]
|
|
@@ -369,6 +371,101 @@ if (opts['git-discipline']) {
|
|
|
369
371
|
process.exit(0);
|
|
370
372
|
}
|
|
371
373
|
|
|
374
|
+
// ---------- search-discipline (flag native search that should have been codesearch/recall)
|
|
375
|
+
// A native-search bypass (Grep/Glob, the Explore/Task search subagent, or bash grep/rg/find/ag)
|
|
376
|
+
// emits NO plugkit deviation because it never touches the spool — it is invisible to gmsniff and
|
|
377
|
+
// the watcher ledger. ccsniff reads the tool-call stream directly, so it is the only surface that
|
|
378
|
+
// can catch the SKILL.md class-rule violation: code/file/symbol search routes through codesearch,
|
|
379
|
+
// prior-knowledge through recall, never a host-native search tool.
|
|
380
|
+
if (opts['search-discipline']) {
|
|
381
|
+
const includeSubagents = opts['include-subagents'];
|
|
382
|
+
const BASH_SEARCH = /(^|[|&;]|\s)(rg|grep|find|ag|ack|fd|fgrep|egrep)\s/;
|
|
383
|
+
const violations = [];
|
|
384
|
+
for (const ev of all) {
|
|
385
|
+
if (!filter(ev)) continue;
|
|
386
|
+
if (ev.block?.type !== 'tool_use') continue;
|
|
387
|
+
if (!includeSubagents && ev.conversation?.isSubagent) continue;
|
|
388
|
+
const name = ev.block?.name || '';
|
|
389
|
+
const project = path.basename(ev.conversation?.cwd || '');
|
|
390
|
+
const ts = ev.timestamp, sid = ev.conversation?.id || '';
|
|
391
|
+
let kind = null, detail = '';
|
|
392
|
+
if (name === 'Grep' || name === 'Glob') {
|
|
393
|
+
kind = `native-search-${name.toLowerCase()}`;
|
|
394
|
+
detail = (ev.block?.input?.pattern || ev.block?.input?.query || '').slice(0, 120);
|
|
395
|
+
} else if (name === 'Task' || name === 'Agent') {
|
|
396
|
+
const sub = (ev.block?.input?.subagent_type || ev.block?.input?.description || '').toLowerCase();
|
|
397
|
+
if (/explore|search|general-purpose/.test(sub)) {
|
|
398
|
+
kind = 'native-search-subagent';
|
|
399
|
+
detail = sub.slice(0, 120);
|
|
400
|
+
}
|
|
401
|
+
} else if (name === 'Bash') {
|
|
402
|
+
const cmd = ev.block?.input?.command || '';
|
|
403
|
+
if (BASH_SEARCH.test(cmd)) {
|
|
404
|
+
kind = 'native-search-bash';
|
|
405
|
+
// show the line that actually invokes the search tool, not line 1 (often a cd)
|
|
406
|
+
const hit = cmd.split('\n').find(l => BASH_SEARCH.test(l)) || cmd;
|
|
407
|
+
detail = hit.trim().slice(0, 120);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
if (kind) violations.push({ ts, sid, project, kind, detail });
|
|
411
|
+
}
|
|
412
|
+
if (opts.stats || opts.count) {
|
|
413
|
+
if (opts.count) { process.stdout.write(`${violations.length}\n`); process.exit(0); }
|
|
414
|
+
process.stdout.write(`# ${violations.length} search-discipline violations (native search instead of codesearch/recall)\n`);
|
|
415
|
+
const byKind = new Map(), byProj = new Map();
|
|
416
|
+
for (const v of violations) { byKind.set(v.kind, (byKind.get(v.kind) || 0) + 1); byProj.set(v.project, (byProj.get(v.project) || 0) + 1); }
|
|
417
|
+
process.stdout.write(`# by kind\n`);
|
|
418
|
+
for (const [k, c] of [...byKind.entries()].sort((a, b) => b[1] - a[1])) process.stdout.write(` ${String(c).padStart(6)} ${k}\n`);
|
|
419
|
+
process.stdout.write(`# by project\n`);
|
|
420
|
+
for (const [p, c] of [...byProj.entries()].sort((a, b) => b[1] - a[1])) process.stdout.write(` ${String(c).padStart(6)} ${p}\n`);
|
|
421
|
+
process.exit(0);
|
|
422
|
+
}
|
|
423
|
+
for (const v of violations) {
|
|
424
|
+
process.stdout.write(`${new Date(v.ts).toISOString().slice(0, 19)} ${v.sid.slice(0, 8)} ${v.kind.padEnd(24)} [${v.project}] ${v.detail}\n`);
|
|
425
|
+
}
|
|
426
|
+
process.stderr.write(`# ${violations.length} violations — use codesearch (code/file/symbol) or recall (prior knowledge) instead\n`);
|
|
427
|
+
process.exit(0);
|
|
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
|
+
const violations = [];
|
|
440
|
+
for (const ev of all) {
|
|
441
|
+
if (!filter(ev)) continue;
|
|
442
|
+
if (ev.block?.type !== 'tool_use') continue;
|
|
443
|
+
if (!includeSubagents && ev.conversation?.isSubagent) continue;
|
|
444
|
+
const name = ev.block?.name || '';
|
|
445
|
+
if (name !== 'Write' && name !== 'Edit' && name !== 'NotebookEdit') continue;
|
|
446
|
+
const inp = ev.block?.input || {};
|
|
447
|
+
const filePath = inp.file_path || inp.notebook_path || '';
|
|
448
|
+
const content = [inp.content, inp.new_string, inp.new_source].filter(s => typeof s === 'string').join('\n');
|
|
449
|
+
if (!content || !GLYPH.test(content)) continue;
|
|
450
|
+
const glyphs = [...new Set((content.match(GLYPH_G) || []))].slice(0, 10).join(' ');
|
|
451
|
+
violations.push({ ts: ev.timestamp, sid: ev.conversation?.id || '', project: path.basename(ev.conversation?.cwd || ''), kind: 'glyph-written', file: path.basename(filePath), glyphs });
|
|
452
|
+
}
|
|
453
|
+
if (opts.stats || opts.count) {
|
|
454
|
+
if (opts.count) { process.stdout.write(`${violations.length}\n`); process.exit(0); }
|
|
455
|
+
process.stdout.write(`# ${violations.length} glyph-discipline violations (decorative glyphs written to files)\n`);
|
|
456
|
+
const byProj = new Map();
|
|
457
|
+
for (const v of violations) byProj.set(v.project, (byProj.get(v.project) || 0) + 1);
|
|
458
|
+
process.stdout.write(`# by project\n`);
|
|
459
|
+
for (const [p, c] of [...byProj.entries()].sort((a, b) => b[1] - a[1])) process.stdout.write(` ${String(c).padStart(6)} ${p}\n`);
|
|
460
|
+
process.exit(0);
|
|
461
|
+
}
|
|
462
|
+
for (const v of violations) {
|
|
463
|
+
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`);
|
|
464
|
+
}
|
|
465
|
+
process.stderr.write(`# ${violations.length} violations — convert decorative glyphs to ASCII (-> for arrow, - or * for bullet, [x]/[ ] for check/cross)\n`);
|
|
466
|
+
process.exit(0);
|
|
467
|
+
}
|
|
468
|
+
|
|
372
469
|
// ---------- learning-xref (join transcript turns to gm-log rs_learn signals)
|
|
373
470
|
if (opts['learning-xref']) {
|
|
374
471
|
const days = opts.days || 1;
|