fleet-logs
Your objective is to show output logs for a CocoFleet instance.
Before proceeding, verify that .cocoplus/ exists.
If not: output "CocoPlus not initialized in this directory. Run $pod init to begin." Then stop.
Parse arguments: $fleet logs [fleet-id] [instance-id]
If missing: output "Usage: $fleet logs [fleet-id] [instance-id]" Then stop.
Log file: .cocoplus/fleet/[instance-id]/output.log
If not found: output "No log file found for [instance-id]. The instance may not have started yet." Then stop.
Read state file to determine if instance is still running.
Check if PID in state.json is alive using a cross-platform Node.js one-liner:
node -e "try{process.kill([pid],0);console.log('alive')}catch(e){console.log('dead')}"
If alive (instance still running):
- Output last 50 lines of output.log
- Append: "[Instance is still running — showing last 50 lines. Re-run
$fleet logsto refresh.]"