@oalacea/daemon 0.5.0 → 0.5.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/CHANGELOG.md +46 -38
- package/LICENSE +23 -23
- package/README.md +147 -141
- package/agents/deps-analyzer.js +366 -366
- package/agents/detector.js +570 -570
- package/agents/fix-engine.js +305 -305
- package/agents/lighthouse-scanner.js +405 -405
- package/agents/perf-analyzer.js +294 -294
- package/agents/perf-front-analyzer.js +229 -229
- package/agents/test-generator.js +387 -387
- package/agents/test-runner.js +318 -318
- package/bin/Dockerfile +75 -74
- package/bin/cli.js +449 -449
- package/lib/config.js +250 -250
- package/lib/docker.js +207 -207
- package/lib/reporter.js +297 -297
- package/package.json +34 -34
- package/prompts/DEPS_EFFICIENCY.md +558 -558
- package/prompts/E2E.md +491 -491
- package/prompts/EXECUTE.md +1060 -1060
- package/prompts/INTEGRATION_API.md +484 -484
- package/prompts/INTEGRATION_DB.md +425 -425
- package/prompts/PERF_API.md +433 -433
- package/prompts/PERF_DB.md +430 -430
- package/prompts/PERF_FRONT.md +357 -357
- package/prompts/REMEDIATION.md +482 -482
- package/prompts/UNIT.md +260 -260
- package/scripts/dev.js +106 -106
- package/templates/README.md +38 -38
- package/templates/k6/load-test.js +54 -54
- package/templates/playwright/e2e.spec.ts +61 -61
- package/templates/vitest/angular-component.test.ts +38 -38
- package/templates/vitest/api.test.ts +51 -51
- package/templates/vitest/component.test.ts +27 -27
- package/templates/vitest/hook.test.ts +36 -36
- package/templates/vitest/solid-component.test.ts +34 -34
- package/templates/vitest/svelte-component.test.ts +33 -33
- package/templates/vitest/vue-component.test.ts +39 -39
package/lib/config.js
CHANGED
|
@@ -1,250 +1,250 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Daemon - Configuration Utilities
|
|
3
|
-
*
|
|
4
|
-
* Handles project configuration and settings.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const fs = require('fs');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Get project root directory
|
|
12
|
-
*/
|
|
13
|
-
function getProjectRoot() {
|
|
14
|
-
let currentDir = process.cwd();
|
|
15
|
-
|
|
16
|
-
while (currentDir !== path.parse(currentDir).root) {
|
|
17
|
-
const pkgPath = path.join(currentDir, 'package.json');
|
|
18
|
-
|
|
19
|
-
if (fs.existsSync(pkgPath)) {
|
|
20
|
-
return currentDir;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
currentDir = path.dirname(currentDir);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return process.cwd();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Read package.json
|
|
31
|
-
*/
|
|
32
|
-
function readPackageJson(projectDir = getProjectRoot()) {
|
|
33
|
-
const pkgPath = path.join(projectDir, 'package.json');
|
|
34
|
-
|
|
35
|
-
if (!fs.existsSync(pkgPath)) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
return JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
41
|
-
} catch {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Get all dependencies
|
|
48
|
-
*/
|
|
49
|
-
function getDependencies(projectDir = getProjectRoot()) {
|
|
50
|
-
const pkg = readPackageJson(projectDir);
|
|
51
|
-
|
|
52
|
-
if (!pkg) {
|
|
53
|
-
return {};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
...(pkg.dependencies || {}),
|
|
58
|
-
...(pkg.devDependencies || {}),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Check if a dependency exists
|
|
64
|
-
*/
|
|
65
|
-
function hasDependency(depName, projectDir = getProjectRoot()) {
|
|
66
|
-
const deps = getDependencies(projectDir);
|
|
67
|
-
return depName in deps;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Get dependency version
|
|
72
|
-
*/
|
|
73
|
-
function getDependencyVersion(depName, projectDir = getProjectRoot()) {
|
|
74
|
-
const deps = getDependencies(projectDir);
|
|
75
|
-
return deps[depName] || null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Check if project uses TypeScript
|
|
80
|
-
*/
|
|
81
|
-
function isTypeScriptProject(projectDir = getProjectRoot()) {
|
|
82
|
-
return (
|
|
83
|
-
hasDependency('typescript', projectDir) ||
|
|
84
|
-
fs.existsSync(path.join(projectDir, 'tsconfig.json'))
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Get test runner
|
|
90
|
-
*/
|
|
91
|
-
function getTestRunner(projectDir = getProjectRoot()) {
|
|
92
|
-
const deps = getDependencies(projectDir);
|
|
93
|
-
|
|
94
|
-
if (deps.vitest) return 'vitest';
|
|
95
|
-
if (deps.jest) return 'jest';
|
|
96
|
-
if (deps.mocha) return 'mocha';
|
|
97
|
-
if (deps.jasmine) return 'jasmine';
|
|
98
|
-
|
|
99
|
-
// Check config files
|
|
100
|
-
const vitestConfig = path.join(projectDir, 'vitest.config.ts');
|
|
101
|
-
const jestConfig = path.join(projectDir, 'jest.config.js');
|
|
102
|
-
|
|
103
|
-
if (fs.existsSync(vitestConfig)) return 'vitest';
|
|
104
|
-
if (fs.existsSync(jestConfig)) return 'jest';
|
|
105
|
-
|
|
106
|
-
return 'vitest'; // Default
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Get framework
|
|
111
|
-
*/
|
|
112
|
-
function getFramework(projectDir = getProjectRoot()) {
|
|
113
|
-
const deps = getDependencies(projectDir);
|
|
114
|
-
|
|
115
|
-
// Meta-frameworks
|
|
116
|
-
if (deps.next) return 'Next.js';
|
|
117
|
-
if (deps['@remix-run/node']) return 'Remix';
|
|
118
|
-
if (deps['@sveltejs/kit']) return 'SvelteKit';
|
|
119
|
-
if (deps.nuxt) return 'Nuxt';
|
|
120
|
-
if (deps.astro) return 'Astro';
|
|
121
|
-
if (deps.gatsby) return 'Gatsby';
|
|
122
|
-
|
|
123
|
-
// UI frameworks
|
|
124
|
-
if (deps['solid-js']) return 'Solid';
|
|
125
|
-
if (deps['@angular/core']) return 'Angular';
|
|
126
|
-
if (deps.vue) return 'Vue';
|
|
127
|
-
if (deps.svelte) return 'Svelte';
|
|
128
|
-
if (deps['react-native']) return 'React Native';
|
|
129
|
-
|
|
130
|
-
// Build tools / Runtimes
|
|
131
|
-
if (deps.vite) return 'Vite';
|
|
132
|
-
if (deps.express) return 'Express';
|
|
133
|
-
if (deps.nest) return 'NestJS';
|
|
134
|
-
|
|
135
|
-
// Check for React without a specific framework
|
|
136
|
-
if (deps.react && deps['react-dom']) return 'React';
|
|
137
|
-
|
|
138
|
-
return 'Unknown';
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Get database config
|
|
143
|
-
*/
|
|
144
|
-
function getDatabaseConfig(projectDir = getProjectRoot()) {
|
|
145
|
-
const deps = getDependencies(projectDir);
|
|
146
|
-
|
|
147
|
-
if (deps['@prisma/client']) {
|
|
148
|
-
return {
|
|
149
|
-
type: 'Prisma',
|
|
150
|
-
schemaPath: path.join(projectDir, 'prisma', 'schema.prisma'),
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (deps['drizzle-orm']) {
|
|
155
|
-
return {
|
|
156
|
-
type: 'Drizzle',
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (deps.typeorm) {
|
|
161
|
-
return {
|
|
162
|
-
type: 'TypeORM',
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (deps.mongoose) {
|
|
167
|
-
return {
|
|
168
|
-
type: 'Mongoose',
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Get environment variable
|
|
177
|
-
*/
|
|
178
|
-
function getEnvVar(key, defaultValue = null) {
|
|
179
|
-
return process.env[key] || defaultValue;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Get Daemon config from package.json
|
|
184
|
-
*/
|
|
185
|
-
function getDaemonConfig(projectDir = getProjectRoot()) {
|
|
186
|
-
const pkg = readPackageJson(projectDir);
|
|
187
|
-
|
|
188
|
-
if (!pkg || !pkg.daemon) {
|
|
189
|
-
return {};
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return pkg.daemon;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Get source directory
|
|
197
|
-
*/
|
|
198
|
-
function getSourceDir(projectDir = getProjectRoot()) {
|
|
199
|
-
const srcDir = path.join(projectDir, 'src');
|
|
200
|
-
const appDir = path.join(projectDir, 'app');
|
|
201
|
-
|
|
202
|
-
if (fs.existsSync(appDir)) {
|
|
203
|
-
return 'app';
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (fs.existsSync(srcDir)) {
|
|
207
|
-
return 'src';
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return '.';
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Get test directory
|
|
215
|
-
*/
|
|
216
|
-
function getTestDir(projectDir = getProjectRoot()) {
|
|
217
|
-
const testsDir = path.join(projectDir, 'tests');
|
|
218
|
-
const testDir = path.join(projectDir, 'test');
|
|
219
|
-
const srcTestsDir = path.join(getSourceDir(projectDir), 'tests');
|
|
220
|
-
|
|
221
|
-
if (fs.existsSync(testsDir)) {
|
|
222
|
-
return 'tests';
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (fs.existsSync(testDir)) {
|
|
226
|
-
return 'test';
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
if (fs.existsSync(srcTestsDir)) {
|
|
230
|
-
return path.join(getSourceDir(projectDir), 'tests');
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
return 'tests';
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
module.exports = {
|
|
237
|
-
getProjectRoot,
|
|
238
|
-
readPackageJson,
|
|
239
|
-
getDependencies,
|
|
240
|
-
hasDependency,
|
|
241
|
-
getDependencyVersion,
|
|
242
|
-
isTypeScriptProject,
|
|
243
|
-
getTestRunner,
|
|
244
|
-
getFramework,
|
|
245
|
-
getDatabaseConfig,
|
|
246
|
-
getEnvVar,
|
|
247
|
-
getDaemonConfig,
|
|
248
|
-
getSourceDir,
|
|
249
|
-
getTestDir,
|
|
250
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Daemon - Configuration Utilities
|
|
3
|
+
*
|
|
4
|
+
* Handles project configuration and settings.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Get project root directory
|
|
12
|
+
*/
|
|
13
|
+
function getProjectRoot() {
|
|
14
|
+
let currentDir = process.cwd();
|
|
15
|
+
|
|
16
|
+
while (currentDir !== path.parse(currentDir).root) {
|
|
17
|
+
const pkgPath = path.join(currentDir, 'package.json');
|
|
18
|
+
|
|
19
|
+
if (fs.existsSync(pkgPath)) {
|
|
20
|
+
return currentDir;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
currentDir = path.dirname(currentDir);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return process.cwd();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Read package.json
|
|
31
|
+
*/
|
|
32
|
+
function readPackageJson(projectDir = getProjectRoot()) {
|
|
33
|
+
const pkgPath = path.join(projectDir, 'package.json');
|
|
34
|
+
|
|
35
|
+
if (!fs.existsSync(pkgPath)) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
return JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
41
|
+
} catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Get all dependencies
|
|
48
|
+
*/
|
|
49
|
+
function getDependencies(projectDir = getProjectRoot()) {
|
|
50
|
+
const pkg = readPackageJson(projectDir);
|
|
51
|
+
|
|
52
|
+
if (!pkg) {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
...(pkg.dependencies || {}),
|
|
58
|
+
...(pkg.devDependencies || {}),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Check if a dependency exists
|
|
64
|
+
*/
|
|
65
|
+
function hasDependency(depName, projectDir = getProjectRoot()) {
|
|
66
|
+
const deps = getDependencies(projectDir);
|
|
67
|
+
return depName in deps;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Get dependency version
|
|
72
|
+
*/
|
|
73
|
+
function getDependencyVersion(depName, projectDir = getProjectRoot()) {
|
|
74
|
+
const deps = getDependencies(projectDir);
|
|
75
|
+
return deps[depName] || null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Check if project uses TypeScript
|
|
80
|
+
*/
|
|
81
|
+
function isTypeScriptProject(projectDir = getProjectRoot()) {
|
|
82
|
+
return (
|
|
83
|
+
hasDependency('typescript', projectDir) ||
|
|
84
|
+
fs.existsSync(path.join(projectDir, 'tsconfig.json'))
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get test runner
|
|
90
|
+
*/
|
|
91
|
+
function getTestRunner(projectDir = getProjectRoot()) {
|
|
92
|
+
const deps = getDependencies(projectDir);
|
|
93
|
+
|
|
94
|
+
if (deps.vitest) return 'vitest';
|
|
95
|
+
if (deps.jest) return 'jest';
|
|
96
|
+
if (deps.mocha) return 'mocha';
|
|
97
|
+
if (deps.jasmine) return 'jasmine';
|
|
98
|
+
|
|
99
|
+
// Check config files
|
|
100
|
+
const vitestConfig = path.join(projectDir, 'vitest.config.ts');
|
|
101
|
+
const jestConfig = path.join(projectDir, 'jest.config.js');
|
|
102
|
+
|
|
103
|
+
if (fs.existsSync(vitestConfig)) return 'vitest';
|
|
104
|
+
if (fs.existsSync(jestConfig)) return 'jest';
|
|
105
|
+
|
|
106
|
+
return 'vitest'; // Default
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Get framework
|
|
111
|
+
*/
|
|
112
|
+
function getFramework(projectDir = getProjectRoot()) {
|
|
113
|
+
const deps = getDependencies(projectDir);
|
|
114
|
+
|
|
115
|
+
// Meta-frameworks
|
|
116
|
+
if (deps.next) return 'Next.js';
|
|
117
|
+
if (deps['@remix-run/node']) return 'Remix';
|
|
118
|
+
if (deps['@sveltejs/kit']) return 'SvelteKit';
|
|
119
|
+
if (deps.nuxt) return 'Nuxt';
|
|
120
|
+
if (deps.astro) return 'Astro';
|
|
121
|
+
if (deps.gatsby) return 'Gatsby';
|
|
122
|
+
|
|
123
|
+
// UI frameworks
|
|
124
|
+
if (deps['solid-js']) return 'Solid';
|
|
125
|
+
if (deps['@angular/core']) return 'Angular';
|
|
126
|
+
if (deps.vue) return 'Vue';
|
|
127
|
+
if (deps.svelte) return 'Svelte';
|
|
128
|
+
if (deps['react-native']) return 'React Native';
|
|
129
|
+
|
|
130
|
+
// Build tools / Runtimes
|
|
131
|
+
if (deps.vite) return 'Vite';
|
|
132
|
+
if (deps.express) return 'Express';
|
|
133
|
+
if (deps.nest) return 'NestJS';
|
|
134
|
+
|
|
135
|
+
// Check for React without a specific framework
|
|
136
|
+
if (deps.react && deps['react-dom']) return 'React';
|
|
137
|
+
|
|
138
|
+
return 'Unknown';
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Get database config
|
|
143
|
+
*/
|
|
144
|
+
function getDatabaseConfig(projectDir = getProjectRoot()) {
|
|
145
|
+
const deps = getDependencies(projectDir);
|
|
146
|
+
|
|
147
|
+
if (deps['@prisma/client']) {
|
|
148
|
+
return {
|
|
149
|
+
type: 'Prisma',
|
|
150
|
+
schemaPath: path.join(projectDir, 'prisma', 'schema.prisma'),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (deps['drizzle-orm']) {
|
|
155
|
+
return {
|
|
156
|
+
type: 'Drizzle',
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (deps.typeorm) {
|
|
161
|
+
return {
|
|
162
|
+
type: 'TypeORM',
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (deps.mongoose) {
|
|
167
|
+
return {
|
|
168
|
+
type: 'Mongoose',
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Get environment variable
|
|
177
|
+
*/
|
|
178
|
+
function getEnvVar(key, defaultValue = null) {
|
|
179
|
+
return process.env[key] || defaultValue;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Get Daemon config from package.json
|
|
184
|
+
*/
|
|
185
|
+
function getDaemonConfig(projectDir = getProjectRoot()) {
|
|
186
|
+
const pkg = readPackageJson(projectDir);
|
|
187
|
+
|
|
188
|
+
if (!pkg || !pkg.daemon) {
|
|
189
|
+
return {};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return pkg.daemon;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Get source directory
|
|
197
|
+
*/
|
|
198
|
+
function getSourceDir(projectDir = getProjectRoot()) {
|
|
199
|
+
const srcDir = path.join(projectDir, 'src');
|
|
200
|
+
const appDir = path.join(projectDir, 'app');
|
|
201
|
+
|
|
202
|
+
if (fs.existsSync(appDir)) {
|
|
203
|
+
return 'app';
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (fs.existsSync(srcDir)) {
|
|
207
|
+
return 'src';
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return '.';
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Get test directory
|
|
215
|
+
*/
|
|
216
|
+
function getTestDir(projectDir = getProjectRoot()) {
|
|
217
|
+
const testsDir = path.join(projectDir, 'tests');
|
|
218
|
+
const testDir = path.join(projectDir, 'test');
|
|
219
|
+
const srcTestsDir = path.join(getSourceDir(projectDir), 'tests');
|
|
220
|
+
|
|
221
|
+
if (fs.existsSync(testsDir)) {
|
|
222
|
+
return 'tests';
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (fs.existsSync(testDir)) {
|
|
226
|
+
return 'test';
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (fs.existsSync(srcTestsDir)) {
|
|
230
|
+
return path.join(getSourceDir(projectDir), 'tests');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return 'tests';
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
module.exports = {
|
|
237
|
+
getProjectRoot,
|
|
238
|
+
readPackageJson,
|
|
239
|
+
getDependencies,
|
|
240
|
+
hasDependency,
|
|
241
|
+
getDependencyVersion,
|
|
242
|
+
isTypeScriptProject,
|
|
243
|
+
getTestRunner,
|
|
244
|
+
getFramework,
|
|
245
|
+
getDatabaseConfig,
|
|
246
|
+
getEnvVar,
|
|
247
|
+
getDaemonConfig,
|
|
248
|
+
getSourceDir,
|
|
249
|
+
getTestDir,
|
|
250
|
+
};
|