# Kotlin Build Pitfalls (Unspooled)

## `by lazy` in companion objects (Kotlin 2.x)

```kotlin
// BROKEN: "Property delegate must have a 'getValue' method"
companion object {
    private val FOO: String by lazy { BuildConfig.SOME_FIELD }
}
// FIX — use custom getter:
companion object {
    private val FOO: String get() = BuildConfig.SOME_FIELD
}
```

Happens when `BuildConfig` fields are referenced inside `by lazy` blocks in companion objects. The Kotlin 2.x compiler can't infer the delegate type. Converting to a computed property with `get()` fixes it with zero runtime difference.

## `read_file` → `write_file` corruption

`hermes_tools.read_file()` returns content with `LINE|` prefixes (e.g. `1|package com...`). Piping directly into `write_file()` corrupts the actual source file. Use `terminal` with `cat << 'EOF'` heredocs for writing source files instead, or strip line prefixes in execute_code before writing.

## `git checkout --` wipes subagent changes

When multiple subagents modify the same file (e.g. `build.gradle.kts`), `git checkout --` on that file wipes everything back to the last commit. This loses both good and bad changes. Use `git stash` or targeted `git checkout -p` instead so you can selectively revert only the problematic hunk.

## Scraper addon (`nexstream-scraper`)

Self-hosted Node.js Stremio addon at `services/nexstream-scraper/` on port 3091:
- 5 parallel scrapers: Torrentio, Comet, MediaFusion, Jackett, Zilean
- 4 debrid providers: Real-Debrid, AllDebrid, Premiumize, TorBox
- Two-tier cache: L1 memory (<50ms hits) + L2 SQLite (24h persistence)
- Start: `PORT=3091 node src/index.js`
- Included as system addon `nexstream_scraper` in SystemAddonCatalog (priority 15)
