How cogensec/gideon works
1. Repository shape
Gideon is a Bun/TypeScript monorepo centered on an autonomous cybersecurity agent. The runtime product is a terminal-first operator experience, while docs/ is a separate Astro documentation site. The codebase is organized around one core loop: accept a security goal, plan work, invoke tools/services, validate findings, and emit a report or answer.
2. Operator interface layer
The entry points in src/cli.tsx and src/index.tsx, plus src/components/ and src/hooks/, form the interactive shell/UI layer. It handles prompt entry, command history, model selection, debug output, and progress indicators. This layer is mostly orchestration and presentation; it does not own the analysis logic.
3. Agent core
src/agent/ contains the ReAct-style execution engine: planning, phase management, approvals, prompts, scratchpad state, and a red-team mode switch. This is the central control loop that turns a user request into a sequence of actions, observations, and reflections. It is the main boundary between user intent and the rest of the system.
4. Tool and data-source boundary
src/tools/ and src/utils/llm-* provide the external I/O adapters. They connect to LLM providers and research sources such as OpenRouter, OpenAI, Anthropic, Google, Ollama, Exa, Tavily, NVD, VirusTotal, and AbuseIPDB. In architecture terms, this is the outbound integration layer for model inference, threat intel lookup, and search.
5. Domain capabilities
The product’s primary security workflows live in src/gideon/, src/scanner/, src/output/, src/graph/, and the command handlers under src/commands/. These subsystems cover CVE research, IOC reputation checks, briefing/report generation, scanning, and graph-based correlation. Commands like brief, cve, ioc, policy, scan, and redteam are just thin entry points into these domain engines.
6. Skills subsystem
src/skills/ is a modular capability system. Each skill directory represents a specialized subdomain with its own commands and behavior, such as security research, post-exploitation, weaponization, voice, governance, threat detection, and OpenClaw Sentinel. The registry.ts file indicates skills are dynamically discoverable and act like pluggable sub-agents rather than a flat command list.
7. Safety, governance, and audit
src/governance/ and src/openclaw/ implement the defensive control plane: policy enforcement, access control, agent monitoring, audit logging, prompt-injection defense, credential guarding, memory integrity checks, and hardening audits. These modules sit on the critical path for both normal and red-team operations, so they are not optional decoration; they enforce scope, record actions, and block unsafe behavior.
8. Red-team execution path
src/redteam/ contains the offensive simulation stack: attack definitions, campaign management, scoring, and report generation. This path is distinct from the defensive research path and is intended for authorized engagements. The readme’s sandboxing and engagement-scope rules imply this subsystem must be diagrammed as gated by governance and isolated execution boundaries.
9. C2 and post-exploitation integration
src/c2/ plus the Sliver adapter connect Gideon to command-and-control style session infrastructure. This is the bridge from planning and analysis into post-exploitation session awareness, host mapping, and controlled operator actions. It is an external-security boundary and should be shown separately from general threat-intel tooling.
10. MCP extensibility
src/mcp/ and mcp-servers/ provide Model Context Protocol integration for external tools. The repository includes a Python MCP server container, which means tool expansion is meant to happen through a protocol boundary rather than only in-process code. In diagrams, MCP should be treated as a plugin surface that feeds additional tools into the agent loop.
11. Configuration, state, and cross-cutting utilities
src/utils/ contains the shared support systems: configuration loading, environment handling, caching, rate limiting, redaction, logger, chat history, and provider-specific helpers. gideon.config.yaml and .env determine runtime behavior, enabled providers, security integrations, and model routing. These utilities are the common substrate used by nearly every subsystem.
12. Supporting infrastructure
docker-compose.yml and the mcp-servers/Dockerfile indicate containerized auxiliary services, especially for sandboxed or protocol-based integrations. The docs site under docs/ is a separate application with its own build/runtime. The architecture therefore has three distinct deployment surfaces: the Bun CLI app, optional containerized support services, and the documentation site.
Main entry points: agent Agent loop · cli.tsx CLI shell · gideon Domain engines · governance Governance
Components 24
Bun app
Main terminal-first Gideon application and its runtime subsystems.
- App entry · Starts the Bun application and wires the terminal experience.
src/index.tsx - CLI shell · Command-line entrypoint for user interaction and command dispatch.
src/cli.tsx - UI widgets · Interactive presentation layer for prompts, history, status, and debug output.
src/components - UI hooks · Shared input, history, model, and runner state for the operator shell.
src/hooks - Agent loop · Main planning and execution loop that turns goals into actions and observations.
src/agent - Phases · Structures the agent lifecycle and execution stages.
src/agent/phases.ts - Approvals · Approval and permission checks before sensitive actions proceed.
src/agent/approval.ts - Prompts · System and task prompt templates for the agent loop.
src/agent/prompts.ts - Red-team mode · Specialized execution mode for offensive simulation workflows.
src/agent/redteam-mode.ts - Commands · Thin entrypoints for brief, CVE, IOC, policy, scan, redteam, and related actions.
src/commands - Domain engines · Core research, scanning, reporting, and graph correlation capabilities.
src/gideon - Scanner · Detection and report pipeline for scanning-focused workflows.
src/scanner - Graph engine · Builds graph-based relationships between findings and entities.
src/graph - Output · Formats answers and reports as JSON or Markdown.
src/output - Skills registry · Discovers and exposes modular skills as specialized sub-agents.
src/skills/registry.ts - Governance · Policy enforcement, access control, auditing, and monitoring.
src/governance - OpenClaw · Prompt-injection defense, credential guarding, integrity checks, and hardening audits.
src/openclaw - Red team · Campaigns, attacks, scoring, and red-team report generation.
src/redteam - C2 bridge · Connects planning and analysis to command-and-control style session infrastructure.
src/c2 - LLM tools · Outbound adapters for model providers and tool-backed inference.
src/utils - Security tools · Adapters for CVE, IOC, search, and external threat-intelligence sources.
src/tools - MCP surface · Model Context Protocol integration for external tools and servers.
src/mcp
Docs site
Separate Astro documentation application.
- Docs app · Separate documentation application and content site.
docs
Support services
Containerized or protocol-based auxiliary infrastructure.
- MCP server · Python-based containerized MCP server support.
mcp-servers
Connections 24
- App entry → CLI shell: boots · The runtime entrypoint initializes the CLI shell.
- CLI shell → UI widgets: renders · CLI uses shared terminal UI components.
- CLI shell → UI hooks: binds state · Input, history, and model selection flow through hooks.
- CLI shell → Agent loop: invokes · User goals are handed to the agent execution loop.
- Agent loop → Phases: organizes · The loop is structured into phases.
- Agent loop → Approvals: checks · Sensitive steps pass through approval gates.
- Agent loop → Prompts: templates · Prompt construction is centralized.
- Agent loop → Red-team mode: switches · Red-team workflows use a distinct execution mode.
- Commands → Domain engines: dispatches · Commands mostly forward into domain engines.
- Domain engines → Scanner: uses · Security workflows can invoke scanning capabilities.
- Domain engines → Graph engine: correlates · Findings can be organized as graphs.
- Domain engines → Output: formats · Domain results are emitted as reports or structured answers.
- Skills registry → Agent loop: extends · Skills act as pluggable capabilities for the main loop.
- Governance → Agent loop: guards · Policy and audit controls sit on the critical path.
- Governance → Red team: gates · Offensive simulation runs under governance control.
- OpenClaw → Governance: reinforces · Defensive controls complement policy enforcement and audit.
- Red team → Output: reports · Campaigns produce scored reports and summaries.
- C2 bridge → Agent loop: feeds · Session-aware post-exploitation context can inform the agent.
- LLM tools → Agent loop: supplies models · Model inference adapters are consumed by the agent loop.
- Security tools → Domain engines: supplies intel · Threat-intel and search connectors back domain workflows.
- MCP surface → Skills registry: adds tools · Protocol-based tools surface through skills and the agent loop.
- MCP surface → Agent loop: plugs into · MCP expands the agent's tool boundary.
- Docs app → CLI shell: documents · Documentation describes the runtime product and workflows.
- MCP server → MCP surface: hosts · Containerized server support sits behind the MCP surface.