@el-j/magic-helix-core 4.0.0-beta.1
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/README.md +192 -0
- package/dist/BasePlugin-6wv0hYJ9.js +98 -0
- package/dist/BasePlugin-6wv0hYJ9.js.map +1 -0
- package/dist/BasePlugin-odQJAKA-.cjs +2 -0
- package/dist/BasePlugin-odQJAKA-.cjs.map +1 -0
- package/dist/ab-testing.d.ts +28 -0
- package/dist/ai-refinement.d.ts +24 -0
- package/dist/analysis.d.ts +18 -0
- package/dist/analysis.service.d.ts +11 -0
- package/dist/browser.d.ts +9 -0
- package/dist/built-in-config.d.ts +8 -0
- package/dist/builtin-plugins/base/BasePlugin.d.ts +69 -0
- package/dist/builtin-plugins/csharp/index.d.ts +20 -0
- package/dist/builtin-plugins/go/index.d.ts +23 -0
- package/dist/builtin-plugins/index.d.ts +15 -0
- package/dist/builtin-plugins/java/index.d.ts +22 -0
- package/dist/builtin-plugins/nodejs/index.d.ts +44 -0
- package/dist/builtin-plugins/php/index.d.ts +20 -0
- package/dist/builtin-plugins/python/index.d.ts +27 -0
- package/dist/builtin-plugins/ruby/index.d.ts +20 -0
- package/dist/builtin-plugins/rust/index.d.ts +53 -0
- package/dist/builtin-plugins/swift/index.d.ts +22 -0
- package/dist/config-merger.d.ts +15 -0
- package/dist/default_templates/angular/angular-core.md +19 -0
- package/dist/default_templates/architecture/codeowners.md +123 -0
- package/dist/default_templates/architecture/monorepo.md +146 -0
- package/dist/default_templates/architecture/nx.md +122 -0
- package/dist/default_templates/architecture/turborepo.md +114 -0
- package/dist/default_templates/ci/github-actions.md +268 -0
- package/dist/default_templates/ci/gitlab-ci.md +330 -0
- package/dist/default_templates/containers/docker-multistage.md +120 -0
- package/dist/default_templates/containers/kubernetes-deploy.md +210 -0
- package/dist/default_templates/devops/docker-compose.md +111 -0
- package/dist/default_templates/devops/docker-dockerfile.md +94 -0
- package/dist/default_templates/devops/github-actions.md +160 -0
- package/dist/default_templates/devops/gitlab-ci.md +210 -0
- package/dist/default_templates/dotnet/framework-aspnetcore.md +205 -0
- package/dist/default_templates/dotnet/framework-blazor.md +271 -0
- package/dist/default_templates/dotnet/lang-csharp.md +162 -0
- package/dist/default_templates/generic/lang-typescript.md +11 -0
- package/dist/default_templates/generic/state-redux.md +21 -0
- package/dist/default_templates/generic/state-rxjs.md +6 -0
- package/dist/default_templates/generic/style-mui.md +23 -0
- package/dist/default_templates/generic/style-tailwind.md +6 -0
- package/dist/default_templates/generic/test-cypress.md +21 -0
- package/dist/default_templates/generic/test-jest.md +20 -0
- package/dist/default_templates/generic/test-playwright.md +21 -0
- package/dist/default_templates/generic/test-vitest.md +6 -0
- package/dist/default_templates/go/lang-go.md +571 -0
- package/dist/default_templates/java/build-gradle.md +102 -0
- package/dist/default_templates/java/build-maven.md +86 -0
- package/dist/default_templates/java/framework-spring-boot.md +179 -0
- package/dist/default_templates/java/lang-java.md +78 -0
- package/dist/default_templates/java/lang-kotlin.md +88 -0
- package/dist/default_templates/meta/magic-helix-meta.md +213 -0
- package/dist/default_templates/meta/meta-debug.md +459 -0
- package/dist/default_templates/meta/meta-implement.md +450 -0
- package/dist/default_templates/meta/meta-roadmap.md +265 -0
- package/dist/default_templates/nestjs/nestjs-core.md +7 -0
- package/dist/default_templates/patterns/architecture/clean-architecture.md +469 -0
- package/dist/default_templates/patterns/architecture/dependency-injection.md +517 -0
- package/dist/default_templates/patterns/architecture/domain-driven-design.md +621 -0
- package/dist/default_templates/patterns/architecture/layered-architecture.md +382 -0
- package/dist/default_templates/patterns/architecture/repository-pattern.md +408 -0
- package/dist/default_templates/patterns/domain-expertise/nextjs-rules.md +115 -0
- package/dist/default_templates/patterns/domain-expertise/react-patterns.md +181 -0
- package/dist/default_templates/patterns/domain-expertise/server-components.md +212 -0
- package/dist/default_templates/patterns/domain-expertise/shadcn-ui.md +52 -0
- package/dist/default_templates/patterns/domain-expertise/tailwind-patterns.md +52 -0
- package/dist/default_templates/patterns/environment/container-awareness.md +17 -0
- package/dist/default_templates/patterns/environment/ide-features.md +17 -0
- package/dist/default_templates/patterns/environment/os-commands.md +17 -0
- package/dist/default_templates/patterns/organization/heading-hierarchy.md +103 -0
- package/dist/default_templates/patterns/organization/sequential-workflows.md +102 -0
- package/dist/default_templates/patterns/organization/xml-rule-groups.md +64 -0
- package/dist/default_templates/patterns/reasoning/agent-loop.md +151 -0
- package/dist/default_templates/patterns/reasoning/confirmation-gates.md +141 -0
- package/dist/default_templates/patterns/reasoning/dependency-analysis.md +132 -0
- package/dist/default_templates/patterns/reasoning/one-tool-per-iteration.md +152 -0
- package/dist/default_templates/patterns/reasoning/preview-before-action.md +194 -0
- package/dist/default_templates/patterns/reasoning/reflection-checkpoints.md +166 -0
- package/dist/default_templates/patterns/reasoning/result-verification.md +157 -0
- package/dist/default_templates/patterns/reasoning/subtask-breakdown.md +131 -0
- package/dist/default_templates/patterns/reasoning/thinking-tags.md +100 -0
- package/dist/default_templates/patterns/role-definition/capability-declarations.md +72 -0
- package/dist/default_templates/patterns/role-definition/expert-identity.md +45 -0
- package/dist/default_templates/patterns/role-definition/scope-boundaries.md +61 -0
- package/dist/default_templates/patterns/safety/code-safety-rules.md +17 -0
- package/dist/default_templates/patterns/safety/credential-handling.md +17 -0
- package/dist/default_templates/patterns/safety/destructive-warnings.md +17 -0
- package/dist/default_templates/patterns/safety/refusal-messages.md +17 -0
- package/dist/default_templates/patterns/tone/adaptive-tone.md +17 -0
- package/dist/default_templates/patterns/tone/concise-communication.md +17 -0
- package/dist/default_templates/patterns/tone/forbidden-phrases.md +17 -0
- package/dist/default_templates/patterns/tool-guidelines/function-schemas.md +143 -0
- package/dist/default_templates/patterns/tool-guidelines/parameter-examples.md +137 -0
- package/dist/default_templates/patterns/tool-guidelines/usage-policies.md +105 -0
- package/dist/default_templates/php/framework-laravel.md +112 -0
- package/dist/default_templates/php/lang-php.md +94 -0
- package/dist/default_templates/python/lang-python.md +508 -0
- package/dist/default_templates/react/react-core.md +677 -0
- package/dist/default_templates/react/react-zustand.md +7 -0
- package/dist/default_templates/ruby/framework-rails.md +309 -0
- package/dist/default_templates/ruby/framework-sinatra.md +227 -0
- package/dist/default_templates/ruby/lang-ruby.md +216 -0
- package/dist/default_templates/rust/lang-rust.md +89 -0
- package/dist/default_templates/swift/framework-vapor.md +352 -0
- package/dist/default_templates/swift/lang-swift.md +291 -0
- package/dist/default_templates/vue/style-primevue.md +6 -0
- package/dist/default_templates/vue/style-quasar.md +22 -0
- package/dist/default_templates/vue/vue-core.md +28 -0
- package/dist/default_templates/vue/vue-pinia.md +5 -0
- package/dist/formatters.d.ts +59 -0
- package/dist/index-AkVwRl-r.js +92 -0
- package/dist/index-AkVwRl-r.js.map +1 -0
- package/dist/index-B6BeG1yT.cjs +68 -0
- package/dist/index-B6BeG1yT.cjs.map +1 -0
- package/dist/index-B8pyjKdF.js +94 -0
- package/dist/index-B8pyjKdF.js.map +1 -0
- package/dist/index-B_6W_RnJ.cjs +76 -0
- package/dist/index-B_6W_RnJ.cjs.map +1 -0
- package/dist/index-Bg8DD8ku.js +216 -0
- package/dist/index-Bg8DD8ku.js.map +1 -0
- package/dist/index-BkJhe5Af.js +1748 -0
- package/dist/index-BkJhe5Af.js.map +1 -0
- package/dist/index-Bv4Q1Pr7.cjs +33 -0
- package/dist/index-Bv4Q1Pr7.cjs.map +1 -0
- package/dist/index-CN8J45Nc.cjs +24 -0
- package/dist/index-CN8J45Nc.cjs.map +1 -0
- package/dist/index-CPbv2Od1.js +62 -0
- package/dist/index-CPbv2Od1.js.map +1 -0
- package/dist/index-Cf-MC6Al.js +63 -0
- package/dist/index-Cf-MC6Al.js.map +1 -0
- package/dist/index-DDPXXXDy.cjs +19 -0
- package/dist/index-DDPXXXDy.cjs.map +1 -0
- package/dist/index-DO30AzDe.cjs +19 -0
- package/dist/index-DO30AzDe.cjs.map +1 -0
- package/dist/index-Dm37u5ut.js +2128 -0
- package/dist/index-Dm37u5ut.js.map +1 -0
- package/dist/index-DqHvgoXJ.cjs +19 -0
- package/dist/index-DqHvgoXJ.cjs.map +1 -0
- package/dist/index-J1qAfsnO.cjs +2 -0
- package/dist/index-J1qAfsnO.cjs.map +1 -0
- package/dist/index-Jz0HYZ7B.js +13 -0
- package/dist/index-Jz0HYZ7B.js.map +1 -0
- package/dist/index-K39pdw94.cjs +31 -0
- package/dist/index-K39pdw94.cjs.map +1 -0
- package/dist/index-L3IVvhd1.cjs +89 -0
- package/dist/index-L3IVvhd1.cjs.map +1 -0
- package/dist/index-OT2XAJkc.js +117 -0
- package/dist/index-OT2XAJkc.js.map +1 -0
- package/dist/index-TPAX4XKg.cjs +30 -0
- package/dist/index-TPAX4XKg.cjs.map +1 -0
- package/dist/index-WmVSB57y.js +107 -0
- package/dist/index-WmVSB57y.js.map +1 -0
- package/dist/index-mYXvc3Fs.js +68 -0
- package/dist/index-mYXvc3Fs.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.mjs +54 -0
- package/dist/index.mjs.map +1 -0
- package/dist/instruction-validator.d.ts +40 -0
- package/dist/meta-instructions/index.d.ts +47 -0
- package/dist/pattern-combiner.d.ts +37 -0
- package/dist/plugin-analyzer.d.ts +21 -0
- package/dist/plugin-loader.d.ts +93 -0
- package/dist/plugin-registry.d.ts +117 -0
- package/dist/plugin-system.d.ts +116 -0
- package/dist/plugins/codeowners-plugin.d.ts +11 -0
- package/dist/plugins/codeowners.plugin.d.ts +8 -0
- package/dist/plugins/docker-plugin.d.ts +11 -0
- package/dist/plugins/docker.plugin.d.ts +8 -0
- package/dist/plugins/dotnet-plugin.d.ts +11 -0
- package/dist/plugins/github-actions-plugin.d.ts +11 -0
- package/dist/plugins/github-actions.plugin.d.ts +7 -0
- package/dist/plugins/gitlab-ci-plugin.d.ts +11 -0
- package/dist/plugins/go.plugin.d.ts +6 -0
- package/dist/plugins/golang-plugin.d.ts +11 -0
- package/dist/plugins/index.d.ts +16 -0
- package/dist/plugins/java-kotlin-plugin.d.ts +11 -0
- package/dist/plugins/monorepo-plugin.d.ts +11 -0
- package/dist/plugins/monorepo.plugin.d.ts +8 -0
- package/dist/plugins/php-plugin.d.ts +11 -0
- package/dist/plugins/plugin.interface.d.ts +59 -0
- package/dist/plugins/python-plugin.d.ts +11 -0
- package/dist/plugins/python.plugin.d.ts +9 -0
- package/dist/plugins/ruby-plugin.d.ts +11 -0
- package/dist/plugins/rust-plugin.d.ts +11 -0
- package/dist/plugins/rust.plugin.d.ts +6 -0
- package/dist/plugins/swift-plugin.d.ts +11 -0
- package/dist/telemetry.d.ts +51 -0
- package/dist/template-loader.d.ts +80 -0
- package/dist/types.d.ts +216 -0
- package/package.json +60 -0
package/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# MagicHelix Core
|
|
2
|
+
|
|
3
|
+
The core library for MagicAgentHelix. Provides project analysis, configuration merging, and tag detection logic.
|
|
4
|
+
|
|
5
|
+
## 📦 Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @el-j/magic-helix-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 🎯 Purpose
|
|
12
|
+
|
|
13
|
+
This package is the brain of MagicAgentHelix. It:
|
|
14
|
+
|
|
15
|
+
1. **Analyzes projects** to detect frameworks, libraries, and conventions
|
|
16
|
+
2. **Merges configurations** (built-in + user custom)
|
|
17
|
+
3. **Tags files** based on dependencies, config files, and file patterns
|
|
18
|
+
4. **Provides built-in templates** for common frameworks
|
|
19
|
+
|
|
20
|
+
## 🔧 Usage
|
|
21
|
+
|
|
22
|
+
### Basic Analysis
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { analyzeProjectTags, mergeConfigs } from '@el-j/magic-helix-core';
|
|
26
|
+
|
|
27
|
+
// Load and merge configuration
|
|
28
|
+
const config = mergeConfigs(userConfig);
|
|
29
|
+
|
|
30
|
+
// Analyze a project
|
|
31
|
+
const analysisData = {
|
|
32
|
+
dependencies: {
|
|
33
|
+
'vue': '^3.4.0',
|
|
34
|
+
'tailwindcss': '^3.4.0',
|
|
35
|
+
'vitest': '^2.0.0'
|
|
36
|
+
},
|
|
37
|
+
configFiles: ['tsconfig.json', 'vite.config.ts'],
|
|
38
|
+
projectFiles: ['src/App.vue', 'src/main.ts']
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const tags = analyzeProjectTags(
|
|
42
|
+
analysisData,
|
|
43
|
+
config.dependencyTagMap,
|
|
44
|
+
config.configFileTagMap,
|
|
45
|
+
config.fileGlobTagMap
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
console.log(tags);
|
|
49
|
+
// Set { 'framework-vue', 'style-tailwind', 'test-vitest', 'lang-typescript' }
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Configuration Merging
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { loadUserConfig, mergeConfigs } from '@el-j/magic-helix-core';
|
|
56
|
+
|
|
57
|
+
// Load user config from file (or pass custom config)
|
|
58
|
+
const userConfig = loadUserConfig('./custom-config.json');
|
|
59
|
+
|
|
60
|
+
// Merge with built-in configuration
|
|
61
|
+
const mergedConfig = mergeConfigs(userConfig);
|
|
62
|
+
|
|
63
|
+
// Access the merged configuration
|
|
64
|
+
console.log(mergedConfig.dependencyTagMap);
|
|
65
|
+
console.log(mergedConfig.tagTemplateMap);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## 📚 API Reference
|
|
69
|
+
|
|
70
|
+
### `analyzeProjectTags(analysisData, dependencyTagMap, configFileTagMap, fileGlobTagMap)`
|
|
71
|
+
|
|
72
|
+
Analyzes project data and returns a set of applicable tags.
|
|
73
|
+
|
|
74
|
+
**Parameters:**
|
|
75
|
+
- `analysisData: ProjectAnalysisData` - Project information
|
|
76
|
+
- `dependencies: Record<string, string>` - Package dependencies
|
|
77
|
+
- `configFiles: string[]` - Configuration files found
|
|
78
|
+
- `projectFiles: string[]` - All project files
|
|
79
|
+
- `dependencyTagMap: DependencyTagMap` - Maps package names to tags
|
|
80
|
+
- `configFileTagMap: ConfigFileTagMap` - Maps config files to tags
|
|
81
|
+
- `fileGlobTagMap: FileGlobTagMap` - Maps file patterns to tags
|
|
82
|
+
|
|
83
|
+
**Returns:** `Set<string>` - Set of applicable tags
|
|
84
|
+
|
|
85
|
+
### `mergeConfigs(userConfig)`
|
|
86
|
+
|
|
87
|
+
Merges user configuration with built-in defaults.
|
|
88
|
+
|
|
89
|
+
**Parameters:**
|
|
90
|
+
- `userConfig: Partial<Config>` - Optional user configuration
|
|
91
|
+
|
|
92
|
+
**Returns:** `MergedConfig` - Complete merged configuration
|
|
93
|
+
|
|
94
|
+
### `loadUserConfig(configPath?)`
|
|
95
|
+
|
|
96
|
+
Loads user configuration from a file.
|
|
97
|
+
|
|
98
|
+
**Parameters:**
|
|
99
|
+
- `configPath?: string` - Optional path to config file (defaults to `magic-helix.config.json`, with legacy support for `ai-aligner.config.json`)
|
|
100
|
+
|
|
101
|
+
**Returns:** `Partial<Config>` - Loaded user configuration or empty object
|
|
102
|
+
|
|
103
|
+
## 🏗️ Built-in Configuration
|
|
104
|
+
|
|
105
|
+
The core includes comprehensive built-in detection for:
|
|
106
|
+
|
|
107
|
+
### Frameworks
|
|
108
|
+
- Vue.js (`vue`)
|
|
109
|
+
- React (`react`)
|
|
110
|
+
- Angular (`@angular/core`)
|
|
111
|
+
- NestJS (`@nestjs/core`)
|
|
112
|
+
|
|
113
|
+
### Styling
|
|
114
|
+
- Tailwind CSS (`tailwindcss`)
|
|
115
|
+
- PrimeVue (`primevue`)
|
|
116
|
+
- Material-UI (`@mui/material`)
|
|
117
|
+
- Quasar (`quasar`)
|
|
118
|
+
|
|
119
|
+
### Testing
|
|
120
|
+
- Vitest (`vitest`)
|
|
121
|
+
- Jest (`jest`)
|
|
122
|
+
- Cypress (`cypress`)
|
|
123
|
+
- Playwright (`playwright`)
|
|
124
|
+
|
|
125
|
+
### State Management
|
|
126
|
+
- RxJS (`rxjs`)
|
|
127
|
+
- Pinia (`pinia`)
|
|
128
|
+
- Redux (`redux`)
|
|
129
|
+
- Zustand (`zustand`)
|
|
130
|
+
|
|
131
|
+
### Languages
|
|
132
|
+
- TypeScript (`tsconfig.json`, `*.ts`, `*.tsx`)
|
|
133
|
+
- JavaScript (`*.js`, `*.jsx`)
|
|
134
|
+
- Go (`*.go`)
|
|
135
|
+
- Python (`*.py`)
|
|
136
|
+
|
|
137
|
+
## 🔌 Browser Support
|
|
138
|
+
|
|
139
|
+
The core library is isomorphic and works in both Node.js and browser environments.
|
|
140
|
+
|
|
141
|
+
For browser usage, all Node.js-specific APIs (like `fs`) should be handled by the consuming application.
|
|
142
|
+
|
|
143
|
+
## 📖 Type Definitions
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
interface ProjectAnalysisData {
|
|
147
|
+
dependencies: Record<string, string>;
|
|
148
|
+
configFiles: string[];
|
|
149
|
+
projectFiles: string[];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
interface Config {
|
|
153
|
+
target: string;
|
|
154
|
+
templateDirectory: string;
|
|
155
|
+
outputDirectory: string;
|
|
156
|
+
dependencyTagMap: DependencyTagMap;
|
|
157
|
+
configFileTagMap: ConfigFileTagMap;
|
|
158
|
+
fileGlobTagMap: FileGlobTagMap;
|
|
159
|
+
tagTemplateMap: TagTemplateMap;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
type DependencyTagMap = Record<string, string>;
|
|
163
|
+
type ConfigFileTagMap = Record<string, string>;
|
|
164
|
+
type FileGlobTagMap = Record<string, string>;
|
|
165
|
+
type TagTemplateMap = Record<string, Array<{ template: string; suffix: string }>>;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## 🧪 Testing
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
npm test # Run tests
|
|
172
|
+
npm run test:watch # Watch mode
|
|
173
|
+
npm run test:coverage # With coverage
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## 📦 Package Structure
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
dist/
|
|
180
|
+
├── index.mjs # ESM bundle
|
|
181
|
+
├── index.cjs # CommonJS bundle
|
|
182
|
+
├── index.d.ts # TypeScript declarations
|
|
183
|
+
└── default_templates/ # Built-in templates
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## 📚 More Information
|
|
187
|
+
|
|
188
|
+
See the [monorepo root README.md](../../README.md) for full development instructions.
|
|
189
|
+
|
|
190
|
+
## 📄 License
|
|
191
|
+
|
|
192
|
+
MIT
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as s from "node:fs";
|
|
2
|
+
import * as a from "node:path";
|
|
3
|
+
class l {
|
|
4
|
+
// Helper methods for common operations
|
|
5
|
+
/**
|
|
6
|
+
* Check if a file exists in the project
|
|
7
|
+
*/
|
|
8
|
+
fileExists(e, r) {
|
|
9
|
+
return s.existsSync(a.join(e, r));
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Read a file from the project
|
|
13
|
+
*/
|
|
14
|
+
readFile(e, r) {
|
|
15
|
+
try {
|
|
16
|
+
const t = a.join(e, r);
|
|
17
|
+
if (s.existsSync(t))
|
|
18
|
+
return s.readFileSync(t, "utf-8");
|
|
19
|
+
} catch {
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parse JSON file from the project
|
|
25
|
+
*/
|
|
26
|
+
readJSON(e, r) {
|
|
27
|
+
try {
|
|
28
|
+
const t = this.readFile(e, r);
|
|
29
|
+
if (t)
|
|
30
|
+
return JSON.parse(t);
|
|
31
|
+
} catch {
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get project name from path
|
|
37
|
+
*/
|
|
38
|
+
getProjectName(e) {
|
|
39
|
+
return a.basename(e);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Load template from file
|
|
43
|
+
*/
|
|
44
|
+
async loadTemplateFromFile(e) {
|
|
45
|
+
try {
|
|
46
|
+
if (s.existsSync(e))
|
|
47
|
+
return s.readFileSync(e, "utf-8");
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Create a template definition with lazy loading
|
|
54
|
+
*/
|
|
55
|
+
createTemplate(e, r, t, n = {}) {
|
|
56
|
+
return {
|
|
57
|
+
name: e,
|
|
58
|
+
tags: r,
|
|
59
|
+
content: t,
|
|
60
|
+
...n
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Parse dependencies from package-like files
|
|
65
|
+
*/
|
|
66
|
+
parseDependencies(e, ...r) {
|
|
67
|
+
const t = {};
|
|
68
|
+
for (const n of r) {
|
|
69
|
+
const i = e[n];
|
|
70
|
+
i && typeof i == "object" && Object.assign(t, i);
|
|
71
|
+
}
|
|
72
|
+
return t;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Find files matching a pattern
|
|
76
|
+
*/
|
|
77
|
+
async findFiles(e, r) {
|
|
78
|
+
try {
|
|
79
|
+
const { glob: t } = await import("glob");
|
|
80
|
+
return await t(r, {
|
|
81
|
+
cwd: e,
|
|
82
|
+
absolute: !1
|
|
83
|
+
});
|
|
84
|
+
} catch {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Check if any files exist matching a pattern
|
|
90
|
+
*/
|
|
91
|
+
async hasFiles(e, r) {
|
|
92
|
+
return (await this.findFiles(e, r)).length > 0;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
l as B
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=BasePlugin-6wv0hYJ9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePlugin-6wv0hYJ9.js","sources":["../src/builtin-plugins/base/BasePlugin.ts"],"sourcesContent":["/**\n * Base Plugin Class\n *\n * Abstract base class providing common functionality for all language plugins.\n * Plugins should extend this class and implement the abstract methods.\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport type {\n ConfigFileTagMap,\n DependencyTagMap,\n FileGlobTagMap,\n LanguagePlugin,\n ProjectMetadata,\n TemplateDefinition,\n} from '../../types';\n\nexport abstract class BasePlugin implements LanguagePlugin {\n abstract name: string;\n abstract displayName: string;\n abstract version: string;\n abstract priority: number;\n\n /**\n * Abstract method: Detect if this plugin applies to the project\n */\n abstract detect(projectPath: string): Promise<ProjectMetadata | null>;\n\n /**\n * Abstract method: Get templates provided by this plugin\n */\n abstract getTemplates(): TemplateDefinition[] | Promise<TemplateDefinition[]>;\n\n /**\n * Optional: Get dependency-to-tag mapping\n */\n getDependencyTagMap?(): DependencyTagMap;\n\n /**\n * Optional: Get config file-to-tag mapping\n */\n getConfigFileTagMap?(): ConfigFileTagMap;\n\n /**\n * Optional: Get file glob-to-tag mapping\n */\n getFileGlobTagMap?(): FileGlobTagMap;\n\n // Helper methods for common operations\n\n /**\n * Check if a file exists in the project\n */\n protected fileExists(projectPath: string, filename: string): boolean {\n return fs.existsSync(path.join(projectPath, filename));\n }\n\n /**\n * Read a file from the project\n */\n protected readFile(projectPath: string, filename: string): string | null {\n try {\n const filePath = path.join(projectPath, filename);\n if (fs.existsSync(filePath)) {\n return fs.readFileSync(filePath, 'utf-8');\n }\n } catch {\n // Ignore errors\n }\n return null;\n }\n\n /**\n * Parse JSON file from the project\n */\n protected readJSON<T = Record<string, unknown>>(\n projectPath: string,\n filename: string,\n ): T | null {\n try {\n const content = this.readFile(projectPath, filename);\n if (content) {\n return JSON.parse(content) as T;\n }\n } catch {\n // Ignore parse errors\n }\n return null;\n }\n\n /**\n * Get project name from path\n */\n protected getProjectName(projectPath: string): string {\n return path.basename(projectPath);\n }\n\n /**\n * Load template from file\n */\n protected async loadTemplateFromFile(\n templatePath: string,\n ): Promise<string | null> {\n try {\n if (fs.existsSync(templatePath)) {\n return fs.readFileSync(templatePath, 'utf-8');\n }\n } catch {\n // Ignore errors\n }\n return null;\n }\n\n /**\n * Create a template definition with lazy loading\n */\n protected createTemplate(\n name: string,\n tags: string[],\n contentOrPath: string | (() => string | Promise<string>),\n options: Partial<TemplateDefinition> = {},\n ): TemplateDefinition {\n return {\n name,\n tags,\n content:\n typeof contentOrPath === 'string' ? contentOrPath : contentOrPath,\n ...options,\n };\n }\n\n /**\n * Parse dependencies from package-like files\n */\n protected parseDependencies(\n obj: Record<string, unknown>,\n ...keys: string[]\n ): Record<string, string> {\n const deps: Record<string, string> = {};\n\n for (const key of keys) {\n const value = obj[key];\n if (value && typeof value === 'object') {\n Object.assign(deps, value);\n }\n }\n\n return deps;\n }\n\n /**\n * Find files matching a pattern\n */\n protected async findFiles(\n projectPath: string,\n pattern: string,\n ): Promise<string[]> {\n try {\n const { glob } = await import('glob');\n return await glob(pattern, {\n cwd: projectPath,\n absolute: false,\n });\n } catch {\n return [];\n }\n }\n\n /**\n * Check if any files exist matching a pattern\n */\n protected async hasFiles(\n projectPath: string,\n pattern: string,\n ): Promise<boolean> {\n const files = await this.findFiles(projectPath, pattern);\n return files.length > 0;\n }\n}\n"],"names":["BasePlugin","projectPath","filename","fs","path","filePath","content","templatePath","name","tags","contentOrPath","options","obj","keys","deps","key","value","pattern","glob"],"mappings":";;AAkBO,MAAeA,EAAqC;AAAA;AAAA;AAAA;AAAA;AAAA,EAoC/C,WAAWC,GAAqBC,GAA2B;AACnE,WAAOC,EAAG,WAAWC,EAAK,KAAKH,GAAaC,CAAQ,CAAC;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA,EAKU,SAASD,GAAqBC,GAAiC;AACvE,QAAI;AACF,YAAMG,IAAWD,EAAK,KAAKH,GAAaC,CAAQ;AAChD,UAAIC,EAAG,WAAWE,CAAQ;AACxB,eAAOF,EAAG,aAAaE,GAAU,OAAO;AAAA,IAE5C,QAAQ;AAAA,IAER;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKU,SACRJ,GACAC,GACU;AACV,QAAI;AACF,YAAMI,IAAU,KAAK,SAASL,GAAaC,CAAQ;AACnD,UAAII;AACF,eAAO,KAAK,MAAMA,CAAO;AAAA,IAE7B,QAAQ;AAAA,IAER;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKU,eAAeL,GAA6B;AACpD,WAAOG,EAAK,SAASH,CAAW;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAgB,qBACdM,GACwB;AACxB,QAAI;AACF,UAAIJ,EAAG,WAAWI,CAAY;AAC5B,eAAOJ,EAAG,aAAaI,GAAc,OAAO;AAAA,IAEhD,QAAQ;AAAA,IAER;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKU,eACRC,GACAC,GACAC,GACAC,IAAuC,CAAA,GACnB;AACpB,WAAO;AAAA,MACL,MAAAH;AAAA,MACA,MAAAC;AAAA,MACA,SACsCC;AAAA,MACtC,GAAGC;AAAA,IAAA;AAAA,EAEP;AAAA;AAAA;AAAA;AAAA,EAKU,kBACRC,MACGC,GACqB;AACxB,UAAMC,IAA+B,CAAA;AAErC,eAAWC,KAAOF,GAAM;AACtB,YAAMG,IAAQJ,EAAIG,CAAG;AACrB,MAAIC,KAAS,OAAOA,KAAU,YAC5B,OAAO,OAAOF,GAAME,CAAK;AAAA,IAE7B;AAEA,WAAOF;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,MAAgB,UACdb,GACAgB,GACmB;AACnB,QAAI;AACF,YAAM,EAAE,MAAAC,EAAA,IAAS,MAAM,OAAO,MAAM;AACpC,aAAO,MAAMA,EAAKD,GAAS;AAAA,QACzB,KAAKhB;AAAA,QACL,UAAU;AAAA,MAAA,CACX;AAAA,IACH,QAAQ;AACN,aAAO,CAAA;AAAA,IACT;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAgB,SACdA,GACAgB,GACkB;AAElB,YADc,MAAM,KAAK,UAAUhB,GAAagB,CAAO,GAC1C,SAAS;AAAA,EACxB;AACF;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var u=Object.create;var l=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var g=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of y(e))!d.call(r,s)&&s!==t&&l(r,s,{get:()=>e[s],enumerable:!(n=f(e,s))||n.enumerable});return r};var b=(r,e,t)=>(t=r!=null?u(p(r)):{},g(e||!r||!r.__esModule?l(t,"default",{value:r,enumerable:!0}):t,r));const m=require("node:fs"),j=require("node:path");function o(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const c=o(m),i=o(j);class F{fileExists(e,t){return c.existsSync(i.join(e,t))}readFile(e,t){try{const n=i.join(e,t);if(c.existsSync(n))return c.readFileSync(n,"utf-8")}catch{}return null}readJSON(e,t){try{const n=this.readFile(e,t);if(n)return JSON.parse(n)}catch{}return null}getProjectName(e){return i.basename(e)}async loadTemplateFromFile(e){try{if(c.existsSync(e))return c.readFileSync(e,"utf-8")}catch{}return null}createTemplate(e,t,n,s={}){return{name:e,tags:t,content:n,...s}}parseDependencies(e,...t){const n={};for(const s of t){const a=e[s];a&&typeof a=="object"&&Object.assign(n,a)}return n}async findFiles(e,t){try{const{glob:n}=await import("glob");return await n(t,{cwd:e,absolute:!1})}catch{return[]}}async hasFiles(e,t){return(await this.findFiles(e,t)).length>0}}exports.BasePlugin=F;
|
|
2
|
+
//# sourceMappingURL=BasePlugin-odQJAKA-.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePlugin-odQJAKA-.cjs","sources":["../src/builtin-plugins/base/BasePlugin.ts"],"sourcesContent":["/**\n * Base Plugin Class\n *\n * Abstract base class providing common functionality for all language plugins.\n * Plugins should extend this class and implement the abstract methods.\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport type {\n ConfigFileTagMap,\n DependencyTagMap,\n FileGlobTagMap,\n LanguagePlugin,\n ProjectMetadata,\n TemplateDefinition,\n} from '../../types';\n\nexport abstract class BasePlugin implements LanguagePlugin {\n abstract name: string;\n abstract displayName: string;\n abstract version: string;\n abstract priority: number;\n\n /**\n * Abstract method: Detect if this plugin applies to the project\n */\n abstract detect(projectPath: string): Promise<ProjectMetadata | null>;\n\n /**\n * Abstract method: Get templates provided by this plugin\n */\n abstract getTemplates(): TemplateDefinition[] | Promise<TemplateDefinition[]>;\n\n /**\n * Optional: Get dependency-to-tag mapping\n */\n getDependencyTagMap?(): DependencyTagMap;\n\n /**\n * Optional: Get config file-to-tag mapping\n */\n getConfigFileTagMap?(): ConfigFileTagMap;\n\n /**\n * Optional: Get file glob-to-tag mapping\n */\n getFileGlobTagMap?(): FileGlobTagMap;\n\n // Helper methods for common operations\n\n /**\n * Check if a file exists in the project\n */\n protected fileExists(projectPath: string, filename: string): boolean {\n return fs.existsSync(path.join(projectPath, filename));\n }\n\n /**\n * Read a file from the project\n */\n protected readFile(projectPath: string, filename: string): string | null {\n try {\n const filePath = path.join(projectPath, filename);\n if (fs.existsSync(filePath)) {\n return fs.readFileSync(filePath, 'utf-8');\n }\n } catch {\n // Ignore errors\n }\n return null;\n }\n\n /**\n * Parse JSON file from the project\n */\n protected readJSON<T = Record<string, unknown>>(\n projectPath: string,\n filename: string,\n ): T | null {\n try {\n const content = this.readFile(projectPath, filename);\n if (content) {\n return JSON.parse(content) as T;\n }\n } catch {\n // Ignore parse errors\n }\n return null;\n }\n\n /**\n * Get project name from path\n */\n protected getProjectName(projectPath: string): string {\n return path.basename(projectPath);\n }\n\n /**\n * Load template from file\n */\n protected async loadTemplateFromFile(\n templatePath: string,\n ): Promise<string | null> {\n try {\n if (fs.existsSync(templatePath)) {\n return fs.readFileSync(templatePath, 'utf-8');\n }\n } catch {\n // Ignore errors\n }\n return null;\n }\n\n /**\n * Create a template definition with lazy loading\n */\n protected createTemplate(\n name: string,\n tags: string[],\n contentOrPath: string | (() => string | Promise<string>),\n options: Partial<TemplateDefinition> = {},\n ): TemplateDefinition {\n return {\n name,\n tags,\n content:\n typeof contentOrPath === 'string' ? contentOrPath : contentOrPath,\n ...options,\n };\n }\n\n /**\n * Parse dependencies from package-like files\n */\n protected parseDependencies(\n obj: Record<string, unknown>,\n ...keys: string[]\n ): Record<string, string> {\n const deps: Record<string, string> = {};\n\n for (const key of keys) {\n const value = obj[key];\n if (value && typeof value === 'object') {\n Object.assign(deps, value);\n }\n }\n\n return deps;\n }\n\n /**\n * Find files matching a pattern\n */\n protected async findFiles(\n projectPath: string,\n pattern: string,\n ): Promise<string[]> {\n try {\n const { glob } = await import('glob');\n return await glob(pattern, {\n cwd: projectPath,\n absolute: false,\n });\n } catch {\n return [];\n }\n }\n\n /**\n * Check if any files exist matching a pattern\n */\n protected async hasFiles(\n projectPath: string,\n pattern: string,\n ): Promise<boolean> {\n const files = await this.findFiles(projectPath, pattern);\n return files.length > 0;\n }\n}\n"],"names":["BasePlugin","projectPath","filename","fs","path","filePath","content","templatePath","name","tags","contentOrPath","options","obj","keys","deps","key","value","pattern","glob"],"mappings":"2yBAkBO,MAAeA,CAAqC,CAoC/C,WAAWC,EAAqBC,EAA2B,CACnE,OAAOC,EAAG,WAAWC,EAAK,KAAKH,EAAaC,CAAQ,CAAC,CACvD,CAKU,SAASD,EAAqBC,EAAiC,CACvE,GAAI,CACF,MAAMG,EAAWD,EAAK,KAAKH,EAAaC,CAAQ,EAChD,GAAIC,EAAG,WAAWE,CAAQ,EACxB,OAAOF,EAAG,aAAaE,EAAU,OAAO,CAE5C,MAAQ,CAER,CACA,OAAO,IACT,CAKU,SACRJ,EACAC,EACU,CACV,GAAI,CACF,MAAMI,EAAU,KAAK,SAASL,EAAaC,CAAQ,EACnD,GAAII,EACF,OAAO,KAAK,MAAMA,CAAO,CAE7B,MAAQ,CAER,CACA,OAAO,IACT,CAKU,eAAeL,EAA6B,CACpD,OAAOG,EAAK,SAASH,CAAW,CAClC,CAKA,MAAgB,qBACdM,EACwB,CACxB,GAAI,CACF,GAAIJ,EAAG,WAAWI,CAAY,EAC5B,OAAOJ,EAAG,aAAaI,EAAc,OAAO,CAEhD,MAAQ,CAER,CACA,OAAO,IACT,CAKU,eACRC,EACAC,EACAC,EACAC,EAAuC,CAAA,EACnB,CACpB,MAAO,CACL,KAAAH,EACA,KAAAC,EACA,QACsCC,EACtC,GAAGC,CAAA,CAEP,CAKU,kBACRC,KACGC,EACqB,CACxB,MAAMC,EAA+B,CAAA,EAErC,UAAWC,KAAOF,EAAM,CACtB,MAAMG,EAAQJ,EAAIG,CAAG,EACjBC,GAAS,OAAOA,GAAU,UAC5B,OAAO,OAAOF,EAAME,CAAK,CAE7B,CAEA,OAAOF,CACT,CAKA,MAAgB,UACdb,EACAgB,EACmB,CACnB,GAAI,CACF,KAAM,CAAE,KAAAC,CAAA,EAAS,KAAM,QAAO,MAAM,EACpC,OAAO,MAAMA,EAAKD,EAAS,CACzB,IAAKhB,EACL,SAAU,EAAA,CACX,CACH,MAAQ,CACN,MAAO,CAAA,CACT,CACF,CAKA,MAAgB,SACdA,EACAgB,EACkB,CAElB,OADc,MAAM,KAAK,UAAUhB,EAAagB,CAAO,GAC1C,OAAS,CACxB,CACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PatternContext } from './pattern-combiner';
|
|
2
|
+
import type { TelemetryClient } from './telemetry';
|
|
3
|
+
export interface ABVariant {
|
|
4
|
+
name: string;
|
|
5
|
+
context: PatternContext;
|
|
6
|
+
description?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ABTestResult {
|
|
9
|
+
variant: string;
|
|
10
|
+
instructions: string;
|
|
11
|
+
score: number;
|
|
12
|
+
structureScore: number;
|
|
13
|
+
clarityScore: number;
|
|
14
|
+
completenessScore: number;
|
|
15
|
+
missingCount: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Generate instructions for multiple A/B test variants
|
|
19
|
+
*/
|
|
20
|
+
export declare function generateABVariants(variants: ABVariant[]): ABTestResult[];
|
|
21
|
+
/**
|
|
22
|
+
* Compare AB test results and return best variant
|
|
23
|
+
*/
|
|
24
|
+
export declare function analyzeBestVariant(results: ABTestResult[]): ABTestResult;
|
|
25
|
+
/**
|
|
26
|
+
* Track A/B test results via telemetry (optional)
|
|
27
|
+
*/
|
|
28
|
+
export declare function trackABTest(results: ABTestResult[], telemetry?: TelemetryClient): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Config } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Default AI refinement configuration
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_AI_REFINEMENT: {
|
|
6
|
+
quality: "standard";
|
|
7
|
+
contextLevel: "balanced";
|
|
8
|
+
outputFormat: "markdown";
|
|
9
|
+
tokenBudget: number;
|
|
10
|
+
includeExamples: boolean;
|
|
11
|
+
includeBestPractices: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Token budget thresholds by quality level
|
|
15
|
+
*/
|
|
16
|
+
export declare const TOKEN_BUDGETS: Record<string, number>;
|
|
17
|
+
/**
|
|
18
|
+
* Apply AI refinement transformations to instruction content
|
|
19
|
+
*/
|
|
20
|
+
export declare function refineInstructions(content: string, config: Config['aiRefinement']): string;
|
|
21
|
+
/**
|
|
22
|
+
* Estimate token count for content
|
|
23
|
+
*/
|
|
24
|
+
export declare function estimateTokens(content: string): number;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ConfigFileTagMap, DependencyTagMap, FileGlobTagMap } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The data structure representing the analysis of a project.
|
|
4
|
+
* This is built by scanning the project's files and dependencies.
|
|
5
|
+
*/
|
|
6
|
+
export interface ProjectAnalysisData {
|
|
7
|
+
/** Dependencies from package.json (both dependencies and devDependencies) */
|
|
8
|
+
dependencies: Record<string, string>;
|
|
9
|
+
/** Key config files found at the project root */
|
|
10
|
+
configFiles: string[];
|
|
11
|
+
/** All project files (for glob matching) */
|
|
12
|
+
projectFiles: string[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Analyzes a project and returns the set of tags that apply to it.
|
|
16
|
+
* This is the core logic that determines which instruction templates to apply.
|
|
17
|
+
*/
|
|
18
|
+
export declare function analyzeProjectTags(analysisData: ProjectAnalysisData, dependencyTagMap: DependencyTagMap, configFileTagMap: ConfigFileTagMap, fileGlobTagMap: FileGlobTagMap): Set<string>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DetectionContext, Instruction } from './plugins/plugin.interface';
|
|
2
|
+
export declare class AnalysisService {
|
|
3
|
+
private plugins;
|
|
4
|
+
constructor();
|
|
5
|
+
/**
|
|
6
|
+
* Analyzes a project and generates all AI instructions.
|
|
7
|
+
* @param context - The project file context.
|
|
8
|
+
* @returns An array of all instructions from all detected plugins.
|
|
9
|
+
*/
|
|
10
|
+
analyzeProject(context: DetectionContext): Promise<Instruction[]>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { analyzeProjectTags, type ProjectAnalysisData } from './analysis';
|
|
2
|
+
export { BUILT_IN_CONFIG } from './built-in-config';
|
|
3
|
+
export { type AssistantTarget, getFormatter, type InstructionFormatter, GitHubCopilotFormatter, ClaudeFormatter, CopilotChatFormatter, GenericFormatter, } from './formatters';
|
|
4
|
+
export * from './types';
|
|
5
|
+
import type { Config, MergedConfig } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Merge user config with built-in config (browser version - no filesystem access)
|
|
8
|
+
*/
|
|
9
|
+
export declare function mergeConfigs(userConfig: Partial<Config>): MergedConfig;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MergedConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* This is the "brain" of the tool.
|
|
4
|
+
* It contains all the pre-configured rules for common frameworks and tools.
|
|
5
|
+
* This configuration is used automatically, so the user doesn't have to
|
|
6
|
+
* create a config file for basic projects.
|
|
7
|
+
*/
|
|
8
|
+
export declare const BUILT_IN_CONFIG: MergedConfig;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Plugin Class
|
|
3
|
+
*
|
|
4
|
+
* Abstract base class providing common functionality for all language plugins.
|
|
5
|
+
* Plugins should extend this class and implement the abstract methods.
|
|
6
|
+
*/
|
|
7
|
+
import type { ConfigFileTagMap, DependencyTagMap, FileGlobTagMap, LanguagePlugin, ProjectMetadata, TemplateDefinition } from '../../types';
|
|
8
|
+
export declare abstract class BasePlugin implements LanguagePlugin {
|
|
9
|
+
abstract name: string;
|
|
10
|
+
abstract displayName: string;
|
|
11
|
+
abstract version: string;
|
|
12
|
+
abstract priority: number;
|
|
13
|
+
/**
|
|
14
|
+
* Abstract method: Detect if this plugin applies to the project
|
|
15
|
+
*/
|
|
16
|
+
abstract detect(projectPath: string): Promise<ProjectMetadata | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Abstract method: Get templates provided by this plugin
|
|
19
|
+
*/
|
|
20
|
+
abstract getTemplates(): TemplateDefinition[] | Promise<TemplateDefinition[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Optional: Get dependency-to-tag mapping
|
|
23
|
+
*/
|
|
24
|
+
getDependencyTagMap?(): DependencyTagMap;
|
|
25
|
+
/**
|
|
26
|
+
* Optional: Get config file-to-tag mapping
|
|
27
|
+
*/
|
|
28
|
+
getConfigFileTagMap?(): ConfigFileTagMap;
|
|
29
|
+
/**
|
|
30
|
+
* Optional: Get file glob-to-tag mapping
|
|
31
|
+
*/
|
|
32
|
+
getFileGlobTagMap?(): FileGlobTagMap;
|
|
33
|
+
/**
|
|
34
|
+
* Check if a file exists in the project
|
|
35
|
+
*/
|
|
36
|
+
protected fileExists(projectPath: string, filename: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Read a file from the project
|
|
39
|
+
*/
|
|
40
|
+
protected readFile(projectPath: string, filename: string): string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Parse JSON file from the project
|
|
43
|
+
*/
|
|
44
|
+
protected readJSON<T = Record<string, unknown>>(projectPath: string, filename: string): T | null;
|
|
45
|
+
/**
|
|
46
|
+
* Get project name from path
|
|
47
|
+
*/
|
|
48
|
+
protected getProjectName(projectPath: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Load template from file
|
|
51
|
+
*/
|
|
52
|
+
protected loadTemplateFromFile(templatePath: string): Promise<string | null>;
|
|
53
|
+
/**
|
|
54
|
+
* Create a template definition with lazy loading
|
|
55
|
+
*/
|
|
56
|
+
protected createTemplate(name: string, tags: string[], contentOrPath: string | (() => string | Promise<string>), options?: Partial<TemplateDefinition>): TemplateDefinition;
|
|
57
|
+
/**
|
|
58
|
+
* Parse dependencies from package-like files
|
|
59
|
+
*/
|
|
60
|
+
protected parseDependencies(obj: Record<string, unknown>, ...keys: string[]): Record<string, string>;
|
|
61
|
+
/**
|
|
62
|
+
* Find files matching a pattern
|
|
63
|
+
*/
|
|
64
|
+
protected findFiles(projectPath: string, pattern: string): Promise<string[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Check if any files exist matching a pattern
|
|
67
|
+
*/
|
|
68
|
+
protected hasFiles(projectPath: string, pattern: string): Promise<boolean>;
|
|
69
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C# / .NET Language Plugin
|
|
3
|
+
*
|
|
4
|
+
* Detects C# projects via .csproj files
|
|
5
|
+
*/
|
|
6
|
+
import type { ProjectMetadata, TemplateDefinition } from '../../types';
|
|
7
|
+
import { BasePlugin } from '../base/BasePlugin';
|
|
8
|
+
export declare class CSharpPlugin extends BasePlugin {
|
|
9
|
+
name: string;
|
|
10
|
+
displayName: string;
|
|
11
|
+
version: string;
|
|
12
|
+
priority: number;
|
|
13
|
+
detect(projectPath: string): Promise<ProjectMetadata | null>;
|
|
14
|
+
getTemplates(): TemplateDefinition[];
|
|
15
|
+
getDependencyTagMap(): {
|
|
16
|
+
'Microsoft.AspNetCore': string;
|
|
17
|
+
xunit: string;
|
|
18
|
+
NUnit: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Language Plugin
|
|
3
|
+
*
|
|
4
|
+
* Detects Go projects via go.mod file
|
|
5
|
+
* Parses module dependencies from go.mod
|
|
6
|
+
*/
|
|
7
|
+
import type { ProjectMetadata, TemplateDefinition } from '../../types';
|
|
8
|
+
import { BasePlugin } from '../base/BasePlugin';
|
|
9
|
+
export declare class GoPlugin extends BasePlugin {
|
|
10
|
+
name: string;
|
|
11
|
+
displayName: string;
|
|
12
|
+
version: string;
|
|
13
|
+
priority: number;
|
|
14
|
+
detect(projectPath: string): Promise<ProjectMetadata | null>;
|
|
15
|
+
getTemplates(): TemplateDefinition[];
|
|
16
|
+
getDependencyTagMap(): {
|
|
17
|
+
'github.com/gin-gonic/gin': string;
|
|
18
|
+
'github.com/gofiber/fiber': string;
|
|
19
|
+
'github.com/labstack/echo': string;
|
|
20
|
+
'gorm.io/gorm': string;
|
|
21
|
+
};
|
|
22
|
+
private getGoTemplate;
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Magic Helix Language Plugins
|
|
3
|
+
*
|
|
4
|
+
* Built-in language detection plugins for popular languages.
|
|
5
|
+
*/
|
|
6
|
+
export { BasePlugin } from './base/BasePlugin';
|
|
7
|
+
export { NodeJSPlugin } from './nodejs';
|
|
8
|
+
export { GoPlugin } from './go';
|
|
9
|
+
export { PythonPlugin } from './python';
|
|
10
|
+
export { RustPlugin } from './rust';
|
|
11
|
+
export { JavaPlugin } from './java';
|
|
12
|
+
export { RubyPlugin } from './ruby';
|
|
13
|
+
export { PHPPlugin } from './php';
|
|
14
|
+
export { CSharpPlugin } from './csharp';
|
|
15
|
+
export { SwiftPlugin } from './swift';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Java Language Plugin
|
|
3
|
+
*
|
|
4
|
+
* Detects Java projects via pom.xml (Maven) or build.gradle (Gradle)
|
|
5
|
+
*/
|
|
6
|
+
import type { ProjectMetadata, TemplateDefinition } from '../../types';
|
|
7
|
+
import { BasePlugin } from '../base/BasePlugin';
|
|
8
|
+
export declare class JavaPlugin extends BasePlugin {
|
|
9
|
+
name: string;
|
|
10
|
+
displayName: string;
|
|
11
|
+
version: string;
|
|
12
|
+
priority: number;
|
|
13
|
+
detect(projectPath: string): Promise<ProjectMetadata | null>;
|
|
14
|
+
getTemplates(): TemplateDefinition[];
|
|
15
|
+
getDependencyTagMap(): {
|
|
16
|
+
'org.springframework.boot:spring-boot': string;
|
|
17
|
+
'spring-boot-starter': string;
|
|
18
|
+
junit: string;
|
|
19
|
+
};
|
|
20
|
+
private detectMaven;
|
|
21
|
+
private detectGradle;
|
|
22
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js Language Plugin
|
|
3
|
+
*
|
|
4
|
+
* Detects Node.js/JavaScript/TypeScript projects via package.json
|
|
5
|
+
* Supports npm workspaces for monorepo detection
|
|
6
|
+
*/
|
|
7
|
+
import type { ProjectMetadata, TemplateDefinition } from '../../types';
|
|
8
|
+
import { BasePlugin } from '../base/BasePlugin';
|
|
9
|
+
export declare class NodeJSPlugin extends BasePlugin {
|
|
10
|
+
name: string;
|
|
11
|
+
displayName: string;
|
|
12
|
+
version: string;
|
|
13
|
+
priority: number;
|
|
14
|
+
detect(projectPath: string): Promise<ProjectMetadata | null>;
|
|
15
|
+
getTemplates(): TemplateDefinition[];
|
|
16
|
+
getDependencyTagMap(): {
|
|
17
|
+
react: string;
|
|
18
|
+
'react-dom': string;
|
|
19
|
+
vue: string;
|
|
20
|
+
'@vue/runtime-core': string;
|
|
21
|
+
pinia: string;
|
|
22
|
+
'@nestjs/core': string;
|
|
23
|
+
tailwindcss: string;
|
|
24
|
+
vitest: string;
|
|
25
|
+
zustand: string;
|
|
26
|
+
typescript: string;
|
|
27
|
+
};
|
|
28
|
+
getConfigFileTagMap(): {
|
|
29
|
+
'tailwind.config.js': string;
|
|
30
|
+
'tailwind.config.ts': string;
|
|
31
|
+
'vitest.config.js': string;
|
|
32
|
+
'vitest.config.ts': string;
|
|
33
|
+
'tsconfig.json': string;
|
|
34
|
+
};
|
|
35
|
+
private extractWorkspaces;
|
|
36
|
+
private getTypescriptTemplate;
|
|
37
|
+
private getReactTemplate;
|
|
38
|
+
private getReactZustandTemplate;
|
|
39
|
+
private getVueTemplate;
|
|
40
|
+
private getVuePiniaTemplate;
|
|
41
|
+
private getNestJSTemplate;
|
|
42
|
+
private getTailwindTemplate;
|
|
43
|
+
private getVitestTemplate;
|
|
44
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PHP Language Plugin
|
|
3
|
+
*
|
|
4
|
+
* Detects PHP projects via composer.json
|
|
5
|
+
*/
|
|
6
|
+
import type { ProjectMetadata, TemplateDefinition } from '../../types';
|
|
7
|
+
import { BasePlugin } from '../base/BasePlugin';
|
|
8
|
+
export declare class PHPPlugin extends BasePlugin {
|
|
9
|
+
name: string;
|
|
10
|
+
displayName: string;
|
|
11
|
+
version: string;
|
|
12
|
+
priority: number;
|
|
13
|
+
detect(projectPath: string): Promise<ProjectMetadata | null>;
|
|
14
|
+
getTemplates(): TemplateDefinition[];
|
|
15
|
+
getDependencyTagMap(): {
|
|
16
|
+
'laravel/framework': string;
|
|
17
|
+
'symfony/symfony': string;
|
|
18
|
+
'phpunit/phpunit': string;
|
|
19
|
+
};
|
|
20
|
+
}
|