Skip to content

Commit 747504c

Browse files
committed
New docs incoming
1 parent fb88fe4 commit 747504c

55 files changed

Lines changed: 10141 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.coderabbit/CODERABBIT.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# CodeRabbit Code Review Context for Degoog
2+
3+
Degoog is a Bun and Hono TypeScript search aggregator created by fccview. It combines server-side search orchestration, a browser UI, extension registries, themes, admin settings, a plugin store, optional Valkey caching, Docker deployment, and tests.
4+
5+
As an AI code reviewer, use the following guidelines to evaluate PRs, generate feedback, and flag regressions.
6+
7+
## Key Review Directives
8+
9+
- **Enforce Standards:** Verify that PRs align with `STANDARDS.md` (located in the root folder). Flag any violations.
10+
- **Protect App Behavior:** Flag any changes that alter existing app behavior unless the PR explicitly notes that the behavior change is intended and approved.
11+
- **Protect Public Contracts:** Ensure public API routes, response shapes, settings keys, environment variables, plugin APIs, extension IDs, theme behavior, and UI expectations remain strictly intact.
12+
- **Scope Checking:** Call out massive rewrites or scope creep. Suggest breaking large, unstructured PRs into smaller, reviewable changes.
13+
- **Test Coverage:** Verify that focused tests have been added or updated for the behavior touched in the PR. Flag missing test coverage for new logic.
14+
- **Reject Style Churn:** Flag and discourage style-only code churn across unrelated files.
15+
- **CSS/SCSS Enforcement:** Check that UI styling is done in modularised `.scss` files. Flag any modifications to standard `.css` files unless the changes are strictly within a `./store` folder.
16+
- **Class Naming:** Ensure new UI elements follow the existing styling patterns and the `degoog-*` class name convention.
17+
18+
## Architecture Context (For validating file placement)
19+
20+
When reviewing, ensure changes are logically placed according to this architecture:
21+
- **Boot/Entry:** Server entrypoint and app boot live around `src/server/index.ts`.
22+
- **Routing:** Hono routes live under `src/server/routes/`.
23+
- **Search Logic:** Core search lives around `src/server/search.ts`. Route-specific handlers are under `src/server/routes/search/` and streaming search is in `src/server/routes/search-stream.ts`.
24+
- **Extensions:** Registries live under `src/server/extensions/` (sharing behavior via `src/server/extensions/registry-factory.ts`). Store install, update, uninstall, and repo handling live under `src/server/extensions/store/`.
25+
- **Utilities:** Server settings, plugin settings, cache, rate limiting, proxy handling, auth helpers, and path helpers live under `src/server/utils/`.
26+
- **Frontend:** Client UI code lives under `src/client/`. Public templates and theme files live under `src/public/`.
27+
- **Testing:** Tests live under `tests/`.
28+
29+
## Important Project Values
30+
31+
- **Strict UI Consistency:** The Front End tech lead is highly particular about UI consistency. Reject PRs that introduce borders, blur, or transparency. Enforce existing styling paradigms strictly.
32+
- **No Developer Comments:** Flag and request the removal of any inline code comments added in the PR. Only the human lead developer is permitted to manually add comments.
33+
- **Code Quality:** Prioritize readability and maintainability over clever, overly terse code in your review suggestions.
34+
- **Backward Compatibility:** Existing users must not be forced to change configuration, URLs, plugins, themes, or workflows due to a PR. Flag any breaking migration impacts immediately.
35+
- **Security vs. Compatibility:** Security fixes are welcome, but scrutinize them heavily for compatibility and migration impact.
36+
- **Extension Trust Model:** Treat installed plugins, themes, engines, and transports as a trusted extension system unless the PR explicitly introduces a stricter user-requested trust model.
37+
38+
## What to Look For During Refactors / Cleanups
39+
40+
Praise or suggest the following improvements during PR reviews:
41+
- **Deduplication:** Look for opportunities to reduce duplicated logic between streaming and non-streaming search, provided the response formats do not change.
42+
- **Cache Integrity:** Verify that cache keys remain complete and behavior-specific.
43+
- **Deterministic IDs:** Ensure extension IDs and settings IDs remain deterministic and backward compatible.
44+
- **Reliable Registries:** Check that registry loading remains deterministic, paying special attention to duplicate triggers, duplicate names, and skip behavior.
45+
- **Data Safety:** Verify that file writes remain atomic for persistent JSON settings or store metadata.
46+
- **Route Consistency:** Ensure route JSON parsing, auth checks, and rate limiting remain consistent across endpoints.
47+
- **Path Safety:** Scrutinize path handling for plugin, theme, proxy, and store assets to prevent directory traversal or unsafe access.
48+
- **Modularization:** Encourage developers moving large modules toward smaller, responsibility-focused modules.
49+
50+
## PR Rejection Criteria (What to Flag Immediately)
51+
52+
Leave blocking review comments if a PR attempts to do any of the following:
53+
- Rewrite the app or replace core architectural decisions.
54+
- Replace Bun or Hono.
55+
- Rename public routes or settings without a clear, approved compatibility strategy.
56+
- Break plugin, theme, engine, transport, or store compatibility.
57+
- Redesign the UI as a byproduct of a cleanup/refactor.
58+
- Change production defaults without explicit approval documented in the PR.

.coderabbit/STANDARDS.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# CodeRabbit PR Review Standards for Degoog
2+
3+
Degoog is a Bun + Hono TypeScript search aggregator. As an AI code reviewer, use these standards to evaluate pull requests, ensuring the project remains maintainable without forcing rewrites or breaking public behavior.
4+
5+
Apply these standards strictly to new code. For existing code, suggest improvements only when the module is already being touched for a feature, bug fix, or security update.
6+
7+
## 1. Core Principles Review
8+
9+
### Directives
10+
- **Protect Contracts:** Flag any unannounced changes to existing APIs, UI contracts, config names, environment variables, plugin/theme/engine interfaces, store layouts, and route behavior. Require a documented migration path or `@deprecated` shim.
11+
- **Scope Control:** Reject massive, style-only rewrites. Praise and encourage small, behavior-preserving changes.
12+
- **Test Enforcement:** Block refactors of routes, search orchestration, persistence, extension loading, security gates, or user settings if they lack tests covering observable behavior.
13+
- **Readability:** Push back on overly clever abstractions. Code must be readable so future contributors can trace route/search/registry behavior easily.
14+
- **Trust Boundaries:** Treat installed extensions/themes as trusted, but rigorously verify that PRs treat their inputs, paths, URLs, rendered HTML, and persisted metadata as untrusted.
15+
16+
## 2. TypeScript Style & Module Boundaries
17+
18+
### What to Look For
19+
- **Strict DTOs:** Verify strict types for data crossing boundaries (client/server, route/orchestration, registry/extensions). Ensure shared shapes use `src/shared` to avoid client/server drift.
20+
- **Return Types:** Flag missing explicit return types on exported functions, route helpers, registry helpers, persistence functions, and security-sensitive utilities.
21+
- **Typing Rules:** Enforce `unknown` at external boundaries (followed by validation/narrowing) over `any`.
22+
- **Naming Conventions:**
23+
- Types/Interfaces: `PascalCase`.
24+
- Constants: `UPPER_SNAKE_CASE`.
25+
- Internal Helpers: Leading underscore `_` only if file-private and matching local convention.
26+
- Verbs: `parse*`, `is*`/`assert*`, `to*`/`from*`, `load*`/`write*`.
27+
- **Function Size:** Suggest splitting functions that exceed ~60 lines or try to handle parsing, validation, persistence, rendering, and logging all at once.
28+
- **Correct Placement:** Ensure changes respect module boundaries (e.g., HTTP concerns in `routes/`, shared logic in `utils/search.ts`, UI orchestration in `client/modules/`).
29+
30+
## 3. Hono Route Standards
31+
32+
### Route PR Checklist
33+
- **Guard Placement:** Verify that rate limiting and auth guards (`guardApiKey`, settings guards) are placed at the *top* of the route handler, before expensive operations.
34+
- **JSON Parsing:** Flag repeated `try/catch` blocks for body parsing; suggest extracting or using existing JSON parser helpers.
35+
- **Error Envelopes:** Ensure JSON routes return consistent `{ error: string }` envelopes and appropriate status codes. Do not allow plain text errors unless the route is a binary/text proxy with an established contract.
36+
- **Separation of Concerns:** Route handlers must focus on HTTP. Suggest moving store mutations, search orchestration, and persistence into helper functions.
37+
- **Default Preservation:** Scrutinize parser refactors to ensure default values (search type, page, lang, streaming toggles) remain intact.
38+
39+
## 4. Extension Registry Standards
40+
41+
### Registry PR Checklist
42+
- **Determinism:** Verify that directory reads/entries are explicitly sorted to guarantee stable load order across restarts.
43+
- **ID Stability:** Enforce canonical ID structures `<folder>-<kind>` (`-engine`, `-slot`, `-command`, `-tab`, etc.). Reject renames of built-in IDs or settings IDs without a valid migration.
44+
- **Duplicate Handling:** Ensure duplicate extension IDs are handled gracefully (logged with context) and do not silently merge unrelated settings.
45+
- **Lifecycle Semantics:** `match() === null` should not log as an error. `onLoad` failures should log context without leaking secrets and safely skip the extension.
46+
- **Immutability:** Ensure callers do not mutate registry-owned arrays (`items()`).
47+
48+
## 5. Store & Installation Standards
49+
50+
### Installation PR Checklist
51+
- **Transparency:** Reject PRs that silently run package manager commands or hide dependency installations.
52+
- **Path Containment:** Scrutinize repository operations. Verify URL scheme validation, git error sanitization, timeouts, and containment checks (reject `..`, absolute child paths, symlink escapes). Never trust repo-provided filenames for writes.
53+
- **Atomic Writes:** Ensure persistence updates for store metadata are atomic (e.g., temp-file creation followed by rename).
54+
- **Concurrency:** Look for locks on store writes, settings writes, and install/uninstall operations to prevent race conditions.
55+
- **ID Preservation:** Ensure installed item IDs and `installedAs` names are preserved across updates unless explicitly changed by the user.
56+
57+
## 6. Search Orchestration Standards
58+
59+
### Search PR Checklist
60+
- **Streaming Parity:** Enforce identical orchestration paths between `/stream` and non-streaming search. Query parsing, engine selection, interceptors, scoring, and cache writes must not be duplicated or drifted.
61+
- **Cache Integrity:** Verify that cache keys include *all* inputs (query, overrides, engine config, page, time, lang, image filters).
62+
- **Interceptor Overrides:** Ensure `searchType`, `lang`, and `timeFilter` overrides from interceptors are correctly applied *before* cache key construction and engine selection.
63+
- **Timeouts/Signals:** Verify that engine fetches receive `AbortSignal` and that streaming stops when the client disconnects.
64+
- **Engine Type Model (CRITICAL):**
65+
- Reject restrictive unions for `EngineSearchType` (it must remain `string`).
66+
- Ensure type arrays (`["web", "karakeep"]`) are supported.
67+
- Verify `resolveTypes` in `engines/registry.ts` is the single source of truth for type resolution.
68+
- Verify `selectActiveEngines` uses unified paths (`getActiveWebEngines` vs `getEnginesForCustomType`). Ensure `includeCustom` is not reintroduced.
69+
70+
## 7. Client UI Standards
71+
72+
### Frontend PR Checklist
73+
- **Layer Separation:** Suggest splitting UI functions that mix parsing, fetching, state updates, and DOM rendering.
74+
- **Selector Stability:** Reject changes to stable DOM IDs, classes (`degoog-*`), and `data-*` attributes. These are public APIs for themes, plugins, and browser extensions.
75+
- **Event Handlers:** Praise/suggest event delegation (`data-action`) over rebinding handlers on every render.
76+
- **DOM Safety:** Strongly flag the use of `innerHTML` unless handling explicitly trusted templates or sanitized HTML. Recommend `textContent` for general data.
77+
- **Accessibility:** Ensure interactive elements are semantic (`<button>`, `<a>`), have `aria-label`s if icon-only, preserve keyboard navigation, and handle loading states visibly.
78+
79+
## 8. Security Standards
80+
81+
### Security PR Checklist
82+
- **SSRF Prevention:** Ensure proxied/fetched URLs strictly allow `http:` and `https:`, re-check protocols after redirects, and use signed proxy URLs for exposed assets.
83+
- **Path Verification:** Assert that all extension/store paths are resolved and checked for containment before reads/writes.
84+
- **Secret Hygiene:** Flag PRs that log settings/admin/search API tokens or nonces. Ensure secret settings are masked in UI/metadata responses.
85+
- **Header Trust:** Do not allow trust of `X-Forwarded-*` headers unless explicit proxy trust settings are enabled.
86+
- **Error Safety:** Ensure error responses do not leak local paths, tokens, repo internals, or stack traces.
87+
88+
## 9. Persistence & Cache Standards
89+
90+
### Persistence PR Checklist
91+
- **JSON Schema:** Ensure JSON persistence logic tolerates missing fields, preserves unknown fields, and recovers safely.
92+
- **Atomicity:** Flag direct overwrites of critical JSON files. Require atomic write patterns (write to temp file -> fsync -> rename).
93+
- **Caching:** Ensure new cache APIs use async `useCache`. Verify cache invalidation clears both local memory and Valkey state. Ensure TTLs rely on safe defaults/env vars.
94+
95+
## 10. Logging & Observability
96+
97+
### Logging PR Checklist
98+
- **Console Usage:** Reject raw `console.*` in server code (except for startup scripts). Enforce the central `logger` utility.
99+
- **Namespaces:** Ensure logs use feature namespaces (e.g., `search`, `store:repo`, `settings`).
100+
- **Telemetry Value:** Ensure logs contain meaningful metrics (query lengths, result counts, timings) and *never* log sensitive payloads, passwords, or tokens.
101+
- **Structured Formats:** Encourage `key=value` paired strings for easier scanning.
102+
103+
## 11. Testing Standards
104+
105+
### Test PR Checklist
106+
- **Coverage:** Reject bug fix PRs that lack regression tests (if testable). Demand tests for route shapes, auth guards, cache keys, and store safety.
107+
- **Isolation:** Verify tests isolate runtime data using env vars/data paths.
108+
- **Mocks:** Ensure network/git mocks are used sparingly and assert the critical commands/options.
109+
- **Determinism:** Flag flaky tests. Inputs must be sorted, time controlled, and external search dependencies mocked or removed.
110+
111+
## 12. Duplication Control
112+
113+
### Refactoring PR Checklist
114+
- **Rule of Two:** Do not praise generic abstractions created for a single call site. Require at least two real use cases before extracting shared helpers.
115+
- **Focus:** Prefer small, narrowly-named helpers over dumping unrelated functions into large utility files.
116+
117+
## 13. Final Approval Gate (Rule of Thumb)
118+
119+
Before approving a PR, verify:
120+
1. Does it preserve user-facing behavior? (Unless explicitly marked as a breaking change).
121+
2. Are compatibility risks for extensions/plugins/themes considered?
122+
3. Are secrets, paths, and HTML boundaries safely handled?
123+
4. Is the PR small enough to review confidently? (If not, suggest splitting it up).

.github/workflows/pages.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Deploy docs to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: pages
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: 20
26+
27+
- name: Build the docs
28+
run: npm run build
29+
30+
- name: Assemble the published site
31+
run: |
32+
mkdir -p _site
33+
rsync -a \
34+
--exclude='.git' \
35+
--exclude='.github' \
36+
--exclude='.gitignore' \
37+
--exclude='_site' \
38+
--exclude='src' \
39+
--exclude='scripts' \
40+
--exclude='assets' \
41+
--exclude='node_modules' \
42+
--exclude='package.json' \
43+
--exclude='package-lock.json' \
44+
--exclude='README.md' \
45+
./ _site/
46+
47+
- uses: actions/upload-pages-artifact@v3
48+
with:
49+
path: _site
50+
51+
deploy:
52+
needs: build
53+
runs-on: ubuntu-latest
54+
environment:
55+
name: github-pages
56+
url: ${{ steps.deployment.outputs.page_url }}
57+
steps:
58+
- id: deployment
59+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
node_modules/
2+
/*.html
3+
/style.css
4+
/docs.js
5+
/docs-ui.js
6+
/search-index.json
7+
/search-index.js
8+
/images/
9+
/fontawesome/
10+
/placeholders/
11+
/_site/
12+
/dist/
13+
.DS_Store

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Official degoog docs
2+
3+
Official docs for the search aggregator [degoog](https://github.io/degoog-org/degoog)
4+
5+
Learn about how everything works here: https://degoog-org.github.io/docs/
6+
7+
## Run
8+
9+
```sh
10+
npm run build
11+
npm run serve
12+
```
13+
14+
The server defaults to `http://127.0.0.1:4173`. Set `PORT=4174 npm run serve` to use another port.
15+
16+
## Editing pages
17+
18+
Add or edit HTML fragments under `src/pages/user/` or `src/pages/developer/`. Keep page chrome, search, sidebar, scripts, and theme controls out of those fragments; the build script adds the shared shell.
19+
20+
When adding a page, add one entry to `src/data/pages.mjs`. The generated cross-document search index uses the combined list, while each generated page renders only the sidebar section for its active docs mode.
21+
22+
Never edit generated root pages by hand. Update `src/pages/`, `src/data/pages.mjs`, or `assets/`, then run `npm run build`.
23+
24+
The build also removes known stale legacy root pages from the previous static docs layout so old generated HTML does not survive a root-served replacement.

assets/docs-ui.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
document.addEventListener("DOMContentLoaded", function () {
2+
var page = window.location.pathname.split("/").pop() || "index.html";
3+
if (!page || page === "") page = "index.html";
4+
document.querySelectorAll(".degoog-docs-nav-item").forEach(function (link) {
5+
if (link.getAttribute("href") === page) {
6+
link.classList.add("degoog-docs-nav-active");
7+
}
8+
});
9+
10+
var burger = document.getElementById("degoog-docs-burger");
11+
var sidebar = document.querySelector(".degoog-docs-sidebar");
12+
var backdrop = document.getElementById("degoog-docs-backdrop");
13+
14+
if (burger && sidebar && backdrop) {
15+
burger.addEventListener("click", function () {
16+
var isOpen = sidebar.classList.toggle("degoog-docs-sidebar-open");
17+
backdrop.style.display = isOpen ? "block" : "none";
18+
});
19+
20+
backdrop.addEventListener("click", function () {
21+
sidebar.classList.remove("degoog-docs-sidebar-open");
22+
backdrop.style.display = "none";
23+
});
24+
}
25+
26+
var themeBtn = document.getElementById("doc-theme-toggle");
27+
if (themeBtn) {
28+
themeBtn.addEventListener("click", function () {
29+
var current = document.documentElement.getAttribute("data-theme");
30+
var next = current === "dark" ? "light" : "dark";
31+
document.documentElement.setAttribute("data-theme", next);
32+
try {
33+
localStorage.setItem("ade:theme", next);
34+
} catch (e) {}
35+
});
36+
}
37+
38+
var modeSwitch = document.querySelector(".doc-mode-switch");
39+
if (modeSwitch) {
40+
modeSwitch.addEventListener("click", function (event) {
41+
var link = event.target.closest("[data-doc-mode]");
42+
if (!link) return;
43+
try {
44+
localStorage.setItem("degoog:docs-mode", link.getAttribute("data-doc-mode"));
45+
} catch (e) {}
46+
});
47+
}
48+
});

0 commit comments

Comments
 (0)