Skip to content
Back to skills

137 Fn 96 455fdb37

ASecurity

Create log watcher and stream-json parser for iter-*.log files.

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
testingtypescriptbashtestingapi

Works with

  • api

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 137-fn-96_455fdb37 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 137 Fn 96 455fdb37?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 137 Fn 96 455fdb37
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-137-fn-96-455fdb37/badge)](https://www.skillsdirectory.com/skills/tools-only-137-fn-96-455fdb37)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
# fn-9.6 Log watcher and parser lib

## Description

Create log watcher and stream-json parser for iter-*.log files.

### Files

- `src/lib/log-watcher.ts` - fs.watch wrapper
- `src/lib/parser.ts` - stream-json format parser

### LogWatcher

```typescript
class LogWatcher extends EventEmitter {
  constructor(runPath: string)
  start(): void
  stop(): void
  // Events: 'line', 'error', 'new-iteration'
}
```

### Watching strategy

1. Watch run directory for new iter-*.log files
2. Tail-follow current iteration log
3. Debounce file change events (100ms)
4. Track byte position for incremental reads

### Parser

stream-json format (from Claude --watch):
```json
{"type":"tool_call","tool":"Read","input":{...}}
{"type":"tool_result","content":"..."}
{"type":"text","content":"..."}
```

Parse into LogEntry with tool icons:
- Read/Write/Glob → `→`
- Bash → `⚡`
- API calls → `◆`
- success → `✓`
- failure → `✗`

### Testing strategy

**Parser tests** (pure function, easy to test):
- Unit test: JSON line → LogEntry mapping
- Test various tool types, malformed lines

**LogWatcher tests** (I/O, harder):
- Use temp directory with test log files
- Append content, verify 'line' events fire
- May need polling fallback on some platforms
## Acceptance
- [ ] LogWatcher emits 'line' events for new log content
- [ ] Detects new iter-*.log files appearing
- [ ] Parser extracts tool type and content from stream-json
- [ ] Parser assigns correct icons per tool type
- [ ] Handles malformed JSON lines gracefully (skip, don't crash)
- [ ] `stop()` properly cleans up watchers
## Done summary
- Added LogWatcher class with fs.watch for run directory and iter-*.log files
- Added parser for stream-json format with tool icons (unicode + ASCII)
- Implemented debounced reads, byte position tracking, iteration detection
- Full test coverage (42 tests)
## Evidence
- Commits: ccd55aeb0edcfb8a235b22158aa83ce1c53c7bf1
- Tests: bun test
- PRs:

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.