<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
# Implementing Threat Modeling Automation — API Reference

## agent.js CLI

```bash
# Init action
node scripts/agent.js --action init

# Pipeline action
node scripts/agent.js --action pipeline

# Analyze action
node scripts/agent.js --action analyze

# Drift action
node scripts/agent.js --action drift

# Gate action
node scripts/agent.js --action gate
```

## GitHub Actions Workflow Example

```yaml
name: Threat Model Analysis
on:
  pull_request:
    paths: ['tm.py', 'threagile.yaml']
jobs:
  analyze:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: pip install pytm graphviz
      - run: python3 tm.py --report report.html
      - run: node scripts/agent.js --action gate --max-critical 0
```

## Drift Detection Output

```json
{
  "new_threats": ["T-004"],
  "resolved_threats": ["T-002"],
  "unchanged": ["T-001", "T-003"],
  "drift_detected": true
}
```
