diff --git a/Makefile b/Makefile index 5747532..8b8e4a3 100644 --- a/Makefile +++ b/Makefile @@ -1,43 +1,70 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: Copyright 2026 The llm-works-docs Authors -infra := $(shell appinfra scripts-path) +# Settings use ?= so the environment and a Makefile.local (gitignored, assigned with :=) can +# override them; `make config` shows where each value came from. # Configuration -APPINFRA_DEV_PKG_NAME := docsite +APPINFRA_DEV_PKG_NAME ?= docsite # Code quality strictness # - true: Fail on any code quality violations (CI mode) # - false: Report violations but don't fail (development mode) -APPINFRA_DEV_CQ_STRICT := true +APPINFRA_DEV_CQ_STRICT ?= true # Include SPDX header check in `make check`; the license comes from pyproject.toml (MIT). -APPINFRA_DEV_CQ_SPDX := true +APPINFRA_DEV_CQ_SPDX ?= true # No ruff rules reported as warnings only: they are enforced in pyproject's select -APPINFRA_DEV_CQ_LINT_SELECT := false +APPINFRA_DEV_CQ_LINT_SELECT ?= false # Fail on duplicated code blocks and unused private definitions -APPINFRA_DEV_CQ_DUP := strict -APPINFRA_DEV_CQ_DEAD := strict +APPINFRA_DEV_CQ_DUP ?= strict +APPINFRA_DEV_CQ_DEAD ?= strict # Report tests that sit in another suite's directory, or leak process-wide state -APPINFRA_DEV_TEST_HEALTH := warn +APPINFRA_DEV_TEST_HEALTH ?= warn # Test coverage threshold (percentage), measured over unit and integration tests -APPINFRA_PYTEST_COVERAGE_THRESHOLD := 95 -APPINFRA_PYTEST_COVERAGE_MARKERS := unit or integration +APPINFRA_PYTEST_COVERAGE_THRESHOLD ?= 95 +APPINFRA_PYTEST_COVERAGE_MARKERS ?= unit or integration # Docstring coverage threshold (percentage) -APPINFRA_DEV_DOCSTRING_THRESHOLD := 90 - -# Include framework (config first). Makefile.docs is left out: it drives MkDocs, and this -# site is built with Zensical. -include $(infra)/make/Makefile.config -include $(infra)/make/Makefile.env -include $(infra)/make/Makefile.help -include $(infra)/make/Makefile.utils -include $(infra)/make/Makefile.dev -include $(infra)/make/Makefile.pytest -include $(infra)/make/Makefile.install -include $(infra)/make/Makefile.clean +APPINFRA_DEV_DOCSTRING_THRESHOLD ?= 90 + +# Locate the framework once, before the first include; the environment and the command line +# can still name another copy. +ifeq ($(origin APPINFRA_SCRIPTS),undefined) +APPINFRA_SCRIPTS := $(shell appinfra scripts-path) +endif + +# Include framework (config first: it loads Makefile.local). Makefile.docs is left out: it drives +# MkDocs, and this site is built with Zensical. +include $(APPINFRA_SCRIPTS)/make/Makefile.config +include $(APPINFRA_SCRIPTS)/make/Makefile.env +include $(APPINFRA_SCRIPTS)/make/Makefile.help +include $(APPINFRA_SCRIPTS)/make/Makefile.utils +include $(APPINFRA_SCRIPTS)/make/Makefile.dev +include $(APPINFRA_SCRIPTS)/make/Makefile.pytest +include $(APPINFRA_SCRIPTS)/make/Makefile.install +include $(APPINFRA_SCRIPTS)/make/Makefile.clean + +# Site: `python -m docsite build` assembles docs/, the header and zensical.toml from the pinned +# packages and the main-site nav; Zensical renders them. Build inputs are docsite config in +# etc/docsite.yaml, overridable per key with INFRA_
_ environment variables (e.g. +# INFRA_NAV_URL for a local main-site dev server). A Makefile.local exports them to the site +# targets only (`build serve: export INFRA_NAV_URL := ...`): appinfra's own tools read INFRA_* +# as well and reject paths their config does not declare. + +# The dev server's address (Zensical's default); set SITE_ADDR := host:port in Makefile.local. +SITE_ADDR ?= localhost:8000 + +.PHONY: build serve + +build: ## Build the docs site into site/ + python -m docsite build + zensical build --clean + +serve: ## Build the site inputs, then serve with live reload on SITE_ADDR (default localhost:8000) + python -m docsite build + zensical serve --dev-addr $(SITE_ADDR) diff --git a/docsite/docstring_code.py b/docsite/docstring_code.py new file mode 100644 index 0000000..a200507 --- /dev/null +++ b/docsite/docstring_code.py @@ -0,0 +1,130 @@ +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: Copyright 2026 The llm-works-docs Authors + +"""Griffe extension: render indented code in docstrings as code blocks. + +Packages write docstring examples as plain indented blocks under a title, e.g. `Example:`, which +the Google-style parser hands to Markdown as text: the lines run together into one paragraph and +a `# comment` becomes a heading. This extension wraps such blocks in fences before parsing. +Loaded by mkdocstrings from zensical.base.toml as `docsite/docstring_code.py:CodeBlocks`. +""" + +import ast +import re +from typing import Any + +from griffe import Extension, Object + +# A section title alone on its line, e.g. "Example:" or "Include Example:" +_TITLE = re.compile(r"[A-Z][\w ()/'-]{0,40}:") +# Titles the Google-style parser reads as structured items, which must stay as they are +_STRUCTURED = frozenset( + { + "args", "arguments", "params", "parameters", "keyword args", "keyword arguments", + "other args", "other arguments", "other params", "other parameters", "raises", + "exceptions", "warns", "warnings", "returns", "return", "yields", "yield", "receives", + "receive", "attributes", "functions", "methods", "classes", "modules", "type aliases", + "type parameters", "deprecated", + } +) # fmt: skip +# A line of a YAML mapping or list, or a comment +_YAML_LINE = re.compile(r"\s*(#.*|[\w.-]+:(\s.*)?|- .*)") +_EXAMPLE_WORDS = ("example", "usage") + + +class CodeBlocks(Extension): + """Fences titled code blocks in every docstring before the parser sees them.""" + + def on_instance(self, *, obj: Object, **kwargs: Any) -> None: + """Rewrite the object's docstring text in place.""" + if obj.docstring is not None: + obj.docstring.value = fence_code_blocks(obj.docstring.value) + + +def fence_code_blocks(text: str) -> str: + """Return `text` with each titled block of code wrapped in a fenced code block.""" + lines = text.split("\n") + out: list[str] = [] + i = 0 + while i < len(lines): + out.append(lines[i]) + end = _block_end(lines, i) + block = lines[i + 1 : end] + if end > i + 1 and _is_code(lines[i].strip()[:-1], block): + out.extend(_fenced(block)) + i = end + else: + i += 1 + return "\n".join(out) + + +def _block_end(lines: list[str], i: int) -> int: + """The index after the block indented under a title at line `i`, or i + 1 if none.""" + if not _TITLE.fullmatch(lines[i].strip()): + return i + 1 + title_indent = _indent(lines[i]) + end = i + 1 + while end < len(lines) and (not lines[end].strip() or _indent(lines[end]) > title_indent): + end += 1 + while end > i + 1 and not lines[end - 1].strip(): + end -= 1 + return end + + +def _is_code(title: str, block: list[str]) -> bool: + """Whether the block under `title` is code rather than items, a doctest or prose.""" + body = [line.strip() for line in block if line.strip()] + if not body or title.lower() in _STRUCTURED: + return False + if any(line.startswith("```") for line in body): + return False + # Doctests too: griffe's own doctest parsing stops at a bare ">>>" and leaves the rest as text. + if _is_doctest(body): + return True + if all(line.startswith(("- ", "* ")) for line in body): + return False + if any(word in title.lower() for word in _EXAMPLE_WORDS): + return True + return _language(_dedent(block)) != "text" + + +def _fenced(block: list[str]) -> list[str]: + """The block as a fenced code block at its own indentation.""" + body = _dedent(block) + pad = " " * min(_indent(line) for line in block if line.strip()) + fence = [f"{pad}```{_language(body)}"] + fence += [f"{pad}{line}" if line else "" for line in body] + return [*fence, f"{pad}```"] + + +def _indent(line: str) -> int: + """The number of leading spaces.""" + return len(line) - len(line.lstrip()) + + +def _dedent(block: list[str]) -> list[str]: + """The block's lines without their common indentation.""" + indent = min(_indent(line) for line in block if line.strip()) + return [line[indent:] for line in block] + + +def _is_doctest(lines: list[str]) -> bool: + """Whether the block is an interactive session: it opens with a >>> prompt.""" + first = next((line.strip() for line in lines if line.strip()), "") + return first.startswith(">>>") + + +def _language(body: list[str]) -> str: + """pycon for a doctest, python if it parses, yaml if every line looks like YAML, else text. + + `key: value` lines also parse as Python annotations; a block of nothing else is YAML. + """ + if _is_doctest(body): + return "pycon" + yaml_shaped = all(_YAML_LINE.fullmatch(line) for line in body if line.strip()) + try: + tree = ast.parse("\n".join(body)) + except SyntaxError: + return "yaml" if yaml_shaped else "text" + only_annotations = bool(tree.body) and all(isinstance(s, ast.AnnAssign) for s in tree.body) + return "yaml" if yaml_shaped and only_annotations else "python" diff --git a/etc/docsite.yaml b/etc/docsite.yaml index 8c6acaf..95e9afe 100644 --- a/etc/docsite.yaml +++ b/etc/docsite.yaml @@ -13,8 +13,13 @@ logging: site: # Package checkouts and the downloaded nav partial build_dir: .build/src - # Zensical docs_dir; each package's guides are staged under //guides + # The site's own pages: home, Get started, How-to guides, Concepts, package landing pages + pages_dir: pages + # Zensical docs_dir, rebuilt by every stage: pages_dir, then each package's docs under / docs_dir: docs + # Zensical config: the tracked base, and the generated file Zensical reads + zensical_base: zensical.base.toml + zensical_config: zensical.toml # The header is the main site's nav, fetched live at every build so a nav change on # www.llm-works.ai needs only a docs rebuild, not a change here. @@ -27,14 +32,83 @@ nav: output: overrides/partials/site-nav.html timeout_s: 10 -# Each package is fetched at a pinned release tag. `docs` is an allowlist of paths under -# the package's docs/ directory: only these files are published, so internal notes in a -# package's docs/ never reach the site. No wildcards: a new file must be listed to ship. -# -# - name: appinfra -# repo: https://github.com/llm-works/appinfra.git -# tag: vX.Y.Z -# docs: -# - index.md -# - guides/getting-started.md -packages: [] +# The main site's shared stylesheets, fetched with the nav and loaded before pages/assets/extra.css: +# tokens.css holds the brand's custom properties (--bg, --accent, --mono, ...), which extra.css +# uses instead of copied values; nav.css styles the nav partial and its theme switch. +brand: + tokens_url: https://www.llm-works.ai/partials/tokens.css + nav_css_url: https://www.llm-works.ai/partials/nav.css + timeout_s: 10 + +# Each package is fetched at a pinned release tag. `docs_root` is its docs directory in the +# repo (default: docs). The package's docs are the source and are published as they are; the +# arrangement is the site's. `docs` is the package's tree in the site nav and its allowlist at +# once: only the files it lists are published, in that order. An entry is a path (titled by the +# page's heading), {Title: path}, or {Section: [entries]}. No wildcards: a new file must be +# listed to ship. `rename` stages a file under another name. `reference` adds an API reference +# generated from the package's docstrings. Each package also needs a landing page, +# pages//index.md, and an entry {: /index.md} under Packages in +# zensical.base.toml. +packages: + - name: appinfra + repo: https://github.com/llm-works/appinfra.git + tag: v0.15.0 + docs_root: appinfra/docs + # Zensical takes a README.md as the folder's index, which is the landing page here + rename: + README.md: user-guide.md + # Generated from the docstrings at the tag: one page per top-level module of appinfra/ + reference: + package: appinfra + # Not listed: SECURITY.md, and index.md, the `appinfra docs` CLI's navigation page + # (the landing page here is pages/appinfra/index.md) + docs: + - User guide: README.md + - Getting started: getting-started.md + - Guides: + - Configuration: + - guides/configuration-precedence.md + - guides/environment-variables.md + - guides/config-protocol.md + - guides/decorator-config-pattern.md + - Logging: + - guides/logging-builder.md + - guides/config-based-logging.md + - guides/hot-reload-logging.md + - Applications: + - guides/framework-integration.md + - guides/library-mode-bootstrap.md + - guides/api-stability.md + - Testing: + - guides/pytest-plugin.md + - guides/pg-test-helper.md + - guides/test-suites.md + - guides/test-naming-standards.md + - guides/coverage-targets.md + - Development tooling: + - guides/virtual-environment.md + - guides/makefile-customization.md + - guides/spdx-header-check.md + - guides/contributing.md + # Hand-written module overviews; the full API reference is generated (see reference) + - Module guides: + - api/index.md + - api/app.md + - api/app-builder.md + - api/fastapi.md + - api/cli.md + - api/config.md + - api/logging.md + - api/ui.md + - api/database.md + - api/cas.md + - api/net.md + - api/time.md + - api/version.md + - api/observability.md + - api/service.md + - api/subprocess.md + - api/utilities.md + - api/errors.md + # The docs are published under appinfra's licence (Apache 2.0), which ships with them + - License: LICENSE diff --git a/overrides/main.html b/overrides/main.html new file mode 100644 index 0000000..1f79940 --- /dev/null +++ b/overrides/main.html @@ -0,0 +1,49 @@ +{#- + The theme's site_nav block (zensical 0.1.2 base.html), with the docs search placed in the + primary sidebar above its scroll container, so it stays put while the tree scrolls. + Re-check against the theme's base.html when upgrading zensical. +-#} +{% extends "base.html" %} + +{% block site_nav %} + {% if nav %} + {% if page.meta and page.meta.hide %} + {% set hidden = "hidden" if "navigation" in page.meta.hide %} + {% endif %} + + {% endif %} + {% if "toc.integrate" not in features %} + {% if page.meta and page.meta.hide %} + {% set hidden = "hidden" if "toc" in page.meta.hide %} + {% endif %} + + {% endif %} +{% endblock %} diff --git a/overrides/partials/footer.html b/overrides/partials/footer.html new file mode 100644 index 0000000..7296ef3 --- /dev/null +++ b/overrides/partials/footer.html @@ -0,0 +1,17 @@ +{#- + The main site's footer (styles.css "footer"): one row, the copyright on the left and text + links on the right. Replaces the theme's footer, with its previous/next band, generator credit + and social icons. Links come from extra.footer_links in zensical.base.toml. +-#} +
+ +
diff --git a/overrides/partials/header.html b/overrides/partials/header.html new file mode 100644 index 0000000..5913f65 --- /dev/null +++ b/overrides/partials/header.html @@ -0,0 +1,27 @@ +{#- The main site's nav and theme switch, unchanged. Narrow screens get a bar for the docs drawer + and search (search-open.js opens it). -#} +
+ + {% include "partials/site-nav.html" %} +
+ + +
+
diff --git a/pages/appinfra/index.md b/pages/appinfra/index.md new file mode 100644 index 0000000..621f7cb --- /dev/null +++ b/pages/appinfra/index.md @@ -0,0 +1,47 @@ +--- +hide: + - toc +--- + +# appinfra + +Production-grade Python infrastructure framework for building reliable CLI tools and services: +configuration, logging, application lifecycle, CLI tools, PostgreSQL and more, with fluent +builder APIs throughout. The other LLM Works packages build on it. +{ .lw-lead } + +
+ +- :lucide-book-open:{ .lw-card-icon } + + **[User guide](user-guide.md)** + + Scope, architecture and the features of each module. + +- :lucide-rocket:{ .lw-card-icon } + + **[Getting started](getting-started.md)** + + Install appinfra and build a first application. + +- :lucide-compass:{ .lw-card-icon } + + **[Guides](guides/configuration-precedence.md)** + + Configuration, logging, testing helpers and the development tooling. + +- :lucide-boxes:{ .lw-card-icon } + + **[Module guides](api/index.md)** + + A tour of each module: what it is for, its main classes and examples. + +- :lucide-braces:{ .lw-card-icon } + + **[API reference](reference/index.md)** + + Every public module, class and function, generated from the source at the release tag. + +
+ +Source: [llm-works/appinfra](https://github.com/llm-works/appinfra) diff --git a/pages/assets/search-open.js b/pages/assets/search-open.js new file mode 100644 index 0000000..0926134 --- /dev/null +++ b/pages/assets/search-open.js @@ -0,0 +1,21 @@ +// Search buttons open the theme's search through its keyboard shortcut (Ctrl+K). +// +// The theme wires its search button once, when the page first loads. The docs search sits in the +// tree's sidebar (overrides/main.html), which instant navigation replaces on every page change, +// so after the first page change the sidebar's button is a fresh, unwired copy and clicking it +// did nothing. The shortcut's handler is global and keeps working across page changes: a click +// on the sidebar's button, or on the search button in the narrow-screen bar, sends it instead. +(function () { + var BUTTONS = ".md-search__button, .lw-docbar__search"; + + document.addEventListener("click", function (e) { + var button = e.target && e.target.closest ? e.target.closest(BUTTONS) : null; + if (!button) return; + // Before the theme's own handler on the first page's button, so search opens once. + e.preventDefault(); + e.stopPropagation(); + document.dispatchEvent(new KeyboardEvent("keydown", { + key: "k", code: "KeyK", ctrlKey: true, bubbles: true, cancelable: true, + })); + }, true); +})(); diff --git a/pages/concepts/architecture.md b/pages/concepts/architecture.md new file mode 100644 index 0000000..9e5fe88 --- /dev/null +++ b/pages/concepts/architecture.md @@ -0,0 +1,5 @@ +# Architecture + +!!! info "Coming soon" + The layers of the stack, from appinfra at the base to llm-gent agents on top, what each + package depends on, and where an application plugs in. diff --git a/pages/concepts/index.md b/pages/concepts/index.md new file mode 100644 index 0000000..a03ffaf --- /dev/null +++ b/pages/concepts/index.md @@ -0,0 +1,18 @@ +--- +hide: + - toc +--- + +# Concepts + +Background that explains the design, for when the how-to guides raise a "why". + +
+ +- :lucide-layers:{ .lw-card-icon } + + **[Architecture](architecture.md)** + + How the five packages depend on and compose with each other. + +
diff --git a/pages/get-started/index.md b/pages/get-started/index.md new file mode 100644 index 0000000..db9eb5f --- /dev/null +++ b/pages/get-started/index.md @@ -0,0 +1,30 @@ +--- +hide: + - toc +--- + +# Get started + +From nothing to a running agent: what the platform is, how to install it, and a first agent. + +
+ +- :lucide-compass:{ .lw-card-icon } + + **[What is LLM Works](what-is-llm-works.md)** + + The five packages and what each one is for. + +- :lucide-terminal:{ .lw-card-icon } + + **[Installation](installation.md)** + + Install the stack, or only the packages you need. + +- :lucide-rocket:{ .lw-card-icon } + + **[Quickstart: your first agent](quickstart.md)** + + Build and run a small agent that uses the whole stack. + +
diff --git a/pages/get-started/installation.md b/pages/get-started/installation.md new file mode 100644 index 0000000..3c22f17 --- /dev/null +++ b/pages/get-started/installation.md @@ -0,0 +1,5 @@ +# Installation + +!!! info "Coming soon" + Python and system requirements, installing the whole stack or single packages, and the + services some packages need, such as PostgreSQL with pgvector for llm-kelt. diff --git a/pages/get-started/quickstart.md b/pages/get-started/quickstart.md new file mode 100644 index 0000000..f06c863 --- /dev/null +++ b/pages/get-started/quickstart.md @@ -0,0 +1,5 @@ +# Quickstart: your first agent + +!!! info "Coming soon" + A step-by-step tutorial from an empty directory to a small working agent built with + llm-infer, llm-saia, llm-kelt and llm-gent. Its code is tested against the released packages. diff --git a/pages/get-started/what-is-llm-works.md b/pages/get-started/what-is-llm-works.md new file mode 100644 index 0000000..319d1ee --- /dev/null +++ b/pages/get-started/what-is-llm-works.md @@ -0,0 +1,5 @@ +# What is LLM Works + +!!! info "Coming soon" + What the platform is for, the five packages and the problem each one solves, and which of + them a project needs. diff --git a/pages/how-to/build-an-agent.md b/pages/how-to/build-an-agent.md new file mode 100644 index 0000000..5950598 --- /dev/null +++ b/pages/how-to/build-an-agent.md @@ -0,0 +1,4 @@ +# Build an agent + +!!! info "Coming soon" + Compose an llm-gent agent from traits, run it standalone, then serve it over HTTP. diff --git a/pages/how-to/configure-and-log.md b/pages/how-to/configure-and-log.md new file mode 100644 index 0000000..b438d6f --- /dev/null +++ b/pages/how-to/configure-and-log.md @@ -0,0 +1,5 @@ +# Configure and log an app + +!!! info "Coming soon" + Build an application with appinfra: config files with environment overrides, structured + logging, and CLI tools. diff --git a/pages/how-to/connect-a-model.md b/pages/how-to/connect-a-model.md new file mode 100644 index 0000000..32148d1 --- /dev/null +++ b/pages/how-to/connect-a-model.md @@ -0,0 +1,5 @@ +# Connect a model + +!!! info "Coming soon" + Configure llm-infer's client for a hosted provider or a local model, with routing and + fallback between them. diff --git a/pages/how-to/index.md b/pages/how-to/index.md new file mode 100644 index 0000000..f96fed9 --- /dev/null +++ b/pages/how-to/index.md @@ -0,0 +1,42 @@ +--- +hide: + - toc +--- + +# How-to guides + +Recipes for one task each, using the packages together. + +
+ +- :lucide-cpu:{ .lw-card-icon } + + **[Connect a model](connect-a-model.md)** + + Call hosted or local models through one client. + +- :lucide-braces:{ .lw-card-icon } + + **[Make typed LLM calls](typed-llm-calls.md)** + + Get typed results instead of free text. + +- :lucide-bot:{ .lw-card-icon } + + **[Build an agent](build-an-agent.md)** + + Compose an agent from traits and run it. + +- :lucide-brain:{ .lw-card-icon } + + **[Add knowledge and memory](knowledge-and-memory.md)** + + Give an agent facts, feedback and retrieval. + +- :lucide-wrench:{ .lw-card-icon } + + **[Configure and log an app](configure-and-log.md)** + + Config files, environment overrides and structured logging. + +
diff --git a/pages/how-to/knowledge-and-memory.md b/pages/how-to/knowledge-and-memory.md new file mode 100644 index 0000000..bab61ba --- /dev/null +++ b/pages/how-to/knowledge-and-memory.md @@ -0,0 +1,5 @@ +# Add knowledge and memory + +!!! info "Coming soon" + Store facts and feedback with llm-kelt, retrieve them into an agent's prompts, and export + them for fine-tuning. diff --git a/pages/how-to/typed-llm-calls.md b/pages/how-to/typed-llm-calls.md new file mode 100644 index 0000000..d1fd193 --- /dev/null +++ b/pages/how-to/typed-llm-calls.md @@ -0,0 +1,5 @@ +# Make typed LLM calls + +!!! info "Coming soon" + Use llm-saia's verbs, such as verify and extract, to get typed results from a model, and + define a verb of your own. diff --git a/pages/index.md b/pages/index.md new file mode 100644 index 0000000..bdb5261 --- /dev/null +++ b/pages/index.md @@ -0,0 +1,76 @@ +--- +hide: + - toc +--- + +# Open-source building blocks for production LLM agents + +LLM Works is a Python platform of five packages: an application foundation, one client for every +model provider, typed LLM calls, a knowledge and learning layer, and an agent framework. Each +works on its own; together they take an agent from a first prototype to a service in production. +{ .lw-lead } + +[Get started →](get-started/index.md){ .lw-cta } +[GitHub →](https://github.com/llm-works){ .lw-link } +{ .lw-actions } + +## Start here + +
+ +- :lucide-rocket:{ .lw-card-icon } + + **[Get started](get-started/index.md)** + + What the platform is, how to install it, and a first agent in a few minutes. + +- :lucide-wrench:{ .lw-card-icon } + + **[How-to guides](how-to/index.md)** + + Task-focused recipes that use the packages together. + +- :lucide-lightbulb:{ .lw-card-icon } + + **[Concepts](concepts/index.md)** + + How the packages fit together, and why they are built the way they are. + +
+ +## Packages + +
+ +- :lucide-layers:{ .lw-card-icon } + + **[appinfra](appinfra/index.md)** + + Application foundation: configuration, logging, CLI tools, services and PostgreSQL. + +- :lucide-cpu:{ .lw-card-icon } + + **[llm-infer](llm-infer/index.md)** + + One client for OpenAI, Anthropic, Google and OpenAI-compatible servers, plus a server for + local models. + +- :lucide-braces:{ .lw-card-icon } + + **[llm-saia](llm-saia/index.md)** + + Typed verbs for LLM calls: verify, critique, extract and more, each with a typed result. + +- :lucide-brain:{ .lw-card-icon } + + **[llm-kelt](llm-kelt/index.md)** + + Knowledge and learning: facts, feedback and retrieval in Postgres, and fine-tuning from them. + +- :lucide-bot:{ .lw-card-icon } + + **[llm-gent](llm-gent/index.md)** + + Agents composed from traits, run standalone or behind an HTTP runtime. + +
diff --git a/pages/llm-gent/index.md b/pages/llm-gent/index.md new file mode 100644 index 0000000..5d94dcb --- /dev/null +++ b/pages/llm-gent/index.md @@ -0,0 +1,9 @@ +# llm-gent + +Composable agent framework: agents are built from traits that provide capabilities such as LLM +access, storage and learning, and run standalone or as services through the HTTP runtime. + +!!! info "Coming soon" + The llm-gent guides and API reference. + +Source: [llm-works/llm-gent](https://github.com/llm-works/llm-gent) diff --git a/pages/llm-infer/index.md b/pages/llm-infer/index.md new file mode 100644 index 0000000..a3412f9 --- /dev/null +++ b/pages/llm-infer/index.md @@ -0,0 +1,10 @@ +# llm-infer + +One client for OpenAI, Anthropic, Google and any OpenAI-compatible server, with routing, +cross-provider fallback, retries and rate limiting; plus `llm-infer serve`, which puts local +models behind one OpenAI-compatible endpoint. + +!!! info "Coming soon" + The llm-infer guides and API reference. + +Source: [llm-works/llm-infer](https://github.com/llm-works/llm-infer) diff --git a/pages/llm-kelt/index.md b/pages/llm-kelt/index.md new file mode 100644 index 0000000..8084c45 --- /dev/null +++ b/pages/llm-kelt/index.md @@ -0,0 +1,10 @@ +# llm-kelt + +Persistent memory and fine-tuning data for LLM applications, backed by Postgres: store facts, +feedback and preferences, retrieve them for prompts and RAG, and train LoRA and DPO adapters +from them. + +!!! info "Coming soon" + The llm-kelt guides and API reference. + +Source: [llm-works/llm-kelt](https://github.com/llm-works/llm-kelt) diff --git a/pages/llm-saia/index.md b/pages/llm-saia/index.md new file mode 100644 index 0000000..c97da07 --- /dev/null +++ b/pages/llm-saia/index.md @@ -0,0 +1,9 @@ +# llm-saia + +Structured verbs for LLM interactions: verify, critique, decompose, extract, synthesize and more, +each returning a typed result instead of free text. + +!!! info "Coming soon" + The llm-saia guides and API reference. + +Source: [llm-works/llm-saia](https://github.com/llm-works/llm-saia) diff --git a/pages/packages/index.md b/pages/packages/index.md new file mode 100644 index 0000000..afbb237 --- /dev/null +++ b/pages/packages/index.md @@ -0,0 +1,44 @@ +--- +hide: + - toc +--- + +# Packages + +Five packages, each usable on its own. Every package section holds that package's full +documentation and its API reference, at its latest release. + +
+ +- :lucide-layers:{ .lw-card-icon } + + **[appinfra](../appinfra/index.md)** + + Application foundation: configuration, logging, CLI tools, services and PostgreSQL. + +- :lucide-cpu:{ .lw-card-icon } + + **[llm-infer](../llm-infer/index.md)** + + One client for OpenAI, Anthropic, Google and OpenAI-compatible servers, plus a server for + local models. + +- :lucide-braces:{ .lw-card-icon } + + **[llm-saia](../llm-saia/index.md)** + + Typed verbs for LLM calls: verify, critique, extract and more, each with a typed result. + +- :lucide-brain:{ .lw-card-icon } + + **[llm-kelt](../llm-kelt/index.md)** + + Knowledge and learning: facts, feedback and retrieval in Postgres, and fine-tuning from them. + +- :lucide-bot:{ .lw-card-icon } + + **[llm-gent](../llm-gent/index.md)** + + Agents composed from traits, run standalone or behind an HTTP runtime. + +
diff --git a/tests/unit/test_docstring_code.py b/tests/unit/test_docstring_code.py new file mode 100644 index 0000000..0ce859d --- /dev/null +++ b/tests/unit/test_docstring_code.py @@ -0,0 +1,96 @@ +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: Copyright 2026 The llm-works-docs Authors + +"""Fencing the indented code blocks that docstrings put under titles like Example:.""" + +from types import SimpleNamespace +from typing import Any, cast + +import pytest + +from docsite.docstring_code import CodeBlocks, fence_code_blocks + + +def _doc(*lines: str) -> str: + return "\n".join(lines) + + +def test_example_block_becomes_a_python_fence() -> None: + """Indented code under Example: keeps its lines, inside a python fence.""" + text = _doc("Summary.", "", "Example:", " app = App()", " # comment", " app.run()") + assert fence_code_blocks(text) == _doc( + "Summary.", + "", + "Example:", + " ```python", + " app = App()", + " # comment", + " app.run()", + " ```", + ) + + +def test_yaml_example_gets_a_yaml_fence() -> None: + """A block that is not Python but looks like YAML is fenced as yaml.""" + text = _doc("Include Example:", " # In config.yaml:", ' db: !include "./db.yaml"') + assert " ```yaml" in fence_code_blocks(text) + + +def test_doctest_is_fenced_as_pycon() -> None: + """A session block, including a bare >>> line, stays together as one code block.""" + text = _doc( + "Example:", " >>> w = Watcher()", " >>>", " >>> # comment", " >>> w.stop()" + ) + out = fence_code_blocks(text) + assert " ```pycon" in out + assert out.count("```") == 2 + + +def test_nested_title_is_fenced_at_its_indent() -> None: + """An Example: inside another section is found, and its block keeps that indent.""" + text = _doc( + "Hyphenated Keys:", + " Text here.", + "", + " Example:", + " YAML: a.b", + " Env: X=1", + ) + out = fence_code_blocks(text) + assert " ```yaml" in out + assert out.endswith(" ```") + + +@pytest.mark.parametrize( + "text", + [ + _doc("Args:", " name: The name.", " size: The size."), + _doc("Examples:", " - Config file not found", " - Invalid YAML"), + _doc("Note:", " Requires watchdog. Install with pip."), + _doc("Example:", " ```python", " x = 1", " ```"), + _doc("Example:"), + _doc( + "This sentence ends with a colon and is much longer than any section title:", + " x = 1", + ), + ], +) +def test_items_prose_and_existing_fences_are_left_alone(text: str) -> None: + """Structured sections, bullet lists, prose, fences and non-titles pass through unchanged.""" + assert fence_code_blocks(text) == text + + +def test_untitled_code_under_a_title_is_fenced_when_it_parses() -> None: + """Under a title without 'example', a block is code only if it reads as Python or YAML.""" + assert "```python" in fence_code_blocks(_doc("Environment Variables:", " INFRA_X=1")) + assert "```text" not in fence_code_blocks(_doc("Format:", " INFRA_
=value")) + + +def test_extension_rewrites_the_object_docstring() -> None: + """The griffe hook replaces the docstring text before it is parsed.""" + obj = SimpleNamespace(docstring=SimpleNamespace(value=_doc("Example:", " x = 1"))) + CodeBlocks().on_instance(obj=cast(Any, obj)) + assert "```python" in obj.docstring.value + no_doc = SimpleNamespace(docstring=None) + CodeBlocks().on_instance(obj=cast(Any, no_doc)) + assert no_doc.docstring is None diff --git a/zensical.base.toml b/zensical.base.toml new file mode 100644 index 0000000..df736e0 --- /dev/null +++ b/zensical.base.toml @@ -0,0 +1,131 @@ +# Zensical base config. `python -m docsite config` writes zensical.toml from this file: each +# package with docs in etc/docsite.yaml has its entry under Packages expanded into its docs tree, +# and project.docs_dir is set to site.docs_dir there. Edit this file, not zensical.toml. + +[project] +site_url = "https://docs.llm-works.ai/" +site_name = "LLM Works Docs" +site_description = "Documentation for the LLM Works open-source platform." +site_dir = "site" +copyright = "© 2026 LLM Works LLC" +# The main site's brand tokens and nav styles first (fetched by docsite), then this site's own +extra_css = ["assets/brand/tokens.css", "assets/brand/nav.css", "assets/extra.css"] +# tree-open.js before tree-scroll.js: it reopens sections in a new tree before that one measures it +extra_javascript = [ + "assets/theme-sync.js", + "assets/search-open.js", + "assets/tree-open.js", + "assets/tree-prev.js", + "assets/tree-scroll.js", + "assets/tree-toggle.js", + "assets/nav-tooltips.js", + "assets/toc-active.js", +] + +nav = [ + { "Home" = "index.md" }, + { "Get started" = [ + "get-started/index.md", + { "What is LLM Works" = "get-started/what-is-llm-works.md" }, + { "Installation" = "get-started/installation.md" }, + { "Quickstart: your first agent" = "get-started/quickstart.md" }, + ] }, + { "How-to guides" = [ + "how-to/index.md", + { "Connect a model" = "how-to/connect-a-model.md" }, + { "Make typed LLM calls" = "how-to/typed-llm-calls.md" }, + { "Build an agent" = "how-to/build-an-agent.md" }, + { "Add knowledge and memory" = "how-to/knowledge-and-memory.md" }, + { "Configure and log an app" = "how-to/configure-and-log.md" }, + ] }, + { "Concepts" = [ + "concepts/index.md", + { "Architecture" = "concepts/architecture.md" }, + ] }, + # The section's own index page first: without one, navigation.indexes takes a package's + # landing page as the section page and drops it from the tree. Then one entry per package, + # by its landing page in pages//index.md. + { "Packages" = [ + "packages/index.md", + { "appinfra" = "appinfra/index.md" }, + { "llm-infer" = "llm-infer/index.md" }, + { "llm-saia" = "llm-saia/index.md" }, + { "llm-kelt" = "llm-kelt/index.md" }, + { "llm-gent" = "llm-gent/index.md" }, + ] }, +] + +[project.theme] +custom_dir = "overrides" +language = "en" +font = false +features = [ + "content.code.copy", + "navigation.indexes", + "navigation.instant", + "navigation.path", + "navigation.top", + "navigation.tracking", + "search.highlight", + "toc.follow", +] + +[[project.theme.palette]] +media = "(prefers-color-scheme: light)" +scheme = "default" +toggle.icon = "lucide/sun" +toggle.name = "Switch to dark mode" + +[[project.theme.palette]] +media = "(prefers-color-scheme: dark)" +scheme = "slate" +toggle.icon = "lucide/moon" +toggle.name = "Switch to light mode" + +# Text links on the right of the footer (overrides/partials/footer.html), the main site's. +# llms.txt is the main site's until this site has its own. +[[project.extra.footer_links]] +name = "llms.txt" +link = "https://www.llm-works.ai/llms.txt" + +[[project.extra.footer_links]] +name = "Terms" +link = "https://www.llm-works.ai/terms/" + +# Generated API reference. `python -m docsite config` adds handlers.python.paths: the checkouts of +# the packages that have a reference. +[project.plugins.mkdocstrings.handlers.python.options] +# Fences the indented example code that docstrings put under titles like "Example:" +extensions = ["docsite/docstring_code.py:CodeBlocks"] +docstring_style = "google" +members_order = "source" +show_submodules = true +show_root_heading = false +show_source = false +show_signature_annotations = true +separate_signature = true +merge_init_into_class = true +heading_level = 2 +show_symbol_type_heading = true +show_symbol_type_toc = true + +[project.markdown_extensions] +# Package docs are written for GitHub: lists may start right after a paragraph, and nested +# items are indented by two spaces. Python-Markdown needs a blank line and four spaces. +mdx_breakless_lists = {} +mdx_truly_sane_lists = { nested_indent = 2, truly_sane = true } +admonition = {} +attr_list = {} +md_in_html = {} +pymdownx.details = {} +pymdownx.highlight.anchor_linenums = true +pymdownx.inlinehilite = {} +pymdownx.superfences = {} +# Icons in pages, e.g. :lucide-rocket: on cards +pymdownx.emoji = { emoji_index = "zensical.extensions.emoji.twemoji", emoji_generator = "zensical.extensions.emoji.to_svg" } + +# Package docs are written for GitHub, so heading anchors follow GitHub's rules +# (e.g. "A — B" becomes #a--b), and their in-page links resolve here too. +[project.markdown_extensions.toc] +permalink = true +slugify = { object = "pymdownx.slugs.slugify", kwds = { case = "lower" } }