@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.
Files changed (38) hide show
  1. package/CHANGELOG.md +46 -38
  2. package/LICENSE +23 -23
  3. package/README.md +147 -141
  4. package/agents/deps-analyzer.js +366 -366
  5. package/agents/detector.js +570 -570
  6. package/agents/fix-engine.js +305 -305
  7. package/agents/lighthouse-scanner.js +405 -405
  8. package/agents/perf-analyzer.js +294 -294
  9. package/agents/perf-front-analyzer.js +229 -229
  10. package/agents/test-generator.js +387 -387
  11. package/agents/test-runner.js +318 -318
  12. package/bin/Dockerfile +75 -74
  13. package/bin/cli.js +449 -449
  14. package/lib/config.js +250 -250
  15. package/lib/docker.js +207 -207
  16. package/lib/reporter.js +297 -297
  17. package/package.json +34 -34
  18. package/prompts/DEPS_EFFICIENCY.md +558 -558
  19. package/prompts/E2E.md +491 -491
  20. package/prompts/EXECUTE.md +1060 -1060
  21. package/prompts/INTEGRATION_API.md +484 -484
  22. package/prompts/INTEGRATION_DB.md +425 -425
  23. package/prompts/PERF_API.md +433 -433
  24. package/prompts/PERF_DB.md +430 -430
  25. package/prompts/PERF_FRONT.md +357 -357
  26. package/prompts/REMEDIATION.md +482 -482
  27. package/prompts/UNIT.md +260 -260
  28. package/scripts/dev.js +106 -106
  29. package/templates/README.md +38 -38
  30. package/templates/k6/load-test.js +54 -54
  31. package/templates/playwright/e2e.spec.ts +61 -61
  32. package/templates/vitest/angular-component.test.ts +38 -38
  33. package/templates/vitest/api.test.ts +51 -51
  34. package/templates/vitest/component.test.ts +27 -27
  35. package/templates/vitest/hook.test.ts +36 -36
  36. package/templates/vitest/solid-component.test.ts +34 -34
  37. package/templates/vitest/svelte-component.test.ts +33 -33
  38. package/templates/vitest/vue-component.test.ts +39 -39
package/lib/docker.js CHANGED
@@ -1,207 +1,207 @@
1
- /**
2
- * Daemon - Docker Management
3
- *
4
- * Handles Docker container operations for the Daemon toolkit.
5
- */
6
-
7
- const { execSync } = require('child_process');
8
-
9
- const CONFIG = {
10
- imageName: 'daemon-tools',
11
- containerName: 'daemon-tools',
12
- dockerfile: path.join(__dirname, '..', 'bin', 'Dockerfile'),
13
- };
14
-
15
- /**
16
- * Check if Docker is running
17
- */
18
- function isDockerRunning() {
19
- try {
20
- execSync('docker info', { stdio: 'pipe' });
21
- return true;
22
- } catch {
23
- return false;
24
- }
25
- }
26
-
27
- /**
28
- * Check if image exists
29
- */
30
- function imageExists() {
31
- try {
32
- const output = execSync(`docker images -q ${CONFIG.imageName}`, { stdio: 'pipe' });
33
- return output.trim().length > 0;
34
- } catch {
35
- return false;
36
- }
37
- }
38
-
39
- /**
40
- * Build the Docker image
41
- */
42
- function buildImage(options = {}) {
43
- const cmd = `docker build -t ${CONFIG.imageName} -f "${CONFIG.dockerfile}" "${path.dirname(CONFIG.dockerfile)}"`;
44
-
45
- return execSync(cmd, {
46
- stdio: options.silent ? 'pipe' : 'inherit',
47
- timeout: options.timeout || 600000, // 10 minutes
48
- });
49
- }
50
-
51
- /**
52
- * Check if container is running
53
- */
54
- function isContainerRunning() {
55
- try {
56
- const output = execSync(
57
- `docker ps --filter "name=^${CONFIG.containerName}$" --format "{{.Names}}"`,
58
- { stdio: 'pipe' }
59
- );
60
- return output.trim() === CONFIG.containerName;
61
- } catch {
62
- return false;
63
- }
64
- }
65
-
66
- /**
67
- * Check if container exists
68
- */
69
- function containerExists() {
70
- try {
71
- const output = execSync(
72
- `docker ps -a --filter "name=^${CONFIG.containerName}$" --format "{{.Names}}"`,
73
- { stdio: 'pipe' }
74
- );
75
- return output.trim() === CONFIG.containerName;
76
- } catch {
77
- return false;
78
- }
79
- }
80
-
81
- /**
82
- * Start container
83
- */
84
- function startContainer() {
85
- const cmd = `docker start ${CONFIG.containerName}`;
86
- return execSync(cmd, { stdio: 'pipe' });
87
- }
88
-
89
- /**
90
- * Create container
91
- */
92
- function createContainer(options = {}) {
93
- const isLinux = process.platform === 'linux';
94
- const networkFlag = isLinux ? '--network=host' : '';
95
- const cmd = `docker run -d --name ${CONFIG.containerName} ${networkFlag} ${CONFIG.imageName}`;
96
-
97
- return execSync(cmd, { stdio: 'pipe' });
98
- }
99
-
100
- /**
101
- * Stop container
102
- */
103
- function stopContainer() {
104
- try {
105
- return execSync(`docker stop ${CONFIG.containerName}`, { stdio: 'pipe' });
106
- } catch {
107
- return null;
108
- }
109
- }
110
-
111
- /**
112
- * Remove container
113
- */
114
- function removeContainer() {
115
- try {
116
- return execSync(`docker rm -f ${CONFIG.containerName}`, { stdio: 'pipe' });
117
- } catch {
118
- return null;
119
- }
120
- }
121
-
122
- /**
123
- * Execute command in container
124
- */
125
- function execInContainer(command, options = {}) {
126
- const cmd = `docker exec ${CONFIG.containerName} ${command}`;
127
-
128
- try {
129
- return {
130
- success: true,
131
- output: execSync(cmd, {
132
- encoding: 'utf-8',
133
- stdio: options.silent ? 'pipe' : 'inherit',
134
- timeout: options.timeout || 60000,
135
- }),
136
- };
137
- } catch (error) {
138
- return {
139
- success: false,
140
- error: error.message,
141
- output: error.stdout || '',
142
- };
143
- }
144
- }
145
-
146
- /**
147
- * Get container logs
148
- */
149
- function getLogs(options = {}) {
150
- const tail = options.tail || 100;
151
- const cmd = `docker logs --tail ${tail} ${CONFIG.containerName}`;
152
-
153
- try {
154
- return execSync(cmd, { encoding: 'utf-8', stdio: 'pipe' });
155
- } catch {
156
- return '';
157
- }
158
- }
159
-
160
- /**
161
- * Setup container (build, start, or create as needed)
162
- */
163
- async function setupContainer(options = {}) {
164
- // Check Docker
165
- if (!isDockerRunning()) {
166
- throw new Error('Docker is not running');
167
- }
168
-
169
- // Build image if needed
170
- if (!imageExists()) {
171
- if (options.onBuildStart) {
172
- options.onBuildStart();
173
- }
174
- buildImage({ silent: options.silent });
175
- if (options.onBuildComplete) {
176
- options.onBuildComplete();
177
- }
178
- }
179
-
180
- // Start or create container
181
- if (isContainerRunning()) {
182
- return { status: 'running' };
183
- }
184
-
185
- if (containerExists()) {
186
- startContainer();
187
- return { status: 'started' };
188
- }
189
-
190
- createContainer();
191
- return { status: 'created' };
192
- }
193
-
194
- module.exports = {
195
- isDockerRunning,
196
- imageExists,
197
- buildImage,
198
- isContainerRunning,
199
- containerExists,
200
- startContainer,
201
- createContainer,
202
- stopContainer,
203
- removeContainer,
204
- execInContainer,
205
- getLogs,
206
- setupContainer,
207
- };
1
+ /**
2
+ * Daemon - Docker Management
3
+ *
4
+ * Handles Docker container operations for the Daemon toolkit.
5
+ */
6
+
7
+ const { execSync } = require('child_process');
8
+
9
+ const CONFIG = {
10
+ imageName: 'daemon-tools',
11
+ containerName: 'daemon-tools',
12
+ dockerfile: path.join(__dirname, '..', 'bin', 'Dockerfile'),
13
+ };
14
+
15
+ /**
16
+ * Check if Docker is running
17
+ */
18
+ function isDockerRunning() {
19
+ try {
20
+ execSync('docker info', { stdio: 'pipe' });
21
+ return true;
22
+ } catch {
23
+ return false;
24
+ }
25
+ }
26
+
27
+ /**
28
+ * Check if image exists
29
+ */
30
+ function imageExists() {
31
+ try {
32
+ const output = execSync(`docker images -q ${CONFIG.imageName}`, { stdio: 'pipe' });
33
+ return output.trim().length > 0;
34
+ } catch {
35
+ return false;
36
+ }
37
+ }
38
+
39
+ /**
40
+ * Build the Docker image
41
+ */
42
+ function buildImage(options = {}) {
43
+ const cmd = `docker build -t ${CONFIG.imageName} -f "${CONFIG.dockerfile}" "${path.dirname(CONFIG.dockerfile)}"`;
44
+
45
+ return execSync(cmd, {
46
+ stdio: options.silent ? 'pipe' : 'inherit',
47
+ timeout: options.timeout || 600000, // 10 minutes
48
+ });
49
+ }
50
+
51
+ /**
52
+ * Check if container is running
53
+ */
54
+ function isContainerRunning() {
55
+ try {
56
+ const output = execSync(
57
+ `docker ps --filter "name=^${CONFIG.containerName}$" --format "{{.Names}}"`,
58
+ { stdio: 'pipe' }
59
+ );
60
+ return output.trim() === CONFIG.containerName;
61
+ } catch {
62
+ return false;
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Check if container exists
68
+ */
69
+ function containerExists() {
70
+ try {
71
+ const output = execSync(
72
+ `docker ps -a --filter "name=^${CONFIG.containerName}$" --format "{{.Names}}"`,
73
+ { stdio: 'pipe' }
74
+ );
75
+ return output.trim() === CONFIG.containerName;
76
+ } catch {
77
+ return false;
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Start container
83
+ */
84
+ function startContainer() {
85
+ const cmd = `docker start ${CONFIG.containerName}`;
86
+ return execSync(cmd, { stdio: 'pipe' });
87
+ }
88
+
89
+ /**
90
+ * Create container
91
+ */
92
+ function createContainer(options = {}) {
93
+ const isLinux = process.platform === 'linux';
94
+ const networkFlag = isLinux ? '--network=host' : '';
95
+ const cmd = `docker run -d --name ${CONFIG.containerName} ${networkFlag} ${CONFIG.imageName}`;
96
+
97
+ return execSync(cmd, { stdio: 'pipe' });
98
+ }
99
+
100
+ /**
101
+ * Stop container
102
+ */
103
+ function stopContainer() {
104
+ try {
105
+ return execSync(`docker stop ${CONFIG.containerName}`, { stdio: 'pipe' });
106
+ } catch {
107
+ return null;
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Remove container
113
+ */
114
+ function removeContainer() {
115
+ try {
116
+ return execSync(`docker rm -f ${CONFIG.containerName}`, { stdio: 'pipe' });
117
+ } catch {
118
+ return null;
119
+ }
120
+ }
121
+
122
+ /**
123
+ * Execute command in container
124
+ */
125
+ function execInContainer(command, options = {}) {
126
+ const cmd = `docker exec ${CONFIG.containerName} ${command}`;
127
+
128
+ try {
129
+ return {
130
+ success: true,
131
+ output: execSync(cmd, {
132
+ encoding: 'utf-8',
133
+ stdio: options.silent ? 'pipe' : 'inherit',
134
+ timeout: options.timeout || 60000,
135
+ }),
136
+ };
137
+ } catch (error) {
138
+ return {
139
+ success: false,
140
+ error: error.message,
141
+ output: error.stdout || '',
142
+ };
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Get container logs
148
+ */
149
+ function getLogs(options = {}) {
150
+ const tail = options.tail || 100;
151
+ const cmd = `docker logs --tail ${tail} ${CONFIG.containerName}`;
152
+
153
+ try {
154
+ return execSync(cmd, { encoding: 'utf-8', stdio: 'pipe' });
155
+ } catch {
156
+ return '';
157
+ }
158
+ }
159
+
160
+ /**
161
+ * Setup container (build, start, or create as needed)
162
+ */
163
+ async function setupContainer(options = {}) {
164
+ // Check Docker
165
+ if (!isDockerRunning()) {
166
+ throw new Error('Docker is not running');
167
+ }
168
+
169
+ // Build image if needed
170
+ if (!imageExists()) {
171
+ if (options.onBuildStart) {
172
+ options.onBuildStart();
173
+ }
174
+ buildImage({ silent: options.silent });
175
+ if (options.onBuildComplete) {
176
+ options.onBuildComplete();
177
+ }
178
+ }
179
+
180
+ // Start or create container
181
+ if (isContainerRunning()) {
182
+ return { status: 'running' };
183
+ }
184
+
185
+ if (containerExists()) {
186
+ startContainer();
187
+ return { status: 'started' };
188
+ }
189
+
190
+ createContainer();
191
+ return { status: 'created' };
192
+ }
193
+
194
+ module.exports = {
195
+ isDockerRunning,
196
+ imageExists,
197
+ buildImage,
198
+ isContainerRunning,
199
+ containerExists,
200
+ startContainer,
201
+ createContainer,
202
+ stopContainer,
203
+ removeContainer,
204
+ execInContainer,
205
+ getLogs,
206
+ setupContainer,
207
+ };