@el-j/magic-helix-plugins 4.0.0-beta.2 → 4.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/architecture/codeowners.md +123 -0
- package/dist/architecture/monorepo.md +146 -0
- package/dist/architecture/nx.md +122 -0
- package/dist/architecture/turborepo.md +114 -0
- package/dist/ci/github-actions.md +268 -0
- package/dist/ci/gitlab-ci.md +330 -0
- package/dist/containers/docker-multistage.md +120 -0
- package/dist/containers/kubernetes-deploy.md +210 -0
- package/dist/cpp/index.cjs +79 -0
- package/dist/cpp/index.mjs +209 -0
- package/dist/csharp/index.cjs +2 -2
- package/dist/csharp/{index.js → index.mjs} +17 -11
- package/dist/csharp/templates/framework-aspnetcore.md +205 -0
- package/dist/csharp/templates/framework-blazor.md +271 -0
- package/dist/csharp/templates/lang-csharp.md +162 -0
- package/dist/devops/docker-compose.md +111 -0
- package/dist/devops/docker-dockerfile.md +94 -0
- package/dist/devops/github-actions.md +160 -0
- package/dist/devops/gitlab-ci.md +210 -0
- package/dist/generic/lang-typescript.md +57 -0
- package/dist/generic/state-redux.md +21 -0
- package/dist/generic/state-rxjs.md +6 -0
- package/dist/generic/style-mui.md +23 -0
- package/dist/generic/style-tailwind.md +76 -0
- package/dist/generic/test-cypress.md +21 -0
- package/dist/generic/test-jest.md +20 -0
- package/dist/generic/test-playwright.md +21 -0
- package/dist/generic/test-vitest.md +131 -0
- package/dist/go/index.cjs +3 -3
- package/dist/go/{index.js → index.mjs} +18 -15
- package/dist/go/templates/lang-go.md +571 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +24 -0
- package/dist/java/index.cjs +2 -2
- package/dist/java/{index.js → index.mjs} +25 -19
- package/dist/java/templates/build-gradle.md +102 -0
- package/dist/java/templates/build-maven.md +86 -0
- package/dist/java/templates/framework-spring-boot.md +179 -0
- package/dist/java/templates/lang-java.md +78 -0
- package/dist/java/templates/lang-kotlin.md +88 -0
- package/dist/meta/magic-helix-meta.md +213 -0
- package/dist/meta/meta-debug.md +459 -0
- package/dist/meta/meta-implement.md +450 -0
- package/dist/meta/meta-roadmap.md +265 -0
- package/dist/nodejs/templates/angular-core.md +19 -0
- package/dist/nodejs/templates/lang-typescript.md +57 -0
- package/dist/nodejs/templates/nestjs-core.md +7 -0
- package/dist/nodejs/templates/react-core.md +677 -0
- package/dist/nodejs/templates/react-zustand.md +7 -0
- package/dist/nodejs/templates/state-redux.md +21 -0
- package/dist/nodejs/templates/state-rxjs.md +6 -0
- package/dist/nodejs/templates/style-primevue.md +6 -0
- package/dist/nodejs/templates/style-quasar.md +22 -0
- package/dist/nodejs/templates/style-tailwind.md +76 -0
- package/dist/nodejs/templates/test-cypress.md +21 -0
- package/dist/nodejs/templates/test-jest.md +20 -0
- package/dist/nodejs/templates/test-playwright.md +21 -0
- package/dist/nodejs/templates/test-vitest.md +131 -0
- package/dist/nodejs/templates/vue-core.md +108 -0
- package/dist/nodejs/templates/vue-pinia.md +5 -0
- package/dist/patterns/architecture/clean-architecture.md +469 -0
- package/dist/patterns/architecture/dependency-injection.md +517 -0
- package/dist/patterns/architecture/domain-driven-design.md +621 -0
- package/dist/patterns/architecture/layered-architecture.md +382 -0
- package/dist/patterns/architecture/repository-pattern.md +408 -0
- package/dist/patterns/domain-expertise/nextjs-rules.md +115 -0
- package/dist/patterns/domain-expertise/react-patterns.md +181 -0
- package/dist/patterns/domain-expertise/server-components.md +212 -0
- package/dist/patterns/domain-expertise/shadcn-ui.md +52 -0
- package/dist/patterns/domain-expertise/tailwind-patterns.md +52 -0
- package/dist/patterns/environment/container-awareness.md +17 -0
- package/dist/patterns/environment/ide-features.md +17 -0
- package/dist/patterns/environment/os-commands.md +17 -0
- package/dist/patterns/organization/heading-hierarchy.md +103 -0
- package/dist/patterns/organization/sequential-workflows.md +102 -0
- package/dist/patterns/organization/xml-rule-groups.md +64 -0
- package/dist/patterns/reasoning/agent-loop.md +151 -0
- package/dist/patterns/reasoning/confirmation-gates.md +141 -0
- package/dist/patterns/reasoning/dependency-analysis.md +132 -0
- package/dist/patterns/reasoning/one-tool-per-iteration.md +152 -0
- package/dist/patterns/reasoning/preview-before-action.md +194 -0
- package/dist/patterns/reasoning/reflection-checkpoints.md +166 -0
- package/dist/patterns/reasoning/result-verification.md +157 -0
- package/dist/patterns/reasoning/subtask-breakdown.md +131 -0
- package/dist/patterns/reasoning/thinking-tags.md +100 -0
- package/dist/patterns/role-definition/capability-declarations.md +72 -0
- package/dist/patterns/role-definition/expert-identity.md +45 -0
- package/dist/patterns/role-definition/scope-boundaries.md +61 -0
- package/dist/patterns/safety/code-safety-rules.md +17 -0
- package/dist/patterns/safety/credential-handling.md +17 -0
- package/dist/patterns/safety/destructive-warnings.md +17 -0
- package/dist/patterns/safety/refusal-messages.md +17 -0
- package/dist/patterns/tone/adaptive-tone.md +17 -0
- package/dist/patterns/tone/concise-communication.md +17 -0
- package/dist/patterns/tone/forbidden-phrases.md +17 -0
- package/dist/patterns/tool-guidelines/function-schemas.md +143 -0
- package/dist/patterns/tool-guidelines/parameter-examples.md +137 -0
- package/dist/patterns/tool-guidelines/usage-policies.md +105 -0
- package/dist/php/index.cjs +2 -2
- package/dist/php/{index.js → index.mjs} +12 -6
- package/dist/php/templates/framework-laravel.md +112 -0
- package/dist/php/templates/lang-php.md +94 -0
- package/dist/python/index.cjs +4 -4
- package/dist/python/{index.js → index.mjs} +10 -7
- package/dist/python/templates/lang-python.md +508 -0
- package/dist/ruby/index.cjs +2 -2
- package/dist/ruby/{index.js → index.mjs} +16 -10
- package/dist/ruby/templates/framework-rails.md +309 -0
- package/dist/ruby/templates/framework-sinatra.md +227 -0
- package/dist/ruby/templates/lang-ruby.md +216 -0
- package/dist/rust/index.cjs +3 -3
- package/dist/rust/{index.js → index.mjs} +24 -18
- package/dist/rust/templates/lang-rust.md +89 -0
- package/dist/swift/index.cjs +32 -0
- package/dist/swift/index.mjs +112 -0
- package/dist/swift/templates/framework-vapor.md +352 -0
- package/dist/swift/templates/lang-swift.md +291 -0
- package/package.json +31 -21
- package/dist/index.js +0 -20
- /package/dist/nodejs/{index.js → index.mjs} +0 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# Ruby Language Instructions
|
|
2
|
+
|
|
3
|
+
## Project Type
|
|
4
|
+
- Language: Ruby
|
|
5
|
+
- Package Manager: Bundler (Gemfile)
|
|
6
|
+
- Framework: {Rails|Sinatra|None}
|
|
7
|
+
|
|
8
|
+
## Build Commands
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
bundle install # Install dependencies
|
|
12
|
+
bundle exec ruby app.rb # Run application
|
|
13
|
+
bundle exec rake test # Run tests
|
|
14
|
+
bundle update # Update dependencies
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Code Conventions
|
|
18
|
+
|
|
19
|
+
### Ruby Style
|
|
20
|
+
```ruby
|
|
21
|
+
# Use descriptive variable names
|
|
22
|
+
user_name = "John Doe"
|
|
23
|
+
users = User.where(active: true)
|
|
24
|
+
|
|
25
|
+
# Prefer blocks and enumerables
|
|
26
|
+
users.each do |user|
|
|
27
|
+
puts user.name
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Use symbols for hash keys
|
|
31
|
+
options = { name: "John", age: 30 }
|
|
32
|
+
|
|
33
|
+
# Prefer string interpolation
|
|
34
|
+
puts "Hello, #{user.name}!"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Classes and Modules
|
|
38
|
+
```ruby
|
|
39
|
+
class User
|
|
40
|
+
attr_accessor :name, :email
|
|
41
|
+
attr_reader :id
|
|
42
|
+
|
|
43
|
+
def initialize(name:, email:)
|
|
44
|
+
@name = name
|
|
45
|
+
@email = email
|
|
46
|
+
@id = SecureRandom.uuid
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def full_profile
|
|
50
|
+
"#{name} <#{email}>"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
module Authenticatable
|
|
55
|
+
def authenticate(password)
|
|
56
|
+
# authentication logic
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
class Admin < User
|
|
61
|
+
include Authenticatable
|
|
62
|
+
end
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Blocks and Procs
|
|
66
|
+
```ruby
|
|
67
|
+
# Block
|
|
68
|
+
numbers.map { |n| n * 2 }
|
|
69
|
+
|
|
70
|
+
# Multiline block
|
|
71
|
+
numbers.each do |n|
|
|
72
|
+
puts n
|
|
73
|
+
log_number(n)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Proc
|
|
77
|
+
double = ->(x) { x * 2 }
|
|
78
|
+
double.call(5) # => 10
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Testing with RSpec
|
|
82
|
+
|
|
83
|
+
```ruby
|
|
84
|
+
# spec/models/user_spec.rb
|
|
85
|
+
require 'rails_helper'
|
|
86
|
+
|
|
87
|
+
RSpec.describe User, type: :model do
|
|
88
|
+
describe '#full_profile' do
|
|
89
|
+
it 'returns formatted name and email' do
|
|
90
|
+
user = User.new(name: 'John', email: 'john@example.com')
|
|
91
|
+
expect(user.full_profile).to eq('John <john@example.com>')
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
describe 'validations' do
|
|
96
|
+
it { should validate_presence_of(:name) }
|
|
97
|
+
it { should validate_presence_of(:email) }
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Docker Optimization
|
|
103
|
+
|
|
104
|
+
### Multi-stage Dockerfile
|
|
105
|
+
```dockerfile
|
|
106
|
+
FROM ruby:3.2-alpine AS builder
|
|
107
|
+
WORKDIR /app
|
|
108
|
+
|
|
109
|
+
# Install build dependencies
|
|
110
|
+
RUN apk add --no-cache build-base postgresql-dev
|
|
111
|
+
|
|
112
|
+
# Install gems
|
|
113
|
+
COPY Gemfile Gemfile.lock ./
|
|
114
|
+
RUN bundle config --local deployment true && \
|
|
115
|
+
bundle config --local without development:test && \
|
|
116
|
+
bundle install -j4
|
|
117
|
+
|
|
118
|
+
# Runtime stage
|
|
119
|
+
FROM ruby:3.2-alpine
|
|
120
|
+
WORKDIR /app
|
|
121
|
+
|
|
122
|
+
# Install runtime dependencies
|
|
123
|
+
RUN apk add --no-cache postgresql-client tzdata
|
|
124
|
+
|
|
125
|
+
# Copy installed gems
|
|
126
|
+
COPY --from=builder /usr/local/bundle /usr/local/bundle
|
|
127
|
+
COPY . .
|
|
128
|
+
|
|
129
|
+
# Non-root user
|
|
130
|
+
RUN adduser -D -u 1000 appuser && chown -R appuser /app
|
|
131
|
+
USER appuser
|
|
132
|
+
|
|
133
|
+
EXPOSE 3000
|
|
134
|
+
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Docker Compose
|
|
138
|
+
```yaml
|
|
139
|
+
services:
|
|
140
|
+
web:
|
|
141
|
+
build: .
|
|
142
|
+
ports:
|
|
143
|
+
- "3000:3000"
|
|
144
|
+
environment:
|
|
145
|
+
- DATABASE_URL=postgresql://postgres:password@db/myapp
|
|
146
|
+
- REDIS_URL=redis://redis:6379/0
|
|
147
|
+
depends_on:
|
|
148
|
+
- db
|
|
149
|
+
- redis
|
|
150
|
+
|
|
151
|
+
db:
|
|
152
|
+
image: postgres:15-alpine
|
|
153
|
+
environment:
|
|
154
|
+
POSTGRES_PASSWORD: password
|
|
155
|
+
volumes:
|
|
156
|
+
- postgres_data:/var/lib/postgresql/data
|
|
157
|
+
|
|
158
|
+
redis:
|
|
159
|
+
image: redis:7-alpine
|
|
160
|
+
volumes:
|
|
161
|
+
- redis_data:/data
|
|
162
|
+
|
|
163
|
+
volumes:
|
|
164
|
+
postgres_data:
|
|
165
|
+
redis_data:
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Dependency Management
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Add a gem
|
|
172
|
+
bundle add puma
|
|
173
|
+
|
|
174
|
+
# Remove a gem
|
|
175
|
+
bundle remove old_gem
|
|
176
|
+
|
|
177
|
+
# Update specific gem
|
|
178
|
+
bundle update rails
|
|
179
|
+
|
|
180
|
+
# Check for outdated gems
|
|
181
|
+
bundle outdated
|
|
182
|
+
|
|
183
|
+
# Audit for security vulnerabilities
|
|
184
|
+
bundle audit
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Performance Tips
|
|
188
|
+
|
|
189
|
+
- Use `pluck` instead of `map` for database queries
|
|
190
|
+
- Eager load associations to avoid N+1 queries
|
|
191
|
+
- Use background jobs (Sidekiq) for slow operations
|
|
192
|
+
- Cache expensive operations
|
|
193
|
+
- Use `find_each` for large datasets
|
|
194
|
+
- Profile with rack-mini-profiler
|
|
195
|
+
- Use Ruby 3.x for YJIT performance improvements
|
|
196
|
+
|
|
197
|
+
## Security
|
|
198
|
+
|
|
199
|
+
- Always use strong parameters in Rails
|
|
200
|
+
- Use `SecureRandom` for tokens
|
|
201
|
+
- Validate user input
|
|
202
|
+
- Use parameterized queries (ActiveRecord does this)
|
|
203
|
+
- Keep dependencies updated with `bundle audit`
|
|
204
|
+
- Set secure headers
|
|
205
|
+
- Use HTTPS in production
|
|
206
|
+
|
|
207
|
+
## Common Gems
|
|
208
|
+
|
|
209
|
+
- **puma**: Web server
|
|
210
|
+
- **sidekiq**: Background jobs
|
|
211
|
+
- **rspec**: Testing framework
|
|
212
|
+
- **rubocop**: Linter
|
|
213
|
+
- **devise**: Authentication
|
|
214
|
+
- **cancancan**: Authorization
|
|
215
|
+
- **kaminari**: Pagination
|
|
216
|
+
- **jbuilder**: JSON API builder
|
package/dist/rust/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`);for(const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("node:path"),g=require("../BasePlugin-odQJAKA-.cjs");function d(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const f=d(p);class h extends g.BasePlugin{constructor(){super(...arguments),this.name="rust",this.displayName="Rust",this.version="3.0.0",this.priority=80}async detect(e){if(!this.fileExists(e,"Cargo.toml"))return null;const t=this.readFile(e,"Cargo.toml");if(!t)return{language:"Rust",name:this.getProjectName(e),dependencies:{},manifestFile:"Cargo.toml",projectPath:e};const n=t.match(/\[package\][\s\S]*?name\s*=\s*"([^"]+)"/),m=t.match(/\[package\][\s\S]*?description\s*=\s*"([^"]+)"/),c={},l=t.match(/\[dependencies\]([\s\S]*?)(?:\n\[|$)/);if(l){const r=l[1].split(`
|
|
2
|
+
`);for(const a of r){const i=a.match(/^([a-zA-Z0-9_-]+)\s*=\s*(?:"([^"]+)"|{[^}]*version\s*=\s*"([^"]+)")/);i&&(c[i[1]]=i[2]||i[3]||"*")}}const u=t.match(/\[workspace\][\s\S]*?members\s*=\s*\[([\s\S]*?)\]/),o=[];if(u){const r=u[1].split(",").map(a=>a.trim().replace(/["']/g,"")).filter(Boolean);o.push(...r)}return{language:"Rust",name:n?.[1]||this.getProjectName(e),description:m?.[1],dependencies:c,manifestFile:"Cargo.toml",projectPath:e,workspaceMembers:o.length>0?o:void 0}}getTemplates(){return[{name:"rust-core",tags:["rust"],content:()=>this.loadTemplateFromFile(f.join(__dirname,"templates/lang-rust.md")).then(e=>e||this.getRustFallbackTemplate())}]}getRustFallbackTemplate(){return`# Rust Development Guidelines
|
|
3
3
|
|
|
4
4
|
This project uses Rust.
|
|
5
5
|
|
|
@@ -26,4 +26,4 @@ This project uses Rust.
|
|
|
26
26
|
## Dependencies
|
|
27
27
|
- Manage with Cargo.toml
|
|
28
28
|
- Review crate security
|
|
29
|
-
- Keep dependencies updated`}
|
|
29
|
+
- Keep dependencies updated`}getDependencyTagMap(){return{tokio:"tokio","actix-web":"actix",rocket:"rocket",serde:"serde"}}}exports.RustPlugin=h;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import * as p from "node:path";
|
|
2
|
+
import { B as u } from "../BasePlugin-6wv0hYJ9.js";
|
|
3
|
+
class h extends u {
|
|
3
4
|
constructor() {
|
|
4
5
|
super(...arguments), this.name = "rust", this.displayName = "Rust", this.version = "3.0.0", this.priority = 80;
|
|
5
6
|
}
|
|
6
7
|
async detect(e) {
|
|
7
8
|
if (!this.fileExists(e, "Cargo.toml"))
|
|
8
9
|
return null;
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
10
|
+
const t = this.readFile(e, "Cargo.toml");
|
|
11
|
+
if (!t)
|
|
11
12
|
return {
|
|
12
13
|
language: "Rust",
|
|
13
14
|
name: this.getProjectName(e),
|
|
@@ -15,25 +16,25 @@ class d extends p {
|
|
|
15
16
|
manifestFile: "Cargo.toml",
|
|
16
17
|
projectPath: e
|
|
17
18
|
};
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
const i =
|
|
19
|
+
const l = t.match(/\[package\][\s\S]*?name\s*=\s*"([^"]+)"/), m = t.match(/\[package\][\s\S]*?description\s*=\s*"([^"]+)"/), a = {}, r = t.match(/\[dependencies\]([\s\S]*?)(?:\n\[|$)/);
|
|
20
|
+
if (r) {
|
|
21
|
+
const i = r[1].split(`
|
|
21
22
|
`);
|
|
22
23
|
for (const o of i) {
|
|
23
|
-
const
|
|
24
|
-
|
|
24
|
+
const s = o.match(/^([a-zA-Z0-9_-]+)\s*=\s*(?:"([^"]+)"|{[^}]*version\s*=\s*"([^"]+)")/);
|
|
25
|
+
s && (a[s[1]] = s[2] || s[3] || "*");
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
|
-
const c =
|
|
28
|
+
const c = t.match(/\[workspace\][\s\S]*?members\s*=\s*\[([\s\S]*?)\]/), n = [];
|
|
28
29
|
if (c) {
|
|
29
30
|
const i = c[1].split(",").map((o) => o.trim().replace(/["']/g, "")).filter(Boolean);
|
|
30
31
|
n.push(...i);
|
|
31
32
|
}
|
|
32
33
|
return {
|
|
33
34
|
language: "Rust",
|
|
34
|
-
name:
|
|
35
|
-
description:
|
|
36
|
-
dependencies:
|
|
35
|
+
name: l?.[1] || this.getProjectName(e),
|
|
36
|
+
description: m?.[1],
|
|
37
|
+
dependencies: a,
|
|
37
38
|
manifestFile: "Cargo.toml",
|
|
38
39
|
projectPath: e,
|
|
39
40
|
workspaceMembers: n.length > 0 ? n : void 0
|
|
@@ -44,7 +45,14 @@ class d extends p {
|
|
|
44
45
|
{
|
|
45
46
|
name: "rust-core",
|
|
46
47
|
tags: ["rust"],
|
|
47
|
-
content:
|
|
48
|
+
content: () => this.loadTemplateFromFile(
|
|
49
|
+
p.join(__dirname, "templates/lang-rust.md")
|
|
50
|
+
).then((e) => e || this.getRustFallbackTemplate())
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
getRustFallbackTemplate() {
|
|
55
|
+
return `# Rust Development Guidelines
|
|
48
56
|
|
|
49
57
|
This project uses Rust.
|
|
50
58
|
|
|
@@ -71,9 +79,7 @@ This project uses Rust.
|
|
|
71
79
|
## Dependencies
|
|
72
80
|
- Manage with Cargo.toml
|
|
73
81
|
- Review crate security
|
|
74
|
-
- Keep dependencies updated
|
|
75
|
-
}
|
|
76
|
-
];
|
|
82
|
+
- Keep dependencies updated`;
|
|
77
83
|
}
|
|
78
84
|
getDependencyTagMap() {
|
|
79
85
|
return {
|
|
@@ -85,5 +91,5 @@ This project uses Rust.
|
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
93
|
export {
|
|
88
|
-
|
|
94
|
+
h as RustPlugin
|
|
89
95
|
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Rust Development Guidelines
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This project uses Rust. Follow Rust idioms, ownership rules, and best practices.
|
|
5
|
+
|
|
6
|
+
## Code Style
|
|
7
|
+
- Use `rustfmt` for automatic code formatting
|
|
8
|
+
- Follow the [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/)
|
|
9
|
+
- Use `clippy` for linting: `cargo clippy`
|
|
10
|
+
- Keep functions small and focused
|
|
11
|
+
- Use descriptive variable names
|
|
12
|
+
|
|
13
|
+
## Ownership & Borrowing
|
|
14
|
+
- Follow Rust's ownership rules strictly
|
|
15
|
+
- Prefer borrowing (`&T`) over taking ownership when possible
|
|
16
|
+
- Use `&mut T` for mutable borrows
|
|
17
|
+
- Avoid unnecessary `.clone()` calls
|
|
18
|
+
- Use `Cow<'_, T>` for conditional ownership
|
|
19
|
+
|
|
20
|
+
## Error Handling
|
|
21
|
+
- Use `Result<T, E>` for operations that can fail
|
|
22
|
+
- Use the `?` operator for error propagation
|
|
23
|
+
- Create custom error types using `thiserror` crate
|
|
24
|
+
- Avoid `unwrap()` and `expect()` in production code
|
|
25
|
+
- Provide meaningful error messages
|
|
26
|
+
|
|
27
|
+
## Types & Traits
|
|
28
|
+
- Use strong typing and avoid `String` everywhere
|
|
29
|
+
- Implement common traits (`Debug`, `Clone`, `PartialEq`) when appropriate
|
|
30
|
+
- Use `derive` macros for automatic implementations
|
|
31
|
+
- Define traits for shared behavior
|
|
32
|
+
- Use generics for code reuse
|
|
33
|
+
|
|
34
|
+
## Cargo Commands
|
|
35
|
+
- Build: `cargo build` (debug) or `cargo build --release` (optimized)
|
|
36
|
+
- Run: `cargo run`
|
|
37
|
+
- Test: `cargo test`
|
|
38
|
+
- Check: `cargo check` (faster than build for syntax checking)
|
|
39
|
+
- Format: `cargo fmt`
|
|
40
|
+
- Lint: `cargo clippy`
|
|
41
|
+
- Doc: `cargo doc --open`
|
|
42
|
+
|
|
43
|
+
## Project Structure
|
|
44
|
+
- `src/main.rs` - Binary entry point
|
|
45
|
+
- `src/lib.rs` - Library entry point
|
|
46
|
+
- `src/bin/` - Additional binaries
|
|
47
|
+
- `tests/` - Integration tests
|
|
48
|
+
- `benches/` - Benchmarks
|
|
49
|
+
- `examples/` - Example code
|
|
50
|
+
|
|
51
|
+
## Dependencies
|
|
52
|
+
- Add dependencies in `Cargo.toml`
|
|
53
|
+
- Use semantic versioning
|
|
54
|
+
- Run `cargo update` to update dependencies
|
|
55
|
+
- Check for outdated deps: `cargo outdated`
|
|
56
|
+
|
|
57
|
+
## Testing
|
|
58
|
+
- Write unit tests in the same file: `#[cfg(test)] mod tests { ... }`
|
|
59
|
+
- Write integration tests in `tests/` directory
|
|
60
|
+
- Use `assert!`, `assert_eq!`, `assert_ne!` macros
|
|
61
|
+
- Run specific tests: `cargo test test_name`
|
|
62
|
+
- Run with output: `cargo test -- --nocapture`
|
|
63
|
+
|
|
64
|
+
## Async/Await
|
|
65
|
+
- Use `tokio` or `async-std` for async runtime
|
|
66
|
+
- Mark async functions with `async fn`
|
|
67
|
+
- Use `.await` to wait for futures
|
|
68
|
+
- Use `#[tokio::main]` or `#[async_std::main]` for async main
|
|
69
|
+
|
|
70
|
+
## Documentation
|
|
71
|
+
- Use `///` for public API documentation
|
|
72
|
+
- Use `//!` for module-level documentation
|
|
73
|
+
- Include examples in doc comments
|
|
74
|
+
- Run `cargo doc` to generate documentation
|
|
75
|
+
- Use `#[doc = "..."]` for advanced docs
|
|
76
|
+
|
|
77
|
+
## Performance
|
|
78
|
+
- Profile before optimizing: use `cargo flamegraph`
|
|
79
|
+
- Use release builds for benchmarks: `cargo bench`
|
|
80
|
+
- Avoid unnecessary allocations
|
|
81
|
+
- Use iterators instead of loops when appropriate
|
|
82
|
+
- Consider using `rayon` for parallel processing
|
|
83
|
+
|
|
84
|
+
## Common Patterns
|
|
85
|
+
- Builder pattern for complex constructors
|
|
86
|
+
- Newtype pattern for type safety
|
|
87
|
+
- Use `match` for exhaustive pattern matching
|
|
88
|
+
- Use `if let` for simple pattern matching
|
|
89
|
+
- Use `Option<T>` instead of null
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("node:path"),p=require("../BasePlugin-odQJAKA-.cjs");function d(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const g=d(u);class m extends p.BasePlugin{constructor(){super(...arguments),this.name="swift",this.displayName="Swift",this.version="3.0.0",this.priority=75}async detect(e){if(this.fileExists(e,"Package.swift"))return this.detectSPM(e);const t=await this.hasFiles(e,"**/*.xcodeproj"),s=await this.hasFiles(e,"**/*.xcworkspace");return t||s?this.detectXcode(e):await this.hasFiles(e,"**/*.swift")?{language:"Swift",name:this.getProjectName(e),dependencies:{},projectPath:e}:null}getTemplates(){return[{name:"swift-core",tags:["swift"],content:()=>this.loadTemplateFromFile(g.join(__dirname,"templates/lang-swift.md")).then(e=>e||this.getSwiftFallbackTemplate())}]}getSwiftFallbackTemplate(){return`# Swift Development Guidelines
|
|
2
|
+
|
|
3
|
+
This project uses Swift.
|
|
4
|
+
|
|
5
|
+
## Project Structure
|
|
6
|
+
- Follow Swift Package Manager conventions
|
|
7
|
+
- Use clear module organization
|
|
8
|
+
- Separate concerns appropriately
|
|
9
|
+
|
|
10
|
+
## Code Style
|
|
11
|
+
- Follow Swift API Design Guidelines
|
|
12
|
+
- Use Swift naming conventions (lowerCamelCase for vars/funcs, UpperCamelCase for types)
|
|
13
|
+
- Leverage SwiftLint for consistency
|
|
14
|
+
- Prefer value types (structs) over reference types when appropriate
|
|
15
|
+
|
|
16
|
+
## Best Practices
|
|
17
|
+
- Use optionals safely with guard/if let
|
|
18
|
+
- Leverage protocol-oriented programming
|
|
19
|
+
- Use strong type system features
|
|
20
|
+
- Handle errors with do/catch or Result types
|
|
21
|
+
- Write clear documentation comments
|
|
22
|
+
|
|
23
|
+
## Async/Concurrency
|
|
24
|
+
- Use async/await for asynchronous operations
|
|
25
|
+
- Use actors for shared mutable state
|
|
26
|
+
- Understand structured concurrency patterns
|
|
27
|
+
|
|
28
|
+
## Testing
|
|
29
|
+
- Write XCTest unit tests
|
|
30
|
+
- Use Quick/Nimble for BDD-style tests (if applicable)
|
|
31
|
+
- Mock dependencies appropriately
|
|
32
|
+
- Test async code with expectations`}getDependencyTagMap(){return{vapor:"vapor",Vapor:"vapor",swift:"swift"}}detectSPM(e){const t=this.readFile(e,"Package.swift");if(!t)return{language:"Swift",name:this.getProjectName(e),dependencies:{},manifestFile:"Package.swift",projectPath:e};const s={},i={language:"Swift",name:this.getProjectName(e),dependencies:s,manifestFile:"Package.swift",projectPath:e},n=t.match(/name:\s*"([^"]+)"/);n&&(i.name=n[1]);const r=t.match(/swift-tools-version:\s*([\d.]+)/);r&&(i.description=`Swift ${r[1]}`),(t.includes("vapor")||t.includes("Vapor"))&&(s.vapor="*");const c=t.matchAll(/\.package\([^)]+url:\s*"([^"]+)"/g);for(const l of c){const o=l[1],f=o.split("/").pop()?.replace(".git","")||o;s[f]="*"}return i}detectXcode(e){return{language:"Swift",name:this.getProjectName(e),dependencies:{},description:"Xcode project",projectPath:e}}}exports.SwiftPlugin=m;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as p from "node:path";
|
|
2
|
+
import { B as f } from "../BasePlugin-6wv0hYJ9.js";
|
|
3
|
+
class u extends f {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments), this.name = "swift", this.displayName = "Swift", this.version = "3.0.0", this.priority = 75;
|
|
6
|
+
}
|
|
7
|
+
async detect(e) {
|
|
8
|
+
if (this.fileExists(e, "Package.swift"))
|
|
9
|
+
return this.detectSPM(e);
|
|
10
|
+
const t = await this.hasFiles(e, "**/*.xcodeproj"), s = await this.hasFiles(
|
|
11
|
+
e,
|
|
12
|
+
"**/*.xcworkspace"
|
|
13
|
+
);
|
|
14
|
+
return t || s ? this.detectXcode(e) : await this.hasFiles(e, "**/*.swift") ? {
|
|
15
|
+
language: "Swift",
|
|
16
|
+
name: this.getProjectName(e),
|
|
17
|
+
dependencies: {},
|
|
18
|
+
projectPath: e
|
|
19
|
+
} : null;
|
|
20
|
+
}
|
|
21
|
+
getTemplates() {
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
name: "swift-core",
|
|
25
|
+
tags: ["swift"],
|
|
26
|
+
content: () => this.loadTemplateFromFile(
|
|
27
|
+
p.join(__dirname, "templates/lang-swift.md")
|
|
28
|
+
).then((e) => e || this.getSwiftFallbackTemplate())
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
getSwiftFallbackTemplate() {
|
|
33
|
+
return `# Swift Development Guidelines
|
|
34
|
+
|
|
35
|
+
This project uses Swift.
|
|
36
|
+
|
|
37
|
+
## Project Structure
|
|
38
|
+
- Follow Swift Package Manager conventions
|
|
39
|
+
- Use clear module organization
|
|
40
|
+
- Separate concerns appropriately
|
|
41
|
+
|
|
42
|
+
## Code Style
|
|
43
|
+
- Follow Swift API Design Guidelines
|
|
44
|
+
- Use Swift naming conventions (lowerCamelCase for vars/funcs, UpperCamelCase for types)
|
|
45
|
+
- Leverage SwiftLint for consistency
|
|
46
|
+
- Prefer value types (structs) over reference types when appropriate
|
|
47
|
+
|
|
48
|
+
## Best Practices
|
|
49
|
+
- Use optionals safely with guard/if let
|
|
50
|
+
- Leverage protocol-oriented programming
|
|
51
|
+
- Use strong type system features
|
|
52
|
+
- Handle errors with do/catch or Result types
|
|
53
|
+
- Write clear documentation comments
|
|
54
|
+
|
|
55
|
+
## Async/Concurrency
|
|
56
|
+
- Use async/await for asynchronous operations
|
|
57
|
+
- Use actors for shared mutable state
|
|
58
|
+
- Understand structured concurrency patterns
|
|
59
|
+
|
|
60
|
+
## Testing
|
|
61
|
+
- Write XCTest unit tests
|
|
62
|
+
- Use Quick/Nimble for BDD-style tests (if applicable)
|
|
63
|
+
- Mock dependencies appropriately
|
|
64
|
+
- Test async code with expectations`;
|
|
65
|
+
}
|
|
66
|
+
getDependencyTagMap() {
|
|
67
|
+
return {
|
|
68
|
+
vapor: "vapor",
|
|
69
|
+
Vapor: "vapor",
|
|
70
|
+
swift: "swift"
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
detectSPM(e) {
|
|
74
|
+
const t = this.readFile(e, "Package.swift");
|
|
75
|
+
if (!t)
|
|
76
|
+
return {
|
|
77
|
+
language: "Swift",
|
|
78
|
+
name: this.getProjectName(e),
|
|
79
|
+
dependencies: {},
|
|
80
|
+
manifestFile: "Package.swift",
|
|
81
|
+
projectPath: e
|
|
82
|
+
};
|
|
83
|
+
const s = {}, a = {
|
|
84
|
+
language: "Swift",
|
|
85
|
+
name: this.getProjectName(e),
|
|
86
|
+
dependencies: s,
|
|
87
|
+
manifestFile: "Package.swift",
|
|
88
|
+
projectPath: e
|
|
89
|
+
}, i = t.match(/name:\s*"([^"]+)"/);
|
|
90
|
+
i && (a.name = i[1]);
|
|
91
|
+
const n = t.match(/swift-tools-version:\s*([\d.]+)/);
|
|
92
|
+
n && (a.description = `Swift ${n[1]}`), (t.includes("vapor") || t.includes("Vapor")) && (s.vapor = "*");
|
|
93
|
+
const o = t.matchAll(/\.package\([^)]+url:\s*"([^"]+)"/g);
|
|
94
|
+
for (const c of o) {
|
|
95
|
+
const r = c[1], l = r.split("/").pop()?.replace(".git", "") || r;
|
|
96
|
+
s[l] = "*";
|
|
97
|
+
}
|
|
98
|
+
return a;
|
|
99
|
+
}
|
|
100
|
+
detectXcode(e) {
|
|
101
|
+
return {
|
|
102
|
+
language: "Swift",
|
|
103
|
+
name: this.getProjectName(e),
|
|
104
|
+
dependencies: {},
|
|
105
|
+
description: "Xcode project",
|
|
106
|
+
projectPath: e
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
u as SwiftPlugin
|
|
112
|
+
};
|