Skip to content

feat(cli): add OpenCode-compatible workspace references - #1939

Merged
limityan merged 1 commit into
GCWing:mainfrom
limityan:feat/tui-workspace-references
Jul 31, 2026
Merged

feat(cli): add OpenCode-compatible workspace references#1939
limityan merged 1 commit into
GCWing:mainfrom
limityan:feat/tui-workspace-references

Conversation

@limityan

@limityan limityan commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add OpenCode-compatible @ 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.
  • Carry selected paths as typed turn metadata through Embedded and Shared Agent Runtime paths, while Core remains authoritative for Session binding, path kind, source range, persistence, and history recovery.
  • Preserve structured references across draft history, failed submission, undo, and fork-prefill flows.
  • Map the new optional Runtime capability through the existing SDK Host capability_unavailable error 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.mjs
  • node scripts/check-core-boundaries.mjs
  • cargo test --locked -p bitfun-sdk-host -p bitfun-sdk-host-app — library, protocol, lifecycle, standalone process, and stdio suites passed
  • cargo test --locked -q -p bitfun-cli — 507 unit tests plus all CLI integration targets passed
  • cargo test --locked -q -p bitfun-core — 1720 passed, 1 ignored, plus integration targets passed
  • cargo test --locked -q -p bitfun-agent-runtime -p bitfun-agent-runtime-ipc -p bitfun-runtime-ports -p bitfun-services-core
  • cargo check --locked --workspace --exclude bitfun-desktop
  • Focused Unicode source-range, invalid path/control-character, workspace resolver, Runtime port, IPC protocol, TUI reference, and SDK Host error-contract tests
  • git diff --check
  • GitHub CI run 30648782583 — all seven jobs passed on the updated head

A local full cargo check --locked --workspace reached the desktop build script but could not continue because this worktree has no generated src/mobile-web/dist and no frontend node_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.

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
limityan force-pushed the feat/tui-workspace-references branch from 8d672ab to 6a08083 Compare July 31, 2026 16:50
@limityan
limityan marked this pull request as ready for review July 31, 2026 17:08
@limityan
limityan merged commit f8281ca into GCWing:main Jul 31, 2026
7 checks passed
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.

1 participant