Skip to content

yoanbernabeu/sfcode

Repository files navigation

sfcode — SymfonyCode

A Claude Code-style CLI coding agent written in PHP, powered by Symfony AI and the brand-new Symfony TUI component.

            __                _
  ___ / _| ___ ___   __| | ___
 / __| |_ / __/ _ \ / _` |/ _ \
 \__ \  _| (_| (_) | (_| |  __/
 |___/_|  \___\___/ \__,_|\___|

Highlights

  • 🔁 Agentic loop hand-rolled and explicit, no framework hiding the magic.
  • 🛠️ 7 built-in tools: read, write, edit, bash, ls, glob, skill.
  • 🖥️ Full TUI built on symfony/tui (live activity bar, streaming Markdown, modal permission overlays, loader spinner between LLM iterations).
  • 🔐 Three-layer permissions: per-tool rule, global mode, modal confirmation.
  • 💬 Slash commands inside the prompt: /help, /clear, /auto, /tools, /cost, /model, /skills, /exit.
  • 📚 Claude Code-compatible skills: drop your SKILL.md files into .sfcode/skills/ and they just work.
  • 🧠 Dynamic system prompt injecting CWD, OS, tools, skills, and the project's AGENTS.md (with CLAUDE.md as a fallback).
  • 💾 Auto session persistence under .sfcode/sessions/.
  • True async HTTP via amphp/http-client, so Ctrl+C is instant and the spinner actually spins while the LLM thinks.
  • 🔌 Multi-provider via symfony/ai-platform (OpenAI by default, Ollama available via SFCODE_PROVIDER=ollama).

Quickstart

git clone https://github.com/yoanbernabeu/sfcode
cd sfcode
composer install
cp .env.example .env.local && $EDITOR .env.local   # paste OPENAI_API_KEY
alias sfcode="$PWD/bin/sfcode"
sfcode

Requirements

  • PHP 8.4.1+
  • Composer 2.x
  • ext-ctype, ext-curl, ext-iconv, ext-json, ext-mbstring
  • Linux / macOS / WSL2 (Windows native is not supported because of stty and pcntl dependencies)
  • An OpenAI API key (or a local Ollama instance via SFCODE_PROVIDER=ollama)

Quality gates

composer cs          # php-cs-fixer dry-run
composer cs-fix      # apply style fixes
composer phpstan     # phpstan level 8
composer qa          # cs + phpstan

Architecture

bin/sfcode                          # entrypoint
src/
├── Kernel.php                      # Symfony 8.1 standard DI kernel
├── Agent/
│   ├── AgentLoop                   # the agentic loop (turn + turnStream)
│   └── MessageHistory              # wrapper over Symfony AI MessageBag
├── Command/ChatCommand             # `chat` command (TUI entrypoint)
├── Exception/                      # custom exceptions
├── Permission/                     # three-mode permission system
├── Platform/PlatformFactory        # picks OpenAI / Ollama from env
├── Prompt/SystemPromptBuilder      # runtime system-prompt composer
├── Session/SessionStore            # JSON session persistence
├── Skill/                          # cascade project > user skill loader
├── Tool/                           # built-in tools
└── Tui/
    ├── TurnRunner                  # one-turn UI choreography
    ├── TuiPermissionRequester      # modal overlay for permissions
    ├── TuiSlashHandler             # slash command dispatcher
    └── Widget/                     # custom Tui widgets
prompts/system.txt                  # system prompt template
.sfcode/skills/                     # bundled skills (committed)

Out of scope (by design)

MCP, subagents, hooks, OS sandbox, advanced context compaction, cross-session memory. These are tracked as future work in CHANGELOG.md.

License

MIT.

About

A Claude Code-style CLI coding agent for PHP, powered by Symfony AI and the new Symfony TUI component.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages