$ show openclaw/ask-molty
Ask Molty is a Cloudflare Worker that serves as a documentation agent for OpenClaw. It accepts user questions via a chat API, builds a read-only workspace from pre-indexed documentation, source code, and GitHub issues/PRs, then uses OpenAI's chat models with tool calls (search_workspace, read_workspace, list_workspace, run_shell) to answer grounded in the workspace. The worker handles authentication via OpenClaw ID or GitHub session cookies, serves artifact files (e.g., github-search.jsonl) via a proxy, and includes robust error handling for timeouts, malformed data, and streaming. The codebase is well-structured with separate modules for auth, prompt, retrieval, and types, and includes a comprehensive smoke test suite that mocks network interactions to verify behavior.
The LLM identified 2 files worth highlighting for reuse:
A standalone Node.js script that builds a flat, read-only workspace from a docs mirror, source repository, and Gitcrawl SQLite database. It walks directories, extracts search records, writes JSONL indexes and markdown files, and generates a manifest. The script is parameterized via environment variables, handles large files with byte caps, and produces output suitable for the Worker's retrieval. It demonstrates careful engineering with idempotent file writing, streaming JSONL generation, and robust error handling for missing data.
The core retrieval module that builds the workspace at runtime by fetching indexes from R2 or public URLs, scoring records against the user query, and mounting the best-matching files. It includes functions for text loading with byte caps, JSONL streaming with chunk boundary handling, tokenization, scoring, and deduplication. The module is self-contained, handles timeouts and retries, and can be extracted for use in other RAG systems. It demonstrates non-obvious skill in managing large streams, abort signals, and efficient scoring.