ccsniff 1.0.27 → 1.0.28
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 +1 -49
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -26,7 +26,7 @@ const FLAGS = {
|
|
|
26
26
|
string: ['since', 'until', 'before', 'after', 'grep', 'igrep', 'cwd', 'project', 'role', 'type', 'tool', 'session', 'sid', 'parent', 'rollup', 'format', 'sort'],
|
|
27
27
|
multi: ['grep', 'igrep', 'role', 'type', 'tool', 'session', 'sid', 'project', 'cwd'],
|
|
28
28
|
number: ['limit', 'head', 'tail-n', 'ctx', 'truncate'],
|
|
29
|
-
bool: ['json', 'ndjson', 'tail', 'f', 'full', 'reverse', 'invert', 'no-subagents', 'only-subagents', 'no-meta', 'only-meta', 'list-sessions', 'list-projects', 'list-tools', 'stats', 'count', '
|
|
29
|
+
bool: ['json', 'ndjson', 'tail', 'f', 'full', 'reverse', 'invert', 'no-subagents', 'only-subagents', 'no-meta', 'only-meta', 'list-sessions', 'list-projects', 'list-tools', 'stats', 'count', 'help', 'h'],
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
function parseArgs(argv) {
|
|
@@ -60,7 +60,6 @@ USAGE
|
|
|
60
60
|
ccsniff --list-projects
|
|
61
61
|
ccsniff --list-tools
|
|
62
62
|
ccsniff --stats [filters]
|
|
63
|
-
ccsniff --gm-audit [filters]
|
|
64
63
|
|
|
65
64
|
TIME (any ISO date, epoch ms, or relative Ns/Nm/Nh/Nd/Nw)
|
|
66
65
|
--since <t> include events at/after t (alias: --after)
|
|
@@ -240,53 +239,6 @@ if (opts.help || process.argv.length <= 2) { printHelp(); process.exit(0); }
|
|
|
240
239
|
const since = parseTime(opts.since || opts.after);
|
|
241
240
|
const filter = buildFilter(opts);
|
|
242
241
|
|
|
243
|
-
// ---------- gm-audit (existing, untouched logic, now respects new filters)
|
|
244
|
-
if (opts['gm-audit']) {
|
|
245
|
-
const sessions = new Map();
|
|
246
|
-
const r2 = new JsonlReplayer();
|
|
247
|
-
r2.on('streaming_progress', ev => {
|
|
248
|
-
if (!filter(ev)) return;
|
|
249
|
-
const conv = ev.conversation;
|
|
250
|
-
if (conv.isSubagent) return;
|
|
251
|
-
if (ev.role !== 'user' && ev.role !== 'assistant') return;
|
|
252
|
-
const sid = conv.id;
|
|
253
|
-
if (!sessions.has(sid)) sessions.set(sid, { cwd: conv.cwd, turns: [] });
|
|
254
|
-
const s = sessions.get(sid);
|
|
255
|
-
if (ev.role === 'user' && ev.block?.type === 'text') {
|
|
256
|
-
const t = ev.block.text || '';
|
|
257
|
-
const isContinuation = /^This session is being continued from a previous conversation/.test(t.trimStart());
|
|
258
|
-
const isSystem = ev.block.isMeta || isContinuation || /^<(task-notification|command-name|local-command|system-reminder)\b/.test(t.trimStart()) || t === '[Request interrupted by user]' || t === '[Request interrupted by user for tool use]';
|
|
259
|
-
s.turns.push({ isMeta: isSystem, firstTool: null, text: t.slice(0, 80) });
|
|
260
|
-
} else if (ev.role === 'assistant' && ev.block?.type === 'tool_use' && s.turns.length) {
|
|
261
|
-
const last = s.turns[s.turns.length - 1];
|
|
262
|
-
if (last.firstTool === null) last.firstTool = ev.block.name || '';
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
r2.replay({ since });
|
|
266
|
-
const isTerse = t => t.text.trim().length <= 5 || /^\/\w/.test(t.text.trim());
|
|
267
|
-
let totalReal = 0, totalCompliant = 0, totalTerse = 0;
|
|
268
|
-
for (const [sid, s] of sessions) {
|
|
269
|
-
const real = s.turns.filter(t => !t.isMeta);
|
|
270
|
-
const compliant = real.filter(t => t.firstTool === 'Skill' || t.firstTool === 'mcp__gm__Skill');
|
|
271
|
-
const terse = real.filter(t => isTerse(t) && t.firstTool !== 'Skill' && t.firstTool !== 'mcp__gm__Skill');
|
|
272
|
-
totalReal += real.length;
|
|
273
|
-
totalCompliant += compliant.length;
|
|
274
|
-
totalTerse += terse.length;
|
|
275
|
-
const pct = real.length ? Math.round(100 * compliant.length / real.length) : 0;
|
|
276
|
-
const violations = real.filter(t => t.firstTool !== 'Skill' && t.firstTool !== 'mcp__gm__Skill' && !isTerse(t));
|
|
277
|
-
if (real.length === 0) continue;
|
|
278
|
-
process.stdout.write(`[${pct}%] ${path.basename(s.cwd || sid)} (${compliant.length}/${real.length}, terse-skip:${terse.length}) sid=${sid.slice(0, 8)}\n`);
|
|
279
|
-
for (const v of violations.slice(0, 3)) {
|
|
280
|
-
process.stdout.write(` MISS first=${v.firstTool || 'none'} msg="${v.text.replace(/\s+/g, ' ')}"\n`);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
const total = totalReal ? Math.round(100 * totalCompliant / totalReal) : 0;
|
|
284
|
-
const adjCompliant = totalCompliant + totalTerse;
|
|
285
|
-
const adjTotal = totalReal ? Math.round(100 * adjCompliant / totalReal) : 0;
|
|
286
|
-
process.stderr.write(`# gm-audit: ${totalCompliant}/${totalReal} compliant (${total}%) | adj (terse-skip): ${adjCompliant}/${totalReal} (${adjTotal}%) | ${sessions.size} sessions\n`);
|
|
287
|
-
process.exit(0);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
242
|
// ---------- rollup (filtered)
|
|
291
243
|
if (opts.rollup) {
|
|
292
244
|
const stats = await rollup({ since, out: opts.rollup, format: opts.format || 'ndjson' });
|