feat(cli): add OpenCode-compatible workspace references - #1939
Merged
Conversation
Add OpenCode-compatible @ file and directory completion with line ranges and composer recovery across history, undo, and fork flows. Route search, persistence, and fail-closed path validation through Agent Runtime ports and the bounded Shared TUI protocol.
limityan
force-pushed
the
feat/tui-workspace-references
branch
from
July 31, 2026 16:50
8d672ab to
6a08083
Compare
limityan
marked this pull request as ready for review
July 31, 2026 17:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@workspace file and directory completion to the interactive TUI, including#start[-end]file ranges, Enter selection, Tab directory drill-down, arrow/Ctrl-P/Ctrl-N navigation, and Esc dismissal.capability_unavailableerror contract so exhaustive consumers remain build-safe.Architecture and scope
The production path is
TUI composer -> CLI runtime client -> AgentWorkspaceReferencePort -> ConversationCoordinator -> services-core path resolver. Shared TUI uses two current-controller, read-only IPC v10 operations; Embedded TUI calls the same typed Runtime port directly.Core validates normalized workspace-relative paths, rejects symlink/reparse escapes and control-character filenames, verifies Unicode character ranges and token boundaries, then emits an untrusted JSON reminder instructing the agent to use the existing Read/Glob tools. File contents are not read eagerly, so existing permission, cancellation, and audit behavior remains intact.
This PR intentionally does not add a slash command, background index, eager file loading, remote-workspace fallback, Relay behavior, agent/MCP mentions, or a generic public wire protocol. Remote workspace search returns an explicit unavailable result.
Compatibility
The entry and keyboard behavior follows OpenCode's current TUI autocomplete model to avoid introducing a BitFun-specific command or interaction. The existing slash-command routing is unchanged.
Validation
node scripts/core-boundaries/self-test.mjsnode scripts/check-core-boundaries.mjscargo test --locked -p bitfun-sdk-host -p bitfun-sdk-host-app— library, protocol, lifecycle, standalone process, and stdio suites passedcargo test --locked -q -p bitfun-cli— 507 unit tests plus all CLI integration targets passedcargo test --locked -q -p bitfun-core— 1720 passed, 1 ignored, plus integration targets passedcargo test --locked -q -p bitfun-agent-runtime -p bitfun-agent-runtime-ipc -p bitfun-runtime-ports -p bitfun-services-corecargo check --locked --workspace --exclude bitfun-desktopgit diff --checkA local full
cargo check --locked --workspacereached the desktop build script but could not continue because this worktree has no generatedsrc/mobile-web/distand no frontendnode_modules. The equivalent GitHub Rust build jobs remain the authoritative cross-platform full-workspace check.Review notes
The original isolated adversarial review found and closed four P2 issues before submission: IPC closed-set drift, editable token-boundary drift, control-character reminder injection, and fail-open undo metadata recovery.
After the CI failure, all failed jobs were traced to one exhaustive SDK Host match that omitted
MissingWorkspaceReferencePort. The fix adds the existing capability-unavailable mapping and a regression test. A fresh isolated full-PR review then rechecked the TUI entry behavior, Runtime/Core/IPC ownership, remote fail-closed behavior, path safety, persistence, undo/fork recovery, and all RuntimeError consumers; it found no remaining P1/P2 blocker.