comparison .claude/skills/zenbu-hg-web/SKILL.md @ 248:b8b6e726964a

[style] Use Dowa type aliases in C Co-authored-by: Copilot <[email protected]>
author MrJuneJune <me@mrjunejune.com>
date Tue, 04 Aug 2026 02:44:06 -0700
parents
children
comparison
equal deleted inserted replaced
247:70f2a3dafc1c 248:b8b6e726964a
1 ---
2 name: zenbu-hg-web
3 description: Use this skill when changing hg-web, the Mercurial repository browser, including the C API server, hg proxying, React/TypeScript frontend, markdown rendering, graph views, or static asset bundle.
4 ---
5
6 # Hg Web
7
8 Use this skill for `hg-web/`, a GitHub-style Mercurial repository browser backed by a C server and a TypeScript frontend.
9
10 ## Structure
11
12 - `hg-web/main.c`: C server, routes, Mercurial proxy APIs, wire protocol streaming.
13 - `hg-web/src/main.tsx`: frontend entry.
14 - `hg-web/src/components/`: React/TypeScript UI components.
15 - `hg-web/src/index.html`, `index.css`, `base.css`: shell and styles.
16 - `hg-web/BUILD`: Bun bundle, static assets, C server, and release bundle.
17 - `hg-web/deploy.sh`: deployment entry point.
18
19 The server depends on `//seobeo:seobeo`. The frontend bundle includes `markdown_converter:markdown_to_html_wasm` and `third_party/highlight:js`.
20
21 ## Backend model
22
23 The C backend proxies to local `hg serve` at:
24
25 ```c
26 #define HG_SERVE_HOST "127.0.0.1"
27 #define HG_SERVE_PORT "4444"
28 ```
29
30 Public endpoints include:
31
32 - `GET /`
33 - `GET /directories`
34 - `GET /graph`
35 - `GET /api/repo/list?path=...`
36 - `GET /api/repo/file?path=...`
37 - `GET /api/repo/readme?path=...`
38 - `GET /api/graph/:graph_id?...`
39 - `GET /repo` and `POST /repo` streaming Mercurial wire protocol proxy.
40
41 Use `sanitize_path` and `Seobeo_Url_Decode` patterns for any path-derived endpoint. Never pass raw path input to an hg path.
42
43 ## Frontend model
44
45 Prefer editing components under `hg-web/src/components/`. Keep API paths aligned with backend registrations in `main.c`. The frontend should be able to handle:
46
47 - directory listings from `/api/repo/list`,
48 - file contents from `/api/repo/file`,
49 - README markdown rendering through the WASM markdown converter,
50 - syntax highlighting through highlight.js,
51 - graph data via `/api/graph/:graph_id`.
52
53 ## Build
54
55 ```bash
56 bazel build //hg-web:hg_web_server
57 bazel build //hg-web:hg_web_server_bundle
58 ```
59
60 If changing shared networking behavior, also run the relevant seobeo tests.
61
62 ## Safety checklist
63
64 - Prefer Dowa aliases (`uint8`, `uint32`, `boolean`, `TRUE`/`FALSE`) over
65 `<stdint.h>` `_t` types and `<stdbool.h>` `bool` in first-party C.
66 - Preserve binary-safe streaming in `StreamHgWireProtocol`; Mercurial bundle data can contain null bytes.
67 - Do not buffer large wire-protocol responses through the normal HTTP client path unless the task explicitly requires it.
68 - Validate and sanitize all path and graph inputs.
69 - Keep content types accurate: JSON for API listing responses, `text/plain` or source-specific content for file/graph proxy responses, `text/html` for the app shell.
70 - If changing route names, update both backend registrations and frontend fetch/navigation code.