Skip to content

Commit 50d5499

Browse files
hu-qiclaude
andcommitted
feat: 完成行为规范文档实现
- 替换"正在制定中……"占位内容为完整的行为规范文档 - 基于 freeCodeCamp 行为规范和参与者公约 2.0 版 - 包含6大核心条款:法律合规、反骚扰、尊重交流、隐私保护、内容质量、社区参与 - 添加举报渠道和执行机制说明 - 符合项目 MDX 格式和 Bootstrap 样式规范 - 已集成到网站导航系统中 Closes #22 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5fc68ef commit 50d5499

2 files changed

Lines changed: 466 additions & 1 deletion

File tree

CLAUDE.md

Lines changed: 386 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,386 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
**Open Source Bazaar** (开源市集) is an open-source project showcase platform built with Next.js 15, TypeScript, React Bootstrap, and MobX. The platform serves as a comprehensive hub for open-source collaboration, featuring license filtering tools, Wiki knowledge base integration, volunteer showcases, and GitHub repository management.
8+
9+
### Key Features
10+
11+
- **License Filter Tool**: Interactive multi-step license selection process with comprehensive i18n support
12+
- **Wiki Knowledge Base**: Integration with GitHub ContentModel to access policy documents
13+
- **Volunteer Showcase**: GitHub organization contributor displays with OSS Insight widgets
14+
- **Project Repository**: GitHub repository listings and management
15+
- **Multi-language Support**: Full i18n with Chinese (Simplified/Traditional) and English
16+
- **Lark Integration**: Enterprise collaboration platform integration
17+
- **PWA Support**: Progressive Web App capabilities
18+
19+
## Repository Structure
20+
21+
### Important Directories
22+
23+
- **`pages/`** - Next.js pages and API routes
24+
- `index.tsx` - Homepage with animated welcome content
25+
- `license-filter.tsx` - Interactive license selection tool
26+
- `policy/` - Wiki/policy document pages
27+
- `volunteer.tsx` - Contributor showcase
28+
- `project.tsx` - GitHub repository listings
29+
- `api/` - API routes for external integrations
30+
31+
- **`components/`** - Reusable React components with Bootstrap styling
32+
- `Layout/` - Page layout components (PageHead, Navigation, Footer)
33+
- `Git/` - GitHub-related components
34+
- `Navigator/` - Navigation components
35+
- `PageContent/` - Content display components
36+
- `License/` - License filter components
37+
38+
- **`models/`** - MobX stores and data models
39+
- `Base.ts` - Core configuration and client setup
40+
- `Repository.ts` - GitHub repository data models
41+
- `Translation.ts` - i18n translation models
42+
- `Wiki.ts` - Wiki content models
43+
- `System.ts` - System configuration models
44+
45+
- **`translation/`** - i18n language files
46+
- `zh-CN.ts` - Simplified Chinese
47+
- `zh-TW.ts` - Traditional Chinese
48+
- `en-US.ts` - English
49+
50+
- **`styles/`** - CSS and styling files
51+
- **`public/`** - Static assets and PWA manifest
52+
- **`types/`** - TypeScript type definitions
53+
54+
### Configuration Files
55+
56+
- **`package.json`** - Dependencies and scripts
57+
- **`next.config.ts`** - Next.js configuration with MDX, PWA, and proxy rewrites
58+
- **`tsconfig.json`** - TypeScript configuration
59+
- **`eslint.config.ts`** - ESLint configuration with spell checking
60+
- **`babel.config.js`** - Babel configuration for decorators
61+
- **`.github/copilot-instructions.md`** - Detailed development guidelines
62+
63+
## Technology Stack
64+
65+
### Core Technologies
66+
67+
- **Next.js 15** - React framework with App Router
68+
- **TypeScript 5.9** - Type-safe JavaScript
69+
- **React 19.1** - UI library with hooks
70+
- **React Bootstrap 2.10** - UI component library
71+
- **MobX 6.13** - State management
72+
- **PNPM** - Package manager
73+
74+
### Key Dependencies
75+
76+
- **MobX Ecosystem**:
77+
- `mobx-github` - GitHub API integration
78+
- `mobx-i18n` - Internationalization
79+
- `mobx-restful` - RESTful API client
80+
- `mobx-restful-table` - Data table components
81+
- `mobx-lark` - Lark integration
82+
- `mobx-react` - React bindings
83+
84+
- **Content Processing**:
85+
- `@mdx-js/react` - MDX support
86+
- `marked` - Markdown processing
87+
- `yaml` - YAML front-matter processing
88+
89+
- **Development Tools**:
90+
- `eslint` - Code linting
91+
- `prettier` - Code formatting
92+
- `husky` - Git hooks
93+
- `lint-staged` - Pre-commit linting
94+
95+
- **Utilities**:
96+
- `web-utility` - Web utility functions
97+
- `license-filter` - License filtering logic
98+
- `koajax` - HTTP client
99+
- `idea-react` - React utilities
100+
101+
## Development Environment
102+
103+
### Critical Requirements
104+
105+
⚠️ **MANDATORY NODE.JS VERSION**: This project requires **Node.js >=20**
106+
107+
- Check Node.js version: `node --version`
108+
- Development and linting commands work on Node.js 20+
109+
- Use **PNPM** as package manager, not NPM or Yarn
110+
111+
### Initial Setup
112+
113+
1. **Install global pnpm**: `npm install -g pnpm`
114+
2. **Install dependencies**: `pnpm install` -- takes 1-3 minutes. NEVER CANCEL
115+
3. **Verify setup**: `pnpm --version` (should be 10.x+)
116+
117+
**Important**: If you see "node_modules missing" error, you MUST run `pnpm install` first before any other commands.
118+
119+
### Development Workflow
120+
121+
```bash
122+
# Development
123+
pnpm dev # Start development server (5-15s) on http://localhost:3000
124+
pnpm build # Production build (30s-2min)
125+
pnpm start # Start production server
126+
127+
# Code Quality
128+
pnpm lint # Run ESLint with auto-fix (15s)
129+
pnpm test # Run tests (lint-staged + lint, 15s)
130+
131+
# Git Hooks
132+
pnpm prepare # Install husky hooks
133+
```
134+
135+
## Development Standards
136+
137+
### Architecture and Code Organization
138+
139+
#### Component Standards
140+
141+
- **ALWAYS use React Bootstrap components** instead of custom HTML elements
142+
- Use utilities from established libraries: 'web-utility'
143+
- Import `'./Base'` in model files for proper configuration
144+
- Use semantic HTML structure: `<article>`, `<header>`, `<section>`
145+
146+
#### Import Patterns
147+
148+
```typescript
149+
// ✅ Correct - use React Bootstrap components
150+
import { Button, Badge, Breadcrumb, Card, Container } from 'react-bootstrap';
151+
152+
// ✅ Correct - import from established sources
153+
import { ContentModel } from 'mobx-github';
154+
import { githubClient } from 'mobx-github';
155+
import { treeFrom } from 'web-utility';
156+
import './Base'; // For GitHub client setup
157+
158+
// ❌ Wrong - custom HTML elements
159+
<a href={url} className="btn btn-outline-primary">Edit</a>
160+
<span className="badge bg-secondary">{label}</span>
161+
```
162+
163+
#### Error Handling
164+
165+
- **Natural error throwing** for static generation - let errors bubble up to catch build issues
166+
- Ensure build passes before pushing - resolve issues at compile time
167+
168+
### Translation and Internationalization
169+
170+
#### Critical Requirements
171+
172+
- **ALL user-facing text** MUST be translated using i18n system
173+
- Use the `t()` function from I18nContext for all translations
174+
- This includes button text, labels, error messages, placeholder text, and dynamic content
175+
176+
#### Translation Patterns
177+
178+
```typescript
179+
// ✅ Correct - use translation function
180+
<Button variant="outline-primary" size="sm">
181+
{t('edit_on_github')}
182+
</Button>
183+
184+
// ❌ Wrong - hardcoded text
185+
<Button variant="outline-primary" size="sm">
186+
Edit on GitHub
187+
</Button>
188+
```
189+
190+
#### Translation Key Management
191+
192+
- Use generic terms unless specifically scoped: `t('knowledge_base')` not `t('policy_documents')`
193+
- Add translation keys to ALL language files: `zh-CN.ts`, `en-US.ts`, `zh-TW.ts`
194+
- Remove unused translation keys when replacing with generic ones
195+
196+
### Data Modeling and GitHub Integration
197+
198+
#### Content Model Patterns
199+
200+
- Use ContentModel with configured client from mobx-github
201+
- Import configuration via `'./Base'` to ensure proper GitHub client setup
202+
- Handle Base64 content decoding when processing GitHub API responses
203+
204+
#### GitHub API Usage
205+
206+
```typescript
207+
// ✅ Correct - use configured client
208+
import { githubClient } from './models/Base';
209+
210+
// ❌ Wrong - create separate instances
211+
const client = new GitHubClient();
212+
```
213+
214+
#### Authentication and Rate Limiting
215+
216+
- GitHub API authentication is configured in `models/Base.ts`
217+
- Use the configured client to avoid rate limiting and authentication issues
218+
- Don't create separate GitHub API instances
219+
220+
### Code Quality Standards
221+
222+
#### Modern ECMAScript Features
223+
224+
- Use optional chaining and modern JavaScript features
225+
- Let TypeScript infer types when possible to avoid verbose annotations
226+
- Use modern ECMAScript patterns for cleaner, more maintainable code
227+
228+
#### Import and Type Management
229+
230+
- Import from established sources: ContentModel from mobx-github, utilities from web-utility
231+
- Import configuration files where needed: `'./Base'` for GitHub client setup
232+
- Use minimal exports and avoid unnecessary custom implementations
233+
234+
### Build and Development Process
235+
236+
#### Pre-commit Standards
237+
238+
1. **Run linting**: `pnpm lint` to auto-fix formatting
239+
2. **Check build**: Ensure `pnpm build` passes
240+
3. **Validate translations**: Verify all text is properly translated
241+
4. **Remove unused code**: Clean up unused imports and translation keys
242+
243+
#### Testing Requirements
244+
245+
After making ANY changes, ALWAYS validate by running through these scenarios:
246+
247+
1. **Start development server**: `pnpm dev` and verify it starts without errors
248+
2. **Navigate to homepage**: Visit http://localhost:3000 and verify page loads
249+
3. **Test core pages**:
250+
- License filter: http://localhost:3000/license-filter
251+
- Wiki pages: http://localhost:3000/policy
252+
- Volunteer page: http://localhost:3000/volunteer
253+
- Projects: http://localhost:3000/project
254+
4. **Test API endpoints**: Verify GitHub API integrations work
255+
5. **Check responsive design**: Test mobile/desktop layouts
256+
6. **Verify i18n functionality**: Check language switching works
257+
258+
## Project-Specific Patterns
259+
260+
### Wiki System Architecture
261+
262+
- Uses GitHub ContentModel to access policy documents from `fpsig/open-source-policy` repository
263+
- Renders markdown content with front-matter metadata
264+
- Supports hierarchical document structure with breadcrumb navigation
265+
- Uses `treeFrom` utility from web-utility for hierarchical data structures
266+
267+
### License Filter Integration
268+
269+
- Interactive multi-step license selection process
270+
- Uses `license-filter` package for license recommendation logic
271+
- Supports multiple languages with comprehensive i18n coverage
272+
- Complex state management with MobX stores
273+
274+
### Volunteer Management
275+
276+
- Displays GitHub organization contributors
277+
- Integrates with OSS Insight widgets for contributor analytics
278+
- Uses GitHub API for real-time contributor data
279+
- Features contributor cards with activity metrics
280+
281+
### Proxy Configuration
282+
283+
The project includes proxy rewrites for external services:
284+
- GitHub API and raw content
285+
- Alibaba Geo Data services
286+
- Lark API integration
287+
288+
## Common Issues and Solutions
289+
290+
### Build and Development Issues
291+
292+
- **"Unsupported engine" warnings**: Expected on Node.js <22, development still works
293+
- **Build hangs**: Never cancel builds - they may take several minutes, set appropriate timeouts
294+
- **Missing dependencies**: Always run `pnpm install` first
295+
296+
### Component and Styling Issues
297+
298+
- **Custom HTML not working**: Replace with React Bootstrap components
299+
- **Translation not showing**: Ensure all text uses `t()` function and keys exist in all language files
300+
- **GitHub API errors**: Verify you're using configured `githubClient` from `models/Base.ts`
301+
302+
### Data and Content Issues
303+
304+
- **Base64 content errors**: Use `atob(item.content)` to decode GitHub API responses
305+
- **Missing content**: Check ContentModel configuration and repository access
306+
- **Tree structure problems**: Use `treeFrom()` utility from web-utility
307+
308+
### Development Environment Setup
309+
310+
- Clear browser cache if components don't render properly
311+
- Restart development server after major configuration changes
312+
- Verify all translation files are updated when adding new keys
313+
314+
## Deployment and CI/CD
315+
316+
### Vercel Deployment
317+
318+
- Project is configured for Vercel deployment
319+
- Uses GitHub Actions for CI/CD pipeline
320+
- PWA support enabled for offline functionality
321+
322+
### Environment Variables
323+
324+
- `NODE_ENV` - Environment detection
325+
- `CI` - Continuous integration flag
326+
- `GithubToken` - GitHub API authentication
327+
- `API_Host` - Backend API host
328+
- `LARK_API_HOST` - Lark API host
329+
330+
## Contributing Guidelines
331+
332+
### Code Review Process
333+
334+
- **Follow exact code suggestions** from reviews when provided
335+
- Use **minimal approach** - only include explicitly requested functionality
336+
- **Don't add extra features** not specified in requirements
337+
- **Address reviewer feedback completely** before requesting re-review
338+
339+
### Pull Request Template
340+
341+
```markdown
342+
Checklist(清单):
343+
344+
- [ ] Labels
345+
- [ ] Assignees
346+
- [ ] Reviewers
347+
348+
Closes #XXXXX
349+
```
350+
351+
### Quality Gates
352+
353+
- [ ] All tests pass
354+
- [ ] Code follows project conventions
355+
- [ ] No linting errors
356+
- [ ] Build succeeds
357+
- [ ] Translations are complete
358+
- [ ] Responsive design verified
359+
- [ ] API integrations working
360+
361+
## Resources and Documentation
362+
363+
### Internal Resources
364+
365+
- **`.github/copilot-instructions.md`** - Detailed development guidelines
366+
- **`README.md`** - Project overview and quick start
367+
- **`package.json`** - Complete dependency list
368+
- **Translation files** - All supported languages and keys
369+
370+
### External Dependencies
371+
372+
- [Next.js Documentation](https://nextjs.org/)
373+
- [React Bootstrap Documentation](https://react-bootstrap.github.io/)
374+
- [MobX Documentation](https://mobx.js.org/)
375+
- [TypeScript Documentation](https://www.typescriptlang.org/)
376+
- [PNPM Documentation](https://pnpm.io/)
377+
378+
### Key Repository Links
379+
380+
- [Upstream Project](https://github.com/idea2app/Lark-Next-Bootstrap-ts)
381+
- [GitHub Actions CI/CD](https://github.com/Open-Source-Bazaar/Open-Source-Bazaar.github.io/actions)
382+
- [Live Demo](https://bazaar.fcc-cd.dev/)
383+
384+
## Contact and Support
385+
386+
For project-specific questions, refer to the existing documentation and GitHub issues. For development guidance, follow the patterns and conventions established in the codebase and the detailed copilot instructions.

0 commit comments

Comments
 (0)