agentk8 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +222 -0
- package/agentk +481 -0
- package/bin/agentk-wrapper.js +35 -0
- package/bin/postinstall.js +97 -0
- package/lib/core.sh +281 -0
- package/lib/ipc.sh +501 -0
- package/lib/spawn.sh +398 -0
- package/lib/ui.sh +415 -0
- package/lib/visual.sh +349 -0
- package/modes/dev/engineer.md +118 -0
- package/modes/dev/orchestrator.md +110 -0
- package/modes/dev/security.md +221 -0
- package/modes/dev/tester.md +161 -0
- package/modes/ml/data-engineer.md +244 -0
- package/modes/ml/evaluator.md +265 -0
- package/modes/ml/ml-engineer.md +239 -0
- package/modes/ml/orchestrator.md +145 -0
- package/modes/ml/researcher.md +198 -0
- package/modes/shared/scout.md +270 -0
- package/package.json +49 -0
package/agentk
ADDED
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# AGENT-K - Multi-Agent Claude Code Terminal Suite
|
|
3
|
+
# Main entry point CLI
|
|
4
|
+
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
# =============================================================================
|
|
8
|
+
# INITIALIZATION
|
|
9
|
+
# =============================================================================
|
|
10
|
+
|
|
11
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
12
|
+
export AGENTK_ROOT="$SCRIPT_DIR"
|
|
13
|
+
|
|
14
|
+
# Source libraries
|
|
15
|
+
source "$SCRIPT_DIR/lib/core.sh"
|
|
16
|
+
source "$SCRIPT_DIR/lib/ui.sh"
|
|
17
|
+
source "$SCRIPT_DIR/lib/ipc.sh"
|
|
18
|
+
source "$SCRIPT_DIR/lib/spawn.sh"
|
|
19
|
+
|
|
20
|
+
# =============================================================================
|
|
21
|
+
# CONFIGURATION
|
|
22
|
+
# =============================================================================
|
|
23
|
+
|
|
24
|
+
# Default mode
|
|
25
|
+
AGENTK_MODE="${AGENTK_MODE:-dev}"
|
|
26
|
+
VISUAL_MODE=false
|
|
27
|
+
ONE_SHOT=false
|
|
28
|
+
ONE_SHOT_PROMPT=""
|
|
29
|
+
FOCUSED_AGENT=""
|
|
30
|
+
|
|
31
|
+
# =============================================================================
|
|
32
|
+
# USAGE
|
|
33
|
+
# =============================================================================
|
|
34
|
+
|
|
35
|
+
show_usage() {
|
|
36
|
+
cat <<EOF
|
|
37
|
+
${BOLD}AGENT-K${RESET} - Multi-Agent Claude Code Terminal Suite
|
|
38
|
+
|
|
39
|
+
${BOLD}USAGE:${RESET}
|
|
40
|
+
agentk Start interactive session (dev mode)
|
|
41
|
+
agentk --mode ml Start ML research & training mode
|
|
42
|
+
agentk --visual Start with tmux visual panels
|
|
43
|
+
agentk -c "prompt" One-shot mode (run task, exit)
|
|
44
|
+
|
|
45
|
+
${BOLD}OPTIONS:${RESET}
|
|
46
|
+
-m, --mode <mode> Set mode: dev (default) or ml
|
|
47
|
+
-v, --visual Enable tmux visual mode
|
|
48
|
+
-c, --command <prompt> Run single command and exit
|
|
49
|
+
-h, --help Show this help message
|
|
50
|
+
--version Show version
|
|
51
|
+
|
|
52
|
+
${BOLD}SESSION COMMANDS:${RESET}
|
|
53
|
+
/status Show all agent states
|
|
54
|
+
/logs <agent> View agent output
|
|
55
|
+
/kill <agent|all> Stop agent(s)
|
|
56
|
+
/focus <agent> Talk directly to agent
|
|
57
|
+
/unfocus Return to orchestrator
|
|
58
|
+
/visual Toggle tmux view
|
|
59
|
+
/clear Clear screen
|
|
60
|
+
/help Show commands
|
|
61
|
+
/exit End session
|
|
62
|
+
|
|
63
|
+
${BOLD}SCOUT COMMANDS:${RESET}
|
|
64
|
+
/search <query> Web search
|
|
65
|
+
/github <query> Search GitHub
|
|
66
|
+
/papers <topic> Search papers (ML mode)
|
|
67
|
+
/libs <task> Find libraries
|
|
68
|
+
/sota <topic> State-of-the-art
|
|
69
|
+
|
|
70
|
+
${BOLD}ML MODE COMMANDS:${RESET}
|
|
71
|
+
/experiment <name> Start experiment
|
|
72
|
+
/metrics Show metrics
|
|
73
|
+
/tensorboard Open TensorBoard
|
|
74
|
+
/huggingface <query> Search HF Hub
|
|
75
|
+
|
|
76
|
+
${BOLD}EXAMPLES:${RESET}
|
|
77
|
+
agentk # Start dev mode chat
|
|
78
|
+
agentk --mode ml # Start ML mode
|
|
79
|
+
agentk -c "Build a REST API" # One-shot task
|
|
80
|
+
|
|
81
|
+
EOF
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
show_version() {
|
|
85
|
+
echo "AGENT-K v${AGENTK_VERSION}"
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
# =============================================================================
|
|
89
|
+
# ARGUMENT PARSING
|
|
90
|
+
# =============================================================================
|
|
91
|
+
|
|
92
|
+
parse_args() {
|
|
93
|
+
while [[ $# -gt 0 ]]; do
|
|
94
|
+
case "$1" in
|
|
95
|
+
-m|--mode)
|
|
96
|
+
AGENTK_MODE="$2"
|
|
97
|
+
shift 2
|
|
98
|
+
;;
|
|
99
|
+
-v|--visual)
|
|
100
|
+
VISUAL_MODE=true
|
|
101
|
+
shift
|
|
102
|
+
;;
|
|
103
|
+
-c|--command)
|
|
104
|
+
ONE_SHOT=true
|
|
105
|
+
ONE_SHOT_PROMPT="$2"
|
|
106
|
+
shift 2
|
|
107
|
+
;;
|
|
108
|
+
-h|--help)
|
|
109
|
+
show_usage
|
|
110
|
+
exit 0
|
|
111
|
+
;;
|
|
112
|
+
--version)
|
|
113
|
+
show_version
|
|
114
|
+
exit 0
|
|
115
|
+
;;
|
|
116
|
+
*)
|
|
117
|
+
log_error "Unknown option: $1"
|
|
118
|
+
show_usage
|
|
119
|
+
exit 1
|
|
120
|
+
;;
|
|
121
|
+
esac
|
|
122
|
+
done
|
|
123
|
+
|
|
124
|
+
# Validate mode
|
|
125
|
+
if [[ "$AGENTK_MODE" != "dev" && "$AGENTK_MODE" != "ml" ]]; then
|
|
126
|
+
log_error "Invalid mode: $AGENTK_MODE (must be 'dev' or 'ml')"
|
|
127
|
+
exit 1
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
export AGENTK_MODE
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
# =============================================================================
|
|
134
|
+
# SESSION COMMANDS
|
|
135
|
+
# =============================================================================
|
|
136
|
+
|
|
137
|
+
handle_command() {
|
|
138
|
+
local cmd="$1"
|
|
139
|
+
local args="${2:-}"
|
|
140
|
+
|
|
141
|
+
case "$cmd" in
|
|
142
|
+
/status)
|
|
143
|
+
cmd_status
|
|
144
|
+
;;
|
|
145
|
+
/logs)
|
|
146
|
+
cmd_logs "$args"
|
|
147
|
+
;;
|
|
148
|
+
/kill)
|
|
149
|
+
cmd_kill "$args"
|
|
150
|
+
;;
|
|
151
|
+
/focus)
|
|
152
|
+
cmd_focus "$args"
|
|
153
|
+
;;
|
|
154
|
+
/unfocus)
|
|
155
|
+
cmd_unfocus
|
|
156
|
+
;;
|
|
157
|
+
/visual)
|
|
158
|
+
cmd_visual
|
|
159
|
+
;;
|
|
160
|
+
/clear)
|
|
161
|
+
clear_screen
|
|
162
|
+
print_banner
|
|
163
|
+
print_mode_banner "$AGENTK_MODE"
|
|
164
|
+
;;
|
|
165
|
+
/help)
|
|
166
|
+
print_command_help
|
|
167
|
+
print_scout_commands
|
|
168
|
+
[[ "$AGENTK_MODE" == "ml" ]] && print_ml_commands
|
|
169
|
+
;;
|
|
170
|
+
/exit|/quit)
|
|
171
|
+
cmd_exit
|
|
172
|
+
;;
|
|
173
|
+
/search|/github|/papers|/libs|/sota|/huggingface)
|
|
174
|
+
cmd_scout "$cmd" "$args"
|
|
175
|
+
;;
|
|
176
|
+
/experiment|/metrics|/tensorboard|/checkpoint|/compare)
|
|
177
|
+
cmd_ml "$cmd" "$args"
|
|
178
|
+
;;
|
|
179
|
+
*)
|
|
180
|
+
print_error "Unknown command: $cmd"
|
|
181
|
+
echo "Type /help for available commands"
|
|
182
|
+
;;
|
|
183
|
+
esac
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
cmd_status() {
|
|
187
|
+
print_section "Agent Status"
|
|
188
|
+
|
|
189
|
+
local agents=()
|
|
190
|
+
case "$AGENTK_MODE" in
|
|
191
|
+
dev) agents=("orchestrator" "engineer" "tester" "security" "scout") ;;
|
|
192
|
+
ml) agents=("orchestrator" "researcher" "ml-engineer" "data-engineer" "evaluator" "scout") ;;
|
|
193
|
+
esac
|
|
194
|
+
|
|
195
|
+
for agent in "${agents[@]}"; do
|
|
196
|
+
local status
|
|
197
|
+
status=$(get_agent_status "$agent")
|
|
198
|
+
local message=""
|
|
199
|
+
|
|
200
|
+
if [[ -n "${AGENT_TASKS[$agent]:-}" ]]; then
|
|
201
|
+
message=$(get_task_field "${AGENT_TASKS[$agent]}" "prompt" | head -c 40)
|
|
202
|
+
[[ ${#message} -eq 40 ]] && message="${message}..."
|
|
203
|
+
fi
|
|
204
|
+
|
|
205
|
+
print_agent_status "$agent" "$status" "$message"
|
|
206
|
+
done
|
|
207
|
+
echo
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
cmd_logs() {
|
|
211
|
+
local agent="$1"
|
|
212
|
+
|
|
213
|
+
if [[ -z "$agent" ]]; then
|
|
214
|
+
print_error "Usage: /logs <agent>"
|
|
215
|
+
return
|
|
216
|
+
fi
|
|
217
|
+
|
|
218
|
+
print_section "Logs: $agent"
|
|
219
|
+
view_agent_log "$agent" 30
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
cmd_kill() {
|
|
223
|
+
local target="$1"
|
|
224
|
+
|
|
225
|
+
if [[ -z "$target" ]]; then
|
|
226
|
+
print_error "Usage: /kill <agent|all>"
|
|
227
|
+
return
|
|
228
|
+
fi
|
|
229
|
+
|
|
230
|
+
if [[ "$target" == "all" ]]; then
|
|
231
|
+
kill_all_agents
|
|
232
|
+
print_success "All agents stopped"
|
|
233
|
+
else
|
|
234
|
+
kill_agent "$target"
|
|
235
|
+
print_success "Agent $target stopped"
|
|
236
|
+
fi
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
cmd_focus() {
|
|
240
|
+
local agent="$1"
|
|
241
|
+
|
|
242
|
+
if [[ -z "$agent" ]]; then
|
|
243
|
+
print_error "Usage: /focus <agent>"
|
|
244
|
+
return
|
|
245
|
+
fi
|
|
246
|
+
|
|
247
|
+
FOCUSED_AGENT="$agent"
|
|
248
|
+
print_info "Now talking directly to: $agent"
|
|
249
|
+
echo "${DIM}Type /unfocus to return to orchestrator${RESET}"
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
cmd_unfocus() {
|
|
253
|
+
if [[ -z "$FOCUSED_AGENT" ]]; then
|
|
254
|
+
print_info "Not focused on any agent"
|
|
255
|
+
return
|
|
256
|
+
fi
|
|
257
|
+
|
|
258
|
+
print_info "Returning to orchestrator"
|
|
259
|
+
FOCUSED_AGENT=""
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
cmd_visual() {
|
|
263
|
+
if ! command -v tmux &>/dev/null; then
|
|
264
|
+
print_error "tmux is not installed. Install with: brew install tmux"
|
|
265
|
+
return
|
|
266
|
+
fi
|
|
267
|
+
|
|
268
|
+
if [[ "$VISUAL_MODE" == "true" ]]; then
|
|
269
|
+
print_info "Disabling visual mode..."
|
|
270
|
+
VISUAL_MODE=false
|
|
271
|
+
# Would detach from tmux here
|
|
272
|
+
else
|
|
273
|
+
print_info "Enabling visual mode..."
|
|
274
|
+
VISUAL_MODE=true
|
|
275
|
+
start_visual_mode
|
|
276
|
+
fi
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
cmd_exit() {
|
|
280
|
+
print_info "Ending session..."
|
|
281
|
+
end_session
|
|
282
|
+
cleanup_agents
|
|
283
|
+
echo
|
|
284
|
+
echo "${GREEN}Goodbye!${RESET}"
|
|
285
|
+
exit 0
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
cmd_scout() {
|
|
289
|
+
local cmd="$1"
|
|
290
|
+
local query="$2"
|
|
291
|
+
|
|
292
|
+
if [[ -z "$query" ]]; then
|
|
293
|
+
print_error "Usage: $cmd <query>"
|
|
294
|
+
return
|
|
295
|
+
fi
|
|
296
|
+
|
|
297
|
+
local scout_task="$cmd: $query"
|
|
298
|
+
print_info "Scout is searching..."
|
|
299
|
+
|
|
300
|
+
# Create task for scout
|
|
301
|
+
local task_id
|
|
302
|
+
task_id=$(create_task "" "research" "scout" "$scout_task" 1)
|
|
303
|
+
|
|
304
|
+
# Spawn scout agent
|
|
305
|
+
spawn_agent "scout" "$task_id" "$AGENTK_MODE"
|
|
306
|
+
|
|
307
|
+
# Wait for result
|
|
308
|
+
print_info "Waiting for Scout..."
|
|
309
|
+
watch_task "$task_id" 120
|
|
310
|
+
|
|
311
|
+
# Display result
|
|
312
|
+
local result_file
|
|
313
|
+
result_file=$(get_result_file "$task_id")
|
|
314
|
+
if [[ -f "$result_file" ]]; then
|
|
315
|
+
local output
|
|
316
|
+
output=$(jq -r '.output' "$result_file")
|
|
317
|
+
echo
|
|
318
|
+
echo "$output"
|
|
319
|
+
fi
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
cmd_ml() {
|
|
323
|
+
local cmd="$1"
|
|
324
|
+
local args="$2"
|
|
325
|
+
|
|
326
|
+
if [[ "$AGENTK_MODE" != "ml" ]]; then
|
|
327
|
+
print_error "ML commands only available in ML mode. Use: agentk --mode ml"
|
|
328
|
+
return
|
|
329
|
+
fi
|
|
330
|
+
|
|
331
|
+
case "$cmd" in
|
|
332
|
+
/experiment)
|
|
333
|
+
print_info "Starting experiment: $args"
|
|
334
|
+
# Would create experiment directory and tracking
|
|
335
|
+
;;
|
|
336
|
+
/metrics)
|
|
337
|
+
print_info "Current metrics:"
|
|
338
|
+
# Would display training metrics
|
|
339
|
+
;;
|
|
340
|
+
/tensorboard)
|
|
341
|
+
print_info "Opening TensorBoard..."
|
|
342
|
+
tensorboard --logdir="$AGENTK_WORKSPACE/experiments" &
|
|
343
|
+
;;
|
|
344
|
+
*)
|
|
345
|
+
print_error "ML command not implemented: $cmd"
|
|
346
|
+
;;
|
|
347
|
+
esac
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
# =============================================================================
|
|
351
|
+
# VISUAL MODE (TMUX)
|
|
352
|
+
# =============================================================================
|
|
353
|
+
|
|
354
|
+
start_visual_mode() {
|
|
355
|
+
source "$SCRIPT_DIR/lib/visual.sh" 2>/dev/null || {
|
|
356
|
+
print_error "Visual mode library not found"
|
|
357
|
+
VISUAL_MODE=false
|
|
358
|
+
return
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
setup_tmux_session "$AGENTK_MODE"
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
# =============================================================================
|
|
365
|
+
# INTERACTIVE LOOP
|
|
366
|
+
# =============================================================================
|
|
367
|
+
|
|
368
|
+
run_interactive() {
|
|
369
|
+
# Initialize workspace
|
|
370
|
+
ensure_workspace
|
|
371
|
+
check_dependencies
|
|
372
|
+
|
|
373
|
+
# Create session
|
|
374
|
+
create_session
|
|
375
|
+
|
|
376
|
+
# Print banner
|
|
377
|
+
clear_screen
|
|
378
|
+
print_banner
|
|
379
|
+
print_mode_banner "$AGENTK_MODE"
|
|
380
|
+
|
|
381
|
+
echo "Type your request or /help for commands."
|
|
382
|
+
echo
|
|
383
|
+
|
|
384
|
+
# Main loop
|
|
385
|
+
while true; do
|
|
386
|
+
# Show prompt
|
|
387
|
+
if [[ -n "$FOCUSED_AGENT" ]]; then
|
|
388
|
+
print_focus_prompt "$FOCUSED_AGENT"
|
|
389
|
+
else
|
|
390
|
+
print_user_prompt
|
|
391
|
+
fi
|
|
392
|
+
|
|
393
|
+
# Read input with readline support
|
|
394
|
+
local input
|
|
395
|
+
if ! read -r -e input; then
|
|
396
|
+
# EOF (Ctrl+D)
|
|
397
|
+
echo
|
|
398
|
+
cmd_exit
|
|
399
|
+
fi
|
|
400
|
+
|
|
401
|
+
# Skip empty input
|
|
402
|
+
[[ -z "$input" ]] && continue
|
|
403
|
+
|
|
404
|
+
# Add to history
|
|
405
|
+
history -s "$input"
|
|
406
|
+
|
|
407
|
+
# Check for command
|
|
408
|
+
if [[ "$input" == /* ]]; then
|
|
409
|
+
local cmd="${input%% *}"
|
|
410
|
+
local args="${input#* }"
|
|
411
|
+
[[ "$cmd" == "$args" ]] && args=""
|
|
412
|
+
handle_command "$cmd" "$args"
|
|
413
|
+
continue
|
|
414
|
+
fi
|
|
415
|
+
|
|
416
|
+
# Regular input - send to orchestrator (or focused agent)
|
|
417
|
+
local target_agent="${FOCUSED_AGENT:-orchestrator}"
|
|
418
|
+
|
|
419
|
+
echo
|
|
420
|
+
print_orchestrator_message "Analyzing task..."
|
|
421
|
+
|
|
422
|
+
# Create task
|
|
423
|
+
local task_id
|
|
424
|
+
task_id=$(create_task "" "analyze" "$target_agent" "$input" 1)
|
|
425
|
+
|
|
426
|
+
# For now, spawn the agent interactively
|
|
427
|
+
spawn_agent_interactive "$target_agent" "$AGENTK_MODE" "$input"
|
|
428
|
+
|
|
429
|
+
echo
|
|
430
|
+
done
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
# =============================================================================
|
|
434
|
+
# ONE-SHOT MODE
|
|
435
|
+
# =============================================================================
|
|
436
|
+
|
|
437
|
+
run_one_shot() {
|
|
438
|
+
local prompt="$1"
|
|
439
|
+
|
|
440
|
+
# Initialize
|
|
441
|
+
ensure_workspace
|
|
442
|
+
check_dependencies
|
|
443
|
+
create_session
|
|
444
|
+
|
|
445
|
+
print_banner
|
|
446
|
+
print_mode_banner "$AGENTK_MODE"
|
|
447
|
+
print_task "$prompt"
|
|
448
|
+
|
|
449
|
+
# Create task for orchestrator
|
|
450
|
+
local task_id
|
|
451
|
+
task_id=$(create_task "" "orchestrate" "orchestrator" "$prompt" 1)
|
|
452
|
+
|
|
453
|
+
# Spawn orchestrator interactively
|
|
454
|
+
spawn_agent_interactive "orchestrator" "$AGENTK_MODE" "$prompt"
|
|
455
|
+
|
|
456
|
+
# Cleanup
|
|
457
|
+
end_session
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
# =============================================================================
|
|
461
|
+
# MAIN
|
|
462
|
+
# =============================================================================
|
|
463
|
+
|
|
464
|
+
main() {
|
|
465
|
+
parse_args "$@"
|
|
466
|
+
|
|
467
|
+
# Check if running in visual mode from start
|
|
468
|
+
if [[ "$VISUAL_MODE" == "true" ]]; then
|
|
469
|
+
start_visual_mode
|
|
470
|
+
fi
|
|
471
|
+
|
|
472
|
+
# One-shot or interactive
|
|
473
|
+
if [[ "$ONE_SHOT" == "true" ]]; then
|
|
474
|
+
run_one_shot "$ONE_SHOT_PROMPT"
|
|
475
|
+
else
|
|
476
|
+
run_interactive
|
|
477
|
+
fi
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
# Run
|
|
481
|
+
main "$@"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* AGENT-K npm wrapper
|
|
4
|
+
* Executes the bash script with proper paths
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { spawn } = require('child_process');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
// Get the path to the actual agentk script
|
|
11
|
+
const agentkPath = path.join(__dirname, '..', 'agentk');
|
|
12
|
+
|
|
13
|
+
// Set AGENTK_ROOT environment variable
|
|
14
|
+
const env = {
|
|
15
|
+
...process.env,
|
|
16
|
+
AGENTK_ROOT: path.join(__dirname, '..')
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// Spawn the bash script with all arguments
|
|
20
|
+
const child = spawn('bash', [agentkPath, ...process.argv.slice(2)], {
|
|
21
|
+
stdio: 'inherit',
|
|
22
|
+
env
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Handle exit
|
|
26
|
+
child.on('exit', (code) => {
|
|
27
|
+
process.exit(code || 0);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Handle errors
|
|
31
|
+
child.on('error', (err) => {
|
|
32
|
+
console.error('Failed to start agentk:', err.message);
|
|
33
|
+
console.error('Make sure bash is installed and in your PATH');
|
|
34
|
+
process.exit(1);
|
|
35
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* AGENT-K npm postinstall script
|
|
4
|
+
* Checks dependencies and provides setup instructions
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { execSync } = require('child_process');
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
const GREEN = '\x1b[32m';
|
|
12
|
+
const YELLOW = '\x1b[33m';
|
|
13
|
+
const RED = '\x1b[31m';
|
|
14
|
+
const CYAN = '\x1b[36m';
|
|
15
|
+
const RESET = '\x1b[0m';
|
|
16
|
+
const BOLD = '\x1b[1m';
|
|
17
|
+
|
|
18
|
+
function checkCommand(cmd) {
|
|
19
|
+
try {
|
|
20
|
+
execSync(`which ${cmd}`, { stdio: 'ignore' });
|
|
21
|
+
return true;
|
|
22
|
+
} catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function main() {
|
|
28
|
+
console.log();
|
|
29
|
+
console.log(`${CYAN}╭─────────────────────────────────────────────────╮${RESET}`);
|
|
30
|
+
console.log(`${CYAN}│${RESET} ${BOLD}AGENT-K Installed${RESET} ${CYAN}│${RESET}`);
|
|
31
|
+
console.log(`${CYAN}╰─────────────────────────────────────────────────╯${RESET}`);
|
|
32
|
+
console.log();
|
|
33
|
+
|
|
34
|
+
// Make scripts executable
|
|
35
|
+
const agentkPath = path.join(__dirname, '..', 'agentk');
|
|
36
|
+
const libPath = path.join(__dirname, '..', 'lib');
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
fs.chmodSync(agentkPath, '755');
|
|
40
|
+
fs.readdirSync(libPath).forEach(file => {
|
|
41
|
+
if (file.endsWith('.sh')) {
|
|
42
|
+
fs.chmodSync(path.join(libPath, file), '755');
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.warn(`${YELLOW}Warning: Could not set executable permissions${RESET}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Check dependencies
|
|
50
|
+
console.log('Checking dependencies...');
|
|
51
|
+
console.log();
|
|
52
|
+
|
|
53
|
+
const deps = [
|
|
54
|
+
{ name: 'bash', required: true },
|
|
55
|
+
{ name: 'jq', required: true },
|
|
56
|
+
{ name: 'claude', required: true, note: 'Claude Code CLI' },
|
|
57
|
+
{ name: 'tmux', required: false, note: 'for visual mode' }
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
let hasIssues = false;
|
|
61
|
+
|
|
62
|
+
deps.forEach(dep => {
|
|
63
|
+
const installed = checkCommand(dep.name);
|
|
64
|
+
const status = installed ? `${GREEN}✓${RESET}` : (dep.required ? `${RED}✗${RESET}` : `${YELLOW}○${RESET}`);
|
|
65
|
+
const note = dep.note ? ` (${dep.note})` : '';
|
|
66
|
+
|
|
67
|
+
console.log(` ${status} ${dep.name}${note}`);
|
|
68
|
+
|
|
69
|
+
if (!installed && dep.required) {
|
|
70
|
+
hasIssues = true;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
console.log();
|
|
75
|
+
|
|
76
|
+
if (hasIssues) {
|
|
77
|
+
console.log(`${RED}Missing required dependencies!${RESET}`);
|
|
78
|
+
console.log();
|
|
79
|
+
console.log('Install missing dependencies:');
|
|
80
|
+
console.log(' brew install jq # macOS');
|
|
81
|
+
console.log(' sudo apt install jq # Linux');
|
|
82
|
+
console.log();
|
|
83
|
+
console.log('Install Claude Code CLI:');
|
|
84
|
+
console.log(' https://claude.ai/code');
|
|
85
|
+
console.log();
|
|
86
|
+
} else {
|
|
87
|
+
console.log(`${GREEN}All required dependencies found!${RESET}`);
|
|
88
|
+
console.log();
|
|
89
|
+
console.log('Get started:');
|
|
90
|
+
console.log(` ${CYAN}agentk${RESET} # Start dev mode`);
|
|
91
|
+
console.log(` ${CYAN}agentk --mode ml${RESET} # Start ML mode`);
|
|
92
|
+
console.log(` ${CYAN}agentk --help${RESET} # Show all options`);
|
|
93
|
+
console.log();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
main();
|