# henchiyb/breaker-ai architecture

> Architecture diagram of the GitHub repository henchiyb/breaker-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/henchiyb/breaker-ai
- Repository: https://github.com/henchiyb/breaker-ai

## Overview

Breaker-AI is a CLI and TypeScript library for prompt security checks, jailbreak testing, and sensitive-word masking. The main workflow starts at the CLI: scan loads text, runs pattern, input-safety, and length checks, computes a score, then prints a table or JSON; jailbreak runs attack prompts against an LLM and reports token and cost totals. Masking is a separate CLI/library capability, and prompts can also be listed. The graph follows shown calls and README capabilities; unsampled prompt data and external service behavior are represented only where documented or referenced.

Main entry points: [`src/cli/index.ts`](https://github.com/henchiyb/breaker-ai/blob/main/src/cli/index.ts) (Command interface), [`src/core/scanPrompt.ts`](https://github.com/henchiyb/breaker-ai/blob/main/src/core/scanPrompt.ts) (Scan and scoring), [`src/core/jailbreakPrompt.ts`](https://github.com/henchiyb/breaker-ai/blob/main/src/core/jailbreakPrompt.ts) (Jailbreak runner), [`src/core/textMask.ts`](https://github.com/henchiyb/breaker-ai/blob/main/src/core/textMask.ts) (Word masking)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI"]
  node_cli["Command interface<br/>[index.ts]"]
  node_table["Scan table<br/>[printTable.ts]"]
end

subgraph group_scan["Prompt scanning"]
  node_scan["Scan and scoring<br/>[scanPrompt.ts]"]
  node_risky["Risky patterns<br/>[riskyPatterns.ts]"]
  node_open["Open-ended patterns"]
  node_input["Input safety<br/>[userInputSafety.ts]"]
  node_length["Length check<br/>[lengthCheck.ts]"]
end

subgraph group_jailbreak["Jailbreak testing"]
  node_checklist["Checklist wrapper"]
  node_runner["Jailbreak runner<br/>[jailbreakPrompt.ts]"]
  node_prompts["Attack prompt set"]
end

subgraph group_utility["Text utilities"]
  node_mask["Word masking<br/>[textMask.ts]"]
  node_load["Text loading<br/>[load.ts]"]
end

node_user(("CLI user"))
node_llm["OpenAI-compatible API"]
node_source["Input text or file"]
node_reportfile["JSON report file"]

node_user -->|"runs commands"| node_cli
node_cli -->|"calls scan"| node_scan
node_scan -->|"loads text"| node_load
node_load -->|"reads if file"| node_source
node_scan -->|"matches patterns"| node_risky
node_scan -->|"matches patterns"| node_open
node_scan -->|"checks safety"| node_input
node_scan -->|"checks length"| node_length
node_scan -->|"returns report"| node_cli
node_cli -->|"prints table"| node_table
node_cli -->|"writes JSON"| node_reportfile
node_cli -->|"runs checklist"| node_checklist
node_checklist -->|"delegates testing"| node_runner
node_runner -->|"uses default prompts"| node_prompts
node_cli -->|"lists prompts"| node_prompts
node_runner -->|"sends attacks and judges"| node_llm
node_cli -->|"calls masking"| node_mask
node_mask -->|"loads text"| node_load
node_mask -->|"returns masked text"| node_cli

click node_cli "https://github.com/henchiyb/breaker-ai/blob/main/src/cli/index.ts"
click node_scan "https://github.com/henchiyb/breaker-ai/blob/main/src/core/scanPrompt.ts"
click node_risky "https://github.com/henchiyb/breaker-ai/blob/main/src/checks/riskyPatterns.ts"
click node_open "https://github.com/henchiyb/breaker-ai/blob/main/src/checks/openEndedPartterns.ts"
click node_input "https://github.com/henchiyb/breaker-ai/blob/main/src/checks/userInputSafety.ts"
click node_length "https://github.com/henchiyb/breaker-ai/blob/main/src/checks/lengthCheck.ts"
click node_table "https://github.com/henchiyb/breaker-ai/blob/main/src/cli/printTable.ts"
click node_checklist "https://github.com/henchiyb/breaker-ai/blob/main/src/checks/jailbreakChecklist.ts"
click node_runner "https://github.com/henchiyb/breaker-ai/blob/main/src/core/jailbreakPrompt.ts"
click node_prompts "https://github.com/henchiyb/breaker-ai/blob/main/src/checks/jailbreakPrompts.json"
click node_mask "https://github.com/henchiyb/breaker-ai/blob/main/src/core/textMask.ts"
click node_load "https://github.com/henchiyb/breaker-ai/blob/main/src/utils/load.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_table,node_user toneBlue
class node_scan,node_risky,node_open,node_input,node_length toneAmber
class node_checklist,node_runner,node_prompts,node_llm toneMint
class node_mask,node_load toneRose
class node_source,node_reportfile toneIndigo
```

## Components

### CLI

- [Command interface](https://github.com/henchiyb/breaker-ai/blob/main/src/cli/index.ts): `src/cli/index.ts`
- [Scan table](https://github.com/henchiyb/breaker-ai/blob/main/src/cli/printTable.ts): `src/cli/printTable.ts`

### Prompt scanning

- [Scan and scoring](https://github.com/henchiyb/breaker-ai/blob/main/src/core/scanPrompt.ts): `src/core/scanPrompt.ts`
- [Risky patterns](https://github.com/henchiyb/breaker-ai/blob/main/src/checks/riskyPatterns.ts): `src/checks/riskyPatterns.ts`
- [Open-ended patterns](https://github.com/henchiyb/breaker-ai/blob/main/src/checks/openEndedPartterns.ts): `src/checks/openEndedPartterns.ts`
- [Input safety](https://github.com/henchiyb/breaker-ai/blob/main/src/checks/userInputSafety.ts): `src/checks/userInputSafety.ts`
- [Length check](https://github.com/henchiyb/breaker-ai/blob/main/src/checks/lengthCheck.ts): `src/checks/lengthCheck.ts`

### Jailbreak testing

- [Checklist wrapper](https://github.com/henchiyb/breaker-ai/blob/main/src/checks/jailbreakChecklist.ts): `src/checks/jailbreakChecklist.ts`
- [Jailbreak runner](https://github.com/henchiyb/breaker-ai/blob/main/src/core/jailbreakPrompt.ts): `src/core/jailbreakPrompt.ts`
- [Attack prompt set](https://github.com/henchiyb/breaker-ai/blob/main/src/checks/jailbreakPrompts.json): `src/checks/jailbreakPrompts.json`

### Text utilities

- [Word masking](https://github.com/henchiyb/breaker-ai/blob/main/src/core/textMask.ts): `src/core/textMask.ts`
- [Text loading](https://github.com/henchiyb/breaker-ai/blob/main/src/utils/load.ts): `src/utils/load.ts`

### Other components

- **CLI user**
- **OpenAI-compatible API**
- **Input text or file**
- **JSON report file**

## Connections

- CLI user → Command interface: runs commands (evidence: `src/cli/index.ts`)
- Command interface → Scan and scoring: calls scan (evidence: `src/cli/index.ts`)
- Scan and scoring → Text loading: loads text (evidence: `src/core/scanPrompt.ts`)
- Text loading → Input text or file: reads if file (evidence: `src/utils/load.ts`)
- Scan and scoring → Risky patterns: matches patterns (evidence: `src/core/scanPrompt.ts`)
- Scan and scoring → Open-ended patterns: matches patterns (evidence: `src/core/scanPrompt.ts`)
- Scan and scoring → Input safety: checks safety (evidence: `src/core/scanPrompt.ts`)
- Scan and scoring → Length check: checks length (evidence: `src/core/scanPrompt.ts`)
- Scan and scoring → Command interface: returns report (evidence: `src/cli/index.ts`)
- Command interface → Scan table: prints table (evidence: `src/cli/index.ts`)
- Command interface → JSON report file: writes JSON (evidence: `src/cli/index.ts`)
- Command interface → Checklist wrapper: runs checklist (evidence: `src/cli/index.ts`)
- Checklist wrapper → Jailbreak runner: delegates testing (evidence: `src/checks/jailbreakChecklist.ts`)
- Jailbreak runner → Attack prompt set: uses default prompts (evidence: `src/core/jailbreakPrompt.ts`)
- Command interface → Attack prompt set: lists prompts (evidence: `src/cli/index.ts`)
- Jailbreak runner → OpenAI-compatible API: sends attacks and judges (evidence: `src/core/jailbreakPrompt.ts`)
- Command interface → Word masking: calls masking (evidence: `src/cli/index.ts`)
- Word masking → Text loading: loads text (evidence: `src/core/textMask.ts`)
- Word masking → Command interface: returns masked text (evidence: `src/cli/index.ts`)
