ccsniff 1.1.9 → 1.1.11
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 +7 -0
- package/src/index.js +11 -9
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -263,6 +263,11 @@ if (opts['bash-discipline']) {
|
|
|
263
263
|
// to compare watcher heartbeat against current epoch. The cat is canonical, not a deviation.
|
|
264
264
|
// Same for reading .watcher.log diagnostics directly.
|
|
265
265
|
const CANONICAL_BOOT_PROBE = /\.gm\/exec-spool\/\.(status\.json|watcher\.log|bootstrap-(status|error)\.json|last-session-start\.json)/;
|
|
266
|
+
// Observability surfaces — multi-file pattern scans over JSONL logs and transcript dirs
|
|
267
|
+
// legitimately need grep/tail/cat because Read tool can't stream multi-file or pipe to head -c.
|
|
268
|
+
// gm-log/<day>/*.jsonl, .claude/projects/*/*.jsonl, and *.jsonl in general are the canonical
|
|
269
|
+
// observability targets per AGENTS.md "rs-learn observability" entry.
|
|
270
|
+
const OBSERVABILITY_TARGET = /\.(jsonl|ndjson|log)\b|gm-log\/|\.claude\/projects\//;
|
|
266
271
|
const violations = [];
|
|
267
272
|
for (const ev of all) {
|
|
268
273
|
if (!filter(ev)) continue;
|
|
@@ -275,6 +280,8 @@ if (opts['bash-discipline']) {
|
|
|
275
280
|
if (ENDORSED_POLL.test(cmd)) continue;
|
|
276
281
|
// Canonical gm-skill boot/diagnostic probes (cat .status.json; date +%s%3N etc.) are prescribed by SKILL.md.
|
|
277
282
|
if (CANONICAL_BOOT_PROBE.test(cmd)) continue;
|
|
283
|
+
// Observability surface reads — grep/cat/tail over JSONL logs and transcript dirs are legit (Read tool can't stream/multi-file).
|
|
284
|
+
if (OBSERVABILITY_TARGET.test(cmd)) continue;
|
|
278
285
|
const kind = SLEEP_POLL.test(cmd) ? 'sleep-poll' : (BAD_LEADING.test(cmd) ? 'bad-leading-cmd' : null);
|
|
279
286
|
if (!kind) continue;
|
|
280
287
|
violations.push({ ts: ev.timestamp, sid: ev.conversation.id, project: path.basename(ev.conversation.cwd || ''), kind, cmd: cmd.slice(0, 200) });
|
package/src/index.js
CHANGED
|
@@ -124,17 +124,19 @@ export class JsonlWatcher extends EventEmitter {
|
|
|
124
124
|
this.emit('streaming_complete', { conversationId: conv.id, conversation: conv, seq: this._seq(sid), timestamp: Date.now() });
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
_push(conv, sid, block, role) {
|
|
128
|
-
|
|
127
|
+
_push(conv, sid, block, role, eventTs) {
|
|
128
|
+
const ts = eventTs != null ? eventTs : Date.now();
|
|
129
|
+
this.emit('streaming_progress', { conversationId: conv.id, conversation: conv, block, role, seq: this._seq(sid), timestamp: ts });
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
_route(conv, sid, e) {
|
|
132
133
|
if (e.type === 'queue-operation' || e.type === 'last-prompt') return;
|
|
134
|
+
const ets = e.timestamp ? Date.parse(e.timestamp) : null;
|
|
133
135
|
if (e.type === 'user' && e.isMeta) {
|
|
134
136
|
this._startStreaming(conv, sid);
|
|
135
137
|
const content = e.message?.content;
|
|
136
138
|
const text = typeof content === 'string' ? content : (Array.isArray(content) ? content.filter(b => b?.type === 'text').map(b => b.text).join('') : '');
|
|
137
|
-
if (text.trim()) this._push(conv, sid, { type: 'text', text, isMeta: true }, 'user');
|
|
139
|
+
if (text.trim()) this._push(conv, sid, { type: 'text', text, isMeta: true }, 'user', ets);
|
|
138
140
|
return;
|
|
139
141
|
}
|
|
140
142
|
|
|
@@ -147,7 +149,7 @@ export class JsonlWatcher extends EventEmitter {
|
|
|
147
149
|
if (e.subtype === 'init') { this._startStreaming(conv, sid); return; }
|
|
148
150
|
if (e.subtype === 'turn_duration' || e.subtype === 'stop_hook_summary') { this._endStreaming(conv, sid); return; }
|
|
149
151
|
this._startStreaming(conv, sid);
|
|
150
|
-
this._push(conv, sid, { type: 'system', subtype: e.subtype, model: e.model, cwd: e.cwd, tools: e.tools }, 'system');
|
|
152
|
+
this._push(conv, sid, { type: 'system', subtype: e.subtype, model: e.model, cwd: e.cwd, tools: e.tools }, 'system', ets);
|
|
151
153
|
return;
|
|
152
154
|
}
|
|
153
155
|
|
|
@@ -158,7 +160,7 @@ export class JsonlWatcher extends EventEmitter {
|
|
|
158
160
|
const newBlocks = e.message.content.slice(prev);
|
|
159
161
|
if (newBlocks.length > 0) {
|
|
160
162
|
this._emitted.set(key, e.message.content.length);
|
|
161
|
-
for (const b of newBlocks) if (b?.type) this._push(conv, sid, b, 'assistant');
|
|
163
|
+
for (const b of newBlocks) if (b?.type) this._push(conv, sid, b, 'assistant', ets);
|
|
162
164
|
}
|
|
163
165
|
if (e.message.stop_reason) this._emitted.delete(key);
|
|
164
166
|
return;
|
|
@@ -168,19 +170,19 @@ export class JsonlWatcher extends EventEmitter {
|
|
|
168
170
|
this._startStreaming(conv, sid);
|
|
169
171
|
const content = e.message.content;
|
|
170
172
|
if (typeof content === 'string') {
|
|
171
|
-
if (content.trim()) this._push(conv, sid, { type: 'text', text: content }, 'user');
|
|
173
|
+
if (content.trim()) this._push(conv, sid, { type: 'text', text: content }, 'user', ets);
|
|
172
174
|
} else if (Array.isArray(content)) {
|
|
173
175
|
for (const b of content) {
|
|
174
176
|
if (!b || !b.type) continue;
|
|
175
|
-
if (b.type === 'tool_result') this._push(conv, sid, b, 'tool_result');
|
|
176
|
-
else this._push(conv, sid, b, 'user');
|
|
177
|
+
if (b.type === 'tool_result') this._push(conv, sid, b, 'tool_result', ets);
|
|
178
|
+
else this._push(conv, sid, b, 'user', ets);
|
|
177
179
|
}
|
|
178
180
|
}
|
|
179
181
|
return;
|
|
180
182
|
}
|
|
181
183
|
|
|
182
184
|
if (e.type === 'result') {
|
|
183
|
-
this._push(conv, sid, { type: 'result', result: e.result, subtype: e.subtype, duration_ms: e.duration_ms, total_cost_usd: e.total_cost_usd, is_error: e.is_error || false }, 'result');
|
|
185
|
+
this._push(conv, sid, { type: 'result', result: e.result, subtype: e.subtype, duration_ms: e.duration_ms, total_cost_usd: e.total_cost_usd, is_error: e.is_error || false }, 'result', ets);
|
|
184
186
|
this._endStreaming(conv, sid);
|
|
185
187
|
}
|
|
186
188
|
}
|