The best developer tools are those that integrate seamlessly into existing terminal workflows without introducing friction or context switching. When developers encounter a broken pipeline, opening a browser to search documentation or digging through internal wikis slows down remediation.
To provide instant, frictionless triage, our team designed an interactive command-line interface in devops_agent.py backed by environment configuration and real-time semantic memory.
Developer Experience & Environment Design
The interactive CLI provides a clean terminal loop that accepts raw logs, queries the Hindsight memory bank, and provides clear diagnostic feedback. Environment variables handle service connectivity securely via a .env file.
+-------------------------------------------------+
| Terminal Startup |
| Loads .env configuration & Hindsight |
+-------------------------------------------------+
|
v
+-------------------------------------------------+
| Interactive CLI Main Loop |
| Prompt: 'Log > ' (or type 'exit' to quit) |
+-------------------------------------------------+
| |
User Pastes Error User Types 'exit'
| |
v v
Query Hindsight API Graceful Shutdown
Complete Implementation of devops_agent.py
Below is the complete, production-ready CLI implementation combining environment setup, semantic recall, and interactive prompt handling:
import os
from dotenv import load_dotenv
from hindsight_client import Hindsight
# Load environment variables from .env file
load_dotenv()
# Initialize Hindsight client
client = Hindsight(
base_url=os.getenv("HINDSIGHT_API_URL"),
api_key=os.getenv("HINDSIGHT_API_TOKEN")
)
BANK_ID = os.getenv("HINDSIGHT_BANK_ID", "devops-pipeline-agent")
def run_agent():
print("==================================================")
print("🤖 DevOps CLI Memory Agent Ready")
print(f"📂 Connected to Hindsight Bank: {BANK_ID}")
print("👉 Paste your pipeline error log below (or type 'exit' to quit):")
print("==================================================")
while True:
try:
user_input = input("\nLog > ").strip()
if not user_input:
continue
if user_input.lower() == 'exit':
print("👋 Exiting DevOps Memory Agent. Happy coding!")
break
# Query Hindsight memory bank
results = client.recall(bank_id=BANK_ID, query=user_input)
if results and hasattr(results, 'results') and results.results:
print("\n🚨 Diagnosis & Past Resolutions Found:")
for idx, match in enumerate(results.results, 1):
print(f" {idx}. {match.document.content}")
else:
print("\n⚠️ No exact match found in memory for this error.")
print("💡 Tip: Use the learn loop to persist a new fix for future runs.")
except KeyboardInterrupt:
print("\n👋 Interrupted. Exiting agent.")
break
except Exception as e:
print(f"❌ Error communicating with Hindsight: {e}")
if __name__ == "__main__":
run_agent()
Key Principles of CLI Design
- Zero Context Switching: Engineers stay inside their shell environment where builds and deployments are managed.
-
Resilient Loop Handling: Gracefully handles keyboard interrupts (
Ctrl+C), empty inputs, and API connection exceptions without crashing. -
Clear User Feedback: Uses visual status indicators (
🤖,🚨,⚠️,✅) to make terminal output easily scannable at a glance.
Resources & Links
-
GitHub Repository:
25wh1a05be/devops-pipeline-agent -
Hindsight Documentation:
hindsight.vectorize.io
Top comments (0)