@dogsbay/plugin-ask 0.2.0-beta.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA0FH,MAAM,QAAQ,GAAkD;IAC9D,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,QAAQ;IACrB,KAAK,EAAE,cAAc;IACrB,WAAW,EAAE,iBAAiB;IAC9B,QAAQ,EAAE,cAAc;IACxB,SAAS,EAAE,MAAM;IACjB,cAAc,EAAE,IAAI;IACpB,QAAQ,EAAE,CAAC;IACX,mBAAmB,EAAE,IAAI;IACzB,QAAQ,EAAE,IAAI;IACd,gBAAgB,EAAE,EAAE;CACrB,CAAC;AAEF,MAAM,GAAG,GAAG,qBAAqB,CAAC;AAElC;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/F,MAAM,IAAI,KAAK,CACb,GAAG,GAAG,sFAAsF,QAAQ,CAAC,KAAK,CAAC,GAAG,CAC/G,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,GAAG,KAAgC,CAAC;IAE9C,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAEtD,MAAM,GAAG,GAAuB,EAAE,GAAG,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAEhE,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC5B,IAAI,IAAI,CAAC,IAAI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EAAE,kBAAkB,CAAC,CAAC;IAC1F,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc,EAAE,KAAa;IAC1D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,aAAa,KAAK,8BAA8B,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,UAAU,CAAC,KAAc,EAAE,KAAa;IAC/C,MAAM,CAAC,GAAG,qBAAqB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC9C,IAAI,CAAC;QACH,kCAAkC;QAClC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,aAAa,KAAK,uCAAuC,CAAC,IAAI,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IACzC,OAAO,OAAO,KAAK,CAAC;AACtB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@dogsbay/plugin-ask",
3
+ "version": "0.2.0-beta.101",
4
+ "description": "Floating \"Ask AI\" widget for Dogsbay docs sites — calls a shared AI Search proxy (dogsbay-ask).",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./client": "./dist/client.js",
15
+ "./styles.css": "./src/styles.css"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "src/styles.css",
20
+ "src/client.ts",
21
+ "src/RightRailAsk.astro",
22
+ "skills",
23
+ "README.md"
24
+ ],
25
+ "dependencies": {
26
+ "@dogsbay/types": "0.2.0-beta.101"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "^22.20.1",
30
+ "typescript": "^5.9.3",
31
+ "vitest": "^4.1.10"
32
+ },
33
+ "license": "MIT",
34
+ "keywords": [
35
+ "dogsbay",
36
+ "dogsbay-plugin",
37
+ "documentation",
38
+ "ai-search",
39
+ "rag",
40
+ "ask-ai"
41
+ ],
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "https://github.com/dogsbay/dogsbay.git",
45
+ "directory": "packages/plugin-ask"
46
+ },
47
+ "scripts": {
48
+ "build": "tsc",
49
+ "test": "vitest run",
50
+ "test:watch": "vitest"
51
+ }
52
+ }
@@ -0,0 +1,46 @@
1
+ ---
2
+ name: plugin-ask-config
3
+ description: Configure the @dogsbay/plugin-ask "Ask AI" widget — endpoint, site id, and presentation options — in dogsbay.config.yml. Use when adding or debugging the Ask AI button on a Dogsbay docs site.
4
+ ---
5
+
6
+ # Configuring @dogsbay/plugin-ask
7
+
8
+ `@dogsbay/plugin-ask` adds a floating "Ask AI" button to every page. It sends
9
+ the question to a configured backend and shows the answer, so the docs site
10
+ stays static and holds no secrets.
11
+
12
+ ## Enable it
13
+
14
+ ```yaml
15
+ # dogsbay.config.yml
16
+ plugins:
17
+ - name: "@dogsbay/plugin-ask"
18
+ options:
19
+ endpoint: "https://<your-ask-endpoint>"
20
+ site: "openshift-docs-dogsbay"
21
+ ```
22
+
23
+ - **`endpoint`** (required) — URL of the backend the widget calls.
24
+ - **`site`** (required) — the site id sent with each request so the backend
25
+ knows which corpus to answer from. Conventionally the site's base path /
26
+ GitHub Pages subfolder, e.g. `tigera-dogsbay`. The team operating the backend
27
+ owns the `site` → corpus mapping; use the value they give you.
28
+
29
+ Optional presentation: `mode` (`answer` | `search`), `buttonLabel`, `title`,
30
+ `placeholder`, `position` (`bottom-right` | `bottom-left`).
31
+
32
+ ## When it isn't working
33
+
34
+ 1. **Button not appearing** — confirm the plugin is listed under `plugins:` and
35
+ that `dogsbay site build` ran; the widget mounts via a client module on every
36
+ page.
37
+ 2. **Errors when asking** — confirm `endpoint` is reachable from the browser and
38
+ that `site` matches the value the backend expects.
39
+ 3. **Empty or "I don't know" answers** — the backend's corpus may not be ready;
40
+ check with whoever operates the endpoint.
41
+
42
+ ## Styling
43
+
44
+ Styles use Dogsbay theme tokens (`--color-accent`, `--color-surface`,
45
+ `--radius`, …) with fallbacks, so the widget picks up the site theme. Override
46
+ the `.dba-*` classes in your own CSS to customize further.
@@ -0,0 +1,66 @@
1
+ ---
2
+ /**
3
+ * Docked "Ask AI" panel shell — rendered into DocsLayout's `right-rail` named
4
+ * slot via the plugin's `componentWrappers()` hook (slot "RightRail").
5
+ *
6
+ * This is the SERVER-RENDERED structure only; behaviour (open, submit, stream,
7
+ * Turnstile) is wired by the client module (`client.ts`), which finds this shell
8
+ * by `[data-dba-panel="rail"]`. Presentational config comes from the same
9
+ * generated module the client uses, resolvable in SSR via the CLI's Vite alias.
10
+ *
11
+ * Must render `<slot />` to satisfy the wrapper contract (the inner slot is
12
+ * empty — this is an additive panel, not a content wrapper). Being a real
13
+ * element child also keeps DocsLayout's empty-rail rule
14
+ * (`aside[data-right-rail]:not(:has(*))`) from hiding the rail.
15
+ */
16
+ // @ts-expect-error: virtual module resolved by the Dogsbay Vite alias at build.
17
+ import config from "virtual:dogsbay-plugin-config/@dogsbay/plugin-ask";
18
+
19
+ interface RailConfig {
20
+ title: string;
21
+ placeholder: string;
22
+ conversational?: boolean;
23
+ persistConversation?: boolean;
24
+ turnstileSitekey?: string;
25
+ }
26
+ const cfg = config as RailConfig;
27
+ ---
28
+
29
+ <section class="dba-panel" data-dba-panel="rail" aria-label={cfg.title}>
30
+ <form class="dba-form" data-dba-form>
31
+ <header class="dba-header">
32
+ <h2 class="dba-title">{cfg.title}</h2>
33
+ {cfg.conversational !== false && (
34
+ <button type="button" class="dba-newchat" data-dba-newchat>New chat</button>
35
+ )}
36
+ </header>
37
+ {cfg.conversational !== false && cfg.persistConversation !== false && (
38
+ <label class="dba-remember">
39
+ <input type="checkbox" data-dba-remember />
40
+ Remember conversation
41
+ </label>
42
+ )}
43
+ <div class="dba-thread" data-dba-thread></div>
44
+ <div class="dba-inputrow">
45
+ <input
46
+ class="dba-input"
47
+ type="text"
48
+ autocomplete="off"
49
+ enterkeyhint="search"
50
+ placeholder={cfg.placeholder}
51
+ />
52
+ <button type="submit" class="dba-submit">Ask</button>
53
+ </div>
54
+ {cfg.turnstileSitekey && (
55
+ <div
56
+ class="cf-turnstile dba-turnstile"
57
+ data-sitekey={cfg.turnstileSitekey}
58
+ data-appearance="interaction-only"
59
+ data-callback="__dbaTsCb"
60
+ data-expired-callback="__dbaTsExpired"
61
+ data-error-callback="__dbaTsExpired"
62
+ />
63
+ )}
64
+ </form>
65
+ </section>
66
+ <slot />