codespace-vscode-open
Auto-discover VS Code CLI in Codespaces and open files in connected editor
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 2
- Forks
- 2
01 前言 Front Matter
- name
- codespace-vscode-open
- author
- Hermes Agent
- license
- MIT
- version
- 1.0.0
- metadata
- { "hermes": { "tags": [ "codespace", "vscode", "editor", "cli" ], "related_skills": [ "codespace-gh-auth", "codespace-port-visibility" ] } }
- platforms
- [ "linux" ]
- description
- Auto-discover VS Code CLI in Codespaces and open files in connected editor
02 资源文件 3
- 参考文档references/vscode-cli-discovery.md1.8 KB
- 脚本scripts/install.sh514 B
- 脚本scripts/vscode-open.sh1.3 KB
03 SKILL.md 正文
codespace-vscode-open
Auto-discovers the VS Code remote CLI path in GitHub Codespaces (/vscode/bin/linux-x64/<commit>/bin/remote-cli/code) and provides a simple command to open files in the user's connected VS Code instance.
Problem
The bare code command often fails in Codespaces because it's not on PATH or the shim is broken. The real CLI lives at a commit-specific path under /vscode/bin/linux-x64/.
Solution
A script that finds the CLI automatically and opens files. Works in any Codespace with VS Code connected.
Installation
# Run the install script to copy vscode-open.sh to ~/.hermes/scripts/
~/.hermes/skills/minions/codespace-vscode-open/scripts/install.sh
# Or from the skill directory
skills/codespace-vscode-open/scripts/install.sh
The script is installed to ~/.hermes/scripts/vscode-open.sh by the install script.
Usage
# As a command
~/.hermes/scripts/vscode-open.sh /path/to/file.md
# Or from skill dir
skills/codespace-vscode-open/scripts/vscode-open.sh /path/to/file.md
How It Works
- Finds the active VS Code server PID (
pgrep -f "server-main.js") - Extracts commit SHA from the server's command line to get the exact matching CLI
- Fallback: if commit SHA extraction fails, picks the newest
codebinary by mtime - Executes the CLI with the provided file path — opens in the user's connected VS Code
This ensures we always use the CLI from the active VS Code server, not a stale version from a previous update.
Files
scripts/vscode-open.sh— Main executable scriptscripts/install.sh— Installs vscode-open.sh to~/.hermes/scripts/references/vscode-cli-discovery.md— Discovery pattern and troubleshooting
Pitfalls
| Pitfall | Symptom | Fix |
|---|---|---|
| Stale CLI selected | File opens against old VS Code server, doesn't reach connected editor | Use active server's commit SHA (from /proc/PID/cmdline) or fallback to newest by mtime |
| Script not installed | ~/.hermes/scripts/vscode-open.sh: No such file or directory |
Run scripts/install.sh — it's not auto-linked like skills |
| VS Code not connected | VS Code server not running error |
Connect VS Code desktop to Codespace before running |
| Multiple VS Code versions | Arbitrary find | head -1 picks wrong version |
Sort by mtime (-printf "%T@ %p\n" | sort -n | tail -1) |
Related Skills
codespace-persistent-symlinks— Same symlink pattern for persisting scripts to~/.hermes/scripts/codespace-gh-auth— GitHub auth in Codespaces (token extraction from VS Code server)codespace-port-visibility— Port forwarding in Codespaces
Mnemon Persistence
This skill follows the repo's persistent knowledge pattern:
- Skill in
skills/codespace-vscode-open/(git-tracked) - Script symlinked to
~/.hermes/scripts/vscode-open.sh(runtime) - Wiki article in
../wiki/vscode-cli-codespaces.md - Mnemon entry in
mnemon/seed.json(validated viamnemon import --dry-run)
The start-hermes.sh repair guard (from codespace-persistent-symlinks) ensures the symlink survives rebuilds.
04 同仓库更多 Skills
version-single-source
Use when adding a new component dependency or versioning a binary in install/boot scripts.
tdd
Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
shell-path-login
Use when a binary or script works in one shell context but not another (interactive vs non-interactive login vs non-login shell).
self-update-fix
Fix a failing dependency update PR. Use when a self-update PR's CI fails, or when invoked by scripts/self-update-fix.sh.
pr-change-log
Use when a multi-commit PR needs its description written/updated, or when closing out a long branch with many fix commits.
persistent-knowledge
Persistent skills/knowledge in Codespace via symlinks.