Skip to content

Importing the public skill module first crashes through an ESM cycle #37424

Closed

Description

@kitlangton

What to build

Remove the order-dependent ESM initialization cycle that makes a fresh process crash when @opencode-ai/core/skill is the first Core module imported.

The current cycle is skill.ts -> permission.ts -> session.ts -> skill.ts. Session.SkillNotFoundError eagerly reads SkillV2.ID before the skill module initializes, producing ReferenceError: Cannot access 'ID' before initialization.

This also prevents the focused aggregate config hot-reload test from running in isolation.

Acceptance criteria

  • A fresh Bun process can import @opencode-ai/core/skill without preloading another Core module.
  • packages/core/test/config/reload.test.ts runs in isolation.
  • The error schema continues to use the canonical skill ID schema.
  • A fresh-process import regression test passes deterministically.

Blocked by

None - can start immediately.

Activity

  1. added
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Jul 17, 2026
  2. kitlangton commented on Jul 17, 2026

    @kitlangton
    ContributorAuthor

    Draft red-test coverage is in #37427. The test imports @opencode-ai/core/skill in a fresh Bun process so module caching cannot hide the initialization cycle.

  3. kitlangton commented on Jul 28, 2026

    @kitlangton
    ContributorAuthor

    Fixed by #37596 (529d55b1c3), which replaced the broad ./session import in permission.ts with narrow session/error and session/schema imports. Verified against current origin/v2 at a2885d1662: a fresh Bun process can import @opencode-ai/core/skill successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.0bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions