Skip to content

Commit cab6fcc

Browse files
committed
new sample doc site + minor updates
1 parent 6869b42 commit cab6fcc

60 files changed

Lines changed: 6284 additions & 136 deletions

Some content is hidden

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

vitepress-plugin-moss/README.md

Lines changed: 67 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# vitepress-plugin-moss
22

3-
A [VitePress](https://vitepress.dev) plugin that adds [Moss](https://moss.dev) semantic (AI) search to your docs. At build time it reads your Markdown source, chunks it, and uploads it to the Moss cloud. At runtime the search UI downloads the index once and runs all queries locally in the browser — no round-trips on every keystroke.
3+
A [VitePress](https://vitepress.dev) plugin that adds [Moss](https://moss.dev) semantic (AI) search to your docs. At build time it reads your Markdown source, chunks it, and uploads it to the Moss cloud. At runtime the search UI uses a **hot-path**: it queries the cloud immediately so search works from the very first keystroke, while the local model and index download in the background. Once ready, all queries automatically switch to sub-10 ms on-device search — no user action needed.
44

55
---
66

@@ -11,16 +11,16 @@ Build time Runtime (browser)
1111
──────────────────────────────────────────── ──────────────────────────────────────
1212
VitePress calls buildEnd hook User presses Ctrl/⌘+K or /
1313
↓ ↓
14-
mossIndexerPlugin reads siteConfig @inferedge/moss downloads the index
14+
mossIndexerPlugin reads siteConfig Phase 1 — SDK imported, client created
15+
↓ Queries routed to Moss cloud ← hot-path
16+
@moss-tools/md-indexer reads source .md (instant results from first keystroke)
17+
using VitePress's own markdown renderer ↓ (parallel)
18+
(understands includes, extensions, etc.) Phase 2 — model + index download (background)
1519
↓ ↓
16-
@moss-tools/md-indexer reads source .md Queries run locally < 10 ms
17-
using VitePress's own markdown renderer ↓
18-
(understands includes, extensions, etc.) Results navigate via metadata.navigation
19-
↓ (pre-computed URL + anchor per chunk)
20-
Uploads via @inferedge-rest/moss REST client
21-
(deletes old index, then re-uploads chunks)
22-
23-
Index is live on Moss cloud
20+
Uploads via @inferedge-rest/moss REST client Index ready → queries switch to local < 10 ms
21+
(deletes old index, then re-uploads chunks) ↓
22+
↓ Active query re-run with local index
23+
Index is live on Moss cloud (seamless handoff, no user action needed)
2424
```
2525

2626
Two separate npm packages are involved:
@@ -163,46 +163,90 @@ If indexing fails (network error, bad credentials, etc.) the build **does not fa
163163

164164
---
165165

166+
## Creating and Loading Indexes
167+
168+
### Automatic indexing on build
169+
170+
When you run `vitepress build`, the `mossIndexerPlugin` automatically builds and uploads the index to Moss at the end of the build. No extra step is needed — just make sure your credentials are set in environment variables.
171+
172+
### Manual indexing with `index:docs`
173+
174+
The demo site includes a standalone script for building and uploading the index without running a full VitePress build. This is useful when you update documentation content and want to refresh the index quickly.
175+
176+
```bash
177+
# From demo-site/
178+
pnpm index:docs # index the documentation/ folder (default)
179+
pnpm index:docs docs # index the docs/ folder instead
180+
pnpm index:docs documentation --inspect # preview chunks as JSON, no upload
181+
```
182+
183+
The script:
184+
185+
1. Reads all `.md` files and chunks them using `@moss-tools/md-indexer`
186+
2. Filters out chunks with 3 or fewer words (lone headings, empty sections, nav-only content)
187+
3. Uploads the remaining chunks to your Moss index
188+
189+
The `--inspect` flag writes chunks to `.index-preview.json` and exits without uploading — useful for verifying index quality before committing to an upload.
190+
191+
---
192+
166193
## Testing Locally (Demo Site)
167194

168-
The repository includes a ready-to-use demo site in the `demo-site/` folder. This is the best way to test changes to the plugin.
195+
The repository includes a demo site in `demo-site/` with two VitePress sites:
196+
197+
- **`documentation/`** — full Moss SDK docs with Moss search enabled (recommended for testing)
198+
- **`docs/`** — minimal site
169199

170200
### Step 1 — Build the plugin
171201

172-
First, build the plugin from the root directory to generate the `dist` folder.
202+
From the repository root:
173203

174204
```bash
175205
pnpm install
176206
pnpm build
177207
```
178208

179-
### Step 2 — Set up the Demo Site
180-
181-
Navigate to the demo site directory and install its dependencies.
209+
### Step 2 — Set up the demo site
182210

183211
```bash
184212
cd demo-site
185213
pnpm install
186214
```
187215

188-
### Step 3 — Configure and Build
216+
Create a `.env` file with your Moss credentials:
217+
218+
```bash
219+
# demo-site/.env (never commit this file)
220+
MOSS_PROJECT_ID=your_project_id
221+
MOSS_PROJECT_KEY=your_api_key
222+
MOSS_INDEX_NAME=your_index_name
223+
```
224+
225+
### Step 3 — Populate the index
189226

190-
The demo site is already configured to use the local plugin. You just need to add your Moss credentials to `demo-site/docs/.vitepress/config.ts` (or use environment variables).
227+
Before starting the dev server, upload the documentation to your Moss index:
191228

192229
```bash
193-
# From inside demo-site/
194-
npx vitepress build docs
230+
# From demo-site/
231+
pnpm index:docs
195232
```
196233

197-
### Step 4 — Preview
234+
You only need to re-run this when you add or change Markdown content.
198235

199-
Start the preview server to test the search modal.
236+
### Step 4 — Start the dev server
200237

201238
```bash
202-
npx vitepress preview docs
239+
pnpm documentation:dev
203240
```
204241

205-
Open [http://localhost:4173](http://localhost:4173) in your browser and verify the search functionality.
242+
Open [http://localhost:5173](http://localhost:5173) and use `Ctrl/⌘+K` or `/` to test the search modal.
243+
244+
### Production build
245+
246+
```bash
247+
pnpm docs:build # builds docs/ site (also runs pnpm build in plugin root first)
248+
pnpm docs:preview # preview at http://localhost:4173
249+
```
206250

207251
---
208252

vitepress-plugin-moss/Search.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ import SearchButton from './SearchButton.vue';
55
// @ts-ignore — resolved by the virtual module at build time
66
import getMossConfig from 'virtual:moss-config';
77
8-
console.log('[MossSearch] Component loaded');
98
const config = getMossConfig();
10-
console.log('[MossSearch] Config:', config);
119
import InferEdgeLogo from './InferEdgeLogo_Dark_Icon.png';
12-
console.log('[MossSearch] Logo imported:', !!InferEdgeLogo);
13-
1410
1511
const isOpen = ref(false);
1612
const query = ref('');

vitepress-plugin-moss/demo-site/docs/.vitepress/config.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

vitepress-plugin-moss/demo-site/docs/guide.md

Lines changed: 0 additions & 63 deletions
This file was deleted.

vitepress-plugin-moss/demo-site/docs/index.md

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
cache
3+
dist
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { defineConfig } from 'vitepress'
2+
import { mossIndexerPlugin } from 'vitepress-plugin-moss'
3+
import dotenv from 'dotenv'
4+
5+
dotenv.config({ path: '../.env' })
6+
7+
// https://vitepress.dev/reference/site-config
8+
export default defineConfig({
9+
vite: {
10+
plugins: [mossIndexerPlugin()]
11+
},
12+
srcDir: "docs",
13+
14+
title: "Moss SDK Documentation",
15+
description: "Get real-time retrieval inside apps, browsers, and enterprise agents — with centralized management, analytics, and scale built in.",
16+
head: [
17+
['link', { rel: 'icon', href: '/favicon.ico' }]
18+
],
19+
themeConfig: {
20+
search: {
21+
provider: 'moss' as any,
22+
options: {
23+
projectId: process.env.MOSS_PROJECT_ID || 'your-project-id',
24+
projectKey: process.env.MOSS_PROJECT_KEY || 'your-project-key',
25+
indexName: process.env.MOSS_INDEX_NAME || 'moss-sdk-docs',
26+
} as any,
27+
},
28+
// https://vitepress.dev/reference/default-theme-config
29+
nav: [
30+
{ text: 'Moss Portal', link: 'https://usemoss.dev', target: '_blank', rel: 'noopener noreferrer' },
31+
{ text: 'Getting Started', link: '/getting-started' },
32+
{ text: 'JavaScript SDK', link: '/reference/js/README.md' },
33+
{ text: 'Python SDK', link: '/reference/python/README.md' }
34+
],
35+
36+
sidebar: [
37+
{
38+
text: 'Guides',
39+
items: [
40+
{ text: 'Getting Started', link: '/getting-started' }
41+
]
42+
},
43+
{
44+
text: 'SDK References',
45+
items: [
46+
{ text: 'JavaScript SDK Overview', link: '/reference/js/README.md' },
47+
{ text: 'JavaScript API Reference', link: '/reference/js/globals.md' },
48+
{ text: 'Python SDK Overview', link: '/reference/python/README.md' },
49+
{ text: 'Python API Reference', link: '/reference/python/globals.md' },
50+
{ text: 'Samples', link: 'https://github.com/usemoss/moss-samples' }
51+
]
52+
}
53+
],
54+
55+
socialLinks: [
56+
{ icon: 'github', link: 'https://github.com/usemoss/moss-samples' }
57+
]
58+
}
59+
})
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Documentation Maintenance Guide
2+
3+
This guide lives alongside the published site so contributors can regenerate the API reference without exposing internal steps to end users.
4+
5+
## Auto-generated content
6+
7+
The following files are completely generated by tooling and should not be edited manually:
8+
9+
| Path | Source | Command |
10+
| --- | --- | --- |
11+
| `docs/reference/js/**/*` | `javascript/user-facing-sdk/typedoc.json` | `npm run docs` (inside `javascript/user-facing-sdk/`) |
12+
| `docs/reference/python/**/*` | `python/user-facing-sdk/src/inferedge_moss/__init__.pyi` | `python scripts/generate_docs.py` (inside `python/user-facing-sdk/`) |
13+
14+
When these commands run, the contents of those paths are overwritten. Commit the regenerated files after confirming they build.
15+
16+
## Manually maintained content
17+
18+
- `docs/index.md`
19+
- `docs/getting-started.md`
20+
- Navigation and sidebar settings in `.vitepress/config.mts`
21+
22+
Update these pages directly to evolve copy, examples, and site structure.
23+
24+
## Regeneration workflow
25+
26+
1. **JavaScript TypeDoc**
27+
28+
```bash
29+
cd javascript/user-facing-sdk
30+
npm install
31+
npm run docs
32+
```
33+
34+
Output lands in `documentation/docs/reference/js/`. (includes `README.md`, `globals.md`, and subfolders)
35+
36+
2. **Python Griffe-based generator**
37+
38+
```bash
39+
cd python/user-facing-sdk
40+
source moss-env/bin/activate # or your virtualenv
41+
pip install -e ".[dev]" # Ensures griffe is installed
42+
python scripts/generate_docs.py
43+
```
44+
45+
Output lands in `documentation/docs/reference/python/` (includes `globals.md`, `classes/`, `interfaces/`, and `type-aliases/` subdirectories).
46+
47+
3. **Build the site**
48+
49+
```bash
50+
cd documentation
51+
npm install
52+
npm run docs:build
53+
```
54+
55+
Fix any dead-link warnings before committing.
56+
57+
## Tips
58+
59+
- Keep the generated references in sync with SDK releases by running the commands above whenever public APIs change.
60+
- If the output paths need to change, update the configs listed in the table and reflect the new locations here.
61+
- To preview changes locally, run `npm run docs:dev` from the `documentation/` folder.
Binary file not shown.

0 commit comments

Comments
 (0)