Skip to content

dsadsadsadsadas/SemanticGuard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

19 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›ก๏ธ SemanticGuard

The Architectural Seatbelt for AI-Assisted Coding

The Fight Against Context Drift - Caused Security vulnerabilities

License: AGPL v3 VS Code Privacy First


๐ŸŽฏ What is SemanticGuard?

SemanticGuard is a VS Code extension that acts as a mandatory enforcement layer between your AI IDE and your codebase. While tools like Semgrep catch patterns, SemanticGuard catches intent violations.

Think of it as an architectural airbag that deploys before bad code hits your repository.


๐ŸŽฌ See SemanticGuard in Action (Local Mode)

SemanticGuard Demo


๐Ÿšจ The Problem: Context Drift

You ask an AI for "Feature A." It gives you "Feature A," but it also:

  • โŒ Reintroduces a security vulnerability you fixed last week
  • โŒ Ignores your architectural boundaries (e.g., puts DB logic in the View)
  • โŒ Leaks PII into logs because "it seemed faster"

Standard linters won't catch this because the code is syntactically perfect.
SemanticGuard catches it because the code is semantically wrong.


โœจ Key Features

Feature Description
๐Ÿง  Semantic Auditing Uses LLMs to verify code against your project's unique "Golden State"
๐Ÿ”’ Privacy-First Can Run 100% locally via Ollama (Llama 3.1/DeepSeek) by default
โšก Power Mode Switch to Cloud (Groq/OpenRouter) for 3x faster audits (sub-1s) using your own API keys
๐Ÿ›ก๏ธ Intent Verification Catches hardcoded secrets, unsafe data flows, and "hallucinated" architecture
๐Ÿ“ The Vault A versioned .SemanticGuard/ directory that stores your project's rules, history, and resolutions

๐Ÿš€ Quick Start (60 Seconds)

Note: SemanticGuard repository is lightweight (~50MB). Models are downloaded separately only if you choose Local Mode.

1๏ธโƒฃ Clone & Install

git clone https://github.com/dsadsadsadsadas/SemanticGuard
cd SemanticGuard
pip install -r requirements.txt

2๏ธโƒฃ Choose Your Engine

Local Mode (Privacy-First):

# Install Ollama (one-time setup)
curl -fsSL https://ollama.com/install.sh | sh

### 3๏ธโƒฃ Install Extension & Initialize

```bash
# Install VS Code extension
code --install-extension extension/SemanticGuard-gatekeeper-2.4.1.vsix  

Power Mode (Cloud-Based):

# Start server (no model download needed)
python start_server.py

# Then configure API key in VS Code extension
# Click โš™๏ธ Gear Icon โ†’ Configure API Key

3๏ธโƒฃ Initialize

Click "Initialize Project" in the sidebar. Choose a persona:

  • ๐Ÿš€ Solo-Indie: Focuses on clean naming and small functions
  • ๐Ÿ—๏ธ Architect: Enforces DI and interface-driven design
  • ๐Ÿ›ก๏ธ Fortress: Strict security, input sanitization, and statelessness

๐Ÿ›๏ธ The "Six Pillars" Architecture

SemanticGuard isn't just a prompt; it's a state machine. It tracks your project via:

.SemanticGuard/
โ”œโ”€โ”€ golden_state.md    # What is allowed (ONLY Allowed)
โ”œโ”€โ”€ system_rules.md    # What is forbidden ( NEVER Allowed)
โ”œโ”€โ”€ done_tasks.md      # Tasks that are done
โ”œโ”€โ”€ pending_tasks.md   # Pending Tasks
โ”œโ”€โ”€ problems_and_resolutions.md #Problems that occured and their Fix
โ”œโ”€โ”€ Walkthrough.md #What Happend Throughout the Audit
โ””โ”€โ”€ 

โš–๏ธ Performance & Privacy

Feature Local Mode Power Mode โšก
Speed 4-6s / audit 0.5s - 1.5s / audit

๐Ÿ“ฆ Repository Size

Component Size Notes
Git Clone ~50MB Code only - lightweight!
Ollama Model (optional) ~4.7GB Downloaded separately, not in repo
Total for Local Mode ~50MB + 4.7GB Model stored in ~/.ollama/, not in Git
Total for Power Mode ~50MB No model download needed

Important: Model files are NEVER included in the Git repository. They are downloaded on-demand when you choose Local Mode and stored in Ollama's directory.


๐ŸŽฎ Usage

Basic Workflow

  1. Write code in your AI IDE (Cursor, Windsurf, etc.)
  2. Save the file (Ctrl+S / Cmd+S)
  3. SemanticGuard audits the changes against your rules
  4. Accept or Reject based on the drift score

Drift Score Interpretation

  • ๐ŸŸข 0.0 - 0.3: Healthy (Auto-accept)
  • ๐ŸŸก 0.3 - 0.6: Warning (Review recommended)
  • ๐Ÿ”ด 0.6 - 1.0: Critical (Auto-reject)

๐Ÿ› ๏ธ Configuration

Local Mode Setup

# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh

# Pull the model
ollama pull llama3.1:8b

# Start Ollama server
ollama serve

Power Mode Setup

  1. Open SemanticGuard sidebar
  2. Click โš™๏ธ Settings
  3. Select "Configure API Key"
  4. Choose provider (Groq or OpenRouter)
  5. Enter your API key

๐Ÿ“š Documentation


๐Ÿค Get Involved

Built by Ethan Baron. If SemanticGuard caught a drift for you, let me know!


๐Ÿ“„ License

AGPLv3 โ€” Keep it open.

This project is licensed under the GNU Affero General Public License v3.0. See LICENSE for details.


๐ŸŒŸ Star History

If SemanticGuard helped you catch a drift, give it a star! โญ


Made with ๐Ÿ›ก๏ธ by developer, for developers

Report Bug

About

A Zero-Baseline, LLM-powered Architectural Gatekeeper & Auditor for VS Code.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors