Skip to content
hackafterdarkPublic

About

Terminal-based, hardened agentic runtime built in Go. Features tree-sitter structural intelligence, native OpenTelemetry observability, and shell-level security sandboxing for local and cloud LLM experimentation.

Topics

Resources

Stars

19 stars

Watchers

0 watching

Forks

Repository files navigation

Phosphor

Ask DeepWiki

Phosphor is a terminal-based, hardened agentic runtime built in Go, designed for developers who demand full visibility, structural intelligence, and uncompromising security in their AI coding tools. While it's primarily focused on being a coding agent, it can be used for more.

It is also a research project and a reference. It is not a commercial project, and its success isn't measured by how many people use it. The goal is to raise awareness around agent security and to share ideas and strategies. I borrow freely from other projects when building features into Phosphor, and I encourage you to borrow from it in return: it takes the best of what I find, adds entirely new ideas and my own design input, tests it, and shares what works. Along the way I'll make decisions you may not agree with, and that's fine: this is an open-source project, so you're free to adapt it to your own tastes.

Why Phosphor?

Phosphor originated from the need to run AI agents against local inference engines and a need to experiment with agents.

Some goals and areas of focus include:

  1. Hardened Security: A defense-in-depth model that enforces filesystem bounds, command allow-lists, and environment variable filtering at the shell interpreter level.
  2. Structural Awareness: Integration of tree-sitter to enable AST-aware editing and structural search, allowing agents to understand the shape of the code they modify.
  3. Observability: Native OpenTelemetry instrumentation to turn autonomous agent behavior from a black box into an auditable flight recorder.

Getting Started

1. Pick a backend

Cloud providers work out of the box: built-in provider definitions activate automatically when their API key is available — either as an environment variable (OPENAI_API_KEY, ANTHROPIC_API_KEY, …) or as an api_key in the providers section. Subscription-style providers authenticate via the CLI:

phosphor login copilot    # GitHub Copilot
phosphor login xai        # xAI (Grok subscription)

Local models (llama.cpp, vLLM, Ollama, LM Studio, anything OpenAI-compatible) are one provider block away:

{
  "providers": {
    "local": {
      "base_url": "http://localhost:11434/v1",
      "type": "openai-compat",
      "api_key": "not-needed",
      "discover_models": true
    }
  },
  "models": {
    "large": { "model": "qwen3-32b", "provider": "local" },
    "small": { "model": "qwen3-32b", "provider": "local" }
  }
}

See Local Models for server-specific notes, and Providers & Models for the full reference.

2. Run it and select a model

Launch phosphor in your project and press Ctrl+L (or / → "Switch Model") to choose the large/small model pair. No config file is required to start — cloud providers activate from their env vars, and the TUI can add custom/local providers for you. Non-interactive runs use phosphor run "your prompt" — handy for scripts and CI.

3. Optional: global config

Phosphor reads ~/.config/phosphor/phosphor.json (%USERPROFILE%\.config\phosphor\phosphor.json on Windows) if it exists, but never creates it and runs fine without it. Copying the annotated example at examples/phosphor.example.json there is only a convenience for editing settings by hand. Providers and model selections made in the TUI go to a separate global data config that always out-ranks it, so a hand-edited file can't clobber anything the TUI configured.

Run phosphor dirs to print the exact paths in use and the config merge order; phosphor models lists every model Phosphor can currently reach.

The Getting Started & Configuration guide walks through config precedence, every configurable section (providers, MCP, LSP, permissions, tools, hooks, security, observability, and more) with snippets, and troubleshooting.

Documentation

The full documentation index lives at docs/INDEX.md, covering configuration, tools, security hardening, and platform integration. Start there to browse everything.

The documentation also ships inside the binary. Run Phosphor and just ask it a question about itself, or ask it to list the docs; it searches the same corpus from within the TUI.

Phosphor is built as a workbench for agentic experimentation. You can read our full mission and architectural approach here: CORE_PHILOSOPHY.

Benchmarks

Phosphor is evaluated on real coding-agent benchmarks with reproducible, self-contained kits in benchmarks/. The flagship result: 78.8% on DeepSWE v1.1 (89/113 resolved, zero infrastructure failures) with DeepSeek V4.1 Flash — above the 74.2% mini-SWE-agent baseline DeepSeek reports for the same model on its model card. Setup and anti-cheat egress details live in benchmarks/deepswe1.1/README.md; benchmarks/swebench/ covers the older SWE-bench Verified kits.

Build Requirements

Phosphor relies on tree-sitter for structural code analysis. Because tree-sitter is a C library, a C compiler is required to build the project.

  • OS: Linux, macOS, or Windows (with MSYS2/MinGW).
  • Toolchain: Go 1.21+, GCC or Clang.
  • CGO: Required for the full experience (enables CGO with CGO_ENABLED=1). Without it, the build still succeeds, but tree-sitter features (structural search, AST-aware editing) are excluded.

Build Instructions

Easiest path, if you have the Taskfile CLI installed:

task build

This enables CGO, sets the required Go experiment flags, and regenerates the embedded docs corpus for you.

Or with plain Go tooling:

# Ensure CGO is enabled
export CGO_ENABLED=1

# Build the binary
go build -o phosphor .

Note for Windows users: Ensure your C compiler (e.g., MSYS2 GCC) is in your %PATH% before running the build command. You can also specify the path to GCC in one line with something like this for example:

$env:CGO_ENABLED="1"; $env:GOTOOLCHAIN="auto"; $env:PATH="C:/msys64/ucrt64/bin;" + $env:Path; go build -o phosphor.exe .

You can also run go test the same way.

Credits

Phosphor is a fork of Crush, the wonderful terminal AI coding agent from Charm. Many of its foundations come from their work, and I'm grateful for it.

License

Phosphor is licensed under FSL-1.1-MIT.

About

Terminal-based, hardened agentic runtime built in Go. Features tree-sitter structural intelligence, native OpenTelemetry observability, and shell-level security sandboxing for local and cloud LLM experimentation.

Topics

Resources

Stars

19 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages