Metadata-Version: 2.5
Name: sagixs
Version: 0.2.0
Summary: A Claude Code-style terminal agent that works with any model API or a local Hugging Face model.
Project-URL: Homepage, https://github.com/suprosmith-coder/sagixs
Project-URL: Repository, https://github.com/suprosmith-coder/sagixs
Project-URL: Issues, https://github.com/suprosmith-coder/sagixs/issues
Author: CyanixLabs
License: MIT License
        
        Copyright (c) 2026 CyanixLabs
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
License-File: LICENSE
Keywords: agent,ai,cli,coding-agent,huggingface,llm,terminal,termux
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development
Requires-Python: >=3.10
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Provides-Extra: gguf
Requires-Dist: llama-cpp-python>=0.2.90; extra == 'gguf'
Provides-Extra: local
Requires-Dist: accelerate>=0.30; extra == 'local'
Requires-Dist: torch>=2.2; extra == 'local'
Requires-Dist: transformers>=4.44; extra == 'local'
Description-Content-Type: text/markdown

# Sagixs In Terminal

A Claude Code-style AI agent for your terminal. It reads and edits files, searches your project, and runs commands, using **any model you point it at**:

- **Any API:** OpenAI, Anthropic, OpenRouter, Groq, Together, Hugging Face Inference Providers, the Cylink API, or any OpenAI-compatible endpoint.
- **Local servers:** Ollama, LM Studio, llama.cpp `llama-server`, vLLM.
- **Local Hugging Face models:** run a model from the Hub (or a folder on disk) directly on your machine with `transformers`, or a GGUF file with `llama-cpp-python`.

No runtime dependencies for the API providers (standard library only), so it installs cleanly on Termux.

> **Status: 0.2.0 alpha.** The agent loop, tools, API providers and CLI are covered by an automated test suite (106 tests, including end-to-end runs against a local fake API server). The local model providers are tested against stand-ins for `transformers` and `llama_cpp`, **not against real model weights** - please report problems. See [Limitations](#limitations).

## Install

```bash
python -m pip install sagixs                 # agent + every API provider
python -m pip install "sagixs[local]"        # + run Hugging Face models locally (torch, transformers)
python -m pip install "sagixs[gguf]"         # + run GGUF models locally (llama-cpp-python)
```

From a checkout: `python -m pip install -e ".[dev]"`. Python 3.10+.

## Quick start

```bash
cd your-project
export GROQ_API_KEY=...                      # or: sagixs auth set groq
sagixs --provider groq
```

```
> add a --verbose flag to cli.py and update the tests
● read_file(cli.py)
● edit_file(cli.py)
  Edit cli.py
  --- a/cli.py ...
  Allow edit_file? [y]es / [n]o / [a]lways this session:
```

One-shot mode, for scripts and pipes:

```bash
sagixs -p "summarize what this repo does"
git diff | sagixs -p "review this diff" --provider openrouter --model anthropic/claude-sonnet-4.5
sagixs -p --yes "run the tests and fix any failures"
```

## Choosing a model

Pick a provider with `--provider` and a model with `--model`, or combine them as `provider:model`.

```bash
sagixs providers                             # what's available and which keys are set
sagixs models --provider groq                # list a provider's models
```

| Provider | Key | Notes |
|---|---|---|
| `openai` | `OPENAI_API_KEY` | default model `gpt-4o-mini` |
| `anthropic` | `ANTHROPIC_API_KEY` | native Messages API; pass `--model` |
| `openrouter` | `OPENROUTER_API_KEY` | default `openrouter/auto`; any model id from their catalog |
| `groq` | `GROQ_API_KEY` | default `llama-3.3-70b-versatile` |
| `together` | `TOGETHER_API_KEY` | pass `--model` |
| `huggingface` | `HF_TOKEN` | Hugging Face Inference Providers (hosted); pass `--model` |
| `cylink` | `CYLINK_API_KEY` | default `cyanix-core`; uses text tool calls (see below) |
| `ollama` | none | `http://127.0.0.1:11434/v1` |
| `lmstudio` | none | `http://127.0.0.1:1234/v1` |
| `llamacpp` | none | `llama-server` on `http://127.0.0.1:8080/v1` |
| `custom` | `SAGIXS_API_KEY` | any OpenAI-compatible URL via `--base-url` |
| `hf-local` | `HF_TOKEN` (gated models) | run a Hub model locally with transformers |
| `gguf` | `HF_TOKEN` (gated models) | run a GGUF model locally |

```bash
sagixs --provider openrouter --model deepseek/deepseek-chat
sagixs --model groq:llama-3.1-8b-instant
sagixs --provider anthropic --model <a model id from `sagixs models --provider anthropic`>
sagixs --provider cylink
sagixs --provider ollama --model qwen2.5-coder:7b
sagixs --provider custom --base-url https://my.server/v1 --model my-model
```

### Your own provider

Register any OpenAI-compatible endpoint once and use it by name:

```bash
sagixs config add-provider mylab --base-url https://api.mylab.dev/v1 --api-key-env MYLAB_KEY --model mylab-1
sagixs --provider mylab
```

### Local Hugging Face models

```bash
pip install "sagixs[local]"
sagixs --provider hf-local --model Qwen/Qwen2.5-Coder-1.5B-Instruct
sagixs --provider hf-local --model ./my-finetuned-model --device cpu
```

Accepts a Hub repo id or a local directory. Options: `--device` (`cpu`, `cuda`, `mps`, `auto`), `--dtype` (`auto`, `float16`, `bfloat16`, `float32`), `--max-tokens`, `--temperature`, `--trust-remote-code` (off by default; only enable it for repos you trust). The model must have a chat template.

### Local GGUF models

```bash
pip install "sagixs[gguf]"
sagixs --provider gguf --model ./model-q4_k_m.gguf
sagixs --provider gguf --model "Qwen/Qwen2.5-Coder-7B-Instruct-GGUF:*q4_k_m.gguf" --n-ctx 8192
```

`owner/repo` downloads a `*q4_k_m.gguf` file; add `:FILE_OR_GLOB` to choose another. `--n-gpu-layers` offloads layers to a GPU.

### Termux (Android)

```bash
pkg install python
pip install sagixs
sagixs auth set groq
sagixs --provider groq
```

PyTorch generally isn't available on Termux, so for on-device models use a GGUF model or run `llama-server` / Ollama and connect with `--provider llamacpp` / `ollama`. API providers work as-is.

## How tool calling works

Models act through tools: `read_file`, `list_dir`, `glob`, `grep`, `edit_file`, `write_file`, and `bash`.

- **Native** - for APIs with function calling (OpenAI, Anthropic, Groq, OpenRouter, ...), Sagixs uses the provider's own tool-calling field.
- **Text protocol** - for local models, and APIs without a `tools` field (Cylink, `llama-server` by default), Sagixs teaches the model a small `<tool_call>{json}</tool_call>` format in the system prompt and parses it from the reply. Any model that can follow instructions can use this; one tool call per reply.
- **Auto** - the default. APIs start native; if one rejects the request because of tools, Sagixs switches to the text protocol mid-conversation and carries on. Force a style with `--tool-mode native|prompt`.

Small models can write malformed or wrong tool calls. Sagixs reports parse problems back to the model so it can retry, but a 1B model is not going to behave like a frontier model.

## Permissions

By default Sagixs **asks before it edits a file or runs a command**, showing a diff for edits. Reading and searching never ask.

| Mode | Reads | Edits | Commands |
|---|---|---|---|
| `readonly` | yes | blocked | blocked |
| `ask` (default) | yes | asks | asks |
| `auto-edit` | yes | yes | asks |
| `yolo` (`--yes`) | yes | yes | yes |

Set with `--mode`, `/mode` in a session, or `sagixs config set mode auto-edit`. Answer `a` at a prompt to stop asking about that tool for the session. When not run from a terminal (`-p` with piped input), anything that would need approval is **declined** unless you pass `--yes` or `--mode auto-edit`.

File tools only touch files inside the folder you launched from (`--cwd` to change it); symlinks that point outside it are refused. **`bash` is not sandboxed** - an approved command can do anything your user can. Use `ask` mode (or a container) with models you don't trust.

## In a session

`/help` `/model NAME` `/provider NAME [MODEL]` `/mode MODE` `/tools` `/status` `/clear` `/exit`. End a line with `\` to continue it. **Ctrl-C** stops the current turn without quitting; files already changed stay changed. `sagixs -c` continues the last conversation in the current folder.

Put standing instructions in `SAGIXS.md` in your project (`AGENTS.md` or `CLAUDE.md` are read too). Machine-wide instructions go in `~/.config/sagixs/SAGIXS.md`.

## Configuration

```bash
sagixs config set provider groq
sagixs config set model llama-3.3-70b-versatile
sagixs config set mode auto-edit
sagixs config show        # never prints keys
```

Keys: `provider model base_url mode tool_mode max_steps temperature max_tokens timeout system_prompt device dtype n_ctx n_gpu_layers`. Flags override the config file.

**API keys** come from, in order: `--api-key`, the provider's environment variable, then `sagixs auth set PROVIDER`, which stores the key in `~/.config/sagixs/credentials.json` with owner-only permissions (plain text on disk - it is not encrypted). Keys are never written to `config.json`.

Safeguards against sending a key to the wrong place: a `base_url` saved in config only applies to the `custom` provider, and if you point a preset at a different host with `--base-url`, Sagixs will not send that preset's key there - supply `SAGIXS_API_KEY` or `--api-key` for that endpoint.

## Limitations

- **Local providers are not yet verified against real weights.** The code paths (loading, streaming, stop handling, errors) are tested with stand-ins, and `transformers`/`llama-cpp-python` APIs change between versions. If something breaks, `sagixs doctor` shows what's installed.
- **The Cylink base URL (`https://cylinkdev.vercel.app/api/v1`) is an assumption.** If your endpoint differs, use `sagixs config add-provider cylink --base-url ... --tool-mode prompt`. Cylink currently ignores `temperature`, `top_p` and `stop`; Sagixs tolerates that, but the model may write text after a tool call, which Sagixs discards.
- Local chat templates vary: some reject a `system` role (Sagixs folds it into the first user message) or require strict user/assistant alternation.
- Context management is simple: when a conversation outgrows the model's budget, old tool output is dropped. There is no summarization yet; use `/clear` if answers degrade. Local models default to a small budget.
- No web access, MCP, or sub-agents yet. `bash` can fetch URLs if you approve it.

## Development

```bash
git clone https://github.com/suprosmith-coder/sagixs.git && cd sagixs
python -m pip install -e ".[dev]"
pytest && ruff check .
```

## Roadmap

- [x] Provider adapters: OpenAI-compatible, Anthropic, local transformers, GGUF
- [x] Streaming output
- [x] Tool runtime (files, search, shell) with permission modes
- [x] Text tool-call protocol for any model
- [ ] Verify local providers against real models; model capability registry
- [ ] Context summarization
- [ ] Web fetch/search tool, MCP client
- [ ] Native Sagixs model adapter

## License

MIT. See [LICENSE](LICENSE).
