ccsniff 1.1.21 → 1.1.22
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 +96 -1
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -31,7 +31,7 @@ const FLAGS = {
|
|
|
31
31
|
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'],
|
|
32
32
|
multi: ['grep', 'igrep', 'role', 'type', 'tool', 'session', 'sid', 'project', 'cwd', 'exclude-sess', 'exclude-sid', 'exclude-cwd', 'exclude-project'],
|
|
33
33
|
number: ['limit', 'head', 'tail-n', 'ctx', 'truncate', 'days'],
|
|
34
|
-
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', 'continuation-discipline', 'learning-xref', 'include-subagents', 'stats', 'count', 'help', 'h'],
|
|
34
|
+
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', 'continuation-discipline', 'verb-bypass-discipline', 'spool-discipline', 'learning-xref', 'include-subagents', 'stats', 'count', 'help', 'h'],
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
function parseArgs(argv) {
|
|
@@ -74,6 +74,11 @@ USAGE
|
|
|
74
74
|
ccsniff --continuation-discipline [--stats] assistant turn that ends in prose with no tool call:
|
|
75
75
|
a summary, or deferred intent ("Let me X" / "I'll X" / "Now to")
|
|
76
76
|
as the final sentence — the toolless-turn stop (paper §38)
|
|
77
|
+
ccsniff --verb-bypass-discipline [--stats] a platform-native tool used where a plugkit verb exists:
|
|
78
|
+
WebFetch/WebSearch->fetch, Task-search->codesearch,
|
|
79
|
+
raw puppeteer/chrome->browser, platform-memory Write->memorize-fire
|
|
80
|
+
ccsniff --spool-discipline [--stats] a spool request written to in/<verb>/ but never read back from
|
|
81
|
+
out/ (the Write-alone-is-not-a-dispatch non-dispatch)
|
|
77
82
|
ccsniff --stats [filters]
|
|
78
83
|
|
|
79
84
|
TIME (any ISO date, epoch ms, or relative Ns/Nm/Nh/Nd/Nw)
|
|
@@ -375,6 +380,96 @@ if (opts['git-discipline']) {
|
|
|
375
380
|
process.exit(0);
|
|
376
381
|
}
|
|
377
382
|
|
|
383
|
+
// ---------- verb-bypass-discipline (a platform-native capability used where a plugkit verb exists)
|
|
384
|
+
// The class rule: every platform-native tool that has a plugkit verb is forbidden in favor of the
|
|
385
|
+
// verb — WebFetch/WebSearch -> the `fetch` verb; a Task/Agent search subagent -> `codesearch`; raw
|
|
386
|
+
// puppeteer/playwright/chrome -> the `browser` verb; a Write into a platform memory dir -> `memorize-fire`.
|
|
387
|
+
// High-precision per-tool patterns; each violation names the verb it should have used.
|
|
388
|
+
if (opts['verb-bypass-discipline']) {
|
|
389
|
+
const includeSubagents = opts['include-subagents'];
|
|
390
|
+
const MEM_PATH = /[\/\\]\.(?:claude[\/\\]projects[\/\\].*[\/\\]memory|codex[\/\\]memory|cursor)[\/\\]/i;
|
|
391
|
+
const RAW_BROWSER = /\b(?:puppeteer|playwright|chromium|chrome\.exe|google-chrome|chrome-headless)\b|--headless\b/i;
|
|
392
|
+
const TASK_SEARCH = /\b(?:where is|what calls|locate the|search the (?:code|repo|codebase|tree)|grep the|explore the (?:code|repo|tree|codebase)|find (?:the )?(?:definition|usages?|references?|callers?|where))\b/i;
|
|
393
|
+
const violations = [];
|
|
394
|
+
for (const ev of all) {
|
|
395
|
+
if (!filter(ev)) continue;
|
|
396
|
+
if (ev.block?.type !== 'tool_use') continue;
|
|
397
|
+
if (!includeSubagents && ev.conversation?.isSubagent) continue;
|
|
398
|
+
const name = ev.block?.name || '';
|
|
399
|
+
const input = ev.block?.input || {};
|
|
400
|
+
let kind = null, should = null, detail = '';
|
|
401
|
+
if (name === 'WebFetch') { kind = 'webfetch-not-fetch-verb'; should = 'fetch'; detail = String(input.url || '').slice(0, 120); }
|
|
402
|
+
else if (name === 'WebSearch') { kind = 'websearch-not-fetch-verb'; should = 'fetch'; detail = String(input.query || '').slice(0, 120); }
|
|
403
|
+
else if ((name === 'Task' || name === 'Agent') && TASK_SEARCH.test(stripQuoted(JSON.stringify(input)).slice(0, 600))) { kind = 'task-search-not-codesearch'; should = 'codesearch'; detail = String(input.description || input.prompt || '').slice(0, 120); }
|
|
404
|
+
else if (name === 'Bash' && RAW_BROWSER.test(stripQuoted(input.command || ''))) { kind = 'raw-browser-not-browser-verb'; should = 'browser'; detail = String(input.command || '').slice(0, 120); }
|
|
405
|
+
else if ((name === 'Write' || name === 'Edit' || name === 'NotebookEdit') && MEM_PATH.test(input.file_path || input.path || input.notebook_path || '')) { kind = 'platform-memory-not-memorize'; should = 'memorize-fire'; detail = String(input.file_path || input.path || input.notebook_path || '').slice(0, 120); }
|
|
406
|
+
if (!kind) continue;
|
|
407
|
+
violations.push({ ts: ev.timestamp, sid: ev.conversation.id, project: path.basename(ev.conversation.cwd || ''), kind, should, detail });
|
|
408
|
+
}
|
|
409
|
+
const byKind = new Map();
|
|
410
|
+
for (const v of violations) byKind.set(v.kind, (byKind.get(v.kind) || 0) + 1);
|
|
411
|
+
if (opts.stats || opts.count) {
|
|
412
|
+
if (opts.count) { process.stdout.write(`${violations.length}\n`); process.exit(0); }
|
|
413
|
+
process.stdout.write(`# ${violations.length} verb-bypass-discipline violations\n`);
|
|
414
|
+
for (const [k, c] of [...byKind.entries()].sort((a, b) => b[1] - a[1])) process.stdout.write(` ${String(c).padStart(6)} ${k}\n`);
|
|
415
|
+
const byProj = new Map();
|
|
416
|
+
for (const v of violations) byProj.set(v.project, (byProj.get(v.project) || 0) + 1);
|
|
417
|
+
process.stdout.write(`# by project\n`);
|
|
418
|
+
for (const [p, c] of [...byProj.entries()].sort((a, b) => b[1] - a[1])) process.stdout.write(` ${String(c).padStart(6)} ${p}\n`);
|
|
419
|
+
process.exit(0);
|
|
420
|
+
}
|
|
421
|
+
for (const v of violations) {
|
|
422
|
+
process.stdout.write(`${new Date(v.ts).toISOString().slice(0, 19)} ${v.sid.slice(0, 8)} ${v.kind.padEnd(28)} [${v.project}] use:${v.should} ${v.detail}\n`);
|
|
423
|
+
}
|
|
424
|
+
process.stderr.write(`# ${violations.length} violations (${[...byKind.entries()].map(([k, c]) => `${k}:${c}`).join(' ')})\n`);
|
|
425
|
+
process.exit(0);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// ---------- spool-discipline (a session that dispatches spool requests but reads NO responses)
|
|
429
|
+
// "The Write alone is not a dispatch." A session that writes `.gm/exec-spool/in/<verb>/<N>.txt`
|
|
430
|
+
// requests and reads ZERO `out/<...>.json` responses is fabricating the chain from prose — it never
|
|
431
|
+
// observed a single plugkit response. Session-level by design: batching (write many, read the
|
|
432
|
+
// first/last) is endorsed, so reading even one out/ response clears the session. Only a session that
|
|
433
|
+
// reads none of its responses is flagged — high precision, no batching false-positive.
|
|
434
|
+
if (opts['spool-discipline']) {
|
|
435
|
+
const includeSubagents = opts['include-subagents'];
|
|
436
|
+
const SPOOL_IN_WRITE = /(?:>\s*[^>|]*|file_path["'\s:]+["']?[^"']*)\.gm[\/\\]exec-spool[\/\\]in[\/\\][a-z0-9_-]+[\/\\]\d+\./i;
|
|
437
|
+
const SPOOL_OUT = /\.gm[\/\\]exec-spool[\/\\]out[\/\\]/i;
|
|
438
|
+
const sess = new Map();
|
|
439
|
+
for (const ev of all) {
|
|
440
|
+
if (!filter(ev)) continue;
|
|
441
|
+
if (ev.block?.type !== 'tool_use') continue;
|
|
442
|
+
if (!includeSubagents && ev.conversation?.isSubagent) continue;
|
|
443
|
+
const sid = ev.conversation.id;
|
|
444
|
+
if (!sess.has(sid)) sess.set(sid, { writes: 0, reads: 0, project: path.basename(ev.conversation.cwd || ''), firstTs: ev.timestamp, lastTs: ev.timestamp });
|
|
445
|
+
const s = sess.get(sid);
|
|
446
|
+
s.lastTs = ev.timestamp;
|
|
447
|
+
const b = ev.block, inp = b.input || {};
|
|
448
|
+
const blob = b.name === 'Write' ? (inp.file_path || '') : (b.name === 'Bash' ? (inp.command || '') : '');
|
|
449
|
+
if (blob && SPOOL_IN_WRITE.test(blob)) s.writes++;
|
|
450
|
+
const rblob = b.name === 'Read' ? (inp.file_path || '') : (b.name === 'Bash' ? (inp.command || '') : '');
|
|
451
|
+
if (rblob && SPOOL_OUT.test(rblob)) s.reads++;
|
|
452
|
+
}
|
|
453
|
+
const violations = [];
|
|
454
|
+
for (const [sid, s] of sess) {
|
|
455
|
+
if (s.writes >= 1 && s.reads === 0) violations.push({ ts: s.lastTs, sid, project: s.project, writes: s.writes });
|
|
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} spool-discipline violations (session dispatched spool writes but read 0 responses)\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)} spool-writes-no-reads [${v.project}] writes:${v.writes} reads:0\n`);
|
|
468
|
+
}
|
|
469
|
+
process.stderr.write(`# ${violations.length} sessions dispatched spool writes but read 0 responses\n`);
|
|
470
|
+
process.exit(0);
|
|
471
|
+
}
|
|
472
|
+
|
|
378
473
|
// ---------- search-discipline (flag native search that should have been codesearch/recall)
|
|
379
474
|
// A native-search bypass (Grep/Glob, the Explore/Task search subagent, or bash grep/rg/find/ag)
|
|
380
475
|
// emits NO plugkit deviation because it never touches the spool — it is invisible to gmsniff and
|