openreport 0.1.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 (86) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -0
  3. package/bin/openreport.ts +6 -0
  4. package/package.json +61 -0
  5. package/src/agents/api-documentation.ts +66 -0
  6. package/src/agents/architecture-analyst.ts +46 -0
  7. package/src/agents/code-quality-reviewer.ts +59 -0
  8. package/src/agents/dependency-analyzer.ts +51 -0
  9. package/src/agents/onboarding-guide.ts +59 -0
  10. package/src/agents/orchestrator.ts +41 -0
  11. package/src/agents/performance-analyzer.ts +57 -0
  12. package/src/agents/registry.ts +50 -0
  13. package/src/agents/security-auditor.ts +61 -0
  14. package/src/agents/test-coverage-analyst.ts +58 -0
  15. package/src/agents/todo-generator.ts +50 -0
  16. package/src/app/App.tsx +151 -0
  17. package/src/app/theme.ts +54 -0
  18. package/src/cli.ts +145 -0
  19. package/src/commands/init.ts +81 -0
  20. package/src/commands/interactive.tsx +29 -0
  21. package/src/commands/list.ts +53 -0
  22. package/src/commands/run.ts +168 -0
  23. package/src/commands/view.tsx +52 -0
  24. package/src/components/generation/AgentStatusItem.tsx +125 -0
  25. package/src/components/generation/AgentStatusList.tsx +70 -0
  26. package/src/components/generation/ProgressSummary.tsx +107 -0
  27. package/src/components/generation/StreamingOutput.tsx +154 -0
  28. package/src/components/layout/Container.tsx +24 -0
  29. package/src/components/layout/Footer.tsx +52 -0
  30. package/src/components/layout/Header.tsx +50 -0
  31. package/src/components/report/MarkdownRenderer.tsx +50 -0
  32. package/src/components/report/ReportCard.tsx +31 -0
  33. package/src/components/report/ScrollableView.tsx +164 -0
  34. package/src/config/cli-detection.ts +130 -0
  35. package/src/config/cli-model.ts +397 -0
  36. package/src/config/cli-prompt-formatter.ts +129 -0
  37. package/src/config/defaults.ts +79 -0
  38. package/src/config/loader.ts +168 -0
  39. package/src/config/ollama.ts +48 -0
  40. package/src/config/providers.ts +199 -0
  41. package/src/config/resolve-provider.ts +62 -0
  42. package/src/config/saver.ts +50 -0
  43. package/src/config/schema.ts +51 -0
  44. package/src/errors.ts +34 -0
  45. package/src/hooks/useReportGeneration.ts +199 -0
  46. package/src/hooks/useTerminalSize.ts +35 -0
  47. package/src/ingestion/context-selector.ts +247 -0
  48. package/src/ingestion/file-tree.ts +227 -0
  49. package/src/ingestion/token-budget.ts +52 -0
  50. package/src/pipeline/agent-runner.ts +360 -0
  51. package/src/pipeline/combiner.ts +199 -0
  52. package/src/pipeline/context.ts +108 -0
  53. package/src/pipeline/extraction.ts +153 -0
  54. package/src/pipeline/progress.ts +192 -0
  55. package/src/pipeline/runner.ts +526 -0
  56. package/src/report/html-renderer.ts +294 -0
  57. package/src/report/html-script.ts +123 -0
  58. package/src/report/html-styles.ts +1127 -0
  59. package/src/report/md-to-html.ts +153 -0
  60. package/src/report/open-browser.ts +22 -0
  61. package/src/schemas/findings.ts +48 -0
  62. package/src/schemas/report.ts +64 -0
  63. package/src/screens/ConfigScreen.tsx +271 -0
  64. package/src/screens/GenerationScreen.tsx +278 -0
  65. package/src/screens/HistoryScreen.tsx +108 -0
  66. package/src/screens/HomeScreen.tsx +143 -0
  67. package/src/screens/ViewerScreen.tsx +82 -0
  68. package/src/storage/metadata.ts +69 -0
  69. package/src/storage/report-store.ts +128 -0
  70. package/src/tools/get-file-tree.ts +157 -0
  71. package/src/tools/get-git-info.ts +123 -0
  72. package/src/tools/glob.ts +48 -0
  73. package/src/tools/grep.ts +149 -0
  74. package/src/tools/index.ts +30 -0
  75. package/src/tools/list-directory.ts +57 -0
  76. package/src/tools/read-file.ts +52 -0
  77. package/src/tools/read-package-json.ts +48 -0
  78. package/src/tools/run-command.ts +154 -0
  79. package/src/tools/shared-ignore.ts +58 -0
  80. package/src/types/index.ts +127 -0
  81. package/src/types/marked-terminal.d.ts +17 -0
  82. package/src/utils/debug.ts +25 -0
  83. package/src/utils/file-utils.ts +77 -0
  84. package/src/utils/format.ts +56 -0
  85. package/src/utils/grade-colors.ts +43 -0
  86. package/src/utils/project-detector.ts +296 -0
@@ -0,0 +1,296 @@
1
+ import * as fs from "fs/promises";
2
+ import * as path from "path";
3
+ import type { ProjectClassification } from "../types/index.js";
4
+ import { debugLog } from "./debug.js";
5
+
6
+ async function fileExists(projectRoot: string, ...segments: string[]): Promise<boolean> {
7
+ try {
8
+ await fs.access(path.join(projectRoot, ...segments));
9
+ return true;
10
+ } catch {
11
+ return false;
12
+ }
13
+ }
14
+
15
+ async function readJson(projectRoot: string, file: string): Promise<Record<string, unknown> | null> {
16
+ try {
17
+ const content = await fs.readFile(path.join(projectRoot, file), "utf-8");
18
+ return JSON.parse(content);
19
+ } catch (e) {
20
+ debugLog("project:readPackageJson", e);
21
+ return null;
22
+ }
23
+ }
24
+
25
+ function getAllDeps(pkg: Record<string, unknown> | null): Record<string, string> {
26
+ return {
27
+ ...((pkg?.dependencies as Record<string, string>) || {}),
28
+ ...((pkg?.devDependencies as Record<string, string>) || {}),
29
+ };
30
+ }
31
+
32
+ async function detectPackageManager(projectRoot: string): Promise<ProjectClassification["packageManager"]> {
33
+ const [hasBunLock, hasBunfig, hasPnpm, hasYarn, hasNpmLock, hasPkg] = await Promise.all([
34
+ fileExists(projectRoot, "bun.lockb"),
35
+ fileExists(projectRoot, "bunfig.toml"),
36
+ fileExists(projectRoot, "pnpm-lock.yaml"),
37
+ fileExists(projectRoot, "yarn.lock"),
38
+ fileExists(projectRoot, "package-lock.json"),
39
+ fileExists(projectRoot, "package.json"),
40
+ ]);
41
+
42
+ if (hasBunLock || hasBunfig) return "bun";
43
+ if (hasPnpm) return "pnpm";
44
+ if (hasYarn) return "yarn";
45
+ if (hasNpmLock) return "npm";
46
+ if (hasPkg) return "npm";
47
+ return null;
48
+ }
49
+
50
+ async function detectLanguage(projectRoot: string): Promise<string> {
51
+ const [
52
+ hasTsconfig, hasTsconfigBase, hasPkg,
53
+ hasRequirements, hasSetupPy, hasPyproject,
54
+ hasGoMod, hasCargo, hasPom, hasGradle,
55
+ hasGemfile, hasComposer, hasSwift,
56
+ ] = await Promise.all([
57
+ fileExists(projectRoot, "tsconfig.json"),
58
+ fileExists(projectRoot, "tsconfig.base.json"),
59
+ fileExists(projectRoot, "package.json"),
60
+ fileExists(projectRoot, "requirements.txt"),
61
+ fileExists(projectRoot, "setup.py"),
62
+ fileExists(projectRoot, "pyproject.toml"),
63
+ fileExists(projectRoot, "go.mod"),
64
+ fileExists(projectRoot, "Cargo.toml"),
65
+ fileExists(projectRoot, "pom.xml"),
66
+ fileExists(projectRoot, "build.gradle"),
67
+ fileExists(projectRoot, "Gemfile"),
68
+ fileExists(projectRoot, "composer.json"),
69
+ fileExists(projectRoot, "Package.swift"),
70
+ ]);
71
+
72
+ if (hasTsconfig || hasTsconfigBase) return "typescript";
73
+ if (hasPkg) return "javascript";
74
+ if (hasRequirements || hasSetupPy || hasPyproject) return "python";
75
+ if (hasGoMod) return "go";
76
+ if (hasCargo) return "rust";
77
+ if (hasPom || hasGradle) return "java";
78
+ if (hasGemfile) return "ruby";
79
+ if (hasComposer) return "php";
80
+ if (hasSwift) return "swift";
81
+ return "unknown";
82
+ }
83
+
84
+ async function detectFramework(
85
+ projectRoot: string,
86
+ pkg: Record<string, unknown> | null
87
+ ): Promise<string | null> {
88
+ const deps = getAllDeps(pkg);
89
+
90
+ if (deps["next"]) return "Next.js";
91
+ if (deps["nuxt"] || deps["nuxt3"]) return "Nuxt";
92
+ if (deps["@remix-run/react"] || deps["remix"]) return "Remix";
93
+ if (deps["@angular/core"]) return "Angular";
94
+ if (deps["vue"]) return "Vue";
95
+ if (deps["svelte"] || deps["@sveltejs/kit"]) return "Svelte";
96
+ if (deps["react"]) return "React";
97
+ if (deps["express"]) return "Express";
98
+ if (deps["fastify"]) return "Fastify";
99
+ if (deps["hono"]) return "Hono";
100
+ if (deps["@nestjs/core"]) return "NestJS";
101
+ if (deps["astro"]) return "Astro";
102
+ if (deps["gatsby"]) return "Gatsby";
103
+ if (deps["vite"]) return "Vite";
104
+ if (deps["electron"]) return "Electron";
105
+
106
+ // Non-JS frameworks — check in parallel
107
+ const [hasManagePy, hasRoutes, hasArtisan] = await Promise.all([
108
+ fileExists(projectRoot, "manage.py"),
109
+ fileExists(projectRoot, "config/routes.rb"),
110
+ fileExists(projectRoot, "artisan"),
111
+ ]);
112
+
113
+ if (hasManagePy) return "Django";
114
+ if (hasRoutes) return "Rails";
115
+ if (hasArtisan) return "Laravel";
116
+
117
+ return null;
118
+ }
119
+
120
+ async function detectProjectType(
121
+ projectRoot: string,
122
+ pkg: Record<string, unknown> | null,
123
+ framework: string | null
124
+ ): Promise<ProjectClassification["projectType"]> {
125
+ // Check for monorepo
126
+ const [hasLerna, hasPnpmWorkspace, hasTurbo] = await Promise.all([
127
+ fileExists(projectRoot, "lerna.json"),
128
+ fileExists(projectRoot, "pnpm-workspace.yaml"),
129
+ fileExists(projectRoot, "turbo.json"),
130
+ ]);
131
+
132
+ if (
133
+ hasLerna || hasPnpmWorkspace || hasTurbo ||
134
+ (pkg?.workspaces && Array.isArray(pkg.workspaces))
135
+ )
136
+ return "monorepo";
137
+
138
+ // Check bin field for CLI
139
+ if (pkg?.bin) return "cli";
140
+
141
+ // Check for API/backend
142
+ const webFrameworks = ["Next.js", "Nuxt", "Remix", "Angular", "Vue", "Svelte", "React", "Astro", "Gatsby"];
143
+ const apiFrameworks = ["Express", "Fastify", "Hono", "NestJS", "Django", "Rails", "Laravel"];
144
+
145
+ if (framework && apiFrameworks.includes(framework)) {
146
+ // Could be web-app if it also has frontend
147
+ const [hasPages, hasPublic] = await Promise.all([
148
+ fileExists(projectRoot, "src/pages"),
149
+ fileExists(projectRoot, "public"),
150
+ ]);
151
+ if (hasPages || hasPublic) return "web-app";
152
+ return "api";
153
+ }
154
+
155
+ if (framework && webFrameworks.includes(framework)) return "web-app";
156
+
157
+ // Check for library (has main/exports but no bin)
158
+ if (pkg?.main || pkg?.exports) return "library";
159
+
160
+ return "other";
161
+ }
162
+
163
+ async function detectBuildTool(
164
+ projectRoot: string,
165
+ pkg: Record<string, unknown> | null
166
+ ): Promise<string | null> {
167
+ const deps = getAllDeps(pkg);
168
+
169
+ // Check deps first (synchronous), then fall back to file checks in parallel
170
+ if (deps["vite"]) return "vite";
171
+ if (deps["webpack"]) return "webpack";
172
+ if (deps["esbuild"]) return "esbuild";
173
+ if (deps["rollup"]) return "rollup";
174
+ if (deps["turbopack"] || deps["@vercel/turbopack"]) return "turbopack";
175
+ if (deps["parcel"]) return "parcel";
176
+ if (deps["tsup"]) return "tsup";
177
+
178
+ const [hasViteConfig, hasWebpackConfig, hasRollupConfig, hasMakefile] = await Promise.all([
179
+ fileExists(projectRoot, "vite.config.ts"),
180
+ fileExists(projectRoot, "webpack.config.js"),
181
+ fileExists(projectRoot, "rollup.config.js"),
182
+ fileExists(projectRoot, "Makefile"),
183
+ ]);
184
+
185
+ if (hasViteConfig) return "vite";
186
+ if (hasWebpackConfig) return "webpack";
187
+ if (hasRollupConfig) return "rollup";
188
+ if (hasMakefile) return "make";
189
+
190
+ return null;
191
+ }
192
+
193
+ function detectTestFramework(
194
+ pkg: Record<string, unknown> | null
195
+ ): string | null {
196
+ const deps = getAllDeps(pkg);
197
+
198
+ if (deps["vitest"]) return "vitest";
199
+ if (deps["jest"]) return "jest";
200
+ if (deps["mocha"]) return "mocha";
201
+ if (deps["ava"]) return "ava";
202
+ if (deps["playwright"] || deps["@playwright/test"]) return "playwright";
203
+ if (deps["cypress"]) return "cypress";
204
+ if (deps["pytest"] || deps["unittest"]) return "pytest";
205
+
206
+ return null;
207
+ }
208
+
209
+ async function detectLinter(
210
+ pkg: Record<string, unknown> | null,
211
+ projectRoot: string
212
+ ): Promise<string | null> {
213
+ const deps = getAllDeps(pkg);
214
+
215
+ if (deps["eslint"]) return "eslint";
216
+ if (deps["biome"] || deps["@biomejs/biome"]) return "biome";
217
+ if (deps["rome"]) return "rome";
218
+
219
+ const [hasEslintJs, hasEslintJson] = await Promise.all([
220
+ fileExists(projectRoot, ".eslintrc.js"),
221
+ fileExists(projectRoot, ".eslintrc.json"),
222
+ ]);
223
+
224
+ if (hasEslintJs || hasEslintJson) return "eslint";
225
+
226
+ return null;
227
+ }
228
+
229
+ async function hasTestDirectory(root: string): Promise<boolean> {
230
+ const results = await Promise.all([
231
+ fileExists(root, "tests"),
232
+ fileExists(root, "test"),
233
+ fileExists(root, "__tests__"),
234
+ fileExists(root, "spec"),
235
+ ]);
236
+ return results.some(Boolean);
237
+ }
238
+
239
+ async function hasCIConfig(root: string): Promise<boolean> {
240
+ const results = await Promise.all([
241
+ fileExists(root, ".github", "workflows"),
242
+ fileExists(root, ".gitlab-ci.yml"),
243
+ fileExists(root, ".circleci"),
244
+ fileExists(root, "Jenkinsfile"),
245
+ fileExists(root, ".travis.yml"),
246
+ ]);
247
+ return results.some(Boolean);
248
+ }
249
+
250
+ async function hasDockerConfig(root: string): Promise<boolean> {
251
+ const results = await Promise.all([
252
+ fileExists(root, "Dockerfile"),
253
+ fileExists(root, "docker-compose.yml"),
254
+ fileExists(root, "docker-compose.yaml"),
255
+ ]);
256
+ return results.some(Boolean);
257
+ }
258
+
259
+ export async function detectProject(
260
+ projectRoot: string
261
+ ): Promise<ProjectClassification> {
262
+ const pkg = await readJson(projectRoot, "package.json");
263
+
264
+ // Run independent detection functions in parallel
265
+ const [language, framework, packageManager, buildTool, linter] = await Promise.all([
266
+ detectLanguage(projectRoot),
267
+ detectFramework(projectRoot, pkg),
268
+ detectPackageManager(projectRoot),
269
+ detectBuildTool(projectRoot, pkg),
270
+ detectLinter(pkg, projectRoot),
271
+ ]);
272
+
273
+ // detectProjectType depends on framework, so run after
274
+ const testFramework = detectTestFramework(pkg);
275
+ const [projectType, hasTestDir, hasCI, hasDocker] = await Promise.all([
276
+ detectProjectType(projectRoot, pkg, framework),
277
+ hasTestDirectory(projectRoot),
278
+ hasCIConfig(projectRoot),
279
+ hasDockerConfig(projectRoot),
280
+ ]);
281
+
282
+ const hasTests = testFramework !== null || hasTestDir;
283
+
284
+ return {
285
+ language,
286
+ framework,
287
+ projectType,
288
+ buildTool,
289
+ packageManager,
290
+ hasTests,
291
+ hasCI,
292
+ hasDocker,
293
+ testFramework,
294
+ linter,
295
+ };
296
+ }