Search, store, and retrieve from the NexusOS Cortex knowledge base using the REST API.
Use this skill to interact with the NexusOS Cortex knowledge base.
Get the Cortex base URL (run once per session):
CORTEX_URL=$(jq -r '.cortex_url // "http://localhost:6400"' ~/.nexus/config/cortex.json 2>/dev/null || echo "http://localhost:6400")
curl -sf "$CORTEX_URL/api/health" | jq .
Returns {"ok": true, "version": "..."} if healthy. If this fails, Cortex is down. Report to user.
curl -sf -X POST "$CORTEX_URL/api/search" \
-H "Content-Type: application/json" \
-d '{"query": "<QUERY>", "limit": 5}' | jq .
Optional: add "collection": "<NAME>" to scope results. Collections: procedures, intelligence, technical, business, training_procedures.
Returns:
{"results": [{"title": "...", "text": "...", "score": 0.85, "metadata": {...}}]}
curl -sf -X POST "$CORTEX_URL/api/search" \
-H "Content-Type: application/json" \
-d '{"query": "<KEYWORD_OR_RULE_ID>", "collection": "procedures", "limit": 3}' | jq .
For non-procedure collections (intelligence, technical, business):
curl -sf -X POST "$CORTEX_URL/api/store" \
-H "Content-Type: application/json" \
-d '{
"collection": "<COLLECTION>",
"title": "<TITLE>",
"text": "<CONTENT>"
}' | jq .
For the procedures collection, FORGE format is REQUIRED:
text MUST contain: # Problema, # Procedura, # Enforcement Loopmetadata MUST include: rule_id, has_enforcement_loop (boolean true), forge_version ("2.0")curl -sf -X POST "$CORTEX_URL/api/store" \
-H "Content-Type: application/json" \
-d '{
"collection": "procedures",
"title": "<TITLE>",
"text": "# Problema\n<PROBLEM>\n\n# Procedura\n<STEPS>\n\n# Enforcement Loop\n<ENFORCEMENT>",
"metadata": {
"rule_id": "<RULE_ID>",
"has_enforcement_loop": true,
"forge_version": "2.0"
}
}' | jq .
Returns {"id": "<uuid>", "ok": true} on success.
If any curl command fails or returns {"error": ...}:
python3 -m json.tool as fallback for formatting