@oalacea/daemon 0.5.1 → 0.6.0

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 (199) hide show
  1. package/dist/cli/cli.d.ts +42 -0
  2. package/dist/cli/cli.d.ts.map +1 -0
  3. package/dist/cli/cli.js +89 -0
  4. package/dist/cli/cli.js.map +1 -0
  5. package/dist/cli/commands/detect.command.d.ts +39 -0
  6. package/dist/cli/commands/detect.command.d.ts.map +1 -0
  7. package/dist/cli/commands/detect.command.js +111 -0
  8. package/dist/cli/commands/detect.command.js.map +1 -0
  9. package/dist/cli/commands/index.d.ts +14 -0
  10. package/dist/cli/commands/index.d.ts.map +1 -0
  11. package/dist/cli/commands/index.js +11 -0
  12. package/dist/cli/commands/index.js.map +1 -0
  13. package/dist/cli/commands/init.command.d.ts +41 -0
  14. package/dist/cli/commands/init.command.d.ts.map +1 -0
  15. package/dist/cli/commands/init.command.js +111 -0
  16. package/dist/cli/commands/init.command.js.map +1 -0
  17. package/dist/cli/commands/test.command.d.ts +58 -0
  18. package/dist/cli/commands/test.command.d.ts.map +1 -0
  19. package/dist/cli/commands/test.command.js +180 -0
  20. package/dist/cli/commands/test.command.js.map +1 -0
  21. package/dist/cli/index.d.ts +8 -0
  22. package/dist/cli/index.d.ts.map +1 -0
  23. package/dist/cli/index.js +10 -0
  24. package/dist/cli/index.js.map +1 -0
  25. package/dist/core/config/daemon.config.d.ts +32 -0
  26. package/dist/core/config/daemon.config.d.ts.map +1 -0
  27. package/dist/core/config/daemon.config.js +83 -0
  28. package/dist/core/config/daemon.config.js.map +1 -0
  29. package/dist/core/config/index.d.ts +5 -0
  30. package/dist/core/config/index.d.ts.map +1 -0
  31. package/dist/core/config/index.js +5 -0
  32. package/dist/core/config/index.js.map +1 -0
  33. package/dist/core/constants.d.ts +36 -0
  34. package/dist/core/constants.d.ts.map +1 -0
  35. package/dist/core/constants.js +56 -0
  36. package/dist/core/constants.js.map +1 -0
  37. package/dist/core/types/common.types.d.ts +250 -0
  38. package/dist/core/types/common.types.d.ts.map +1 -0
  39. package/dist/core/types/common.types.js +7 -0
  40. package/dist/core/types/common.types.js.map +1 -0
  41. package/dist/core/types/detection.types.d.ts +232 -0
  42. package/dist/core/types/detection.types.d.ts.map +1 -0
  43. package/dist/core/types/detection.types.js +22 -0
  44. package/dist/core/types/detection.types.js.map +1 -0
  45. package/dist/core/types/docker.types.d.ts +322 -0
  46. package/dist/core/types/docker.types.d.ts.map +1 -0
  47. package/dist/core/types/docker.types.js +7 -0
  48. package/dist/core/types/docker.types.js.map +1 -0
  49. package/dist/core/types/index.d.ts +11 -0
  50. package/dist/core/types/index.d.ts.map +1 -0
  51. package/dist/core/types/index.js +7 -0
  52. package/dist/core/types/index.js.map +1 -0
  53. package/dist/core/types/project.types.d.ts +74 -0
  54. package/dist/core/types/project.types.d.ts.map +1 -0
  55. package/dist/core/types/project.types.js +7 -0
  56. package/dist/core/types/project.types.js.map +1 -0
  57. package/dist/core/types/shared.types.d.ts +118 -0
  58. package/dist/core/types/shared.types.d.ts.map +1 -0
  59. package/dist/core/types/shared.types.js +7 -0
  60. package/dist/core/types/shared.types.js.map +1 -0
  61. package/dist/core/types/test.types.d.ts +230 -0
  62. package/dist/core/types/test.types.d.ts.map +1 -0
  63. package/dist/core/types/test.types.js +7 -0
  64. package/dist/core/types/test.types.js.map +1 -0
  65. package/dist/services/detection/__tests__/framework-detector.test.d.ts +5 -0
  66. package/dist/services/detection/__tests__/framework-detector.test.d.ts.map +1 -0
  67. package/dist/services/detection/__tests__/framework-detector.test.js +52 -0
  68. package/dist/services/detection/__tests__/framework-detector.test.js.map +1 -0
  69. package/dist/services/detection/framework-detector.d.ts +179 -0
  70. package/dist/services/detection/framework-detector.d.ts.map +1 -0
  71. package/dist/services/detection/framework-detector.js +636 -0
  72. package/dist/services/detection/framework-detector.js.map +1 -0
  73. package/dist/services/detection/index.d.ts +10 -0
  74. package/dist/services/detection/index.d.ts.map +1 -0
  75. package/dist/services/detection/index.js +7 -0
  76. package/dist/services/detection/index.js.map +1 -0
  77. package/dist/services/docker/__tests__/docker-manager.test.d.ts +5 -0
  78. package/dist/services/docker/__tests__/docker-manager.test.d.ts.map +1 -0
  79. package/dist/services/docker/__tests__/docker-manager.test.js +67 -0
  80. package/dist/services/docker/__tests__/docker-manager.test.js.map +1 -0
  81. package/dist/services/docker/docker-manager.d.ts +157 -0
  82. package/dist/services/docker/docker-manager.d.ts.map +1 -0
  83. package/dist/services/docker/docker-manager.js +516 -0
  84. package/dist/services/docker/docker-manager.js.map +1 -0
  85. package/dist/services/docker/index.d.ts +9 -0
  86. package/dist/services/docker/index.d.ts.map +1 -0
  87. package/dist/services/docker/index.js +9 -0
  88. package/dist/services/docker/index.js.map +1 -0
  89. package/dist/services/index.d.ts +10 -0
  90. package/dist/services/index.d.ts.map +1 -0
  91. package/dist/services/index.js +8 -0
  92. package/dist/services/index.js.map +1 -0
  93. package/dist/shared/errors/__tests__/base.error.test.d.ts +5 -0
  94. package/dist/shared/errors/__tests__/base.error.test.d.ts.map +1 -0
  95. package/dist/shared/errors/__tests__/base.error.test.js +61 -0
  96. package/dist/shared/errors/__tests__/base.error.test.js.map +1 -0
  97. package/dist/shared/errors/__tests__/command.error.test.d.ts +5 -0
  98. package/dist/shared/errors/__tests__/command.error.test.d.ts.map +1 -0
  99. package/dist/shared/errors/__tests__/command.error.test.js +62 -0
  100. package/dist/shared/errors/__tests__/command.error.test.js.map +1 -0
  101. package/dist/shared/errors/__tests__/file.error.test.d.ts +5 -0
  102. package/dist/shared/errors/__tests__/file.error.test.d.ts.map +1 -0
  103. package/dist/shared/errors/__tests__/file.error.test.js +75 -0
  104. package/dist/shared/errors/__tests__/file.error.test.js.map +1 -0
  105. package/dist/shared/errors/__tests__/index.test.d.ts +5 -0
  106. package/dist/shared/errors/__tests__/index.test.d.ts.map +1 -0
  107. package/dist/shared/errors/__tests__/index.test.js +62 -0
  108. package/dist/shared/errors/__tests__/index.test.js.map +1 -0
  109. package/dist/shared/errors/__tests__/validation.error.test.d.ts +5 -0
  110. package/dist/shared/errors/__tests__/validation.error.test.d.ts.map +1 -0
  111. package/dist/shared/errors/__tests__/validation.error.test.js +79 -0
  112. package/dist/shared/errors/__tests__/validation.error.test.js.map +1 -0
  113. package/dist/shared/errors/base.error.d.ts +54 -0
  114. package/dist/shared/errors/base.error.d.ts.map +1 -0
  115. package/dist/shared/errors/base.error.js +85 -0
  116. package/dist/shared/errors/base.error.js.map +1 -0
  117. package/dist/shared/errors/command.error.d.ts +58 -0
  118. package/dist/shared/errors/command.error.d.ts.map +1 -0
  119. package/dist/shared/errors/command.error.js +102 -0
  120. package/dist/shared/errors/command.error.js.map +1 -0
  121. package/dist/shared/errors/detection.error.d.ts +42 -0
  122. package/dist/shared/errors/detection.error.d.ts.map +1 -0
  123. package/dist/shared/errors/detection.error.js +82 -0
  124. package/dist/shared/errors/detection.error.js.map +1 -0
  125. package/dist/shared/errors/docker.error.d.ts +142 -0
  126. package/dist/shared/errors/docker.error.d.ts.map +1 -0
  127. package/dist/shared/errors/docker.error.js +172 -0
  128. package/dist/shared/errors/docker.error.js.map +1 -0
  129. package/dist/shared/errors/file.error.d.ts +66 -0
  130. package/dist/shared/errors/file.error.d.ts.map +1 -0
  131. package/dist/shared/errors/file.error.js +93 -0
  132. package/dist/shared/errors/file.error.js.map +1 -0
  133. package/dist/shared/errors/index.d.ts +56 -0
  134. package/dist/shared/errors/index.d.ts.map +1 -0
  135. package/dist/shared/errors/index.js +86 -0
  136. package/dist/shared/errors/index.js.map +1 -0
  137. package/dist/shared/errors/validation.error.d.ts +67 -0
  138. package/dist/shared/errors/validation.error.d.ts.map +1 -0
  139. package/dist/shared/errors/validation.error.js +97 -0
  140. package/dist/shared/errors/validation.error.js.map +1 -0
  141. package/dist/shared/templates/index.d.ts +2 -0
  142. package/dist/shared/templates/index.d.ts.map +1 -0
  143. package/dist/shared/templates/index.js +2 -0
  144. package/dist/shared/templates/index.js.map +1 -0
  145. package/dist/shared/templates/prompt-builder.d.ts +2 -0
  146. package/dist/shared/templates/prompt-builder.d.ts.map +1 -0
  147. package/dist/shared/templates/prompt-builder.js +2 -0
  148. package/dist/shared/templates/prompt-builder.js.map +1 -0
  149. package/dist/shared/templates/template-engine.d.ts +2 -0
  150. package/dist/shared/templates/template-engine.d.ts.map +1 -0
  151. package/dist/shared/templates/template-engine.js +2 -0
  152. package/dist/shared/templates/template-engine.js.map +1 -0
  153. package/dist/shared/utils/__tests__/command-executor.test.d.ts +5 -0
  154. package/dist/shared/utils/__tests__/command-executor.test.d.ts.map +1 -0
  155. package/dist/shared/utils/__tests__/command-executor.test.js +45 -0
  156. package/dist/shared/utils/__tests__/command-executor.test.js.map +1 -0
  157. package/dist/shared/utils/__tests__/file-helper.test.d.ts +5 -0
  158. package/dist/shared/utils/__tests__/file-helper.test.d.ts.map +1 -0
  159. package/dist/shared/utils/__tests__/file-helper.test.js +71 -0
  160. package/dist/shared/utils/__tests__/file-helper.test.js.map +1 -0
  161. package/dist/shared/utils/__tests__/logger.test.d.ts +5 -0
  162. package/dist/shared/utils/__tests__/logger.test.d.ts.map +1 -0
  163. package/dist/shared/utils/__tests__/logger.test.js +83 -0
  164. package/dist/shared/utils/__tests__/logger.test.js.map +1 -0
  165. package/dist/shared/utils/command-executer.d.ts +2 -0
  166. package/dist/shared/utils/command-executer.d.ts.map +1 -0
  167. package/dist/shared/utils/command-executer.js +2 -0
  168. package/dist/shared/utils/command-executer.js.map +1 -0
  169. package/dist/shared/utils/command-executor.d.ts +255 -0
  170. package/dist/shared/utils/command-executor.d.ts.map +1 -0
  171. package/dist/shared/utils/command-executor.js +287 -0
  172. package/dist/shared/utils/command-executor.js.map +1 -0
  173. package/dist/shared/utils/file-helper.d.ts +86 -0
  174. package/dist/shared/utils/file-helper.d.ts.map +1 -0
  175. package/dist/shared/utils/file-helper.js +323 -0
  176. package/dist/shared/utils/file-helper.js.map +1 -0
  177. package/dist/shared/utils/index.d.ts +9 -0
  178. package/dist/shared/utils/index.d.ts.map +1 -0
  179. package/dist/shared/utils/index.js +9 -0
  180. package/dist/shared/utils/index.js.map +1 -0
  181. package/dist/shared/utils/logger.d.ts +163 -0
  182. package/dist/shared/utils/logger.d.ts.map +1 -0
  183. package/dist/shared/utils/logger.js +389 -0
  184. package/dist/shared/utils/logger.js.map +1 -0
  185. package/package.json +25 -6
  186. package/CHANGELOG.md +0 -46
  187. package/agents/deps-analyzer.js +0 -366
  188. package/agents/detector.js +0 -570
  189. package/agents/fix-engine.js +0 -305
  190. package/agents/lighthouse-scanner.js +0 -405
  191. package/agents/perf-analyzer.js +0 -294
  192. package/agents/perf-front-analyzer.js +0 -229
  193. package/agents/test-generator.js +0 -387
  194. package/agents/test-runner.js +0 -318
  195. package/bin/cli.js +0 -449
  196. package/lib/config.js +0 -250
  197. package/lib/docker.js +0 -207
  198. package/lib/reporter.js +0 -297
  199. package/scripts/dev.js +0 -106
package/lib/docker.js DELETED
@@ -1,207 +0,0 @@
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
- };
package/lib/reporter.js DELETED
@@ -1,297 +0,0 @@
1
- /**
2
- * Daemon - Reporter
3
- *
4
- * Generates test reports and summaries.
5
- */
6
-
7
- const fs = require('fs');
8
- const path = require('path');
9
-
10
- /**
11
- * Generate test report
12
- */
13
- function generateReport(results, options = {}) {
14
- const report = {
15
- summary: generateSummary(results),
16
- details: results,
17
- recommendations: generateRecommendations(results),
18
- timestamp: new Date().toISOString(),
19
- };
20
-
21
- if (options.output) {
22
- const outputPath = path.resolve(options.output);
23
- fs.writeFileSync(outputPath, JSON.stringify(report, null, 2));
24
- }
25
-
26
- return report;
27
- }
28
-
29
- /**
30
- * Generate summary
31
- */
32
- function generateSummary(results) {
33
- const summary = {
34
- totalTests: 0,
35
- passing: 0,
36
- failing: 0,
37
- skipped: 0,
38
- coverage: results.coverage || null,
39
- performance: results.performance || null,
40
- };
41
-
42
- // Count unit tests
43
- if (results.unit) {
44
- summary.totalTests += results.unit.total || 0;
45
- summary.passing += results.unit.passing || 0;
46
- summary.failing += results.unit.failing || 0;
47
- summary.skipped += results.unit.skipped || 0;
48
- }
49
-
50
- // Count integration tests
51
- if (results.integration) {
52
- summary.totalTests += results.integration.total || 0;
53
- summary.passing += results.integration.passing || 0;
54
- summary.failing += results.integration.failing || 0;
55
- summary.skipped += results.integration.skipped || 0;
56
- }
57
-
58
- // Count E2E tests
59
- if (results.e2e) {
60
- summary.totalTests += results.e2e.total || 0;
61
- summary.passing += results.e2e.passing || 0;
62
- summary.failing += results.e2e.failing || 0;
63
- summary.skipped += results.e2e.skipped || 0;
64
- }
65
-
66
- summary.passRate = summary.totalTests > 0
67
- ? ((summary.passing / summary.totalTests) * 100).toFixed(2) + '%'
68
- : 'N/A';
69
-
70
- return summary;
71
- }
72
-
73
- /**
74
- * Generate recommendations
75
- */
76
- function generateRecommendations(results) {
77
- const recommendations = [];
78
-
79
- // Coverage recommendations
80
- if (results.coverage) {
81
- const coverage = results.coverage;
82
- if (coverage.lines && coverage.lines < 80) {
83
- recommendations.push({
84
- type: 'coverage',
85
- priority: 'high',
86
- message: `Line coverage is ${coverage.lines}%. Aim for at least 80%.`,
87
- });
88
- }
89
- if (coverage.branches && coverage.branches < 80) {
90
- recommendations.push({
91
- type: 'coverage',
92
- priority: 'medium',
93
- message: `Branch coverage is ${coverage.branches}%. Add tests for conditional logic.`,
94
- });
95
- }
96
- }
97
-
98
- // Performance recommendations
99
- if (results.performance) {
100
- const perf = results.performance;
101
- if (perf.p95 && perf.p95 > 200) {
102
- recommendations.push({
103
- type: 'performance',
104
- priority: 'high',
105
- message: `API p95 is ${perf.p95}ms. Target is <200ms. Consider optimization.`,
106
- });
107
- }
108
- if (perf.failureRate && perf.failureRate > 1) {
109
- recommendations.push({
110
- type: 'performance',
111
- priority: 'high',
112
- message: `Failure rate is ${perf.failureRate}%. Check for infrastructure issues.`,
113
- });
114
- }
115
- }
116
-
117
- // Test failure recommendations
118
- if (results.unit && results.unit.failing > 0) {
119
- recommendations.push({
120
- type: 'tests',
121
- priority: 'high',
122
- message: `${results.unit.failing} unit test(s) failing. Review and fix.`,
123
- });
124
- }
125
-
126
- if (results.e2e && results.e2e.failing > 0) {
127
- recommendations.push({
128
- type: 'tests',
129
- priority: 'medium',
130
- message: `${results.e2e.failing} E2E test(s) failing. Check for flaky tests.`,
131
- });
132
- }
133
-
134
- return recommendations;
135
- }
136
-
137
- /**
138
- * Format report as markdown
139
- */
140
- function formatMarkdown(report) {
141
- const lines = [];
142
-
143
- lines.push('# Daemon Test Report');
144
- lines.push('');
145
- lines.push(`**Generated:** ${new Date(report.timestamp).toLocaleString()}`);
146
- lines.push('');
147
-
148
- // Summary
149
- lines.push('## Summary');
150
- lines.push('');
151
- lines.push('| Metric | Value |');
152
- lines.push('|--------|-------|');
153
- lines.push(`| Total Tests | ${report.summary.totalTests} |`);
154
- lines.push(`| Passing | ${report.summary.passing} |`);
155
- lines.push(`| Failing | ${report.summary.failing} |`);
156
- lines.push(`| Skipped | ${report.summary.skipped} |`);
157
- lines.push(`| Pass Rate | ${report.summary.passRate} |`);
158
-
159
- if (report.summary.coverage) {
160
- lines.push(`| Coverage | ${report.summary.coverage.lines || 'N/A'}% (lines) |`);
161
- }
162
-
163
- if (report.summary.performance) {
164
- const perf = report.summary.performance;
165
- lines.push(`| API p95 | ${perf.p95 || 'N/A'}ms |`);
166
- lines.push(`| API p99 | ${perf.p99 || 'N/A'}ms |`);
167
- }
168
-
169
- lines.push('');
170
-
171
- // Recommendations
172
- if (report.recommendations.length > 0) {
173
- lines.push('## Recommendations');
174
- lines.push('');
175
-
176
- for (const rec of report.recommendations) {
177
- const icon = rec.priority === 'high' ? '🔴' : rec.priority === 'medium' ? '🟡' : '🟢';
178
- lines.push(`### ${icon} ${rec.type}`);
179
- lines.push('');
180
- lines.push(rec.message);
181
- lines.push('');
182
- }
183
- }
184
-
185
- // Details by layer
186
- lines.push('## Details by Layer');
187
- lines.push('');
188
-
189
- for (const [layer, data] of Object.entries(report.details)) {
190
- if (!data || typeof data !== 'object') continue;
191
-
192
- lines.push(`### ${layer.charAt(0).toUpperCase() + layer.slice(1)}`);
193
- lines.push('');
194
- lines.push(`| Tests | Pass | Fail | Skip |`);
195
- lines.push(`|-------|------|------|------|`);
196
- lines.push(
197
- `| ${data.total || 0} | ${data.passing || 0} | ${data.failing || 0} | ${data.skipped || 0} |`
198
- );
199
- lines.push('');
200
- }
201
-
202
- return lines.join('\n');
203
- }
204
-
205
- /**
206
- * Format report as JSON
207
- */
208
- function formatJSON(report) {
209
- return JSON.stringify(report, null, 2);
210
- }
211
-
212
- /**
213
- * Format report as console output
214
- */
215
- function formatConsole(report) {
216
- const lines = [];
217
-
218
- lines.push('');
219
- lines.push('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
220
- lines.push(' Daemon Test Report');
221
- lines.push('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
222
- lines.push('');
223
-
224
- const summary = report.summary;
225
-
226
- lines.push(` Total Tests: ${summary.totalTests}`);
227
- lines.push(` Passing: ${summary.passing} ✓`);
228
- lines.push(` Failing: ${summary.failing} ✗`);
229
- lines.push(` Skipped: ${summary.skipped} ○`);
230
- lines.push(` Pass Rate: ${summary.passRate}`);
231
-
232
- if (summary.coverage) {
233
- lines.push(` Coverage: ${summary.coverage.lines || 'N/A'}%`);
234
- }
235
-
236
- if (summary.performance) {
237
- lines.push(` API p95: ${summary.performance.p95 || 'N/A'}ms`);
238
- }
239
-
240
- lines.push('');
241
-
242
- if (report.recommendations.length > 0) {
243
- lines.push(' Recommendations:');
244
- for (const rec of report.recommendations) {
245
- const icon = rec.priority === 'high' ? '✗' : rec.priority === 'medium' ? '⚠' : 'ℹ';
246
- lines.push(` ${icon} ${rec.message}`);
247
- }
248
- lines.push('');
249
- }
250
-
251
- lines.push('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
252
- lines.push('');
253
-
254
- return lines.join('\n');
255
- }
256
-
257
- /**
258
- * Save report to file
259
- */
260
- function saveReport(report, format, outputPath) {
261
- let content;
262
-
263
- switch (format) {
264
- case 'markdown':
265
- content = formatMarkdown(report);
266
- break;
267
- case 'json':
268
- content = formatJSON(report);
269
- break;
270
- case 'console':
271
- content = formatConsole(report);
272
- break;
273
- default:
274
- throw new Error(`Unknown format: ${format}`);
275
- }
276
-
277
- fs.writeFileSync(outputPath, content);
278
- return outputPath;
279
- }
280
-
281
- /**
282
- * Print report to console
283
- */
284
- function printReport(report) {
285
- console.log(formatConsole(report));
286
- }
287
-
288
- module.exports = {
289
- generateReport,
290
- generateSummary,
291
- generateRecommendations,
292
- formatMarkdown,
293
- formatJSON,
294
- formatConsole,
295
- saveReport,
296
- printReport,
297
- };
package/scripts/dev.js DELETED
@@ -1,106 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Daemon Development Script
5
- *
6
- * For local development and testing of the Daemon CLI.
7
- */
8
-
9
- const { execSync } = require('child_process');
10
- const path = require('path');
11
-
12
- const command = process.argv[2] || 'help';
13
-
14
- const commands = {
15
- help: () => {
16
- console.log(`
17
- Daemon Development Commands
18
-
19
- Usage: node scripts/dev.js <command>
20
-
21
- Commands:
22
- test Run detector test
23
- build Build Docker image
24
- start Start container
25
- stop Stop container
26
- clean Remove container and image
27
- logs Show container logs
28
- shell Open shell in container
29
- link Link package globally for testing
30
- `);
31
- },
32
-
33
- test: () => {
34
- console.log('Testing detector...');
35
- const detector = require('../agents/detector.js');
36
- detector.analyze(process.cwd())
37
- .then((context) => {
38
- console.log(JSON.stringify(context, null, 2));
39
- })
40
- .catch((err) => {
41
- console.error('Detection failed:', err);
42
- process.exit(1);
43
- });
44
- },
45
-
46
- build: () => {
47
- console.log('Building Docker image...');
48
- const dockerfile = path.join(__dirname, '..', 'bin', 'Dockerfile');
49
- execSync(`docker build -t daemon-tools -f "${dockerfile}" "${path.dirname(dockerfile)}"`, {
50
- stdio: 'inherit',
51
- });
52
- console.log('✓ Build complete');
53
- },
54
-
55
- start: () => {
56
- console.log('Starting container...');
57
- try {
58
- execSync('docker start daemon-tools', { stdio: 'inherit' });
59
- console.log('✓ Container started');
60
- } catch {
61
- const isLinux = process.platform === 'linux';
62
- const networkFlag = isLinux ? '--network=host' : '';
63
- execSync(`docker run -d --name daemon-tools ${networkFlag} daemon-tools`, {
64
- stdio: 'inherit',
65
- });
66
- console.log('✓ Container created');
67
- }
68
- },
69
-
70
- stop: () => {
71
- console.log('Stopping container...');
72
- execSync('docker stop daemon-tools', { stdio: 'inherit' });
73
- console.log('✓ Container stopped');
74
- },
75
-
76
- clean: () => {
77
- console.log('Removing container...');
78
- execSync('docker rm -f daemon-tools', { stdio: 'inherit', timeout: 5000 }).catch(() => {});
79
- console.log('Removing image...');
80
- execSync('docker rmi daemon-tools', { stdio: 'inherit', timeout: 30000 }).catch(() => {});
81
- console.log('✓ Clean complete');
82
- },
83
-
84
- logs: () => {
85
- execSync('docker logs -f daemon-tools', { stdio: 'inherit' });
86
- },
87
-
88
- shell: () => {
89
- console.log('Opening shell in container...');
90
- execSync('docker exec -it daemon-tools bash', { stdio: 'inherit' });
91
- },
92
-
93
- link: () => {
94
- console.log('Linking package globally...');
95
- execSync('npm link', { stdio: 'inherit', cwd: path.join(__dirname, '..') });
96
- console.log('✓ Package linked globally');
97
- console.log('You can now run: daemon');
98
- },
99
- };
100
-
101
- if (commands[command]) {
102
- commands[command]();
103
- } else {
104
- console.log(`Unknown command: ${command}`);
105
- commands.help();
106
- }