Skip to content

OpenCode/Kilo instructions arrays accumulate stale entries (union merge never removes deleted rules) #2548

Description

@dyoshikawa

Background

Finding from the PR #2547 review round (pre-existing behavior, both scopes and both tools): fromInstructions merges the existing instructions array with the newly generated list by union (dedupe + sort), so an entry registered for a since-deleted non-root rule persists in opencode.json / kilo.jsonc forever. A user's hand-written entry for the same file in a different spelling (e.g. .config/opencode/memories/x.md vs the stripped memories/x.md at global scope) also coexists as a duplicate, loading the file twice.

Details

  • OpencodeMcp.fromInstructions (src/features/mcp/opencode-mcp.ts): new Set([...existingInstructions, ...normalizedInstructions]).
  • The kilo counterpart shares the pattern.
  • Deleting a rule from .rulesync/rules/ removes the memories file (orphan deletion) but never the registered path, leaving a dangling instructions entry OpenCode then fails to load or silently ignores.

Solution / Next Steps

Scope the union: rulesync owns entries that point under its managed rules directories (.opencode/memories/, .kilo/rules/, global memories/) — rebuild that subset from the current generate and preserve only entries outside those roots verbatim. Mirrors how other adapters scope managed-name ownership (e.g. Rovo Dev's disabledMcpServers handling in PR #2545).

Metadata

Metadata

Assignees

No one assigned

    Labels

    maintainer-scrapRough notes for AI implementation. Not for human eyes.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions