kbws-forge-cli
Scaffolding and local development CLI for the kbws-forge-runtime agent framework. Generate a production-shaped FastAPI agent service and inspect its agent runs in a local browser UI.
Install
pip install kbws-forge-cli
Requires Python ≥ 3.13 and uv.
Usage
Run forge init and answer the prompts (Vite-style interactive picker):
forge init
✔ Project name: … my-agent
✔ Select a template: › service-agent
Or pass everything explicitly for non-interactive/scripted use:
forge init my-agent # name given, template picked interactively
forge init my-agent -t base-agent # fully non-interactive
Then start developing:
cd my-agent
uv sync # installs kbws-forge-runtime from PyPI
uv run uvicorn app.main:app --reload # dev server
uv run pytest # tests (fake models, no cost)
Trace UI
With the generated service running, start the local Trace UI in another terminal:
forge trace --api-url http://127.0.0.1:8000/api/v1
The command serves a loopback-only browser UI at http://127.0.0.1:8765,
modeled on the Google ADK / LangSmith trace consoles: a session list, a
per-session Turns panel (conversation context that stays visible while you
debug), and an execution tree with a Chrome-devtools-style time ruler and
waterfall bars. It connects automatically on load (API URL comes from the
CLI's --api-url; connection settings — including an optional API key — are
remembered in the page's localStorage) and ships light/dark themes.
The service records every run (from any client — curl, Yaak, scripts)
into a server-side trace store exposed via GET /api/v1/traces and
GET /api/v1/traces/{run_id} (generated by the service-agent template, so
any forge init project supports the panel out of the box). Traces produced
outside the UI appear automatically (the list auto-refreshes every few
seconds). The runtime persists runs to logs/traces.json (bounded,
newest-first), so they survive restarts.
Evaluating agents (CLI)
forge eval drives the service's eval API and produces CI-ready output:
forge eval run <suite> [--mode live|replay] [--cases a,b] [--repetitions N]
[--fail-under 0.9] [--report json junit] [-o out/]
forge eval compare --baseline <eval_run_id> [--candidate <id> | --live]
forge eval dataset export <suite> -o cases.jsonl
forge eval dataset import cases.jsonl --name golden --agent test_agent
runexecutes a suite on the service (live calls the model, replay re-grades recorded runs with zero external calls), prints a per-case score table, writes JSON/JUnit4 reports, and--fail-undergates the exit code for CI.comparediffs two eval runs per case (regressions list, score deltas) and exits 1 when a case regressed or the candidate falls below--fail-under.datasetexports a suite's cases to JSONL (graders as names) and imports a JSONL file back into a code-firstevals/module.--api-keyalso reads theFORGE_API_KEYenv var.
Browser e2e (opt-in)
The Trace UI has a Playwright regression suite (e2e/) that runs the full
connect → run → inspect → reload-persistence flow against a hermetic Node stub
of the agent API (deterministic SSE events, no real model or network):
FORGE_E2E=1 uv run pytest tests/test_e2e_trace_ui.py -v
It starts the real forge trace server on an ephemeral port and drives a real
Chrome/Chromium. Prerequisites on first opt-in run: Node.js + npm (the
harness auto-installs @playwright/test into e2e/) and a Chrome/Chromium
binary (or npx playwright install chromium, then drop channel: "chrome" in
e2e/playwright.config.mjs). Without FORGE_E2E=1 the test is skipped, so the
default test suite stays dependency-free.
Templates
| Template | Description |
|---|---|
service-agent (default) |
Full layered service: business aggregation (agents/) + technical layering (app/), global exception handling, unified {code, info, data} responses, API-key auth, multi-environment config, persistent JSON logging, request-id tracing, model-middleware and structured-output examples, unit/API/integration tests |
base-agent |
Minimal FastAPI Hello World for a quick start |
New templates placed in the CLI's templates/ directory appear in the
interactive picker automatically.
Generated project
forge init my-service produces:
my-service/
├── agents/ # business units: one directory per agent
│ ├── <module_name>/ # main agent
│ │ ├── agent.py # exports `agent`; middleware example
│ │ ├── prompts.py # composable Prompt components (code-first)
│ │ └── tools.py # this agent's tools
│ └── extract/ # structured-output example (output_schema)
│ ├── agent.py # pydantic schema -> Agent(output_schema=...)
│ └── prompts.py
├── app/ # technical layering
│ ├── main.py # create_app() + lifespan (load_agents)
│ ├── core/ # config / errors / response / security / logging
│ ├── api/v1/ # agents / sessions / chat / chat_stream / health
│ ├── schemas/ # request & response models
│ ├── services/ # chat orchestration
│ └── providers/ # LLM factory
├── tests/ # unit / api / integration (real-provider gated)
├── scripts/run.sh
└── .env.example # multi-env config template
Endpoints: GET /api/v1/health · GET /api/v1/agents · POST /api/v1/sessions ·
POST /api/v1/chat (supports variables, returns parsed for structured
output) · POST /api/v1/chat_stream (SSE), all behind X-API-Key / Bearer
auth except health.
Development
uv sync
uv run pytest packages/forge-cli/tests
License
MIT License
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kbws_forge_cli-1.2.2.tar.gz.
File metadata
- Download URL: kbws_forge_cli-1.2.2.tar.gz
- Upload date:
- Size: 481.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
249692405ffe84661b32f1298de83ce42543d9c1725530526d3e82b7ab46d858
|
|
| MD5 |
fdd613ecf93e4d121564399149d60ff1
|
|
| BLAKE2b-256 |
16467c270b00294bf07c7fd99f55ef7104f260056477e3110546966f93987792
|
File details
Details for the file kbws_forge_cli-1.2.2-py3-none-any.whl.
File metadata
- Download URL: kbws_forge_cli-1.2.2-py3-none-any.whl
- Upload date:
- Size: 77.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
511ad99c55a269412002891c8a358ad2f0017e707e29e08a780472038d36e299
|
|
| MD5 |
7b3a75148dc82de921a4971839fbeb3a
|
|
| BLAKE2b-256 |
18b375540a00b7f99a61063395858f7970a0c23e8bb810afe34ce3a167f3f6f5
|