-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrustloop-session
More file actions
executable file
·97 lines (86 loc) · 3.1 KB
/
trustloop-session
File metadata and controls
executable file
·97 lines (86 loc) · 3.1 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
#!/bin/bash
# trustloop-session — Launch a forensic Claude Code session
#
# Usage:
# ./trustloop-session # use default traces
# ./trustloop-session /path/to/traces.jsonl # use specific traces
# ./trustloop-session --ingest domains/rrma-lean # ingest first, then launch
#
# What happens:
# 1. Ensures traces are ingested
# 2. Launches Claude Code with TrustLoop MCP tools
# 3. You just talk. Ask forensic questions in natural language.
# 4. Claude uses native MCP tools to query trace data (no bash shelling)
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
TRACES="${TRACES_JSONL:-/tmp/rrma_traces.jsonl}"
# Handle --ingest flag
if [ "$1" = "--ingest" ]; then
shift
DOMAIN="${1:?Usage: trustloop-session --ingest <domain_dir> [--logs <logs_dir>]}"
shift
echo "Ingesting traces from $DOMAIN..."
"$SCRIPT_DIR/trustloop" ingest "$DOMAIN" "$@"
echo ""
fi
# Handle explicit traces path
if [ -n "$1" ] && [ -f "$1" ]; then
TRACES="$1"
fi
# Check traces exist
if [ ! -f "$TRACES" ]; then
echo "No traces found at $TRACES"
echo ""
echo "Ingest first:"
echo " ./trustloop-session --ingest domains/rrma-lean --logs data/rrma_lean_logs"
echo ""
echo "Or point to existing traces:"
echo " ./trustloop-session /path/to/traces.jsonl"
exit 1
fi
# Find python with mcp installed (venv or system)
PYTHON="python3"
if [ -f "$HOME/venv/bin/python3" ] && "$HOME/venv/bin/python3" -c "import mcp" 2>/dev/null; then
PYTHON="$HOME/venv/bin/python3"
elif ! python3 -c "import mcp" 2>/dev/null; then
echo "Error: 'mcp' package not found. Install with: pip install 'mcp[cli]'"
exit 1
fi
# Show what we're loading
echo "╔══════════════════════════════════════╗"
echo "║ TrustLoop Forensics (MCP) ║"
echo "╚══════════════════════════════════════╝"
echo ""
"$SCRIPT_DIR/trustloop" --traces "$TRACES" status 2>/dev/null
echo ""
# Build the forensic index
INDEX=$("$SCRIPT_DIR/trustloop" --traces "$TRACES" index 2>/dev/null)
# Write MCP config with correct traces path
MCP_CONFIG=$(cat <<MCPEOF
{
"mcpServers": {
"trustloop": {
"command": "$PYTHON",
"args": ["$SCRIPT_DIR/tools/trustloop_mcp.py"],
"env": {
"TRUSTLOOP_TRACES": "$TRACES"
}
}
}
}
MCPEOF
)
echo "$MCP_CONFIG" > /tmp/trustloop_mcp_config.json
# Launch interactive Claude Code session with:
# --mcp-config: TrustLoop MCP server (native tools, no bash shelling)
# --append-system-prompt-file: forensic analyst persona + skill docs
# --allowed-tools: MCP tools + read-only file access
# initial prompt: seed with index so Claude knows what's loaded
cd "$SCRIPT_DIR"
exec claude \
--mcp-config /tmp/trustloop_mcp_config.json \
--append-system-prompt-file .trustloop/SKILL.md \
--allowed-tools "mcp__trustloop__*,Read,Glob,Grep" \
"Trace data loaded. Here is the forensic index:
$INDEX
I'm ready to investigate. What do you want to know about this multi-agent run?"