Watch Claude Code JSONL output files and emit structured events as a Node.js EventEmitter.
npm install @lanmower/ccfimport { watch } from '@lanmower/ccf';
const watcher = watch()
.on('conversation_created', ({ conversation }) => {
console.log('New session:', conversation.title);
})
.on('streaming_progress', ({ block, role }) => {
if (block.type === 'text') process.stdout.write(block.text);
})
.on('streaming_complete', ({ conversationId }) => {
console.log('Done:', conversationId);
});
process.on('SIGINT', () => watcher.stop());CommonJS:
const { watch, JsonlWatcher } = require('@lanmower/ccf');Creates and starts a watcher. projectsDir defaults to ~/.claude/projects.
Class constructor. Call .start() manually after attaching listeners.
Scans for existing .jsonl files and begins watching. Chainable.
Closes file descriptors and directory watcher.
| Event | Payload |
|---|---|
conversation_created |
{ conversation: { id, title, cwd }, timestamp } |
streaming_start |
{ conversationId, conversation, timestamp } |
streaming_progress |
{ conversationId, conversation, block, role, seq, timestamp } |
streaming_complete |
{ conversationId, conversation, seq, timestamp } |
streaming_error |
{ conversationId, error, recoverable, timestamp } |
error |
Error |
block.type values: text, tool_use, tool_result, system, result, etc.
Node >= 18. Zero external dependencies.
MIT