Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/adapters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
# flags — comma-separated modifiers (optional):
# "workspace" — pass .code-workspace file instead of directory
# "background" — launch with & (for terminal editors that fork)
# "dot" — cd to directory and pass "." instead of full path
#
# Loading: file override (adapters/editor/<name>.sh) → registry → generic PATH fallback
_EDITOR_REGISTRY="
antigravity|agy|standard|Antigravity 'agy' command not found. Install from https://antigravity.google|workspace
antigravity|agy|standard|Antigravity 'agy' command not found. Install from https://antigravity.google|workspace,dot
atom|atom|standard|Atom not found. Install from https://atom.io|
cursor|cursor|standard|Cursor not found. Install from https://cursor.com or enable the shell command.|workspace
emacs|emacs|terminal|Emacs not found. Install from https://www.gnu.org/software/emacs/|background
Expand Down Expand Up @@ -86,13 +87,17 @@ _load_from_editor_registry() {
_EDITOR_ERR_MSG="$err_msg"
_EDITOR_WORKSPACE=0
_EDITOR_BACKGROUND=0
_EDITOR_DOT=0

case ",$flags," in
*,workspace,*) _EDITOR_WORKSPACE=1 ;;
esac
case ",$flags," in
*,background,*) _EDITOR_BACKGROUND=1 ;;
esac
case ",$flags," in
*,dot,*) _EDITOR_DOT=1 ;;
esac

case "$type" in
terminal) _editor_define_terminal ;;
Expand Down Expand Up @@ -207,7 +212,7 @@ _ai_define_standard() {
}

# Standard editor adapter builder — used by adapter files that follow the common pattern
# Sets globals then call this: _EDITOR_CMD, _EDITOR_ERR_MSG, _EDITOR_WORKSPACE (optional, 0 or 1)
# Sets globals then call this: _EDITOR_CMD, _EDITOR_ERR_MSG, _EDITOR_WORKSPACE (optional, 0 or 1), _EDITOR_DOT (optional, 0 or 1)
_editor_define_standard() {
# shellcheck disable=SC2317 # Functions are called indirectly via adapter dispatch
editor_can_open() {
Expand All @@ -224,6 +229,8 @@ _editor_define_standard() {
fi
if [ "${_EDITOR_WORKSPACE:-0}" = "1" ] && [ -n "$workspace" ] && [ -f "$workspace" ]; then
"$_EDITOR_CMD" "$workspace"
elif [ "${_EDITOR_DOT:-0}" = "1" ]; then
(cd "$path" && "$_EDITOR_CMD" .)
else
"$_EDITOR_CMD" "$path"
fi
Expand Down
9 changes: 9 additions & 0 deletions tests/adapters.bats
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ setup() {
[ "$_EDITOR_BACKGROUND" -eq 1 ]
}

@test "_load_from_editor_registry parses antigravity with workspace and dot flags" {
local entry
entry=$(_registry_lookup "$_EDITOR_REGISTRY" "antigravity")
_load_from_editor_registry "$entry"
[ "$_EDITOR_CMD" = "agy" ]
[ "$_EDITOR_WORKSPACE" -eq 1 ]
[ "$_EDITOR_DOT" -eq 1 ]
}

# ── _load_from_ai_registry ──────────────────────────────────────────────────

@test "_load_from_ai_registry parses aider entry correctly" {
Expand Down