-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconvert-to-mdc.sh
More file actions
103 lines (92 loc) · 4.38 KB
/
Copy pathconvert-to-mdc.sh
File metadata and controls
103 lines (92 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# Convert all .cursorrules files to .mdc format with proper frontmatter
# Output goes to rules-mdc/ mirroring the rules/ structure
set -e
cd "$(dirname "$0")"
# Glob mappings for language/framework-specific rules
declare -A GLOBS
GLOBS[languages/python]='["*.py"]'
GLOBS[languages/javascript]='["*.js", "*.jsx", "*.mjs"]'
GLOBS[languages/typescript]='["*.ts", "*.tsx"]'
GLOBS[languages/go]='["*.go"]'
GLOBS[languages/rust]='["*.rs"]'
GLOBS[languages/java]='["*.java"]'
GLOBS[languages/csharp]='["*.cs"]'
GLOBS[languages/ruby]='["*.rb"]'
GLOBS[languages/php]='["*.php"]'
GLOBS[languages/swift]='["*.swift"]'
GLOBS[frameworks/react]='["*.jsx", "*.tsx"]'
GLOBS[frameworks/nextjs]='["*.js", "*.jsx", "*.ts", "*.tsx"]'
GLOBS[frameworks/vue]='["*.vue", "*.ts", "*.js"]'
GLOBS[frameworks/svelte]='["*.svelte", "*.ts", "*.js"]'
GLOBS[frameworks/django]='["*.py"]'
GLOBS[frameworks/fastapi]='["*.py"]'
GLOBS[frameworks/express]='["*.js", "*.ts"]'
GLOBS[frameworks/rails]='["*.rb"]'
GLOBS[frameworks/laravel]='["*.php"]'
GLOBS[frameworks/flutter]='["*.dart"]'
GLOBS[frameworks/docker]='["Dockerfile", "docker-compose*.yml"]'
# Description mappings
declare -A DESCS
DESCS[languages/python]="Python best practices: type hints, pathlib, pytest, clean error handling"
DESCS[languages/javascript]="Modern JavaScript: ES6+, async/await, pure functions"
DESCS[languages/typescript]="Strict TypeScript: generics, discriminated unions, no any"
DESCS[languages/go]="Go patterns: error wrapping, goroutines, interfaces"
DESCS[languages/rust]="Rust patterns: ownership, Result types, iterators"
DESCS[languages/java]="Modern Java: records, sealed classes, streams"
DESCS[languages/csharp]="C# patterns: async/await, nullable refs, LINQ"
DESCS[languages/ruby]="Idiomatic Ruby: blocks, RSpec, clean patterns"
DESCS[languages/php]="PHP 8.x+: typed properties, PSR standards"
DESCS[languages/swift]="Swift patterns: SwiftUI, actors, async/await, value types"
DESCS[frameworks/react]="React: hooks, composition, performance patterns"
DESCS[frameworks/nextjs]="Next.js: App Router, Server Components, server actions"
DESCS[frameworks/vue]="Vue 3: Composition API, Pinia, script setup"
DESCS[frameworks/svelte]="Svelte 5: runes, reactivity, stores"
DESCS[frameworks/django]="Django: models, views, ORM best practices"
DESCS[frameworks/fastapi]="FastAPI: Pydantic v2, dependency injection, async"
DESCS[frameworks/express]="Express: middleware, error handling, validation"
DESCS[frameworks/rails]="Rails: thin controllers, service objects, Turbo"
DESCS[frameworks/laravel]="Laravel: Eloquent, Form Requests, policies"
DESCS[frameworks/flutter]="Flutter: Riverpod, widget extraction, Dart 3"
DESCS[practices/clean-code]="Clean code: naming, functions, simplicity"
DESCS[practices/testing]="Testing: AAA pattern, mocking, coverage strategy"
DESCS[practices/documentation]="Documentation: code docs, READMEs, ADRs"
DESCS[practices/git-workflow]="Git workflow: commits, branches, PRs"
DESCS[practices/code-review]="Code review: reviewing, authoring, conventions"
DESCS[practices/security]="Security: input validation, auth, data protection"
DESCS[practices/performance]="Performance: profiling, caching, optimization"
DESCS[practices/accessibility]="Accessibility: semantic HTML, ARIA, keyboard nav"
DESCS[tools/docker]="Docker: multi-stage builds, security, compose"
DESCS[tools/ci-cd]="CI/CD: pipelines, deployment, automation"
DESCS[tools/kubernetes]="Kubernetes: deployments, services, config"
DESCS[tools/terraform]="Terraform: modules, state, best practices"
DESCS[tools/vscode]="VS Code: settings, extensions, workspace config"
mkdir -p rules-mdc/{languages,frameworks,practices,tools}
count=0
for file in rules/**/*.cursorrules; do
# Get the relative key like "languages/python"
key="${file#rules/}"
key="${key%.cursorrules}"
name=$(basename "$key")
dir=$(dirname "$key")
outfile="rules-mdc/${dir}/${name}.mdc"
desc="${DESCS[$key]:-}"
globs="${GLOBS[$key]:-}"
# Build frontmatter
echo "---" > "$outfile"
if [ -n "$desc" ]; then
echo "description: \"$desc\"" >> "$outfile"
fi
if [ -n "$globs" ]; then
echo "globs: $globs" >> "$outfile"
fi
echo "alwaysApply: true" >> "$outfile"
echo "---" >> "$outfile"
echo "" >> "$outfile"
# Append original content
cat "$file" >> "$outfile"
count=$((count + 1))
echo "✅ $key"
done
echo ""
echo "Converted $count files to rules-mdc/"