Skip to content

[FEATURE]: run export/import without booting a project instance #42490

Closed as not planned

Description

@cameronalizadeh-distyl

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

opencode export reads session rows and prints them, but boots a full project instance to do it: config load, plugin init, and the LSP forks. With any plugin configured, plugin init npm-installs into the config dir before a single row is read. db already declares instance: false at three call sites, and export yields only Session.Service, which the app runtime provides — so for export this is a one-line change. Happy to PR it.

import is why this is a question rather than a patch. It reads three things off InstanceRef (project id, directory, worktree) that are all reachable another way — but nothing in the import path creates the project row the imported session's project_id points at. That row appears as a side effect of instance boot (Project resolve inserts it) or of session creation (packages/core/src/session.ts does an onConflictDoNothing insert). With PRAGMA foreign_keys = ON that side effect is load-bearing: drop the instance and a cold import into a fresh workspace has nothing to satisfy the foreign key. Should import ensure the project row itself, the way session creation does? If that's the right shape I'll PR both.

Context: we drive opencode over ACP and spawn opencode export once per turn to persist transcripts, so the instance boot is a per-turn cost.

Activity

  1. github-actions commented on Aug 14, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. cameronalizadeh-distyl commented on Aug 14, 2026

    @cameronalizadeh-distyl
    Author

    Same root cause as #37435, and its PR (#37477) covers session list only — so the export half here is complementary: the same one-line pattern on a different command. The import half is the part that sweep can't take mechanically: import writes a session row whose project_id row only exists because the instance boot created it (foreign_keys is ON), so import needs the project row ensured before it can drop the instance. That contract question is what this issue is really asking.

  3. github-actions commented on Oct 14, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions