Metadata-Version: 2.4
Name: farningcode-api
Version: 0.1.0
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Requires-Dist: farningcode-core
Requires-Dist: flask>=3.1.3
Requires-Dist: requests>=2.34.2
Requires-Dist: waitress>=3.0.2

# Farning Code API
## Usage

```bash
uv sync
uv run main.py
```

When `main.py` runs from a source checkout, it copies the adjacent `core` source
into `API/dev_core` on startup. Restart the API after editing core; no rebuild is
needed. Sessions and settings both use this copy and the same config file.

`uv sync` also installs `farningcode-core` as a local package dependency.
For deployment, build the core wheel from the repository root with `uv build`,
then install that wheel alongside the API dependencies. Deployments without the source tree use the installed package.

Configuration is shared through the user config directory (`FarningCode/config.json`
under Application Support on macOS, LOCALAPPDATA on Windows, or ~/.config on Linux).
Set `FARNING_CODE_CONFIG` to an explicit config file to use an existing deployment
configuration. Repository config files are no longer selected automatically.

Best accessed through the Farning Code UI.

## Settings

`GET /settings` returns configured model IDs and display names, `selected_model`,
`ignore_folders`, and `auto_approve_tools`. Model connection hosts, endpoint types, and a `has_api_key` flag are included; API keys are excluded.

`PATCH /settings` saves any of these preferences to the shared configuration:

```json
{
  "selected_model": "your-configured-model-id",
  "ignore_folders": [".git", ".venv"],
  "auto_approve_tools": ["file_reader"]
}
```

To add, edit, or remove model connections, include a complete `models` array in
`PATCH /settings`, together with `selected_model` when changing the active ID:

```json
{
  "models": [{
    "id": "local-model",
    "name": "Local model",
    "api_host": "http://localhost:1234",
    "ai": "openai",
    "api_key": ""
  }],
  "selected_model": "local-model"
}
```

Model IDs must be unique; hosts must use HTTP(S). Only OpenAI-compatible endpoints
are supported. Omit `api_key` to preserve a saved key, supply a value to replace it,
or an empty string to clear it. Include `original_id` when renaming an existing
model to retain its key. Omitted models are removed; use an empty array and an
empty `selected_model` to remove all connections.
Allowed tools: `file_reader`, `file_writer`, `file_deleter`, `execute_code`.
An empty tool list requires manual approval for every tool. Invalid updates return
400; persistence failures return 500 and restore the in-memory preferences.
Model selection applies to new sessions, ignored folders to subsequent workspace
scans, and tool approval changes to future tool batches. Already queued approvals
remain unchanged. Run this local API only for trusted users; settings are shared.
