Skip to content

feat(core): add SSH remote directory references#31900

Draft
heitorfreitasferreira wants to merge 3 commits into
anomalyco:devfrom
heitorfreitasferreira:ssh-references
Draft

feat(core): add SSH remote directory references#31900
heitorfreitasferreira wants to merge 3 commits into
anomalyco:devfrom
heitorfreitasferreira:ssh-references

Conversation

@heitorfreitasferreira

@heitorfreitasferreira heitorfreitasferreira commented Jun 11, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #31901

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a new SSH remote directory reference type to opencode's references system. Currently references support local paths and Git repositories. This adds a third type that syncs a remote directory via rsync over SSH and makes it available as a project reference.

The implementation follows the same patterns as existing reference types: a config schema class (ConfigSsh), a config plugin with three-way dispatch (local → ssh → git), a runtime SshSource type in the Source tagged union, and async cache materialization via SshCache.ensure() forked in background (same pattern as Git references).

The rsync approach was chosen over ssh2/SFTP because it provides incremental sync, delete propagation, and uses the user's existing SSH config (~/.ssh/config, ssh-agent) without additional dependencies.

How did you verify your code works?

  • tsgo --noEmit — typecheck clean across all 29 packages
  • bun test test/reference.test.ts — 5/5 pass (3 existing + 2 SSH-specific)
  • bun test test/reference-guidance.test.ts — 3/3 pass
  • Full core test suite: 1011 pass, 7 fail (4 pre-existing SessionRunner + schema tests, 3 flaky model-switching tests — all unrelated)

Screenshots / recordings

N/A — no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Add a new reference type that syncs a remote directory via rsync over
SSH. Configured with host and remotePath, plus optional user, port,
and identityFile fields. The remote directory is cached locally using
EffectFlock-based concurrency control.

Follows the same async materialization pattern as Git references:
Info is created synchronously with the computed cache path, while the
rsync sync runs in a background fiber.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 11, 2026
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jun 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: add SSH remote directory references

1 participant