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
42 changes: 24 additions & 18 deletions .claude/skills/api/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ Review the `api/` package for quality, consistency, and every-plugin best practi
```
api/
├── src/
│ ├── contract.ts # oRPC route definitions
│ ├── index.ts # Plugin definition (createPlugin)
│ ├── contract.ts # oRPC route definitions
│ ├── index.ts # Plugin definition (createPlugin)
│ ├── db/
│ │ └── schema.ts # Drizzle ORM schema
│ ├── services/
│ │ └── agent.ts # NEAR AI integration
│ └── store.ts # Database connection
├── plugin.dev.ts # Local dev configuration
│ │ ├── index.ts # Database connection layer
│ │ ├── schema.ts # Drizzle ORM schema
│ │ └── migrations/ # SQL migration files
│ └── services/
│ ├── index.ts # Service exports
│ └── agent.ts # NEAR AI integration
├── plugin.dev.ts # Local dev configuration
├── drizzle.config.ts # Drizzle config
└── package.json
```

Expand All @@ -35,40 +38,43 @@ api/

### 2. Plugin Structure
- [ ] Uses `createPlugin()` from every-plugin
- [ ] Variables and secrets properly typed
- [ ] Context schema defined
- [ ] Initialize/shutdown handlers implemented
- [ ] Variables and secrets properly typed with Zod schemas
- [ ] Context schema defined (nearAccountId, role)
- [ ] Initialize returns `{ db, agentService }`
- [ ] Shutdown handler implemented

### 3. Database Schema
- [ ] Tables defined for core features (conversations, messages, key-value store)
- [ ] Tables defined: `conversation`, `message`, `kvStore`
- [ ] Proper indexes for query performance
- [ ] Relations defined correctly with cascading deletes
- [ ] Timestamps use Date type
- [ ] Per-user isolation via `nearAccountId`

### 4. Services
- [ ] AgentService integrates NEAR AI Cloud
- [ ] AgentService integrates NEAR AI Cloud via OpenAI SDK
- [ ] Streaming chat implementation with async generators
- [ ] Conversation history management (context window)
- [ ] Graceful fallback when API key not configured

### 5. Router Handlers
- [ ] Authentication middleware applied
- [ ] `requireAuth` middleware for protected routes
- [ ] `requireAdmin` middleware for admin routes
- [ ] Proper error handling with ORPCError
- [ ] Input validation via contract
- [ ] Date serialization to ISO strings

### 6. Configuration
- [ ] `plugin.dev.ts` matches production config
- [ ] Secrets loaded from environment
- [ ] Default values are sensible
- [ ] Secrets: `API_DATABASE_URL`, `API_DATABASE_AUTH_TOKEN`, `NEAR_AI_API_KEY`, `NEAR_AI_BASE_URL`
- [ ] Variables: `NEAR_AI_MODEL`, `NEAR_AI_BASE_URL`

## Key Files to Check

1. `src/contract.ts` - API contract definitions
2. `src/index.ts` - Plugin implementation
3. `src/db/schema.ts` - Database tables
4. `src/services/agent.ts` - NEAR AI integration
5. `plugin.dev.ts` - Development configuration
4. `src/db/index.ts` - Database connection
5. `src/services/agent.ts` - NEAR AI integration
6. `plugin.dev.ts` - Development configuration

## Output Format

Expand Down
81 changes: 55 additions & 26 deletions .claude/skills/host/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,62 +13,91 @@ Review the `host/` package for quality, consistency, and Module Federation best

```
host/
├── server.ts # HTTP server entry point
├── server.ts # Entry point
├── bootstrap.ts # Remote host loader
├── src/
│ ├── config.ts # Runtime config loader (bos.config.json)
│ ├── runtime.ts # Plugin initialization
│ ├── routers/ # Route handlers
│ └── auth/ # Better-Auth setup
├── .env.example # Environment template
│ ├── program.ts # Main server program
│ ├── ui.tsx # UI rendering
│ ├── types.ts # Type definitions
│ ├── db/
│ │ └── schema/
│ │ └── auth.ts # Auth schema
│ ├── layers/
│ │ └── index.ts # Effect layers composition
│ ├── lib/
│ │ └── schemas.ts # Shared schemas
│ ├── services/
│ │ ├── auth.ts # Better-Auth setup
│ │ ├── config.ts # Runtime config loader (bos.config.json)
│ │ ├── context.ts # Request context
│ │ ├── database.ts # Database connection
│ │ ├── errors.ts # Error types
│ │ ├── federation.server.ts # UI module loading
│ │ ├── plugins.ts # API plugin loading
│ │ └── router.ts # Router creation
│ └── utils/
│ └── logger.ts # Logging utility
├── migrations/ # Drizzle migrations
├── drizzle.config.ts # Drizzle config
├── rsbuild.config.ts # Build configuration
└── package.json
bos.config.json # Central runtime configuration (root level)
bos.config.json # Central runtime configuration (root level)
```

## Review Checklist

### 1. Server Setup
- [ ] Hono.js configured correctly
- [ ] CORS and security headers
- [ ] Static file serving
- [ ] Hono.js configured correctly in `src/program.ts`
- [ ] CORS configured with `CORS_ORIGIN` or config URLs
- [ ] Health endpoint at `/health`
- [ ] Error handling middleware

### 2. Configuration Loading
- [ ] `bos.config.json` parsed correctly
- [ ] `src/services/config.ts` parses `bos.config.json` correctly
- [ ] Environment-based URL switching (dev/prod)
- [ ] Secret template injection (`{{VAR_NAME}}`)
- [ ] Secret loading from environment variables
- [ ] Variables vs secrets distinction

### 3. Plugin Runtime
- [ ] Uses `createPluginRuntime()` from every-plugin
- [ ] `src/services/plugins.ts` uses every-plugin runtime
- [ ] Secrets extracted from environment
- [ ] Plugin URL resolved correctly
- [ ] Plugin URL resolved from config
- [ ] Error handling for plugin load failures

### 4. Authentication
- [ ] Better-Auth configured
- [ ] NEAR Protocol auth (better-near-auth)
- [ ] `src/services/auth.ts` uses Better-Auth
- [ ] NEAR Protocol auth via better-near-auth
- [ ] Session management
- [ ] Protected routes
- [ ] Auth routes at `/api/auth/*`

### 5. Module Federation
- [ ] UI remote loaded correctly
- [ ] SSR/CSR handling
- [ ] Fallback behavior
- [ ] `src/services/federation.server.ts` loads UI remote
- [ ] SSR rendering via `loadRouterModule`
- [ ] Fallback behavior when module not loaded

### 6. bos.config.json
- [ ] All apps configured (host, ui, api)
- [ ] Development and production URLs
- [ ] API variables include NEAR_AI_MODEL
- [ ] API secrets include all required keys
- [ ] Host secrets include auth secrets

### 7. Effect-TS Architecture
- [ ] Services use Effect Service pattern
- [ ] Layers composed in `src/layers/index.ts`
- [ ] Proper error handling with ConfigError, etc.

## Key Files to Check

1. `server.ts` - Main entry point
2. `src/config.ts` - Configuration loader
3. `src/runtime.ts` - Plugin initialization
4. `src/routers/index.ts` - Route merging
5. `../bos.config.json` - Central config
6. `.env.example` - Required environment variables
1. `server.ts` - Entry point
2. `src/program.ts` - Main server logic
3. `src/services/config.ts` - Configuration loader
4. `src/services/auth.ts` - Authentication setup
5. `src/services/plugins.ts` - Plugin loading
6. `src/services/federation.server.ts` - UI module loading
7. `src/services/router.ts` - Route creation
8. `src/layers/index.ts` - Layer composition
9. `../bos.config.json` - Central config

## Output Format

Expand Down
65 changes: 55 additions & 10 deletions .claude/skills/ui/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,44 @@ Review the `ui/` package for quality, consistency, and best practices.
```
ui/
├── src/
│ ├── components/ # React components (chat)
│ ├── routes/ # TanStack Router file-based routes
│ ├── integrations/ # API client setup
│ └── utils/ # Utilities (orpc client)
├── rsbuild.config.ts # Build configuration
│ ├── router.tsx # Client router
│ ├── router.server.tsx # Server router (SSR)
│ ├── hydrate.tsx # Client hydration entry
│ ├── components/
│ │ ├── index.ts # Public component exports
│ │ ├── chat/ # Chat feature components
│ │ │ ├── chat-input.tsx
│ │ │ ├── chat-message.tsx
│ │ │ └── chat-page.tsx
│ │ ├── kv/ # Key-value editor
│ │ │ └── kv-editor.tsx
│ │ └── ui/ # shadcn/ui primitives
│ ├── hooks/
│ │ ├── index.ts
│ │ └── use-client.ts
│ ├── lib/
│ │ ├── auth-client.ts # better-auth client
│ │ ├── auth-utils.ts # Auth utilities
│ │ ├── session.ts # Session management
│ │ └── utils.ts # General utilities (cn)
│ ├── providers/
│ │ └── index.tsx # Context providers
│ ├── routes/ # TanStack file-based routes
│ │ ├── __root.tsx
│ │ ├── _layout.tsx
│ │ └── _layout/
│ │ ├── _authenticated.tsx
│ │ ├── login.tsx
│ │ └── _authenticated/
│ ├── types/
│ │ └── index.ts
│ ├── utils/
│ │ ├── orpc.ts # oRPC client setup
│ │ └── stream.ts # Streaming utilities
│ └── integrations/
│ └── tanstack-query/
│ └── devtools.tsx
├── rsbuild.config.ts # Build configuration
└── package.json
```

Expand All @@ -29,35 +62,47 @@ ui/
- [ ] Props are properly typed with TypeScript
- [ ] No unused imports or variables
- [ ] Proper error boundaries and loading states
- [ ] Files follow **kebab-case** naming convention

### 2. Route Structure
- [ ] Routes follow TanStack Router conventions
- [ ] Protected routes use `_authenticated` layout
- [ ] Admin routes use `_authenticated/_admin` layout
- [ ] Route components are properly exported

### 3. API Integration
- [ ] Uses oRPC client from `utils/orpc.ts`
- [ ] TanStack Query for data fetching
- [ ] Streaming via `utils/stream.ts`
- [ ] Proper error handling with toast notifications

### 4. Styling
- [ ] Semantic color tokens (not hardcoded colors)
- [ ] Responsive design patterns
- [ ] shadcn/ui components used consistently
- [ ] Tailwind CSS v4 conventions

### 5. Performance
### 5. Module Federation
- [ ] Exports defined in `rsbuild.config.ts`
- [ ] Shared dependencies configured correctly
- [ ] SSR build separate from client build

### 6. Performance
- [ ] Proper use of `useMemo` and `useCallback`
- [ ] No unnecessary re-renders
- [ ] Lazy loading for heavy components

## Key Files to Check

1. `src/routes/_layout/_authenticated/chat/index.tsx` - Main chat page
2. `src/components/chat/ChatPage.tsx` - Chat page component
3. `src/components/chat/ChatInput.tsx` - Chat input component
4. `src/components/chat/ChatMessage.tsx` - Message display
1. `src/router.tsx` - Client router setup
2. `src/router.server.tsx` - SSR router
3. `src/components/index.ts` - Public exports
4. `src/components/chat/chat-page.tsx` - Chat feature
5. `src/utils/orpc.ts` - API client setup
6. `src/utils/stream.ts` - Streaming utilities
7. `src/lib/auth-client.ts` - Auth client
8. `src/routes/_layout/_authenticated.tsx` - Auth guard
9. `rsbuild.config.ts` - Build configuration

## Output Format

Expand Down
12 changes: 8 additions & 4 deletions host/.env.example → .env.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Better Auth
BETTER_AUTH_SECRET=
BETTER_AUTH_URL=http://localhost:3001

# CORS
CORS_ORIGIN=http://localhost:3001,http://localhost:3002
# Host Database
HOST_DATABASE_URL=file:./database.db
HOST_DATABASE_AUTH_TOKEN= # for Turso

# API Plugin Database (path relative to host/)
API_DATABASE_URL=file:../api/api.db
API_DATABASE_AUTH_TOKEN= # for Turso

# Host Database
HOST_DATABASE_URL=file:./database.db
HOST_DATABASE_AUTH_TOKEN= # for Turso

# API Plugin Database (path relative to host/)
API_DATABASE_URL=file:../api/api.db
API_DATABASE_AUTH_TOKEN= # for Turso
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,11 @@ fabric.properties

# near
.near/data
.bos

# db
/**/*.db

.turbo
**/*.sqlite

Loading
Loading