Skip to content

Instantly share code, notes, and snippets.

@lharp
Last active October 27, 2025 08:44
Show Gist options
  • Select an option

  • Save lharp/e5858fa18e7d0f9933698e84ad2105ef to your computer and use it in GitHub Desktop.

Select an option

Save lharp/e5858fa18e7d0f9933698e84ad2105ef to your computer and use it in GitHub Desktop.
Agent OS Helper Script
#!/bin/bash
# Agent OS Helper Script
# This script is a wrapper for running various Agent OS commands
# Created by Tomas Lehuta <tomas@flexets.com>
# Installation: curl -sSL https://is.gd/pOUyX4 | bash -s setup
echo ""
echo "⚙️ Agent OS Helper"
echo "=================="
echo ""
AGENTOS_NAME='agent-os'
AGENTOS_HOME="$HOME/$AGENTOS_NAME"
AGENTOS_PROFILES="$AGENTOS_HOME/profiles"
AGENTOS_SCRIPTS="$AGENTOS_HOME/scripts"
AGENTOS_OPTIONS="agent_os_commands|claude_code_commands|use_claude_code_subagents|standards_as_claude_code_skills"
AGENTOS_SOURCE="https://raw.githubusercontent.com/buildermethods/$AGENTOS_NAME/main"
AGENTOS_GIST="https://gist.githubusercontent.com/lharp/e5858fa18e7d0f9933698e84ad2105ef/raw/$AGENTOS_NAME"
AGENTOS_HELPER=$(which $AGENTOS_NAME) || AGENTOS_HELPER="$HOME/bin/$AGENTOS_NAME"
CODE_EDITOR=$(which code) || CODE_EDITOR=$(which cursor)
YAML_PARSER=$(which yq)
VERSION=1.1.2
command=$1
target=$2
name=$3
show_help() {
cat << EOF
Global Commands:
info Show info about the Agent OS installation
check Check the latest Agent OS version
install Install fresh Agent OS into the system
upgrade Upgrade current Agent OS installation to the latest version
backup Backup current Agent OS installation
setup Setup Agent OS helper in your system
Profile Commands:
create profile Create new Agent OS profile
list profiles List existing Agent OS profiles
edit profile <name> Edit existing Agent OS profile with VSCode or Cursor IDE
Project Commands:
init project Install Agent OS into the current project folder
update project Update Agent OS in the current project folder
EOF
exit 0
}
show_helper_info() {
echo "Helper version: $VERSION"
echo ""
}
show_global_info() {
local config; local version; local profile; local format; local options
if check_home && check_parser
then
echo "Global Info:"
config="$AGENTOS_HOME/config.yml"
printf " Agent OS home: $AGENTOS_HOME\n"
version=$($YAML_PARSER '.version' $config)
printf " Agent OS version: $version\n"
profile=$($YAML_PARSER '.profile' $config)
printf " Default profile: $profile\n"
format=$(echo "$AGENTOS_OPTIONS" | sed 's/\([^|]*\)/"\1": .\1/g' | sed 's/|/, /g')
options=$($YAML_PARSER "{$format}" $config | sed 's/^/ /')
printf " Config options: \n$options\n"
echo ""
fi
}
show_project_info() {
local config; local version; local profile; local format; local options
if check_project && check_parser
then
echo "Project Info:"
config="$(pwd)/$AGENTOS_NAME/config.yml"
printf " Agent OS folder: $(dirname $config)\n"
version=$($YAML_PARSER '.version' $config)
printf " Agent OS version: $version\n"
profile=$($YAML_PARSER '.profile' $config)
printf " Current profile: $profile\n"
format=$(echo "$AGENTOS_OPTIONS" | sed 's/\([^|]*\)/"\1": .\1/g' | sed 's/|/, /g')
options=$($YAML_PARSER "{$format}" $config | sed 's/^/ /')
printf " Config options: \n$options\n"
echo ""
fi
}
test_version() {
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"
}
check_agentos() {
local new_version; local version
if check_home && check_parser
then
version=$($YAML_PARSER '.version' "$AGENTOS_HOME/config.yml")
new_version=$(curl -sSL "$AGENTOS_SOURCE/config.yml" | $YAML_PARSER '.version')
if [ "$1" == 'version' ]
then
echo "Checking Agent OS $1.."
echo ""
if test_version $new_version $version
then
echo "New Agent OS $1: $new_version"
echo ""
fi
fi
if [ "$new_version" == "$version" ]
then
echo "Agent OS is up-to-date!"
echo ""
[ ! -z "$1" ] || exit 1
fi
fi
}
check_helper() {
local new_version
if [ -f "$AGENTOS_HELPER" ]
then
new_version=$(curl -sSL "$AGENTOS_GIST" | grep 'VERSION=.*' | awk -F'=' '/^VERSION=/ { print $2 }')
if [ "$1" == 'version' ]
then
echo "Checking Helper $1.."
echo ""
if test_version $new_version $VERSION
then
echo "New Helper $1: $new_version"
echo ""
fi
fi
if [ "$new_version" == "$VERSION" ]
then
echo "Helper is up-to-date!"
echo ""
[ ! -z "$1" ] || exit 1
fi
fi
}
check_home() {
if [ ! -d "$AGENTOS_HOME" ]
then
echo "Agent OS not installed!"
echo ""
exit 1
fi
}
check_project() {
[ "$HOME" != "$(pwd)" ] && [ -d "$AGENTOS_NAME" ]
}
check_editor() {
if [ -z "$CODE_EDITOR" ]
then
echo "Code editor not found!"
echo "Please install 'VSCode' or 'Cursor' IDE tool."
echo ""
exit 1
fi
}
check_parser() {
if [ -z "$YAML_PARSER" ]
then
echo "Config parser not found!"
echo "Please install 'yq' command-line tool."
echo ""
exit 1
fi
}
check_target() {
if [ ! -z "$target" ] && [ "$target" != "$1" ] && [ ! -z "$1" ]
then
echo "Unknown target: $target"
echo ""
exit 1
elif [ -z "$target" ]
then
echo "Target not specified!"
echo ""
show_help
fi
}
check_profile() {
if [ ! -z "$name" ] && [ ! -d "$1" ]
then
echo "Unknown profile: $name"
echo ""
exit 1
elif [ -z "$name" ]
then
echo "Profile not specified!"
echo ""
show_help
fi
}
backup_agentos() {
if check_home
then
echo "Backing up Agent OS installation.."
echo ""
zip -r9 "$AGENTOS_HOME/backup.zip" $AGENTOS_HOME
fi
}
install_agentos() {
if ! check_home
then
if [ -z "$@" ]
then
echo "Installing Agent OS.."
fi
curl -sSL "$AGENTOS_SOURCE/scripts/base-install.sh" | bash $@
else
echo "Agent OS is already installed!"
echo ""
fi
}
upgrade_agentos() {
if check_home
then
if [ -z "$@" ]
then
echo "Upgrading Agent OS installation.."
echo ""
fi
curl -sSL "$AGENTOS_SOURCE/scripts/base-install.sh" | bash $@
fi
}
setup_helper() {
if check_helper
then
echo "Setting up Agent OS Helper.."
echo ""
mkdir -p $(dirname $AGENTOS_HELPER)
curl -sSL "$AGENTOS_GIST" > $AGENTOS_HELPER
chmod +x $AGENTOS_HELPER
echo "Agent OS Helper stored in $AGENTOS_HELPER"
echo ""
fi
}
create_target() {
if check_home && check_target
then
case $target in
profile)
bash "$AGENTOS_SCRIPTS/create-profile.sh" $@
;;
role)
bash "$AGENTOS_SCRIPTS/create-role.sh" $@
;;
*)
echo "Unknown target: $target"
echo ""
show_help
;;
esac
fi
}
list_profiles() {
if check_home && check_target 'profiles'
then
echo "Existing Agent OS profiles:"
echo ""
ls -1 $AGENTOS_PROFILES
echo ""
fi
}
edit_profile() {
if check_home && check_target 'profile'
then
profile="$AGENTOS_PROFILES/$name"
if check_editor && check_profile $profile
then
echo "Editing Agent OS profile '$name'.."
echo ""
$CODE_EDITOR $profile
fi
fi
}
init_project() {
if check_home && check_target 'project'
then
if [ -z "$@" ]
then
echo "Installing Agent OS into the current project.."
fi
bash "$AGENTOS_SCRIPTS/project-install.sh" $@
fi
}
update_project() {
if check_home && check_target 'project'
then
if [ -z "$@" ]
then
echo "Updating Agent OS in the current project.."
fi
bash "$AGENTOS_SCRIPTS/project-update.sh" $@
fi
}
if [ -z "$command" ]
then
show_help
fi
shift
shift
case $command in
info)
show_helper_info
show_global_info
show_project_info
;;
check)
check_agentos 'version'
check_helper 'version'
;;
install)
install_agentos $@
;;
upgrade)
upgrade_agentos $@
;;
backup)
backup_agentos
;;
setup)
setup_helper
;;
create)
create_target $@
;;
list)
list_profiles
;;
edit)
edit_profile
;;
init)
init_project $@
;;
update)
update_project $@
;;
*)
echo "Unknown command: $command"
echo ""
show_help
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment