From df3295938b3dde964c9953f9985f7b7498f291f9 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Fri, 13 Mar 2026 05:14:57 +0000
Subject: [PATCH 1/2] Initial plan
From c13a2e684c11b226b771d81a8fdf686d8f4e89b4 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Fri, 13 Mar 2026 05:28:39 +0000
Subject: [PATCH 2/2] Fix CLI: package standalone.html, use directory= instead
of os.chdir, add tests, fix hardcoded URLs
Co-authored-by: pearsonkyle <4556546+pearsonkyle@users.noreply.github.com>
---
README.md | 2 +-
docs/index.html | 2 +-
src/docbuddy/cli.py | 39 +-
src/docbuddy/standalone.html | 765 +++++++++++++++++++++++++++++++++++
tests/test_plugin.py | 93 +++++
5 files changed, 877 insertions(+), 24 deletions(-)
create mode 100644 src/docbuddy/standalone.html
diff --git a/README.md b/README.md
index 50f2a4a..7a223cd 100644
--- a/README.md
+++ b/README.md
@@ -64,7 +64,7 @@ pip install docbuddy
docbuddy
```
-This starts a local server on port **8008** and opens your browser to [http://localhost:8008/docs/index.html](http://localhost:8008/docs/index.html).
+This starts a local server on port **8008** and opens your browser to `http://localhost:8008/standalone.html`.
#### Custom Host/Port
diff --git a/docs/index.html b/docs/index.html
index f7830b6..2665a26 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -448,7 +448,7 @@
π Run Locally with CLI
Click to copy
- Opens at http://localhost:8008/docs/index.html
+ Opens at the address shown in the terminal (default port 8008)
Python Plugin
diff --git a/src/docbuddy/cli.py b/src/docbuddy/cli.py
index ff5e9e5..0cb2f8e 100644
--- a/src/docbuddy/cli.py
+++ b/src/docbuddy/cli.py
@@ -2,11 +2,12 @@
"""CLI entry point for launching DocBuddy standalone webpage."""
import argparse
+import functools
import http.server
-import os
import sys
+import threading
+import time
import webbrowser
-
from importlib.resources import files
@@ -33,36 +34,30 @@ def main():
args = parser.parse_args()
- # Use importlib.resources to find the docs directory
- docbuddy_pkg = files("docbuddy")
-
- # The docs directory is at the project root, one level up from src/docbuddy
- # When installed, it's in site-packages/docbuddy/../..
- docs_path = docbuddy_pkg.parent.parent / "docs"
+ # Locate packaged assets via importlib.resources (works for both editable
+ # and normal pip installs; no os.chdir() needed).
+ pkg_ref = files("docbuddy")
+ standalone_ref = pkg_ref.joinpath("standalone.html")
- if not docs_path.exists():
- print(f"Error: Could not find 'docs' directory at {docs_path}", file=sys.stderr)
+ if not standalone_ref.is_file():
+ print(
+ f"Error: Could not find 'standalone.html' in the docbuddy package ({pkg_ref})",
+ file=sys.stderr,
+ )
sys.exit(1)
- # Serve from the project root (parent of docs) so static files are accessible
- # The index.html uses paths like /src/docbuddy/static/core.js which need the parent
- os.chdir(docs_path.parent)
+ # Serve only the package directory β not the whole repo/site-packages root.
+ pkg_dir = str(pkg_ref)
+ handler = functools.partial(http.server.SimpleHTTPRequestHandler, directory=pkg_dir)
- url = f"http://{args.host}:{args.port}/docs/index.html"
+ url = f"http://{args.host}:{args.port}/standalone.html"
print(f"Serving DocBuddy at {url}")
print("Press Ctrl+C to stop the server")
- # Start HTTP server
- with http.server.HTTPServer(
- (args.host, args.port), http.server.SimpleHTTPRequestHandler
- ) as httpd:
- # Give it a moment for server to fully start before opening browser
- import threading
+ with http.server.HTTPServer((args.host, args.port), handler) as httpd:
def open_browser():
- import time
-
time.sleep(0.5)
webbrowser.open(url)
diff --git a/src/docbuddy/standalone.html b/src/docbuddy/standalone.html
new file mode 100644
index 0000000..07b05db
--- /dev/null
+++ b/src/docbuddy/standalone.html
@@ -0,0 +1,765 @@
+
+
+
+ DocBuddy β AI-Enhanced API Documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
DocBuddy
+
AI-Enhanced API Documentation
+
+ Load any OpenAPI schema and explore it with Chat, Workflow, and Agent
+ assistance β powered by your local LLM.
+
+
+
+
+
+
+
+
+ Enter a direct openapi.json URL, or paste a /docs page URL
+ and DocBuddy will auto-detect the schema.
+