DEV Community

Cover image for Protocol Launcher Series: One-Click CodeBuddy Development Experience
zhensherlock
zhensherlock

Posted on

Protocol Launcher Series: One-Click CodeBuddy Development Experience

After introducing one-click configuration for Cursor, today let’s talk about a powerful code editor — CodeBuddy.

As remote development and cloud collaboration become more common, developers need a lightweight way to quickly open projects, inspect code, or connect to remote environments. With Protocol Launcher, you can generate elegant launch links for CodeBuddy and achieve seamless jumps from web pages or automation scripts into the editor.


CodeBuddy and Deep Links

CodeBuddy provides a well-designed deep link protocol. Whether you want to open local files, open directories, or establish remote SSH connections, you can trigger these actions via specific URL schemes.

However, manually composing such links usually means dealing with complex path encoding and subtle differences in how protocols are handled across operating systems.

With Protocol Launcher, you can wrap these operations in type-safe function calls and make app launching both simple and robust.


Core Capabilities: Fast and Versatile

Protocol Launcher provides a dedicated protocol-launcher/code-buddy module for CodeBuddy with the following core features:

  1. Quick editor launch: Start the CodeBuddy client with one click.
  2. Precise file navigation: Open a specific file path and jump to a given line and column.
  3. Folder and workspace management: Open local project folders in one step.
  4. Remote development connections: Use SSH to connect to remote servers with a single link.
  5. Shortcut to settings: Jump directly to the settings interface.

Quick Start

First, make sure you have installed the package:

npm install protocol-launcher
Enter fullscreen mode Exit fullscreen mode

In your code, you can choose between two import styles depending on your scenario:

  • On-demand imports (via subpaths) with tree shaking for smaller bundle size.
  • Full imports (from the root package) with simpler syntax but including all supported app logic.
// ✅ Recommended: load only the CodeBuddy module on demand
import { openFile, openRemote, openFolder } from 'protocol-launcher/code-buddy'

// You can also import from the root package, but this will include all app modules
// import { codeBuddy } from 'protocol-launcher'
Enter fullscreen mode Exit fullscreen mode

Scenario 1: Open a File Precisely (openFile)

In code review tools or log analysis systems, you can guide users to view the corresponding code directly in CodeBuddy:

import { openFile } from 'protocol-launcher/code-buddy'

const url = openFile({
  path: '/Users/dev/project/src/index.ts', // Absolute path to the file
  line: 42, // Optional: jump to line 42
  column: 10, // Optional: jump to column 10
  openInNewWindow: true, // Optional: open in a new window
})
Enter fullscreen mode Exit fullscreen mode

Scenario 2: One-Click Remote Environment Connection (openRemote)

If you need to guide users to develop on a remote server, you can generate an SSH remote connection link. This greatly simplifies entering remote environments:

import { openRemote } from 'protocol-launcher/code-buddy'

const url = openRemote({
  type: 'ssh-remote', // Remote connection type
  host: 'root@172.18.105.209:22', // Remote host address
  path: '/code/my-project', // Project path
})
Enter fullscreen mode Exit fullscreen mode

Scenario 3: Open a Folder (openFolder)

After an automation script finishes running, you can automatically open the generated project directory for the user:

import { openFolder } from 'protocol-launcher/code-buddy'

const url = openFolder({
  path: '/Users/dev/project', // Absolute path to the project or module folder
  openInNewWindow: true, // Optional: open in a new window
})
Enter fullscreen mode Exit fullscreen mode

Why Protocol Launcher?

  1. Automatic encoding and Unicode support: The library automatically handles special characters and Chinese characters in paths, ensuring that generated URLs never become garbled when launching CodeBuddy.
  2. Type safety and completion: TypeScript’s strong typing ensures parameter correctness and helps avoid typos that are easy to make when manually concatenating strings.
  3. Extreme tree shaking: A modular design supports tree shaking to minimize bundle size:
    • Recommended: Use subpath imports such as import { openFile } from 'protocol-launcher/code-buddy'.
    • Full import: You can also import from the root package, for example import { codeBuddy } from 'protocol-launcher'.
  4. Cross-platform consistency: It abstracts away low-level protocol-triggering differences, ensuring consistent behavior across macOS, Windows, and other systems.

Conclusion

With Protocol Launcher, you can provide CodeBuddy users with a smoother development experience. Whether in web consoles, documentation centers, or automation tools, one-click editor launching can significantly boost developer productivity.


🔗 Related Links

Top comments (0)