Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·172 lines (142 loc) · 3.94 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·172 lines (142 loc) · 3.94 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/bin/bash
# Agent Watchboard - CLI Installation Script
# Creates wrapper scripts in ~/.local/bin that call the built Node.js CLIs
set -e
INSTALL_DIR="$HOME/.local/bin"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$SCRIPT_DIR"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log() {
local level=$1
local message=$2
local color=""
case $level in
"INFO") color=$BLUE ;;
"WARN") color=$YELLOW ;;
"ERROR") color=$RED ;;
"SUCCESS") color=$GREEN ;;
esac
echo -e "${color}[$(date '+%H:%M:%S')] [$level] $message${NC}"
}
check_dependencies() {
log "INFO" "Checking dependencies..."
if ! command -v node &> /dev/null; then
log "ERROR" "node not found. Install Node.js >= 22."
exit 1
fi
log "INFO" "Found node: $(node --version)"
if ! command -v pnpm &> /dev/null; then
log "ERROR" "pnpm not found. Install with: npm install -g pnpm"
exit 1
fi
log "INFO" "Found pnpm: $(pnpm --version)"
log "SUCCESS" "Dependencies check passed"
}
build_cli() {
log "INFO" "Building CLI entry points..."
cd "$PROJECT_DIR"
if [[ ! -d node_modules ]]; then
log "INFO" "Installing npm packages..."
pnpm install --frozen-lockfile
fi
pnpm run build:node
log "SUCCESS" "Build complete"
}
verify_build() {
log "INFO" "Verifying build output..."
local missing=0
for cli in watchboard session-log; do
if [[ ! -f "$PROJECT_DIR/dist-node/cli/${cli}.cjs" ]]; then
log "ERROR" "Missing: dist-node/cli/${cli}.cjs"
missing=1
fi
done
if [[ $missing -eq 1 ]]; then
log "ERROR" "Build verification failed"
exit 1
fi
log "SUCCESS" "All CLI binaries present"
}
create_commands() {
log "INFO" "Creating command scripts in $INSTALL_DIR..."
mkdir -p "$INSTALL_DIR"
for cli in watchboard session_log; do
local cli_file="${cli//_/-}" # session_log -> session-log
rm -f "$INSTALL_DIR/$cli"
cat > "$INSTALL_DIR/$cli" << EOF
#!/bin/bash
# $cli: Agent Watchboard CLI
# Auto-generated by install.sh - DO NOT EDIT
# Project: $PROJECT_DIR
exec node "$PROJECT_DIR/dist-node/cli/${cli_file}.cjs" "\$@"
EOF
chmod +x "$INSTALL_DIR/$cli"
log "INFO" " Installed: $cli"
done
log "SUCCESS" "Commands created"
}
check_path() {
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
log "WARN" "$INSTALL_DIR is not in your PATH"
echo ""
echo " Add this to your ~/.bashrc or ~/.zshrc:"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
echo ""
else
log "SUCCESS" "$INSTALL_DIR is already in PATH"
fi
}
show_help() {
cat << HELP_EOF
Agent Watchboard - CLI Installation
Usage: $0 [COMMAND]
Commands:
install Install CLIs globally (default)
--help Show this help message
This script builds the Node.js CLIs and creates wrapper scripts in
~/.local/bin that call the built binaries at:
$PROJECT_DIR/dist-node/cli/
After installation, the following commands are available:
session_log Query/fetch agent session logs
watchboard Workspace and settings management
To uninstall:
$PROJECT_DIR/uninstall.sh
HELP_EOF
}
main() {
echo ""
log "INFO" "Installing Agent Watchboard CLIs..."
log "INFO" "Project: $PROJECT_DIR"
echo ""
check_dependencies
build_cli
verify_build
create_commands
check_path
echo ""
log "SUCCESS" "Installation complete!"
echo ""
echo " Commands installed:"
echo " session_log --help"
echo " watchboard --help"
echo ""
echo " To uninstall: $PROJECT_DIR/uninstall.sh"
echo ""
}
case "${1:-install}" in
install)
main
;;
--help|-h|help)
show_help
;;
*)
echo "Unknown command: $1"
echo "Use --help for usage information"
exit 1
;;
esac