Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/laravel-boost.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@javaabu/onu": patch
"@javaabu/onu-mcp": patch
---

Ship Laravel Boost guidelines and skills in `resources/boost/` (`javaabu-onu`, `javaabu-onu-mcp`), and an `llms.txt` in `@javaabu/onu-mcp`.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ jobs:
run: pnpm build:web
- name: Docs cover every component
run: node scripts/check-docs.mjs
- name: Boost guidelines, skills and llms.txt
run: node scripts/boost.mjs --check
- name: Licences
run: node scripts/check-licenses.mjs
- name: Audit
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ test-results
/packages/onu/docs/
/packages/onu/llms.txt
/packages/onu/llms-full.txt
# Generated by scripts/boost.mjs from plugins/onu/skills/onu/SKILL.md
/packages/onu/resources/boost/skills/
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Onu (`@javaabu/onu`) is Javaabu's React UI library: shadcn/ui (Radix base) and T
| `web` | Docs and demo site: `src/showcase/<group>/<name>.demo.tsx`, `src/pages/<group>/<name>.page.tsx` |
| `docs` | Markdown docs, one page per component (`docs/<group>/<name>.md`) |
| `scripts/llms.mjs` | Builds `llms.txt`, `llms-full.txt` and `docs/*.md` for AI assistants from `docs/` |
| `scripts/boost.mjs` | Copies the plugin skill into the package for Laravel Boost; `--check` checks each package ships its Boost files |
| `e2e`, `figma` | Playwright tests and the Next.js server-rendering fixture (`e2e/nextjs`), Figma plugin |

## Commands
Expand Down
18 changes: 18 additions & 0 deletions docs/guides/ai-assistants.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ Other clients (Cursor's `.cursor/mcp.json`, VS Code's `.vscode/mcp.json`, Claude

Set `ONU_DOCS_DIR` to read the docs from another folder.

# Laravel Boost

In a Laravel app, [Laravel Boost](https://laravel.com/docs/boost) picks Onu up by itself. Both packages ship a Boost guideline and skill in `resources/boost/`, which Boost reads from the npm packages the app depends on directly:

| Package | Guideline | Skill |
| --- | --- | --- |
| `@javaabu/onu` | Use Onu for UI, read `llms.txt`, logical (RTL) utilities | `javaabu-onu`: load the rules, pick components from the index, read each page, check your work |
| `@javaabu/onu-mcp` | Call `onu_get_rules`, then `onu_get_doc` per component | `javaabu-onu-mcp`: when and how to use each MCP tool |

Install the package, then run Boost's installer, and choose the guidelines and skills when it asks:

```bash
npm install @javaabu/onu
php artisan boost:install
```

The guideline goes into the app's `AGENTS.md` / `CLAUDE.md`, and the skill into its skills folder. Run `php artisan boost:update` after upgrading Onu so they match the new version. `@javaabu/onu-mcp` is usually run with `npx`; add it to `devDependencies` too if you want Boost to install its guideline and skill.

# Claude Code plugin

The Onu repository is a Claude Code plugin marketplace. The `onu` plugin adds a skill that tells Claude to load the rules and read each component's page before using it, and sets up the MCP server:
Expand Down
26 changes: 26 additions & 0 deletions packages/onu-mcp/llms.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# @javaabu/onu-mcp

> A Model Context Protocol server that gives AI assistants the docs of Onu (`@javaabu/onu`), Javaabu's React UI library, and the rules for writing Onu code. It reads the docs of the `@javaabu/onu` installed in the project (`node_modules/@javaabu/onu/docs`, looked up from the folder the assistant runs in and its parents), and falls back to the docs it was published with.

Paths are relative to this file. In a project, that's node_modules/@javaabu/onu-mcp/.

## Rules

- Call `onu_get_rules` once before writing Onu code, and follow the rules over habits from other UI kits.
- Search (`onu_search_docs`) or list (`onu_list_components`) before writing a component yourself: Onu probably has it.
- Call `onu_get_doc` for each component before using it. Use the import from the page's first code block and only the props in its Props table.
- Run it with `npx -y @javaabu/onu-mcp` (stdio). `ONU_DOCS_DIR` points it at another docs folder.

## Tools

- `onu_get_rules`: the rules for writing Onu code: setup, imports, forms with Laravel validation, Thaana and RTL, theming, icons, accessibility. Also the resource `onu://rules`.
- `onu_list_components`: every docs page by section, with a one-line description; `section` lists one section.
- `onu_get_doc`: a page as Markdown, by component name (`PasswordInput`), file name or path.
- `onu_search_docs`: searches every page, e.g. `"date range laravel"`; `limit` caps the results.

## Docs

- [README](README.md): tools and setup for Claude Code, Cursor, VS Code and Claude Desktop
- [Boost skill](resources/boost/skills/javaabu-onu-mcp/SKILL.md): how an assistant should use the tools
- [AI assistants](https://github.com/Javaabu/onu/blob/main/docs/guides/ai-assistants.md): every way to give an assistant Onu's docs, including Laravel Boost
- [Onu's llms.txt](https://onu.on-forge.com/llms.txt): the rules and every Onu component, hook and guide
2 changes: 2 additions & 0 deletions packages/onu-mcp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"files": [
"dist",
"data",
"resources",
"llms.txt",
"README.md"
],
"engines": {
Expand Down
10 changes: 10 additions & 0 deletions packages/onu-mcp/resources/boost/guidelines/core.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{--
@javaabu/onu-mcp guidelines for AI code assistants

Maintained by: Javaabu (https://javaabu.com)
--}}

## Onu MCP server (`@javaabu/onu-mcp`)

- This project has the Onu MCP server, which serves the docs of the installed `@javaabu/onu`. When writing UI with Onu, call `onu_get_rules` once, then `onu_get_doc` for each component before using it.
- Always activate the `javaabu-onu-mcp` skill when looking up Onu components or their props.
36 changes: 36 additions & 0 deletions packages/onu-mcp/resources/boost/skills/javaabu-onu-mcp/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: javaabu-onu-mcp
description: Look up Onu (@javaabu/onu) components, props and rules with the Onu MCP server's tools (onu_get_rules, onu_list_components, onu_get_doc, onu_search_docs). Use whenever the project has @javaabu/onu-mcp and the task writes or changes React UI with Onu, or asks which Onu component or prop to use.
license: MIT
metadata:
author: Javaabu
---

# Looking up Onu with the MCP server

`@javaabu/onu-mcp` serves the docs of the `@javaabu/onu` installed in the project, so its answers match that version. Use it instead of guessing props from other UI kits.

## Tools

| Tool | Use it to |
| --------------------- | ------------------------------------------------------------------------------ |
| `onu_get_rules` | Load the rules for writing Onu code. Call it once, before writing any Onu code |
| `onu_list_components` | See every page by section with a one-line description; `section` lists one |
| `onu_search_docs` | Find the component for a need, e.g. `"date range laravel"` or `"thaana input"` |
| `onu_get_doc` | Read a page by component name (`PasswordInput`), file name or path |

The rules are also the resource `onu://rules`.

## How to use them

1. Call `onu_get_rules` and follow the rules over habits from other UI kits.
2. Before writing a component yourself, search (`onu_search_docs`) or list (`onu_list_components`): Onu probably has it.
3. Call `onu_get_doc` for each component before using it. Use the import from the page's first code block and only the props in its **Props** table, and follow its **Accessibility** notes.

## When the tools aren't available

Read the same docs from the package: the rules and the index are in `node_modules/@javaabu/onu/llms.txt`, and each page is at `node_modules/@javaabu/onu/docs/<group>/<name>.md`. The `javaabu-onu` skill (shipped with `@javaabu/onu`) covers writing the code.

## Setup, if the server isn't configured

Claude Code: `claude mcp add --scope project --transport stdio onu -- npx -y @javaabu/onu-mcp`. Other clients: `{ "mcpServers": { "onu": { "command": "npx", "args": ["-y", "@javaabu/onu-mcp"] } } }`. Set `ONU_DOCS_DIR` to read the docs from another folder.
4 changes: 3 additions & 1 deletion packages/onu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"docs",
"llms.txt",
"llms-full.txt",
"resources",
"README.md"
],
"exports": {
Expand Down Expand Up @@ -94,8 +95,9 @@
"./fonts-optional.css": "./src/styles/fonts-optional.css"
},
"scripts": {
"build": "vite build && node scripts/build-types.mjs && pnpm llms",
"build": "vite build && node scripts/build-types.mjs && pnpm llms && pnpm boost",
"llms": "node ../../scripts/llms.mjs --out .",
"boost": "node ../../scripts/boost.mjs",
"build:types": "node scripts/build-types.mjs",
"test": "vitest run",
"test:watch": "vitest",
Expand Down
12 changes: 12 additions & 0 deletions packages/onu/resources/boost/guidelines/core.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{--
@javaabu/onu guidelines for AI code assistants

Maintained by: Javaabu (https://javaabu.com)
--}}

## Onu (`@javaabu/onu`)

- This project builds its React UI with Onu (`@javaabu/onu`), Javaabu's component library on shadcn/ui and Tailwind CSS v4, installed from npm. Don't copy shadcn/ui components into the project or add another UI kit next to it.
- Always activate the `javaabu-onu` skill when adding or changing React pages, forms, tables, layouts or components.
- The rules for writing Onu code, and the docs of the installed version, are in `node_modules/@javaabu/onu/llms.txt`. Read a component's page there before using it, and use only the props it lists.
- Pages run in Dhivehi (right to left): use logical utilities (`ms-`, `pe-`, `start-`, `text-start`), never `left`/`right`.
91 changes: 91 additions & 0 deletions scripts/boost.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/env node
/**
* Laravel Boost (https://laravel.com/docs/boost) reads guidelines and skills from
* resources/boost/ in the npm packages a Laravel app depends on directly, and adds
* them to the app's AGENTS.md / CLAUDE.md and skills folder on `boost:install`.
*
* The Onu skill is written once, for the Claude Code plugin
* (plugins/onu/skills/onu/SKILL.md). This copies it into the package as
* packages/onu/resources/boost/skills/javaabu-onu/SKILL.md (generated, not in git),
* named like the other Javaabu packages' skills.
*
* node scripts/boost.mjs # write the package skill (part of the package build)
* node scripts/boost.mjs --check # fail if a published package doesn't ship its Boost
* # guideline, skill and llms.txt (CI, after the build)
*/
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs"
import path from "node:path"

const root = path.resolve(import.meta.dirname, "..")
const pluginSkill = path.join(root, "plugins/onu/skills/onu/SKILL.md")
const packageSkill = path.join(root, "packages/onu/resources/boost/skills/javaabu-onu/SKILL.md")

/** The plugin skill with Boost's name and the metadata the other Javaabu skills carry. */
function boostSkill() {
const source = readFileSync(pluginSkill, "utf8")
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n/.exec(source)
if (!match || !/^name: onu$/m.test(match[1])) {
throw new Error(`${path.relative(root, pluginSkill)} must start with front matter containing "name: onu".`)
}
const frontMatter = match[1].replace(/^name: onu$/m, "name: javaabu-onu")
const generated =
"<!-- Generated from plugins/onu/skills/onu/SKILL.md by scripts/boost.mjs. Edit that file instead. -->\n"
return `---\n${frontMatter}\nlicense: MIT\nmetadata:\n author: Javaabu\n---\n\n${generated}${source.slice(match[0].length)}`
}

/** Problems with a published package's AI files; an empty list when it ships them all. */
function problems(dir) {
const pkg = JSON.parse(readFileSync(path.join(dir, "package.json"), "utf8"))
if (pkg.private) return []
const found = []
const files = pkg.files ?? []
const shipped = (file) => files.some((entry) => file === entry || file.startsWith(`${entry}/`))
const guideline = "resources/boost/guidelines/core.blade.php"
const skills = path.join(dir, "resources/boost/skills")
const skillFiles = existsSync(skills)
? readdirSync(skills).map((name) => `resources/boost/skills/${name}/SKILL.md`)
: []

for (const file of ["llms.txt", guideline]) {
if (!existsSync(path.join(dir, file))) found.push(`${file} is missing`)
else if (!shipped(file)) found.push(`${file} is not in "files"`)
}
if (!skillFiles.length) found.push("resources/boost/skills/<name>/SKILL.md is missing")
for (const file of skillFiles) {
if (!shipped(file)) found.push(`${file} is not in "files"`)
const name = path.basename(path.dirname(file))
const text = existsSync(path.join(dir, file)) ? readFileSync(path.join(dir, file), "utf8") : ""
if (!new RegExp(`^---\\r?\\nname: ${name}\\r?\\ndescription: .+`, "m").test(text)) {
found.push(`${file} needs front matter starting with "name: ${name}" and a description`)
}
}
// Boost compiles guidelines with Blade: {{ }} and @directives would run instead of showing.
if (existsSync(path.join(dir, guideline))) {
const text = readFileSync(path.join(dir, guideline), "utf8")
.replace(/\{\{--[\s\S]*?--\}\}/g, "")
.replace(/`[^`\n]*`/g, "")
if (/\{\{|\{!!|(^|\s)@(?!javaabu\/)[a-z]+/m.test(text)) {
found.push(`${guideline} has Blade syntax outside backticks`)
}
}
return found.map((problem) => `${pkg.name}: ${problem}`)
}

if (process.argv.includes("--check")) {
const expected = boostSkill()
const all = readdirSync(path.join(root, "packages"), { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.flatMap((entry) => problems(path.join(root, "packages", entry.name)))
if (existsSync(packageSkill) && readFileSync(packageSkill, "utf8") !== expected) {
all.push("@javaabu/onu: the Boost skill differs from plugins/onu/skills/onu/SKILL.md; run node scripts/boost.mjs")
}
if (all.length) {
console.error(all.join("\n"))
process.exit(1)
}
console.log("Every package ships its Boost guideline, skill and llms.txt.")
} else {
mkdirSync(path.dirname(packageSkill), { recursive: true })
writeFileSync(packageSkill, boostSkill())
console.log(`Wrote ${path.relative(root, packageSkill)}`)
}
Loading