Save the default ai harness setup until we have a better use case

This commit is contained in:
David Heinemeier Hansson
2026-06-29 14:42:16 -05:00
parent 89615a526d
commit 38553effa3
4 changed files with 14 additions and 216 deletions
-32
View File
@@ -1,32 +0,0 @@
#!/bin/bash
# omarchy:summary=Set the default AI harness used by omarchy-launch-ai
# omarchy:args=[pi|claude|codex|opencode]
# omarchy:examples=omarchy default ai | omarchy default ai pi | omarchy default ai claude
ai_file="$HOME/.local/state/omarchy/defaults/ai"
if (( $# == 0 )); then
if [[ -f $ai_file ]]; then
read -r harness <"$ai_file"
fi
[[ -n ${harness:-} ]] && echo "$harness" || echo "pi"
exit 0
fi
case "$1" in
pi) harness="pi"; name="Pi"; glyph=󰚩 ;;
claude) harness="claude"; name="Claude Code"; glyph=󰚩 ;;
codex) harness="codex"; name="Codex"; glyph=󰚩 ;;
opencode) harness="opencode"; name="OpenCode"; glyph=󰚩 ;;
*)
echo "Usage: omarchy-default-ai <pi|claude|codex|opencode>" >&2
exit 1
;;
esac
mkdir -p "$(dirname "$ai_file")"
printf '%s\n' "$harness" >"$ai_file"
omarchy-notification-send -g "$glyph" "$name is now the default AI harness"
-105
View File
@@ -1,105 +0,0 @@
#!/bin/bash
# omarchy:summary=Launch the default AI coding harness in a project path
# omarchy:args=[--path <path>] [--prompt <prompt>] [--harness <pi|claude|codex|opencode>] [path]
# omarchy:examples=omarchy launch ai --path ~/.config/omarchy/plugins/local.clock | omarchy launch ai --harness claude --path . --prompt "Review this plugin"
set -euo pipefail
path="."
prompt=""
harness=""
usage() {
cat <<'USAGE'
Usage: omarchy-launch-ai [--path <path>] [--prompt <prompt>] [--harness <pi|claude|codex|opencode>] [path]
Launches an interactive AI coding harness in the given path. If no harness is
provided, uses the value from `omarchy default ai`.
USAGE
}
fail() {
echo "omarchy-launch-ai: $*" >&2
exit 1
}
while (( $# > 0 )); do
case "$1" in
--path)
path="${2:-}"
[[ -n $path ]] || fail "--path requires a value"
shift 2
;;
--prompt)
prompt="${2:-}"
shift 2
;;
--harness)
harness="${2:-}"
[[ -n $harness ]] || fail "--harness requires a value"
shift 2
;;
-h | --help)
usage
exit 0
;;
--)
shift
break
;;
--*)
fail "unknown option: $1"
;;
*)
path="$1"
shift
;;
esac
done
[[ -d $path ]] || fail "path is not a directory: $path"
path=$(cd "$path" && pwd)
if [[ -z $harness ]]; then
harness=$(omarchy-default-ai)
fi
case "$harness" in
pi | claude | codex | opencode)
;;
*)
fail "unknown AI harness: $harness"
;;
esac
launch_in_place() {
cd "$path"
case "$harness" in
pi)
omarchy-cmd-present pi || fail "pi is not installed"
if [[ -n $prompt ]]; then exec pi "$prompt"; else exec pi; fi
;;
claude)
omarchy-cmd-present claude || fail "claude is not installed"
if [[ -n $prompt ]]; then exec claude "$prompt"; else exec claude; fi
;;
codex)
omarchy-cmd-present codex || fail "codex is not installed"
if [[ -n $prompt ]]; then exec codex "$prompt"; else exec codex; fi
;;
opencode)
omarchy-cmd-present opencode || fail "opencode is not installed"
if [[ -n $prompt ]]; then exec opencode --prompt "$prompt" .; else exec opencode .; fi
;;
esac
}
if [[ -t 0 && -t 1 ]]; then
launch_in_place
fi
quoted_path=$(printf '%q' "$path")
quoted_prompt=$(printf '%q' "$prompt")
quoted_harness=$(printf '%q' "$harness")
exec omarchy-launch-tui bash -lc "cd $quoted_path && exec omarchy-launch-ai --harness $quoted_harness --prompt $quoted_prompt --path ."
+11 -75
View File
@@ -3,7 +3,7 @@
# omarchy:summary=Manage Omarchy shell plugins and bar widgets
# omarchy:group=plugin
# omarchy:args=<list|rescan|enable|disable|clone|edit|bar> [...]
# omarchy:examples=omarchy plugin list | omarchy plugin clone omarchy.clock local.clock --with ai | omarchy plugin edit local.clock --with editor | omarchy plugin enable acme.weather --section right | omarchy plugin bar settings
# omarchy:examples=omarchy plugin list | omarchy plugin clone omarchy.clock local.clock | omarchy plugin edit local.clock | omarchy plugin enable acme.weather --section right | omarchy plugin bar settings
set -euo pipefail
@@ -19,8 +19,7 @@ Plugin commands:
enable <id> [placement] Enable a plugin
disable <id> Disable a plugin
clone [source] [new-id] [options] Clone a built-in or user plugin
edit [id] [--with <ai|editor>] [--prompt <prompt>]
Open a user plugin for editing
edit [id] Open a user plugin directory in a shell
Add from sources (see 'omarchy plugin <command> --help'):
source <add|list|remove|refresh> Manage trusted plugin source repos
@@ -37,8 +36,6 @@ Add from sources (see 'omarchy plugin <command> --help'):
Clone options:
--name <name> Display name for the clone
--with <ai|editor> Open the clone with AI or editor
--prompt <prompt> Initial prompt when opening with AI
--replace Replace the first source bar instance
--add [placement] Add cloned bar widget to the bar
--use Use cloned bar options as the active bar
@@ -65,9 +62,8 @@ Examples:
omarchy plugin list
omarchy plugin rescan
omarchy plugin clone
omarchy plugin clone omarchy.clock local.clock --name "My Clock" --replace --with ai --prompt "Customize this clock"
omarchy plugin edit local.clock --with editor
omarchy plugin edit local.clock --with ai --prompt "Customize this clock"
omarchy plugin clone omarchy.clock local.clock --name "My Clock" --replace
omarchy plugin edit local.clock
omarchy plugin enable acme.weather --section right
omarchy plugin bar options
omarchy plugin bar use local.neon-bar
@@ -851,28 +847,6 @@ plugin_dir_for_id() {
validate_user_plugin_dir "$HOME/.config/omarchy/plugins/$id" "$id"
}
open_plugin_dir() {
local tool="$1"
local dir="$2"
local prompt="${3:-}"
case "$tool" in
"" | none)
printf 'Plugin directory: %s\n' "$dir"
return
;;
ai)
omarchy-launch-ai --path "$dir" --prompt "$prompt"
;;
editor)
omarchy-launch-editor "$dir"
;;
*)
fail "unknown edit target: $tool (use ai, editor, or none)"
;;
esac
}
edit_command() {
local id=""
if (( $# > 0 )) && [[ $1 != --* ]]; then
@@ -880,24 +854,8 @@ edit_command() {
shift
fi
local open_tool=""
local prompt=""
while (( $# > 0 )); do
case "$1" in
--with)
open_tool="${2:-}"
[[ -n $open_tool ]] || fail "--with requires a value"
shift 2
;;
--open)
open_tool="${2:-}"
[[ -n $open_tool ]] || fail "--open requires a value"
shift 2
;;
--prompt)
prompt="${2:-}"
shift 2
;;
-h | --help)
usage
return
@@ -919,15 +877,11 @@ edit_command() {
local dir
dir=$(plugin_dir_for_id "$id")
if [[ -z $open_tool ]]; then
if [[ -t 0 && -t 1 ]]; then
open_tool=$(choose_value "Edit with" ai editor)
else
open_tool="editor"
fi
if [[ -t 0 && -t 1 ]]; then
cd "$dir"
exec "${SHELL:-bash}"
fi
open_plugin_dir "$open_tool" "$dir" "$prompt"
printf '%s\n' "$dir"
}
rewrite_cloned_qml() {
@@ -1055,8 +1009,6 @@ clone_command() {
fi
local display_name=""
local open_tool=""
local prompt=""
local replace="false"
local add="false"
local use_bar="false"
@@ -1069,20 +1021,6 @@ clone_command() {
[[ -n $display_name ]] || fail "--name requires a value"
shift 2
;;
--with)
open_tool="${2:-}"
[[ -n $open_tool ]] || fail "--with requires a value"
shift 2
;;
--open)
open_tool="${2:-}"
[[ -n $open_tool ]] || fail "--open requires a value"
shift 2
;;
--prompt)
prompt="${2:-}"
shift 2
;;
--replace)
replace="true"
shift
@@ -1196,11 +1134,9 @@ clone_command() {
echo "Cloned $source_id to $new_id"
fi
if [[ -z $open_tool && -t 0 && -t 1 ]]; then
open_tool=$(choose_value "Edit with" ai editor)
fi
if [[ -n $open_tool ]]; then
edit_command "$new_id" --with "$open_tool" --prompt "$prompt"
if [[ -t 0 && -t 1 ]]; then
cd "$target_dir"
exec "${SHELL:-bash}"
fi
}
+3 -4
View File
@@ -146,10 +146,9 @@ editing the built-in source. Third-party ids must be namespaced and may not use
the reserved `omarchy.*` prefix.
```bash
omarchy plugin clone omarchy.clock local.clock --replace --with ai --prompt "Customize this clock widget"
omarchy plugin clone # interactive source/name/tool picker
omarchy plugin edit local.clock --with editor # edit with `omarchy launch editor`
omarchy plugin edit local.clock --with ai # edit with `omarchy launch ai`
omarchy plugin clone omarchy.clock local.clock --replace
omarchy plugin clone # interactive source/name picker
omarchy plugin edit local.clock # cd into the plugin directory
```
First-party plugins under `shell/plugins/`