Skip to content

Lightpanda: the headless browser designed for AI and automation

docs: generate reference partials with `zig build docs`

Adrià Arrufate5a7d3fab210
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 995ec0f3b..192bd1fdc 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -63,6 +63,15 @@ jobs:
- name: zig build
run: zig build -Dsnapshot_path=../../snapshot.bin -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=fast -Dorderfile=orderfile/lightpanda.ld ${{ matrix.cpu_flag }} ${{ env.VERSION_FLAG }}
+ # Reference partials for the docs site, pulled daily by its
+ # browser-reference workflow. A debug build: the output doesn't depend
+ # on the optimize mode and the self-hosted backend compiles it fastest.
+ - name: docs reference
+ if: matrix.arch == 'x86_64'
+ run: |
+ zig build -Dprebuilt_v8_path=v8/libc_v8.a docs
+ tar -czf lightpanda-docs.tar.gz -C zig-out/docs .
+
- name: Rename binary
run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }}
@@ -89,7 +98,7 @@ jobs:
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
with:
allowUpdates: true
- artifacts: lightpanda-${{ env.ARCH }}-${{ env.OS }},lightpanda-${{ env.ARCH }}-${{ env.OS }}.debug
+ artifacts: lightpanda-${{ env.ARCH }}-${{ env.OS }},lightpanda-${{ env.ARCH }}-${{ env.OS }}.debug${{ matrix.arch == 'x86_64' && ',lightpanda-docs.tar.gz' || '' }}
tag: ${{ env.RELEASE }}
makeLatest: ${{ github.ref_type == 'tag' }}
diff --git a/build.zig b/build.zig
index 5e67e4528..f123a4939 100644
--- a/build.zig
+++ b/build.zig
@@ -204,6 +204,21 @@ pub fn build(b: *Build) !void {
skills_step.dependOn(&install.step);
}
+ {
+ // docs-site reference partials
+ const exe = addExe(b, exe_config, "lightpanda-docs", "docs_check", "src/main_docs.zig");
+
+ const run_cmd = b.addRunArtifact(exe);
+ const out_dir = run_cmd.addOutputDirectoryArg2("docs", .{});
+ const install = b.addInstallDirectory(.{
+ .source_dir = out_dir,
+ .install_dir = .prefix,
+ .install_subdir = "docs",
+ });
+ const docs_step = b.step("docs", "Generate reference partials for the docs site (zig-out/docs/*.mdx)");
+ docs_step.dependOn(&install.step);
+ }
+
{
// test
const tests = b.addTest(.{
diff --git a/src/browser/tools.zig b/src/browser/tools.zig
index 356012346..054cd78e5 100644
--- a/src/browser/tools.zig
+++ b/src/browser/tools.zig
@@ -376,6 +376,50 @@ pub const Tool = enum {
};
}
+ /// Reference-docs section (`zig build docs`). Exhaustive so a new tool
+ /// can't ship undocumented.
+ pub fn group(self: Tool) Group {
+ return switch (self) {
+ .goto, .search => .navigation,
+ .markdown, .html, .screenshot, .tree, .links, .nodeDetails, .findElement, .interactiveElements, .structuredData, .detectForms => .reading,
+ .extract, .evaluate => .extraction,
+ .click, .fill, .scroll, .hover, .press, .selectOption, .setChecked => .interaction,
+ .waitForSelector, .waitForScript, .waitForState => .waiting,
+ .getUrl, .getCookies, .getEnv, .consoleLogs => .state,
+ };
+ }
+
+ pub const Group = enum {
+ navigation,
+ reading,
+ extraction,
+ interaction,
+ waiting,
+ state,
+
+ pub fn title(self: Group) []const u8 {
+ return switch (self) {
+ .navigation => "Navigation and search",
+ .reading => "Reading the page",
+ .extraction => "Data extraction and scripting",
+ .interaction => "Interacting with the page",
+ .waiting => "Waiting",
+ .state => "State and debugging",
+ };
+ }
+
+ pub fn intro(self: Group) []const u8 {
+ return switch (self) {
+ .navigation => "These tools bring a page into the browser.",
+ .reading => "These tools read the loaded page without modifying it.",
+ .extraction => "These tools return structured results from the loaded page.",
+ .interaction => "These tools dispatch real DOM events on the page.",
+ .waiting => "These tools block until the page reaches a condition.",
+ .state => "These tools inspect browser state outside the DOM.",
+ };
+ }
+ };
+
/// Per-tool LLM-facing metadata. Tool identity (name + predicates) lives
/// on the enclosing `Tool` enum; this struct just carries the strings.
pub const Definition = struct {
diff --git a/src/docs.zig b/src/docs.zig
new file mode 100644
index 000000000..552db4cdf
--- /dev/null
+++ b/src/docs.zig
@@ -0,0 +1,412 @@
+// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
+//
+// Francis Bouvier <[email protected]>
+// Pierre Tachoire <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+//! Reference partials for the docs site (lightpanda.io/docs), written by
+//! `zig build docs`. Each is an MDX fragment with no frontmatter that a
+//! handwritten docs page imports, rendered from the registries the runtime
+//! serves (`lp.tools`, the MCP tool list, the REPL slash commands) so the
+//! reference can't drift from the code.
+
+const std = @import("std");
+const lp = @import("lightpanda");
+const Schema = @import("script/Schema.zig");
+const SlashCommand = @import("agent/SlashCommand.zig");
+const mcp_tools = @import("mcp/tools.zig");
+const mcp_resources = @import("mcp/resources.zig");
+const protocol = @import("mcp/protocol.zig");
+
+const Tool = lp.tools.Tool;
+const Writer = std.Io.Writer;
+
+pub const Partial = struct {
+ name: []const u8,
+ write: *const fn (w: *Writer) Writer.Error!void,
+};
+
+pub const partials = [_]Partial{
+ .{ .name = "browser-tools.mdx", .write = writeBrowserTools },
+ .{ .name = "mcp-tools.mdx", .write = writeMcpTools },
+ .{ .name = "agent-commands.mdx", .write = writeAgentCommands },
+};
+
+const banner = "{/* Generated by `zig build docs` from the lightpanda browser source. Do not edit. */}\n\n";
+const browser_tools_page = "/reference/browser-tools";
+
+/// Every browser tool, grouped, with its full description and parameters.
+/// The MCP and agent partials link here instead of repeating it.
+pub fn writeBrowserTools(w: *Writer) Writer.Error!void {
+ try w.writeAll(banner);
+ for (std.enums.values(Tool.Group)) |g| {
+ try w.print("## {s}\n\n{s}\n\n| Tool | Summary |\n|---|---|\n", .{ g.title(), g.intro() });
+ for (std.enums.values(Tool)) |t| {
+ if (t.group() != g) continue;
+ try w.print("| [`{s}`](", .{@tagName(t)});
+ try writeAnchor(w, "", @tagName(t));
+ try w.writeAll(") | ");
+ try writeCell(w, t.definition().summary);
+ try w.writeAll(" |\n");
+ }
+ try w.writeAll("\n");
+
+ for (std.enums.values(Tool)) |t| {
+ if (t.group() != g) continue;
+ const def = t.definition();
+ try w.print("### {s}\n\n", .{@tagName(t)});
+ try writeText(w, def.description);
+ try w.writeAll("\n\n");
+ try writeParams(w, def.input_schema);
+ try writeTraits(w, t);
+ }
+ }
+}
+
+/// The MCP view: titles and hints per browser tool, plus the MCP-only tools
+/// and resources in full.
+pub fn writeMcpTools(w: *Writer) Writer.Error!void {
+ try w.writeAll(banner);
+ const browser_list = mcp_tools.all_tools[0 .. mcp_tools.all_tools.len - mcp_tools.extra_tools.len];
+ for (std.enums.values(Tool.Group)) |g| {
+ try w.print("## {s}\n\n{s}\n\n| Tool | Title | Hints |\n|---|---|---|\n", .{ g.title(), g.intro() });
+ for (std.enums.values(Tool), browser_list) |t, mt| {
+ if (t.group() != g) continue;
+ std.debug.assert(std.mem.eql(u8, @tagName(t), mt.name));
+ try w.print("| [`{s}`](", .{mt.name});
+ try writeAnchor(w, browser_tools_page, mt.name);
+ try w.writeAll(") | ");
+ try writeCell(w, mt.title orelse "");
+ try w.writeAll(" | ");
+ try writeHints(w, mt);
+ try w.writeAll(" |\n");
+ }
+ try w.writeAll("\n");
+ }
+
+ try w.writeAll("## MCP-only tools\n\nThese tools exist only in the MCP server, not in the agent or in scripts.\n\n");
+ for (mcp_tools.extra_tools) |mt| {
+ try w.print("### {s}\n\n", .{mt.name});
+ if (mt.title) |title| {
+ try w.writeAll("**");
+ try writeText(w, title);
+ try w.writeAll(".** ");
+ }
+ try writeText(w, mt.description orelse "");
+ try w.writeAll("\n\n");
+ try writeParams(w, mt.inputSchema);
+ try w.writeAll("Hints: ");
+ try writeHints(w, mt);
+ try w.writeAll("\n\n");
+ }
+
+ try w.writeAll("## Resources\n\nRead with `resources/read`.\n\n| URI | MIME type | Description |\n|---|---|---|\n");
+ for (mcp_resources.resource_list) |r| {
+ try w.print("| `{s}` | `{s}` | ", .{ r.uri, r.mimeType orelse "" });
+ try writeCell(w, r.description orelse r.name);
+ try w.writeAll(" |\n");
+ }
+}
+
+/// The agent REPL's slash commands: meta, LLM-prompt, and one per browser
+/// tool in the `key=value` syntax the REPL parses.
+pub fn writeAgentCommands(w: *Writer) Writer.Error!void {
+ try w.writeAll(banner);
+ try w.writeAll("### Meta commands\n\nThese commands configure the REPL and never reach the model.\n\n| Command | Description |\n|---|---|\n");
+ for (SlashCommand.meta_commands) |m| {
+ try w.print("| `/{s}", .{m.name});
+ if (m.hint.len > 0) {
+ try w.writeAll(" ");
+ try writeCellRaw(w, m.hint);
+ }
+ try w.writeAll("` | ");
+ try writeCell(w, m.description);
+ try w.writeAll(" |\n");
+ }
+
+ try w.writeAll("\n### LLM commands\n\nThese commands send a prebuilt prompt to the model, so they need a provider.\n\n| Command | Description |\n|---|---|\n");
+ for (SlashCommand.llm_commands) |row| {
+ try w.print("| `/{s}` | ", .{row.name});
+ try writeCell(w, row.description);
+ try w.writeAll(" |\n");
+ }
+
+ try w.writeAll("\n### Browser commands\n\nEvery browser tool runs directly as a slash command, with no model call. A lone required argument can be passed positionally; the rest take `key=value` or a JSON object.\n\n| Command | Description |\n|---|---|\n");
+ const schemas = Schema.all();
+ for (std.enums.values(Tool.Group)) |g| {
+ for (schemas) |*s| {
+ if (s.tool.group() != g) continue;
+ try w.print("| [`/{s}", .{s.tool_name});
+ for (s.hints) |h| {
+ try w.writeAll(" ");
+ try writeCellRaw(w, h.fragment);
+ }
+ try w.writeAll("`](");
+ try writeAnchor(w, browser_tools_page, s.tool_name);
+ try w.writeAll(") | ");
+ try writeCell(w, s.summary);
+ try w.writeAll(" |\n");
+ }
+ }
+}
+
+/// An `Argument | Type | Required | Description` table for a JSON Schema
+/// object. Panics on malformed JSON: the schemas are comptime constants.
+fn writeParams(w: *Writer, input_schema: []const u8) Writer.Error!void {
+ var arena: std.heap.ArenaAllocator = .init(std.heap.page_allocator);
+ defer arena.deinit();
+ const schema = std.json.parseFromSliceLeaky(std.json.Value, arena.allocator(), input_schema, .{}) catch |err| {
+ std.debug.panic("invalid tool input schema: {s}", .{@errorName(err)});
+ };
+
+ const props = schema.object.get("properties") orelse return w.writeAll("No arguments.\n\n");
+ if (props.object.count() == 0) return w.writeAll("No arguments.\n\n");
+ const required: []const std.json.Value = if (schema.object.get("required")) |r| r.array.items else &.{};
+
+ try w.writeAll("| Argument | Type | Required | Description |\n|---|---|---|---|\n");
+ var it = props.object.iterator();
+ while (it.next()) |entry| {
+ const name = entry.key_ptr.*;
+ const prop = entry.value_ptr.*.object;
+ try w.print("| `{s}` | ", .{name});
+ try writeType(w, prop);
+ try w.print(" | {s} | ", .{if (isRequired(required, name)) "yes" else "no"});
+
+ var sep: []const u8 = "";
+ if (prop.get("description")) |d| {
+ try writeCell(w, d.string);
+ sep = " ";
+ }
+ if (prop.get("enum")) |values| {
+ try w.print("{s}One of ", .{sep});
+ for (values.array.items, 0..) |v, i| {
+ if (i > 0) try w.writeAll(", ");
+ try w.print("`{s}`", .{v.string});
+ }
+ try w.writeAll(".");
+ sep = " ";
+ }
+ if (prop.get("default")) |d| {
+ try w.print("{s}Defaults to `", .{sep});
+ try std.json.Stringify.value(d, .{}, w);
+ try w.writeAll("`.");
+ sep = " ";
+ }
+ if (prop.get("properties")) |sub| {
+ try w.print("{s}Keys:", .{sep});
+ var sub_it = sub.object.iterator();
+ var first = true;
+ while (sub_it.next()) |s| : (first = false) {
+ try w.print("{s} `{s}`", .{ if (first) "" else ",", s.key_ptr.* });
+ }
+ try w.writeAll(".");
+ }
+ try w.writeAll(" |\n");
+ }
+ try w.writeAll("\n");
+}
+
+/// Nextra slugs headings in lowercase, so `### nodeDetails` is
+/// `#nodedetails`.
+fn writeAnchor(w: *Writer, page: []const u8, name: []const u8) Writer.Error!void {
+ try w.print("{s}#", .{page});
+ for (name) |c| try w.writeByte(std.ascii.toLower(c));
+}
+
+fn writeType(w: *Writer, prop: std.json.ObjectMap) Writer.Error!void {
+ const ty = prop.get("type") orelse return w.writeAll("any");
+ if (std.mem.eql(u8, ty.string, "array")) {
+ const item_ty = if (prop.get("items")) |items| if (items.object.get("type")) |t| t.string else "any" else "any";
+ return w.print("{s}[]", .{item_ty});
+ }
+ try w.writeAll(ty.string);
+}
+
+fn isRequired(required: []const std.json.Value, name: []const u8) bool {
+ for (required) |r| {
+ if (std.mem.eql(u8, r.string, name)) return true;
+ }
+ return false;
+}
+
+fn writeTraits(w: *Writer, t: Tool) Writer.Error!void {
+ const traits = [_]struct { bool, []const u8 }{
+ .{ t.isRecorded(), "Recorded in saved scripts." },
+ .{ t.navigatesToUrl(), "Navigates first when given `url`." },
+ .{ t.reportsPageState(), "Reports the resulting page state (`url`, `httpStatus`, `title`)." },
+ };
+ var first = true;
+ for (traits) |trait| {
+ if (!trait[0]) continue;
+ if (!first) try w.writeAll(" ");
+ try w.writeAll(trait[1]);
+ first = false;
+ }
+ if (!first) try w.writeAll("\n\n");
+}
+
+fn writeHints(w: *Writer, mt: protocol.Tool) Writer.Error!void {
+ const a = mt.annotations orelse protocol.ToolAnnotations{};
+ const hints = [_]struct { bool, []const u8 }{
+ .{ a.readOnlyHint, "read-only" },
+ .{ !a.readOnlyHint and a.destructiveHint, "destructive" },
+ .{ a.idempotentHint, "idempotent" },
+ .{ a.openWorldHint, "open-world" },
+ .{ mt.outputSchema != null, "page state" },
+ };
+ var first = true;
+ for (hints) |hint| {
+ if (!hint[0]) continue;
+ if (!first) try w.writeAll(", ");
+ try w.writeAll(hint[1]);
+ first = false;
+ }
+ if (first) try w.writeAll("—");
+}
+
+/// Prose for MDX: outside code spans, `<` would open JSX and `{` an
+/// expression. Tool descriptions are written for models, so a run of
+/// indented lines after a line ending in `:` is an aligned listing (extract's
+/// value shapes), kept verbatim in a fence instead of reflowing.
+fn writeText(w: *Writer, s: []const u8) Writer.Error!void {
+ var lines = std.mem.splitScalar(u8, s, '\n');
+ var prev: []const u8 = "";
+ var in_fence = false;
+ var first = true;
+ while (lines.next()) |line| : (first = false) {
+ const indented = std.mem.startsWith(u8, line, " ");
+ if (!in_fence and indented and std.mem.endsWith(u8, prev, ":")) {
+ try w.writeAll("\n\n```text");
+ in_fence = true;
+ } else if (in_fence and !indented) {
+ try w.writeAll("\n```\n");
+ in_fence = false;
+ }
+ if (!first) try w.writeAll("\n");
+ if (in_fence) {
+ try w.writeAll(line[2..]);
+ } else {
+ try writeEscaped(w, line, false);
+ }
+ prev = line;
+ }
+ if (in_fence) try w.writeAll("\n```");
+}
+
+/// Like `writeText`, for a GFM table cell: `|` ends the cell even inside a
+/// code span, and a newline ends the row.
+fn writeCell(w: *Writer, s: []const u8) Writer.Error!void {
+ try writeEscaped(w, s, true);
+}
+
+/// A table cell already inside a code span.
+fn writeCellRaw(w: *Writer, s: []const u8) Writer.Error!void {
+ for (s) |c| switch (c) {
+ '|' => try w.writeAll("\\|"),
+ else => try w.writeByte(c),
+ };
+}
+
+fn writeEscaped(w: *Writer, s: []const u8, cell: bool) Writer.Error!void {
+ var i: usize = 0;
+ while (i < s.len) {
+ if (s[i] == '`') {
+ const run_end = std.mem.findNonePos(u8, s, i, "`") orelse s.len;
+ const fence = s[i..run_end];
+ if (std.mem.findPos(u8, s, run_end, fence)) |close| {
+ try w.writeAll(fence);
+ if (cell) {
+ try writeCellRaw(w, s[run_end..close]);
+ } else {
+ try w.writeAll(s[run_end..close]);
+ }
+ try w.writeAll(fence);
+ i = close + fence.len;
+ continue;
+ }
+ try w.writeAll(fence);
+ i = run_end;
+ continue;
+ }
+ switch (s[i]) {
+ '<' => try w.writeAll("&lt;"),
+ '{' => try w.writeAll("\\{"),
+ '}' => try w.writeAll("\\}"),
+ '|' => try w.writeAll(if (cell) "\\|" else "|"),
+ '\n' => try w.writeAll(if (cell) " " else "\n"),
+ else => try w.writeByte(s[i]),
+ }
+ i += 1;
+ }
+}
+
+const testing = std.testing;
+
+fn render(partial: Partial) ![]u8 {
+ var aw: Writer.Allocating = .init(testing.allocator);
+ errdefer aw.deinit();
+ try partial.write(&aw.writer);
+ return aw.toOwnedSlice();
+}
+
+test "docs: browser-tools documents every tool exactly once" {
+ const out = try render(partials[0]);
+ defer testing.allocator.free(out);
+ for (std.enums.values(Tool)) |t| {
+ var buf: [64]u8 = undefined;
+ const heading = try std.mem.print(&buf, "\n### {s}\n", .{@tagName(t)});
+ try testing.expectEqual(1, std.mem.count(u8, out, heading));
+ }
+}
+
+test "docs: mcp-tools lists every MCP tool and resource" {
+ const out = try render(partials[1]);
+ defer testing.allocator.free(out);
+ for (mcp_tools.all_tools) |mt| {
+ var row_buf: [64]u8 = undefined;
+ var heading_buf: [64]u8 = undefined;
+ const row = try std.mem.print(&row_buf, "| [`{s}`]", .{mt.name});
+ const heading = try std.mem.print(&heading_buf, "\n### {s}\n", .{mt.name});
+ try testing.expectEqual(1, std.mem.count(u8, out, row) + std.mem.count(u8, out, heading));
+ }
+ for (mcp_resources.resource_list) |r| {
+ try testing.expect(std.mem.find(u8, out, r.uri) != null);
+ }
+}
+
+test "docs: agent-commands covers every slash command" {
+ const out = try render(partials[2]);
+ defer testing.allocator.free(out);
+ for (SlashCommand.all_names) |name| {
+ var buf: [64]u8 = undefined;
+ const cmd = try std.mem.print(&buf, "`/{s}", .{name});
+ try testing.expect(std.mem.find(u8, out, cmd) != null);
+ }
+ try testing.expect(std.mem.find(u8, out, "[`/goto <url> [timeout=…]") != null);
+}
+
+test "docs: escaping leaves code spans alone" {
+ var aw: Writer.Allocating = .init(testing.allocator);
+ defer aw.deinit();
+ try writeCell(&aw.writer, "a <b> {c} `x|<y>{}` d|e\nf `open");
+ try testing.expectEqualStrings("a &lt;b> \\{c\\} `x\\|<y>{}` d\\|e f `open", aw.written());
+}
+
+test "docs: an indented listing after a colon is fenced" {
+ var aw: Writer.Allocating = .init(testing.allocator);
+ defer aw.deinit();
+ try writeText(&aw.writer, "Shapes:\n \"<sel>\" → text\n {a} → b\nAfter <x>.");
+ try testing.expectEqualStrings("Shapes:\n\n```text\n\"<sel>\" → text\n{a} → b\n```\n\nAfter &lt;x>.", aw.written());
+}
diff --git a/src/lightpanda.zig b/src/lightpanda.zig
index ec45bcc01..819384275 100644
--- a/src/lightpanda.zig
+++ b/src/lightpanda.zig
@@ -71,6 +71,7 @@ const Selector = @import("browser/webapi/selector/Selector.zig");
pub const Agent = @import("agent/Agent.zig");
pub const skill = @import("script/skill.zig");
+pub const docs = @import("docs.zig");
pub const Recorder = @import("script/Recorder.zig");
pub const Runtime = @import("script/Runtime.zig");
pub const Schema = @import("script/Schema.zig");
diff --git a/src/main_docs.zig b/src/main_docs.zig
new file mode 100644
index 000000000..900449c17
--- /dev/null
+++ b/src/main_docs.zig
@@ -0,0 +1,47 @@
+// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
+//
+// Francis Bouvier <[email protected]>
+// Pierre Tachoire <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+//! Writes the docs-site reference partials (`<outdir>/<name>.mdx`), invoked
+//! by `zig build docs`.
+
+const std = @import("std");
+const lp = @import("lightpanda");
+
+pub fn main(init: std.process.Init) !void {
+ // usage: docs <outdir>
+ var args = std.process.Args.Iterator.init(init.minimal.args);
+ _ = args.next(); // executable name
+ const out_path = args.next() orelse {
+ std.debug.print("usage: lightpanda-docs <outdir>\n", .{});
+ return error.MissingArgument;
+ };
+
+ try std.Io.Dir.cwd().createDirPath(lp.io, out_path);
+ var out_dir = try std.Io.Dir.cwd().openDir(lp.io, out_path, .{});
+ defer out_dir.close(lp.io);
+
+ for (lp.docs.partials) |p| {
+ const file = try out_dir.createFile(lp.io, p.name, .{});
+ defer file.close(lp.io);
+
+ var buffer: [4096]u8 = undefined;
+ var writer = file.writer(lp.io, &buffer);
+ try p.write(&writer.interface);
+ try writer.end();
+ }
+}
diff --git a/src/mcp/resources.zig b/src/mcp/resources.zig
index 04fe42190..67046bf02 100644
--- a/src/mcp/resources.zig
+++ b/src/mcp/resources.zig
@@ -6,7 +6,7 @@ const log = lp.log;
const protocol = @import("protocol.zig");
const Server = @import("Server.zig");
-const resource_list = [_]protocol.Resource{
+pub const resource_list = [_]protocol.Resource{
.{
.uri = "mcp://page/html",
.name = "Page HTML",
diff --git a/src/mcp/tools.zig b/src/mcp/tools.zig
index 438e4b679..0b43b75bc 100644
--- a/src/mcp/tools.zig
+++ b/src/mcp/tools.zig
@@ -92,7 +92,8 @@ const session_id_schema = browser_tools.minify(
\\}
);
-const extra_tools = [_]McpTool{
+/// MCP-only tools, absent from the agent and scripts.
+pub const extra_tools = [_]McpTool{
.{
.name = "save",
.title = "Save the session as an agent script",
@@ -123,7 +124,7 @@ const extra_tools = [_]McpTool{
},
};
-const all_tools = browser_tool_list ++ extra_tools;
+pub const all_tools = browser_tool_list ++ extra_tools;
/// Tools that bypass the browser-tool dispatch and have their own handlers.
/// Values are telemetry wire ids, kept clear of `browser_tools.Tool`'s.