@el-j/magic-helix-plugins 4.0.0-beta.6 → 4.0.0-beta.8
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/{BasePlugin-6wv0hYJ9.js → BasePlugin-BXz3Zpy5.js} +33 -16
- package/dist/BasePlugin-Be6rLq9o.cjs +1 -0
- package/dist/cpp/index.cjs +3 -3
- package/dist/cpp/index.mjs +2 -2
- package/dist/csharp/index.cjs +1 -1
- package/dist/csharp/index.mjs +11 -10
- package/dist/dart/templates/flutter.md +340 -0
- package/dist/dart/templates/lang-dart.md +233 -0
- package/dist/elixir/templates/lang-elixir.md +147 -0
- package/dist/go/index.cjs +3 -3
- package/dist/go/index.mjs +38 -23
- package/dist/index.cjs +147 -1
- package/dist/index.mjs +581 -22
- package/dist/java/index.cjs +2 -2
- package/dist/java/index.mjs +4 -3
- package/dist/nodejs/index.cjs +2 -2
- package/dist/nodejs/index.mjs +60 -29
- package/dist/php/index.cjs +2 -2
- package/dist/php/index.mjs +7 -6
- package/dist/python/index.cjs +4 -4
- package/dist/python/index.mjs +57 -31
- package/dist/ruby/index.cjs +2 -2
- package/dist/ruby/index.mjs +6 -5
- package/dist/rust/index.cjs +3 -3
- package/dist/rust/index.mjs +7 -6
- package/dist/swift/index.cjs +2 -2
- package/dist/swift/index.mjs +4 -3
- package/package.json +1 -1
- package/dist/BasePlugin-odQJAKA-.cjs +0 -1
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# Dart Development Guidelines
|
|
2
|
+
|
|
3
|
+
## Language Overview
|
|
4
|
+
Dart is a client-optimized language for fast apps on any platform. It's the programming language behind Flutter and supports strong typing with null safety.
|
|
5
|
+
|
|
6
|
+
## Code Style & Conventions
|
|
7
|
+
|
|
8
|
+
### Naming
|
|
9
|
+
- **Classes/Enums/Typedefs**: PascalCase (`UserModel`, `ColorState`)
|
|
10
|
+
- **Functions/Variables**: camelCase (`getUserData`, `userName`)
|
|
11
|
+
- **Constants**: lowerCamelCase (`defaultTimeout`, `maxRetries`)
|
|
12
|
+
- **Private members**: Prefix with underscore (`_privateMethod`, `_internalState`)
|
|
13
|
+
|
|
14
|
+
### Null Safety
|
|
15
|
+
```dart
|
|
16
|
+
// Non-nullable by default
|
|
17
|
+
String name; // Must be initialized
|
|
18
|
+
String? optionalName; // Can be null
|
|
19
|
+
|
|
20
|
+
// Null-aware operators
|
|
21
|
+
String? maybeValue;
|
|
22
|
+
final length = maybeValue?.length ?? 0; // Default value
|
|
23
|
+
final value = maybeValue!; // Null assertion (use carefully)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Collections
|
|
27
|
+
```dart
|
|
28
|
+
// Use const for immutable collections
|
|
29
|
+
const colors = ['red', 'green', 'blue'];
|
|
30
|
+
|
|
31
|
+
// Type-safe collections
|
|
32
|
+
final List<User> users = [];
|
|
33
|
+
final Map<String, int> scores = {};
|
|
34
|
+
final Set<String> uniqueNames = {};
|
|
35
|
+
|
|
36
|
+
// Collection operators
|
|
37
|
+
final adults = users.where((u) => u.age >= 18).toList();
|
|
38
|
+
final names = users.map((u) => u.name).toList();
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Object-Oriented Programming
|
|
42
|
+
|
|
43
|
+
### Classes
|
|
44
|
+
```dart
|
|
45
|
+
class User {
|
|
46
|
+
final String id;
|
|
47
|
+
final String name;
|
|
48
|
+
final int age;
|
|
49
|
+
|
|
50
|
+
// Constructor with named parameters
|
|
51
|
+
const User({
|
|
52
|
+
required this.id,
|
|
53
|
+
required this.name,
|
|
54
|
+
required this.age,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Named constructor
|
|
58
|
+
User.guest() : this(id: 'guest', name: 'Guest', age: 0);
|
|
59
|
+
|
|
60
|
+
// Factory constructor
|
|
61
|
+
factory User.fromJson(Map<String, dynamic> json) {
|
|
62
|
+
return User(
|
|
63
|
+
id: json['id'],
|
|
64
|
+
name: json['name'],
|
|
65
|
+
age: json['age'],
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Copyhold
|
|
70
|
+
User copyWith({String? name, int? age}) {
|
|
71
|
+
return User(
|
|
72
|
+
id: id,
|
|
73
|
+
name: name ?? this.name,
|
|
74
|
+
age: age ?? this.age,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Mixins
|
|
81
|
+
```dart
|
|
82
|
+
mixin LoggerMixin {
|
|
83
|
+
void log(String message) {
|
|
84
|
+
print('[${DateTime.now()}] $message');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
class MyService with LoggerMixin {
|
|
89
|
+
void doSomething() {
|
|
90
|
+
log('Doing something');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Async Programming
|
|
96
|
+
|
|
97
|
+
### Futures
|
|
98
|
+
```dart
|
|
99
|
+
Future<User> fetchUser(String id) async {
|
|
100
|
+
final response = await http.get(Uri.parse('/users/$id'));
|
|
101
|
+
return User.fromJson(json.decode(response.body));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Error handling
|
|
105
|
+
try {
|
|
106
|
+
final user = await fetchUser('123');
|
|
107
|
+
} catch (e) {
|
|
108
|
+
print('Error: $e');
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Streams
|
|
113
|
+
```dart
|
|
114
|
+
Stream<int> countStream(int max) async* {
|
|
115
|
+
for (int i = 1; i <= max; i++) {
|
|
116
|
+
await Future.delayed(Duration(seconds: 1));
|
|
117
|
+
yield i;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Usage
|
|
122
|
+
await for (final count in countStream(5)) {
|
|
123
|
+
print(count);
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Testing
|
|
128
|
+
|
|
129
|
+
### Unit Tests
|
|
130
|
+
```dart
|
|
131
|
+
import 'package:test/test.dart';
|
|
132
|
+
|
|
133
|
+
void main() {
|
|
134
|
+
group('User', () {
|
|
135
|
+
test('creates from JSON', () {
|
|
136
|
+
final json = {'id': '1', 'name': 'John', 'age': 30};
|
|
137
|
+
final user = User.fromJson(json);
|
|
138
|
+
|
|
139
|
+
expect(user.id, '1');
|
|
140
|
+
expect(user.name, 'John');
|
|
141
|
+
expect(user.age, 30);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('copyWith preserves unchanged fields', () {
|
|
145
|
+
final user = User(id: '1', name: 'John', age: 30);
|
|
146
|
+
final updated = user.copyWith(name: 'Jane');
|
|
147
|
+
|
|
148
|
+
expect(updated.id, user.id);
|
|
149
|
+
expect(updated.name, 'Jane');
|
|
150
|
+
expect(updated.age, user.age);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Best Practices
|
|
157
|
+
|
|
158
|
+
### Performance
|
|
159
|
+
- Use `const` constructors when possible
|
|
160
|
+
- Prefer `final` over `var` for immutability
|
|
161
|
+
- Use collection literals instead of constructors
|
|
162
|
+
- Avoid unnecessary rebuilds
|
|
163
|
+
|
|
164
|
+
### Code Organization
|
|
165
|
+
- One class per file (generally)
|
|
166
|
+
- Group related files in directories
|
|
167
|
+
- Use barrel files (index.dart) for clean exports
|
|
168
|
+
- Separate models, services, and utilities
|
|
169
|
+
|
|
170
|
+
### Error Handling
|
|
171
|
+
- Use exceptions for exceptional cases
|
|
172
|
+
- Return `Result<T, E>` types for expected failures
|
|
173
|
+
- Validate input early
|
|
174
|
+
- Provide meaningful error messages
|
|
175
|
+
|
|
176
|
+
## Common Patterns
|
|
177
|
+
|
|
178
|
+
### Singleton
|
|
179
|
+
```dart
|
|
180
|
+
class ApiService {
|
|
181
|
+
static final ApiService _instance = ApiService._internal();
|
|
182
|
+
factory ApiService() => _instance;
|
|
183
|
+
ApiService._internal();
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Factory Pattern
|
|
188
|
+
```dart
|
|
189
|
+
abstract class Shape {
|
|
190
|
+
factory Shape(String type) {
|
|
191
|
+
switch (type) {
|
|
192
|
+
case 'circle':
|
|
193
|
+
return Circle();
|
|
194
|
+
case 'square':
|
|
195
|
+
return Square();
|
|
196
|
+
default:
|
|
197
|
+
throw ArgumentError('Unknown shape: $type');
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Repository Pattern
|
|
204
|
+
```dart
|
|
205
|
+
abstract class UserRepository {
|
|
206
|
+
Future<User> getUser(String id);
|
|
207
|
+
Future<void> saveUser(User user);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
class ApiUserRepository implements UserRepository {
|
|
211
|
+
@override
|
|
212
|
+
Future<User> getUser(String id) async {
|
|
213
|
+
// Implementation
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Tools & Commands
|
|
219
|
+
```bash
|
|
220
|
+
# Format code
|
|
221
|
+
dart format .
|
|
222
|
+
|
|
223
|
+
# Analyze code
|
|
224
|
+
dart analyze
|
|
225
|
+
|
|
226
|
+
# Run tests
|
|
227
|
+
dart test
|
|
228
|
+
|
|
229
|
+
# Pub commands
|
|
230
|
+
dart pub get
|
|
231
|
+
dart pub upgrade
|
|
232
|
+
dart pub outdated
|
|
233
|
+
```
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Elixir Development Guidelines
|
|
2
|
+
|
|
3
|
+
## Language Overview
|
|
4
|
+
Elixir is a functional, concurrent programming language built on the Erlang VM (BEAM). It's designed for building scalable, maintainable applications with excellent support for distributed systems.
|
|
5
|
+
|
|
6
|
+
## Code Style & Conventions
|
|
7
|
+
|
|
8
|
+
### Naming
|
|
9
|
+
- **Modules**: PascalCase (`MyApp.UserController`)
|
|
10
|
+
- **Functions/Variables**: snake_case (`create_user`, `user_id`)
|
|
11
|
+
- **Atoms**: snake_case (`:ok`, `:error`, `:user_not_found`)
|
|
12
|
+
- **Constants**: snake_case module attributes (`@default_timeout`)
|
|
13
|
+
|
|
14
|
+
### Pattern Matching
|
|
15
|
+
```elixir
|
|
16
|
+
# Use pattern matching extensively
|
|
17
|
+
def process({:ok, result}), do: result
|
|
18
|
+
def process({:error, reason}), do: Logger.error(reason)
|
|
19
|
+
|
|
20
|
+
# Guards for additional constraints
|
|
21
|
+
def divide(a, b) when b != 0, do: {:ok, a / b}
|
|
22
|
+
def divide(_, 0), do: {:error, :division_by_zero}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Pipe Operator
|
|
26
|
+
```elixir
|
|
27
|
+
# Chain operations with |>
|
|
28
|
+
user
|
|
29
|
+
|> validate_user()
|
|
30
|
+
|> create_record()
|
|
31
|
+
|> send_welcome_email()
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## OTP Patterns
|
|
35
|
+
|
|
36
|
+
### GenServer
|
|
37
|
+
```elixir
|
|
38
|
+
defmodule MyApp.Worker do
|
|
39
|
+
use GenServer
|
|
40
|
+
|
|
41
|
+
def start_link(opts) do
|
|
42
|
+
GenServer.start_link(__MODULE__, opts, name: __MODULE__)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def init(state) do
|
|
46
|
+
{:ok, state}
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def handle_call({:get, key}, _from, state) do
|
|
50
|
+
{:reply, Map.get(state, key), state}
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Supervision
|
|
56
|
+
```elixir
|
|
57
|
+
children = [
|
|
58
|
+
{MyApp.Repo, []},
|
|
59
|
+
{MyApp.Worker, []},
|
|
60
|
+
{Phoenix.PubSub, name: MyApp.PubSub}
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
Supervisor.start_link(children, strategy: :one_for_one)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Phoenix Framework
|
|
67
|
+
|
|
68
|
+
### Controllers
|
|
69
|
+
```elixir
|
|
70
|
+
defmodule MyAppWeb.UserController do
|
|
71
|
+
use MyAppWeb, :controller
|
|
72
|
+
|
|
73
|
+
def create(conn, %{"user" => user_params}) do
|
|
74
|
+
case Accounts.create_user(user_params) do
|
|
75
|
+
{:ok, user} ->
|
|
76
|
+
conn
|
|
77
|
+
|> put_status(:created)
|
|
78
|
+
|> render("show.json", user: user)
|
|
79
|
+
|
|
80
|
+
{:error, changeset} ->
|
|
81
|
+
conn
|
|
82
|
+
|> put_status(:unprocessable_entity)
|
|
83
|
+
|> render("error.json", changeset: changeset)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Contexts
|
|
90
|
+
- Group related functionality in contexts
|
|
91
|
+
- Keep controllers thin, business logic in contexts
|
|
92
|
+
- Use Ecto changesets for validation
|
|
93
|
+
|
|
94
|
+
## Ecto Database
|
|
95
|
+
|
|
96
|
+
### Schemas
|
|
97
|
+
```elixir
|
|
98
|
+
defmodule MyApp.User do
|
|
99
|
+
use Ecto.Schema
|
|
100
|
+
import Ecto.Changeset
|
|
101
|
+
|
|
102
|
+
schema "users" do
|
|
103
|
+
field :email, :string
|
|
104
|
+
field :name, :string
|
|
105
|
+
has_many :posts, MyApp.Post
|
|
106
|
+
|
|
107
|
+
timestamps()
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def changeset(user, attrs) do
|
|
111
|
+
user
|
|
112
|
+
|> cast(attrs, [:email, :name])
|
|
113
|
+
|> validate_required([:email])
|
|
114
|
+
|> validate_format(:email, ~r/@/)
|
|
115
|
+
|> unique_constraint(:email)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Testing
|
|
121
|
+
|
|
122
|
+
### ExUnit
|
|
123
|
+
```elixir
|
|
124
|
+
defmodule MyApp.UserTest do
|
|
125
|
+
use MyApp.DataCase
|
|
126
|
+
|
|
127
|
+
test "creates user with valid attrs" do
|
|
128
|
+
attrs = %{email: "test@example.com", name: "Test"}
|
|
129
|
+
assert {:ok, user} = Accounts.create_user(attrs)
|
|
130
|
+
assert user.email == "test@example.com"
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Error Handling
|
|
136
|
+
- Use tagged tuples: `{:ok, result}`, `{:error, reason}`
|
|
137
|
+
- Pattern match on results
|
|
138
|
+
- Use `with` for complex error handling
|
|
139
|
+
- Leverage supervisor restart strategies
|
|
140
|
+
|
|
141
|
+
## Best Practices
|
|
142
|
+
- Keep functions pure when possible
|
|
143
|
+
- Use immutable data structures
|
|
144
|
+
- Leverage concurrency with Task and GenServer
|
|
145
|
+
- Follow "let it crash" philosophy
|
|
146
|
+
- Use telemetry for observability
|
|
147
|
+
- Run `mix format` before committing
|
package/dist/go/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`);let
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("node:path"),d=require("../BasePlugin-Be6rLq9o.cjs");var c=typeof document<"u"?document.currentScript:null;function u(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=u(m);class p extends d.BasePlugin{constructor(){super(...arguments),this.name="go",this.displayName="Go",this.version="3.0.0",this.priority=90}async detect(e){if(!this.fileExists(e,"go.mod"))return null;const t=this.readFile(e,"go.mod");if(!t){const i=await this.enrichTags(e,{});return{language:"Go",name:this.getProjectName(e),dependencies:{},manifestFile:"go.mod",projectPath:e,tags:Array.from(i)}}const n=t.match(/module\s+([^\s\n]+)/),o={},a=t.split(`
|
|
2
|
+
`);let g=!1;for(const i of a){if(i.trim().startsWith("require (")){g=!0;continue}if(g){if(i.trim()===")")break;const r=i.match(/^\s*([^\s]+)\s+v([^\s]+)/);r&&(o[r[1]]=r[2])}else if(i.trim().startsWith("require ")){const r=i.match(/require\s+([^\s]+)\s+v([^\s]+)/);r&&(o[r[1]]=r[2])}}const l=await this.enrichTags(e,o);return{language:"Go",name:n?.[1]||this.getProjectName(e),dependencies:o,manifestFile:"go.mod",projectPath:e,tags:Array.from(l)}}async enrichTags(e,t){const n=new Set(["go"]),o=this.getDependencyTagMap();for(const a in t)o[a]&&n.add(o[a]);return n}getTemplates(){const e=this.getDirname(typeof document>"u"?require("url").pathToFileURL(__filename).href:c&&c.tagName.toUpperCase()==="SCRIPT"&&c.src||new URL("go/index.cjs",document.baseURI).href);return[{name:"go-core",tags:["go"],content:()=>this.loadTemplateFromFile(f.join(e,"templates/lang-go.md")).then(t=>t||this.getGoFallbackTemplate())}]}getDependencyTagMap(){return{"github.com/gin-gonic/gin":"gin","github.com/gofiber/fiber":"fiber","github.com/labstack/echo":"echo","gorm.io/gorm":"gorm"}}getGoFallbackTemplate(){return`# Go Development Guidelines
|
|
3
3
|
|
|
4
4
|
This project uses Go.
|
|
5
5
|
|
|
@@ -26,4 +26,4 @@ This project uses Go.
|
|
|
26
26
|
## Dependencies
|
|
27
27
|
- Use Go modules (\`go.mod\`)
|
|
28
28
|
- Keep dependencies minimal
|
|
29
|
-
- Review dependency licenses`}}exports.GoPlugin=
|
|
29
|
+
- Review dependency licenses`}}exports.GoPlugin=p;
|
package/dist/go/index.mjs
CHANGED
|
@@ -1,54 +1,69 @@
|
|
|
1
1
|
import * as m from "node:path";
|
|
2
|
-
import { B as
|
|
3
|
-
class
|
|
2
|
+
import { B as c } from "../BasePlugin-BXz3Zpy5.js";
|
|
3
|
+
class u extends c {
|
|
4
4
|
constructor() {
|
|
5
5
|
super(...arguments), this.name = "go", this.displayName = "Go", this.version = "3.0.0", this.priority = 90;
|
|
6
6
|
}
|
|
7
7
|
async detect(e) {
|
|
8
8
|
if (!this.fileExists(e, "go.mod"))
|
|
9
9
|
return null;
|
|
10
|
-
const
|
|
11
|
-
if (!
|
|
10
|
+
const t = this.readFile(e, "go.mod");
|
|
11
|
+
if (!t) {
|
|
12
|
+
const i = await this.enrichTags(e, {});
|
|
12
13
|
return {
|
|
13
14
|
language: "Go",
|
|
14
15
|
name: this.getProjectName(e),
|
|
15
16
|
dependencies: {},
|
|
16
17
|
manifestFile: "go.mod",
|
|
17
|
-
projectPath: e
|
|
18
|
+
projectPath: e,
|
|
19
|
+
tags: Array.from(i)
|
|
18
20
|
};
|
|
19
|
-
|
|
21
|
+
}
|
|
22
|
+
const o = t.match(/module\s+([^\s\n]+)/), s = {}, r = t.split(`
|
|
20
23
|
`);
|
|
21
|
-
let
|
|
22
|
-
for (const
|
|
23
|
-
if (
|
|
24
|
-
|
|
24
|
+
let a = !1;
|
|
25
|
+
for (const i of r) {
|
|
26
|
+
if (i.trim().startsWith("require (")) {
|
|
27
|
+
a = !0;
|
|
25
28
|
continue;
|
|
26
29
|
}
|
|
27
|
-
if (
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
} else if (
|
|
32
|
-
const
|
|
33
|
-
|
|
30
|
+
if (a) {
|
|
31
|
+
if (i.trim() === ")") break;
|
|
32
|
+
const n = i.match(/^\s*([^\s]+)\s+v([^\s]+)/);
|
|
33
|
+
n && (s[n[1]] = n[2]);
|
|
34
|
+
} else if (i.trim().startsWith("require ")) {
|
|
35
|
+
const n = i.match(/require\s+([^\s]+)\s+v([^\s]+)/);
|
|
36
|
+
n && (s[n[1]] = n[2]);
|
|
34
37
|
}
|
|
35
38
|
}
|
|
39
|
+
const g = await this.enrichTags(e, s);
|
|
36
40
|
return {
|
|
37
41
|
language: "Go",
|
|
38
|
-
name:
|
|
39
|
-
dependencies:
|
|
42
|
+
name: o?.[1] || this.getProjectName(e),
|
|
43
|
+
dependencies: s,
|
|
40
44
|
manifestFile: "go.mod",
|
|
41
|
-
projectPath: e
|
|
45
|
+
projectPath: e,
|
|
46
|
+
tags: Array.from(g)
|
|
42
47
|
};
|
|
43
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Enrich tags from dependencies
|
|
51
|
+
*/
|
|
52
|
+
async enrichTags(e, t) {
|
|
53
|
+
const o = /* @__PURE__ */ new Set(["go"]), s = this.getDependencyTagMap();
|
|
54
|
+
for (const r in t)
|
|
55
|
+
s[r] && o.add(s[r]);
|
|
56
|
+
return o;
|
|
57
|
+
}
|
|
44
58
|
getTemplates() {
|
|
59
|
+
const e = this.getDirname(import.meta.url);
|
|
45
60
|
return [
|
|
46
61
|
{
|
|
47
62
|
name: "go-core",
|
|
48
63
|
tags: ["go"],
|
|
49
64
|
content: () => this.loadTemplateFromFile(
|
|
50
|
-
m.join(
|
|
51
|
-
).then((
|
|
65
|
+
m.join(e, "templates/lang-go.md")
|
|
66
|
+
).then((t) => t || this.getGoFallbackTemplate())
|
|
52
67
|
}
|
|
53
68
|
];
|
|
54
69
|
}
|
|
@@ -92,5 +107,5 @@ This project uses Go.
|
|
|
92
107
|
}
|
|
93
108
|
}
|
|
94
109
|
export {
|
|
95
|
-
|
|
110
|
+
u as GoPlugin
|
|
96
111
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,147 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./BasePlugin-Be6rLq9o.cjs"),d=require("./nodejs/index.cjs"),m=require("./go/index.cjs"),p=require("./python/index.cjs"),g=require("./rust/index.cjs"),f=require("./java/index.cjs"),h=require("./ruby/index.cjs"),y=require("./php/index.cjs"),b=require("./csharp/index.cjs"),x=require("./cpp/index.cjs"),F=require("./swift/index.cjs"),P=require("node:path");var i=typeof document<"u"?document.currentScript:null;function v(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const o=v(P);class T extends c.BasePlugin{constructor(){super(...arguments),this.name="elixir",this.displayName="Elixir",this.version="1.0.0",this.priority=80}async detect(e){if(!this.fileExists(e,"mix.exs"))return null;const t=this.readFile(e,"mix.exs"),n=["elixir"],s={};if(t){const l=t.match(/app:\s*:(\w+)/),r=t.match(/version:\s*"([^"]+)"/);return t.includes(":phoenix")&&(n.push("phoenix"),s.phoenix="*"),t.includes(":ecto")&&(n.push("ecto"),s.ecto="*"),{language:"Elixir",name:l?.[1]||this.getProjectName(e),version:r?.[1]||"0.1.0",dependencies:s,manifestFile:"mix.exs",projectPath:e,tags:n}}return{language:"Elixir",name:this.getProjectName(e),dependencies:{},manifestFile:"mix.exs",projectPath:e,tags:n}}getTemplates(){const e=this.getDirname(typeof document>"u"?require("url").pathToFileURL(__filename).href:i&&i.tagName.toUpperCase()==="SCRIPT"&&i.src||new URL("index.cjs",document.baseURI).href);return[{name:"elixir-core",tags:["elixir"],content:()=>this.loadTemplateFromFile(o.join(e,"templates/lang-elixir.md")).then(t=>t||this.getElixirFallbackTemplate())}]}getDependencyTagMap(){return{phoenix:"phoenix",ecto:"ecto",absinthe:"graphql",plug:"plug"}}getElixirFallbackTemplate(){return`# Elixir Development Guidelines
|
|
2
|
+
|
|
3
|
+
## Language-Specific Rules
|
|
4
|
+
- Use pattern matching and guards extensively
|
|
5
|
+
- Prefer immutable data structures
|
|
6
|
+
- Use pipe operator |> for data transformations
|
|
7
|
+
- Follow OTP principles for concurrent systems
|
|
8
|
+
- Use GenServer for stateful processes
|
|
9
|
+
|
|
10
|
+
## Code Style
|
|
11
|
+
- Follow Elixir formatter conventions
|
|
12
|
+
- Use snake_case for functions and variables
|
|
13
|
+
- Use PascalCase for module names
|
|
14
|
+
- Keep functions small and focused
|
|
15
|
+
- Use \`with\` for complex case matching
|
|
16
|
+
|
|
17
|
+
## Common Patterns
|
|
18
|
+
- Supervision trees for fault tolerance
|
|
19
|
+
- GenServer for state management
|
|
20
|
+
- Phoenix contexts for domain logic
|
|
21
|
+
- Ecto changesets for data validation
|
|
22
|
+
`}}class U extends c.BasePlugin{constructor(){super(...arguments),this.name="dart",this.displayName="Dart",this.version="1.0.0",this.priority=80}async detect(e){if(!this.fileExists(e,"pubspec.yaml"))return null;const t=this.readFile(e,"pubspec.yaml"),n=["dart"],s={};if(t){const l=t.match(/name:\s*(.+)/),r=t.match(/version:\s*(.+)/);return(t.includes("flutter:")||t.includes("flutter_test:"))&&(n.push("flutter"),s.flutter="*"),(t.includes("flutter_riverpod:")||t.includes("riverpod:"))&&n.push("riverpod"),(t.includes("flutter_bloc:")||t.includes("bloc:"))&&n.push("bloc"),{language:"Dart",name:l?.[1]?.trim()||this.getProjectName(e),version:r?.[1]?.trim()||"1.0.0",dependencies:s,manifestFile:"pubspec.yaml",projectPath:e,tags:n}}return{language:"Dart",name:this.getProjectName(e),dependencies:{},manifestFile:"pubspec.yaml",projectPath:e,tags:n}}getTemplates(){const e=this.getDirname(typeof document>"u"?require("url").pathToFileURL(__filename).href:i&&i.tagName.toUpperCase()==="SCRIPT"&&i.src||new URL("index.cjs",document.baseURI).href);return[{name:"dart-core",tags:["dart"],content:()=>this.loadTemplateFromFile(o.join(e,"templates/lang-dart.md")).then(t=>t||this.getDartFallbackTemplate())},{name:"flutter-core",tags:["flutter"],content:()=>this.loadTemplateFromFile(o.join(e,"templates/flutter.md")).then(t=>t||this.getFlutterFallbackTemplate())}]}getDependencyTagMap(){return{flutter:"flutter",flutter_riverpod:"riverpod",riverpod:"riverpod",flutter_bloc:"bloc",bloc:"bloc",provider:"provider"}}getDartFallbackTemplate(){return`# Dart Development Guidelines
|
|
23
|
+
|
|
24
|
+
## Language-Specific Rules
|
|
25
|
+
- Use strong typing throughout
|
|
26
|
+
- Leverage null safety features
|
|
27
|
+
- Prefer const constructors where possible
|
|
28
|
+
- Use named parameters for clarity
|
|
29
|
+
- Follow effective Dart guidelines
|
|
30
|
+
|
|
31
|
+
## Code Style
|
|
32
|
+
- Use dartfmt for formatting
|
|
33
|
+
- Follow Dart style guide
|
|
34
|
+
- Use camelCase for variables/functions
|
|
35
|
+
- Use PascalCase for classes
|
|
36
|
+
`}getFlutterFallbackTemplate(){return`# Flutter Development Guidelines
|
|
37
|
+
|
|
38
|
+
## Widget Best Practices
|
|
39
|
+
- Keep widgets small and focused
|
|
40
|
+
- Use StatelessWidget when possible
|
|
41
|
+
- Implement proper dispose() methods
|
|
42
|
+
- Use const constructors for performance
|
|
43
|
+
|
|
44
|
+
## State Management
|
|
45
|
+
- Choose appropriate state solution (Riverpod, Bloc, Provider)
|
|
46
|
+
- Keep business logic separate from UI
|
|
47
|
+
- Use ValueNotifier for simple state
|
|
48
|
+
`}}class k extends c.BasePlugin{constructor(){super(...arguments),this.name="scala",this.displayName="Scala",this.version="1.0.0",this.priority=80}async detect(e){return this.fileExists(e,"build.sbt")?this.detectFromSbt(e):this.fileExists(e,"build.sc")?this.detectFromMill(e):null}getTemplates(){const e=this.getDirname(typeof document>"u"?require("url").pathToFileURL(__filename).href:i&&i.tagName.toUpperCase()==="SCRIPT"&&i.src||new URL("index.cjs",document.baseURI).href);return[{name:"scala-core",tags:["scala"],content:()=>this.loadTemplateFromFile(o.join(e,"templates/lang-scala.md")).then(t=>t||this.getScalaFallbackTemplate())}]}getDependencyTagMap(){return{akka:"akka","akka-http":"akka-http",play:"play","cats-effect":"cats",zio:"zio",scalatest:"scalatest"}}detectFromSbt(e){const t=this.readFile(e,"build.sbt"),n=["scala"],s={};if(t){const l=t.match(/name\s*:=\s*"([^"]+)"/);return(t.includes("akka-actor")||t.includes("com.typesafe.akka"))&&(n.push("akka"),s.akka="*"),(t.includes("play")||t.includes("com.typesafe.play"))&&(n.push("play"),s.play="*"),t.includes("zio")&&n.push("zio"),(t.includes("cats-effect")||t.includes("cats-core"))&&n.push("cats"),{language:"Scala",name:l?.[1]||this.getProjectName(e),dependencies:s,manifestFile:"build.sbt",projectPath:e,tags:n}}return{language:"Scala",name:this.getProjectName(e),dependencies:{},manifestFile:"build.sbt",projectPath:e,tags:n}}detectFromMill(e){return{language:"Scala",name:this.getProjectName(e),dependencies:{},manifestFile:"build.sc",projectPath:e,tags:["scala"]}}getScalaFallbackTemplate(){return`# Scala Development Guidelines
|
|
49
|
+
|
|
50
|
+
## Functional Programming
|
|
51
|
+
- Prefer immutable data structures
|
|
52
|
+
- Use case classes for data models
|
|
53
|
+
- Leverage pattern matching
|
|
54
|
+
- Use for-comprehensions for sequential operations
|
|
55
|
+
|
|
56
|
+
## Collections
|
|
57
|
+
- Use immutable collections by default
|
|
58
|
+
- Leverage map, flatMap, filter, fold
|
|
59
|
+
- Understand lazy vs strict evaluation
|
|
60
|
+
|
|
61
|
+
## Type System
|
|
62
|
+
- Use type inference where appropriate
|
|
63
|
+
- Leverage sealed traits for ADTs
|
|
64
|
+
- Use implicit conversions sparingly
|
|
65
|
+
`}}class R extends c.BasePlugin{constructor(){super(...arguments),this.name="kotlin",this.displayName="Kotlin",this.version="1.0.0",this.priority=85}async detect(e){if(!(this.fileExists(e,"build.gradle.kts")||this.fileExists(e,"settings.gradle.kts")))return null;const n=this.readFile(e,"build.gradle.kts"),s=["kotlin"],l={};return n&&(n.includes("ktor")&&(s.push("ktor"),l.ktor="*"),n.includes("spring-boot")&&(s.push("spring-boot"),l["spring-boot"]="*"),n.includes("exposed")&&s.push("exposed"),n.includes("kotlinx-coroutines")&&s.push("coroutines")),{language:"Kotlin",name:this.getProjectName(e),dependencies:l,manifestFile:"build.gradle.kts",projectPath:e,tags:s}}getTemplates(){const e=this.getDirname(typeof document>"u"?require("url").pathToFileURL(__filename).href:i&&i.tagName.toUpperCase()==="SCRIPT"&&i.src||new URL("index.cjs",document.baseURI).href);return[{name:"kotlin-core",tags:["kotlin"],content:()=>this.loadTemplateFromFile(o.join(e,"templates/lang-kotlin.md")).then(t=>t||this.getKotlinFallbackTemplate())}]}getDependencyTagMap(){return{ktor:"ktor","spring-boot":"spring-boot",exposed:"exposed","kotlinx-coroutines":"coroutines"}}getKotlinFallbackTemplate(){return`# Kotlin Development Guidelines
|
|
66
|
+
|
|
67
|
+
## Language Features
|
|
68
|
+
- Use data classes for simple data holders
|
|
69
|
+
- Leverage null safety with ?
|
|
70
|
+
- Use scope functions (let, apply, run, with, also)
|
|
71
|
+
- Prefer extension functions over utility classes
|
|
72
|
+
|
|
73
|
+
## Coroutines
|
|
74
|
+
- Use suspend functions for async operations
|
|
75
|
+
- Leverage Flow for reactive streams
|
|
76
|
+
- Understand structured concurrency
|
|
77
|
+
|
|
78
|
+
## Collections
|
|
79
|
+
- Use collection builders and operations
|
|
80
|
+
- Leverage sequences for large datasets
|
|
81
|
+
- Understand the difference between List/MutableList
|
|
82
|
+
`}}class S extends c.BasePlugin{constructor(){super(...arguments),this.name="lua",this.displayName="Lua",this.version="1.0.0",this.priority=75}async detect(e){const n=this.listFiles(e)?.find(s=>s.endsWith(".rockspec"));if(n||this.fileExists(e,"lua_modules")){const s=["lua"];return{language:"Lua",name:this.getProjectName(e),dependencies:{},manifestFile:n||"lua_modules",projectPath:e,tags:s}}return null}getTemplates(){const e=this.getDirname(typeof document>"u"?require("url").pathToFileURL(__filename).href:i&&i.tagName.toUpperCase()==="SCRIPT"&&i.src||new URL("index.cjs",document.baseURI).href);return[{name:"lua-core",tags:["lua"],content:()=>this.loadTemplateFromFile(o.join(e,"templates/lang-lua.md")).then(t=>t||this.getLuaFallbackTemplate())}]}getDependencyTagMap(){return{lapis:"lapis",openresty:"openresty",busted:"busted"}}getLuaFallbackTemplate(){return`# Lua Development Guidelines
|
|
83
|
+
|
|
84
|
+
## Tables
|
|
85
|
+
- Tables are the primary data structure
|
|
86
|
+
- Use them for arrays, dictionaries, objects
|
|
87
|
+
- Arrays are 1-indexed
|
|
88
|
+
|
|
89
|
+
## Metatables
|
|
90
|
+
- Use metatables for OOP patterns
|
|
91
|
+
- Implement __index for inheritance
|
|
92
|
+
- Leverage metamethods
|
|
93
|
+
|
|
94
|
+
## Best Practices
|
|
95
|
+
- Keep functions small
|
|
96
|
+
- Use local variables for performance
|
|
97
|
+
- Understand upvalues and closures
|
|
98
|
+
`}}class D extends c.BasePlugin{constructor(){super(...arguments),this.name="r",this.displayName="R",this.version="1.0.0",this.priority=75}async detect(e){const n=this.listFiles(e)?.some(s=>s.endsWith(".Rproj"));if(this.fileExists(e,"DESCRIPTION")||n){const s=["r"],l={},r=this.readFile(e,"DESCRIPTION");if(r){const u=r.match(/Package:\s*(.+)/);return(r.includes("tidyverse")||r.includes("dplyr"))&&s.push("tidyverse"),r.includes("shiny")&&(s.push("shiny"),l.shiny="*"),{language:"R",name:u?.[1]?.trim()||this.getProjectName(e),dependencies:l,manifestFile:"DESCRIPTION",projectPath:e,tags:s}}return{language:"R",name:this.getProjectName(e),dependencies:{},manifestFile:n?".Rproj":"DESCRIPTION",projectPath:e,tags:s}}return null}getTemplates(){const e=this.getDirname(typeof document>"u"?require("url").pathToFileURL(__filename).href:i&&i.tagName.toUpperCase()==="SCRIPT"&&i.src||new URL("index.cjs",document.baseURI).href);return[{name:"r-core",tags:["r"],content:()=>this.loadTemplateFromFile(o.join(e,"templates/lang-r.md")).then(t=>t||this.getRFallbackTemplate())}]}getDependencyTagMap(){return{tidyverse:"tidyverse",shiny:"shiny",ggplot2:"ggplot2","data.table":"data-table"}}getRFallbackTemplate(){return`# R Development Guidelines
|
|
99
|
+
|
|
100
|
+
## Tidyverse Principles
|
|
101
|
+
- Use pipes (%>% or |>) for data transformations
|
|
102
|
+
- Prefer dplyr verbs (select, filter, mutate, summarize)
|
|
103
|
+
- Use ggplot2 for visualization
|
|
104
|
+
|
|
105
|
+
## Vectorization
|
|
106
|
+
- Operate on entire vectors, not loops
|
|
107
|
+
- Use apply family functions
|
|
108
|
+
- Leverage data.table for performance
|
|
109
|
+
|
|
110
|
+
## Best Practices
|
|
111
|
+
- Document functions with roxygen2
|
|
112
|
+
- Write unit tests with testthat
|
|
113
|
+
- Use consistent naming (snake_case)
|
|
114
|
+
`}}class L extends c.BasePlugin{constructor(){super(...arguments),this.name="perl",this.displayName="Perl",this.version="1.0.0",this.priority=70}async detect(e){if(this.fileExists(e,"Makefile.PL")||this.fileExists(e,"Build.PL")||this.fileExists(e,"cpanfile")){const t=this.fileExists(e,"Makefile.PL")?"Makefile.PL":this.fileExists(e,"Build.PL")?"Build.PL":"cpanfile";return{language:"Perl",name:this.getProjectName(e),dependencies:{},manifestFile:t,projectPath:e,tags:["perl"]}}return null}getTemplates(){const e=this.getDirname(typeof document>"u"?require("url").pathToFileURL(__filename).href:i&&i.tagName.toUpperCase()==="SCRIPT"&&i.src||new URL("index.cjs",document.baseURI).href);return[{name:"perl-core",tags:["perl"],content:()=>this.loadTemplateFromFile(o.join(e,"templates/lang-perl.md")).then(t=>t||this.getPerlFallbackTemplate())}]}getDependencyTagMap(){return{Mojolicious:"mojolicious",Dancer2:"dancer",Catalyst:"catalyst"}}getPerlFallbackTemplate(){return`# Perl Development Guidelines
|
|
115
|
+
|
|
116
|
+
## Modern Perl
|
|
117
|
+
- Use strict and warnings
|
|
118
|
+
- Leverage Moose/Moo for OOP
|
|
119
|
+
- Use Try::Tiny for exception handling
|
|
120
|
+
|
|
121
|
+
## CPAN Modules
|
|
122
|
+
- Use cpanm for installation
|
|
123
|
+
- Declare dependencies in cpanfile
|
|
124
|
+
- Test with prove
|
|
125
|
+
|
|
126
|
+
## Best Practices
|
|
127
|
+
- Follow PBP (Perl Best Practices)
|
|
128
|
+
- Use perlcritic for linting
|
|
129
|
+
- Write tests with Test::More
|
|
130
|
+
`}}class C extends c.BasePlugin{constructor(){super(...arguments),this.name="shell",this.displayName="Shell",this.version="1.0.0",this.priority=60}async detect(e){const t=this.listFiles(e);if(t?.some(s=>s.endsWith(".sh")||s==="Makefile"||s.endsWith(".bash")||s.endsWith(".zsh"))){const s=["shell"];if((t?.filter(r=>r.endsWith(".sh")||r.endsWith(".bash")||r.endsWith(".zsh")).length||0)>=2||t?.includes("install.sh")||t?.includes("setup.sh"))return{language:"Shell",name:this.getProjectName(e),dependencies:{},manifestFile:"scripts",projectPath:e,tags:s}}return null}getTemplates(){const e=this.getDirname(typeof document>"u"?require("url").pathToFileURL(__filename).href:i&&i.tagName.toUpperCase()==="SCRIPT"&&i.src||new URL("index.cjs",document.baseURI).href);return[{name:"shell-core",tags:["shell"],content:()=>this.loadTemplateFromFile(o.join(e,"templates/lang-shell.md")).then(t=>t||this.getShellFallbackTemplate())}]}getDependencyTagMap(){return{}}getShellFallbackTemplate(){return`# Shell Script Development Guidelines
|
|
131
|
+
|
|
132
|
+
## Best Practices
|
|
133
|
+
- Use #!/usr/bin/env bash for portability
|
|
134
|
+
- Always quote variables: "$var"
|
|
135
|
+
- Use set -euo pipefail for safety
|
|
136
|
+
- Check command existence with command -v
|
|
137
|
+
|
|
138
|
+
## Error Handling
|
|
139
|
+
- Use trap for cleanup
|
|
140
|
+
- Check exit codes: if ! command; then
|
|
141
|
+
- Provide meaningful error messages
|
|
142
|
+
|
|
143
|
+
## Functions
|
|
144
|
+
- Keep functions focused
|
|
145
|
+
- Use local variables
|
|
146
|
+
- Return meaningful exit codes
|
|
147
|
+
`}}exports.BasePlugin=c.BasePlugin;exports.NodeJSPlugin=d.NodeJSPlugin;exports.GoPlugin=m.GoPlugin;exports.PythonPlugin=p.PythonPlugin;exports.RustPlugin=g.RustPlugin;exports.JavaPlugin=f.JavaPlugin;exports.RubyPlugin=h.RubyPlugin;exports.PHPPlugin=y.PHPPlugin;exports.CSharpPlugin=b.CSharpPlugin;exports.CppPlugin=x.CppPlugin;exports.SwiftPlugin=F.SwiftPlugin;exports.DartPlugin=U;exports.ElixirPlugin=T;exports.KotlinPlugin=R;exports.LuaPlugin=S;exports.PerlPlugin=L;exports.RPlugin=D;exports.ScalaPlugin=k;exports.ShellPlugin=C;
|