summarylogtreecommitdiffstats
path: root/forge-code-bin.install
blob: b2cbc24c661366f0b66f440d46250e7db6f67aa6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
post_install() {
    local BLUE='\033[0;34m'
    local GREEN='\033[0;32m'
    local YELLOW='\033[1;33m'
    local RED='\033[0;31m'
    local BOLD='\033[1m'
    local NC='\033[0m'

    echo ""
    echo -e "${BLUE}+============================================================================+${NC}"
    echo -e "${BLUE}|            ${BOLD}FORGE-CODE-BIN — Installation Complete${NC}${BLUE}                            |${NC}"
    echo -e "${BLUE}+============================================================================+${NC}"
    echo -e ""
    echo -e "  ${BOLD}Available commands:${NC}"
    echo -e "    ${GREEN}forge-code${NC}          — main CLI entry point"
    echo -e "    ${GREEN}forge${NC}               — alias for forge-code"
    echo -e "    ${GREEN}: <prompt>${NC}           — ZSH: ask Forge from any shell prompt"
    echo -e "    ${GREEN}:commit${NC}              — ZSH: AI writes a git commit message"
    echo -e "    ${GREEN}:new${NC}                — ZSH: start a fresh conversation"
    echo -e ""
    echo -e "${BOLD}  First time setup:${NC}"
    echo -e "    1. ${BOLD}forge-code provider login${NC} — configure your AI provider (Claude/GPT/Gemini/...)"
    echo -e "    2. ${BOLD}forge-code${NC}              — start an interactive session"
    echo -e "    3. In ZSH: type ${GREEN}: help${NC} to see all commands"
    echo -e ""

    # ZSH plugin setup
    local zsh_plugin_dir="/usr/share/zsh/plugins/forge-code"
    local zsh_site_func="/usr/share/zsh/site-functions/_forge-code"

    if command -v zsh >/dev/null 2>&1; then
        echo -e "${GREEN}  ZSH plugin installed to:${NC}"
        echo -e "    ${BOLD}${zsh_plugin_dir}/${NC}"
        echo -e "    ${BOLD}${zsh_site_func}${NC}"
        echo -e ""
        echo -e "  ${YELLOW}To enable in your ZSH:${NC}"
        echo -e "    # Add to ~/.zshrc (oh-my-zsh):"
        echo -e "    plugins+=(forge-code)"
        echo -e ""
        echo -e "    # Or with zinit:"
        echo -e "    zinit load z-shell/zinit  # or your plugin manager"
        echo -e "    zplugin ice wait\"\" lucid; zplugin light ${zsh_plugin_dir}"
        echo -e ""
        echo -e "    # Or standalone (add to end of ~/.zshrc):"
        echo -e "    source ${zsh_plugin_dir}/forge-code.zsh"
        echo -e ""
    else
        echo -e "${YELLOW}  ZSH not detected — ZSH plugin not installed${NC}"
        echo -e "    Install zsh to enable : prefix command integration"
    fi

    # AppArmor
    if command -v apparmor_parser >/dev/null 2>&1; then
        echo -e "${GREEN}  AppArmor detected — consider hardening:${NC}"
        echo -e "    sudo cp /usr/share/apparmor/forge-code.apparmor /etc/apparmor.d/forge-code"
        echo -e "    sudo aa-enforce /etc/apparmor.d/forge-code"
    else
        echo -e "${YELLOW}  AppArmor not installed — skipping MAC profile${NC}"
        echo -e "    Install apparmor for mandatory access control: ${BOLD}sudo pacman -S apparmor${NC}"
    fi

    echo -e ""
    echo -e "${BOLD}  Documentation:${NC}"
    echo -e "    ${BLUE}forge-code --help${NC}    — CLI help"
    echo -e "    ${BLUE}forge-code config${NC}    — show effective configuration"
    echo -e "    ${BLUE}https://forgecode.dev/${NC} — full documentation"
    echo -e ""
    echo -e "${BLUE}----------------------------------------------------------------------------${NC}"
    echo -e ""
}

post_upgrade() {
    post_install
    echo -e "${YELLOW}  Note:${NC} Upgrading preserves your conversations and configuration."
    echo -e "  If Forge behaves unexpectedly, clear the cache:"
    echo -e "  ${BOLD}rm -rf ~/.forge/cache ~/.forge/Code\\ Cache${NC}"
    echo ""
}

post_remove() {
    echo ""
    echo -e "${BLUE}  FORGE-CODE REMOVAL${NC}"
    echo -e ""
    echo -e "  ${YELLOW}Remove ZSH plugin:${NC}"
    echo -e "    Remove ${BOLD}forge-code${NC} from your plugin list in ~/.zshrc"
    echo -e "    Or remove the source line: ${BOLD}source /usr/share/zsh/plugins/forge-code/forge-code.zsh${NC}"
    echo -e ""
    echo -e "  ${YELLOW}Remove user data (optional):${NC}"
    echo -e "    ${BOLD}rm -rf ~/.forge ~/.config/forge-code${NC}"
    echo ""
}