Skip to main content

kbws-forge-cli

PyPI version Python versions License

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.

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

kbws_forge_cli-1.1.0.tar.gz (467.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kbws_forge_cli-1.1.0-py3-none-any.whl (63.7 kB view details)

Uploaded Python 3

File details

Details for the file kbws_forge_cli-1.1.0.tar.gz.

File metadata

  • Download URL: kbws_forge_cli-1.1.0.tar.gz
  • Upload date:
  • Size: 467.0 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

Hashes for kbws_forge_cli-1.1.0.tar.gz
Algorithm Hash digest
SHA256 009998017f2af50328061ade958cfeb3e29657715350764fa9e438349b9ccae6
MD5 236de55c08150ff8d6d4115675d67c9d
BLAKE2b-256 a29a23b468b4f0a1fbc75a8c6737f73be424357d82bfb9f1e99568fa0627b9e6

See more details on using hashes here.

File details

Details for the file kbws_forge_cli-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: kbws_forge_cli-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 63.7 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

Hashes for kbws_forge_cli-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c8bf5835dbed64e0eaf36b12964fd5c344aeb8799a188eb0cd349dbbe1c5ff3
MD5 9ad46cf8083c22b7949876f467843316
BLAKE2b-256 f422f317a0e85d5e211c4a39fc789682ce5e58089143763f194854967576874f

See more details on using hashes here.

Release history Release notifications | RSS feed

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

This release

1.1.0 This release

2 files

1.0.0

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page