Skip to content

Commit 0f6f8dc

Browse files
authored
Merge pull request #41 from nuwa-protocol/dev
Merge Dev into Main
2 parents 984bafa + acedf64 commit 0f6f8dc

File tree

424 files changed

+15152
-11296
lines changed

Some content is hidden

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

424 files changed

+15152
-11296
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,10 @@ playwright-report/
4646
test-results/
4747

4848
# cap
49-
public/caps.json
49+
public/caps.json
50+
51+
# claude
52+
.claude
53+
54+
# cursor
55+
.cursor

CLAUDE.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Package Management & Scripts
6+
7+
This project uses **pnpm** for package management. Common commands:
8+
9+
```bash
10+
# Development
11+
pnpm dev # Start development server
12+
pnpm build # Build for production
13+
pnpm preview # Preview production build
14+
15+
# Code Quality
16+
pnpm lint # Lint with Biome
17+
pnpm lint:fix # Fix linting issues
18+
pnpm format # Check formatting
19+
pnpm format:fix # Fix formatting
20+
pnpm check # Run all checks
21+
pnpm check:fix # Fix all issues
22+
```
23+
24+
**Important**: Always use `pnpm` commands. The project uses Biome (not ESLint/Prettier) for linting and formatting.
25+
26+
## Application Architecture
27+
28+
**Nuwa Client** is a React 19 + TypeScript + Vite application for AI chat with CAP (Conversational AI Programs) creation capabilities, Web3 wallet integration, and decentralized identity.
29+
30+
### Core Technology Stack
31+
32+
- **Frontend**: React 19, TypeScript, Vite, React Router v7
33+
- **Styling**: Tailwind CSS + Radix UI components
34+
- **State**: Zustand with persistence middleware
35+
- **Storage**: Dexie (IndexedDB) for structured data
36+
- **AI**: AI SDK (@ai-sdk/react), OpenRouter, LiteLLM providers
37+
- **Web3**: Reown AppKit, Wagmi, Viem
38+
- **Identity**: @nuwa-ai/identity-kit (decentralized identity)
39+
- **Code Quality**: Biome for linting/formatting
40+
41+
### Feature-Based Architecture
42+
43+
The codebase uses a feature-based structure under `src/features/`:
44+
45+
- **`auth/`** - Authentication and authorization
46+
- **`chat/`** - Core chat functionality with AI models
47+
- **`cap-studio/`** - CAP creation/editing interface (like an IDE)
48+
- **`cap-store/`** - CAP marketplace and discovery
49+
- **`settings/`** - User preferences and configuration
50+
- **`sidebar/`** - Navigation and chat history
51+
- **`wallet/`** - Web3 wallet integration and payments
52+
53+
Each feature follows this structure:
54+
```
55+
feature/
56+
├── components/ # React components
57+
├── hooks/ # Custom React hooks
58+
├── stores.ts # Zustand state stores
59+
├── services.ts # Business logic
60+
├── types.ts # TypeScript definitions
61+
└── utils.ts # Utility functions
62+
```
63+
64+
### Key Architectural Concepts
65+
66+
**CAPs (Conversational AI Programs)**: User-configurable AI assistants with custom prompts, models, and MCP (Model Context Protocol) tool integrations. Users can create, edit, and share CAPs.
67+
68+
**MCP Integration**: The app connects to MCP servers to provide tools and capabilities to AI models. Managed by `GlobalMCPManager` singleton.
69+
70+
**Decentralized Identity**: All user data is scoped to their DID (Decentralized Identifier) for privacy and portability.
71+
72+
**Multi-Layer Storage**:
73+
- Zustand stores (in-memory state)
74+
- localStorage (user preferences)
75+
- IndexedDB via Dexie (structured data: chats, CAPs, settings)
76+
77+
### Core Services
78+
79+
**Global Services** (in `src/shared/services/`):
80+
- **`global-mcp-manager.ts`** - Manages MCP server connections and tool registration
81+
- **`identity-kit.ts`** - Decentralized identity management
82+
- **`mcp-client.ts`** - Model Context Protocol client
83+
- **`authorized-fetch.ts`** - Authenticated HTTP requests
84+
85+
**Key Data Entities**:
86+
- **ChatSession** - Chat conversations with message history
87+
- **Cap** - AI assistant configuration (prompt, model, MCP servers)
88+
- **Settings** - User preferences and app configuration
89+
90+
### UI Components
91+
92+
**Shared Components** (in `src/shared/components/ui/`):
93+
- Based on Radix UI primitives with Tailwind styling
94+
- Do not modify files in `ui/` folder - they are generated components
95+
- For custom components, create in feature-specific `components/` folders
96+
97+
### Development Patterns
98+
99+
**State Management**:
100+
- Use Zustand stores with persistence middleware
101+
- Store files typically export both store and selectors
102+
- User data automatically scoped by DID
103+
104+
**Data Fetching**:
105+
- Use SWR for server state management
106+
- Custom hooks in feature `hooks/` folders
107+
- Services handle business logic and API calls
108+
109+
**Routing**:
110+
- React Router v7 with nested layouts
111+
- Route components in `src/pages/`
112+
- Layout components in `src/layout/`
113+
114+
**Styling**:
115+
- Tailwind CSS with custom design system
116+
- Radix UI for accessible primitives
117+
- Theme support via next-themes
118+
119+
### Important Files
120+
121+
- **`src/main.tsx`** - Application entry point
122+
- **`src/router.tsx`** - Route configuration
123+
- **`src/layout/main-layout.tsx`** - Main application layout
124+
- **`biome.json`** - Biome configuration for linting/formatting
125+
- **`tailwind.config.ts`** - Tailwind CSS configuration
126+
127+
### Development Notes
128+
129+
- The app supports both light and dark themes
130+
- All user interfaces are internationalized (i18n support)
131+
- Web3 functionality uses Reown AppKit for wallet connections
132+
- AI model switching is supported via the model selector
133+
- MCP servers can be dynamically added/removed per CAP

package.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "tsc -b && vite build",
9-
"prebuild": "tsx src/caps/build.ts",
109
"preview": "vite preview",
1110
"lint": "biome lint src/",
1211
"lint:fix": "biome lint --apply src/",
@@ -30,8 +29,9 @@
3029
"@hookform/resolvers": "^5.1.1",
3130
"@lobehub/icons": "^2.9.0",
3231
"@modelcontextprotocol/sdk": "^1.13.2",
33-
"@nuwa-ai/identity-kit": "^0.2.2",
34-
"@nuwa-ai/identity-kit-web": "^0.2.2",
32+
"@nuwa-ai/cap-kit": "^0.3.5",
33+
"@nuwa-ai/identity-kit": "^0.3.4",
34+
"@nuwa-ai/identity-kit-web": "^0.3.5",
3535
"@openrouter/ai-sdk-provider": "^0.7.2",
3636
"@radix-ui/react-accordion": "^1.2.11",
3737
"@radix-ui/react-alert-dialog": "^1.1.14",
@@ -59,11 +59,16 @@
5959
"@radix-ui/react-toggle": "^1.1.9",
6060
"@radix-ui/react-toggle-group": "^1.1.10",
6161
"@radix-ui/react-tooltip": "^1.2.7",
62+
"@reown/appkit": "^1.7.17",
63+
"@reown/appkit-adapter-wagmi": "^1.7.17",
64+
"@reown/appkit-pay": "^1.7.17",
6265
"@rjsf/core": "^5.24.12",
6366
"@rjsf/validator-ajv8": "^5.24.12",
6467
"@tailwindcss/typography": "^0.5.16",
68+
"@tanstack/react-query": "^5.84.1",
6569
"@uiw/react-markdown-preview": "^5.1.4",
6670
"@vercel/functions": "^2.2.2",
71+
"@web3icons/react": "^4.0.19",
6772
"@xenova/transformers": "^2.17.2",
6873
"ai": "^4.3.16",
6974
"class-variance-authority": "^0.7.1",
@@ -113,8 +118,10 @@
113118
"url-metadata": "^5.2.1",
114119
"usehooks-ts": "^3.1.1",
115120
"vaul": "^1.1.2",
121+
"viem": "^2.33.2",
122+
"wagmi": "^2.16.1",
116123
"zod": "^3.25.67",
117-
"zustand": "^5.0.5"
124+
"zustand": "^5.0.7"
118125
},
119126
"devDependencies": {
120127
"@biomejs/biome": "^2.0.5",

0 commit comments

Comments
 (0)