joy-cli/bin/joy.bash
feibisi 3874b562c3 feat: joy CLI Python 2.0 — 50 命令全量重写 + pip 全集群部署
- 50 命令:patrol/health/board/recall/poke/who/inbox/mind/message/team 等
- 异步并行 SSH (asyncio subprocess)
- 命令注册表 + @command decorator + 插件扩展架构
- 环境检测 (Mac/VM/agent 身份)
- JSON 输出契约 (stdout=成功, stderr=错误 code)
- 权限模型 (agent 身份检测 + 环境限制)
- pytest 23/23 通过
- deploy-joy.sh 全集群 16 VM 部署脚本 (含 PEP 668 兼容)
- 旧 bash 版归档到 archive/commands.bash/

Closes: joy CLI 2.0 迁移
2026-07-07 11:38:03 +08:00

42 lines
1.1 KiB
Bash
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# joy — 麟悦飞轮统一 CLI
# AI 原生:默认 JSON 输出,位置参数优先,最少 token 消耗
set -euo pipefail
JOY_ROOT="$(cd "$(dirname "$(readlink "$0" 2>/dev/null || echo "$0")")/.." && pwd)"
JOY_LIB="$JOY_ROOT/lib"
JOY_COMMANDS="$JOY_ROOT/commands"
source "$JOY_LIB/core.sh"
cmd="${1:-help}"
shift 2>/dev/null || true
cmd_file="$JOY_COMMANDS/${cmd}.sh"
if [[ -f "$cmd_file" ]]; then
source "$cmd_file"
"cmd_${cmd}" "$@"
else
# 尝试子命令格式joy board ls → commands/board.sh cmd_board ls
parent="${cmd}"
sub="${1:-}"
parent_file="$JOY_COMMANDS/${parent}.sh"
if [[ -f "$parent_file" ]]; then
shift 2>/dev/null || true
source "$parent_file"
if declare -f "cmd_${parent}_${sub}" >/dev/null 2>&1; then
"cmd_${parent}_${sub}" "$@"
elif declare -f "cmd_${parent}" >/dev/null 2>&1; then
"cmd_${parent}" "$sub" "$@"
else
joy_error "未知子命令: joy $parent $sub"
exit 1
fi
else
joy_error "未知命令: joy $cmd"
echo ""
cmd_help
exit 1
fi
fi