Skip to content

Fix: cache bootstrap content at module level to eliminate per-step file I/O #1206

@fuleinist

Description

@fuleinist

What problem are you trying to solve?

getBootstrapContent() in .opencode/plugins/superpowers.js calls fs.existsSync + fs.readFileSync + regex frontmatter parsing + string concatenation every agent step with zero caching.

The experimental.chat.messages.transform hook fires every step in opencode's agent loop. In a 10-step session, this means 10 file reads + 10 regex parses for content that never changes during a session.

What does this PR change?

Add module-level cache for bootstrap content:

After the first call, subsequent calls return the cached string instantly with zero filesystem access.

Note: the duplication guard checking for EXTREMELY_IMPORTANT text is also ineffective (messages are loaded fresh from DB each step, so the guard always fails) but this PR does NOT address that — it only fixes the I/O issue.

Environment tested

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions