@fathippo/fathippo-context-engine 0.1.3 → 0.1.5

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 (39) hide show
  1. package/dist/engine.d.ts +4 -0
  2. package/dist/engine.d.ts.map +1 -1
  3. package/dist/engine.js +60 -2
  4. package/dist/engine.js.map +1 -1
  5. package/dist/profiler/framework-detection.d.ts +6 -0
  6. package/dist/profiler/framework-detection.d.ts.map +1 -0
  7. package/dist/profiler/framework-detection.js +452 -0
  8. package/dist/profiler/framework-detection.js.map +1 -0
  9. package/dist/profiler/git-analysis.d.ts +7 -0
  10. package/dist/profiler/git-analysis.d.ts.map +1 -0
  11. package/dist/profiler/git-analysis.js +125 -0
  12. package/dist/profiler/git-analysis.js.map +1 -0
  13. package/dist/profiler/import-analysis.d.ts +7 -0
  14. package/dist/profiler/import-analysis.d.ts.map +1 -0
  15. package/dist/profiler/import-analysis.js +160 -0
  16. package/dist/profiler/import-analysis.js.map +1 -0
  17. package/dist/profiler/index.d.ts +29 -0
  18. package/dist/profiler/index.d.ts.map +1 -0
  19. package/dist/profiler/index.js +176 -0
  20. package/dist/profiler/index.js.map +1 -0
  21. package/dist/profiler/scanner.d.ts +6 -0
  22. package/dist/profiler/scanner.d.ts.map +1 -0
  23. package/dist/profiler/scanner.js +360 -0
  24. package/dist/profiler/scanner.js.map +1 -0
  25. package/dist/profiler/serializer.d.ts +7 -0
  26. package/dist/profiler/serializer.d.ts.map +1 -0
  27. package/dist/profiler/serializer.js +112 -0
  28. package/dist/profiler/serializer.js.map +1 -0
  29. package/dist/profiler/types.d.ts +104 -0
  30. package/dist/profiler/types.d.ts.map +1 -0
  31. package/dist/profiler/types.js +8 -0
  32. package/dist/profiler/types.js.map +1 -0
  33. package/dist/profiler/workspace-id.d.ts +5 -0
  34. package/dist/profiler/workspace-id.d.ts.map +1 -0
  35. package/dist/profiler/workspace-id.js +65 -0
  36. package/dist/profiler/workspace-id.js.map +1 -0
  37. package/dist/types.d.ts +4 -0
  38. package/dist/types.d.ts.map +1 -1
  39. package/package.json +1 -1
@@ -0,0 +1,360 @@
1
+ /**
2
+ * File tree scanner with ignore patterns, LOC counting, and structure detection.
3
+ */
4
+ import { readdir, readFile } from "node:fs/promises";
5
+ import { existsSync, readFileSync } from "node:fs";
6
+ import path from "node:path";
7
+ const DEFAULT_IGNORE = new Set([
8
+ "node_modules",
9
+ ".git",
10
+ "dist",
11
+ "build",
12
+ ".next",
13
+ "__pycache__",
14
+ ".venv",
15
+ "target",
16
+ "vendor",
17
+ "coverage",
18
+ ".turbo",
19
+ ".cache",
20
+ ".fathippo",
21
+ ".DS_Store",
22
+ ".idea",
23
+ ".vscode",
24
+ ]);
25
+ const EXTENSION_TO_LANGUAGE = {
26
+ ts: "typescript",
27
+ tsx: "typescript",
28
+ js: "javascript",
29
+ jsx: "javascript",
30
+ mjs: "javascript",
31
+ cjs: "javascript",
32
+ py: "python",
33
+ go: "go",
34
+ rs: "rust",
35
+ java: "java",
36
+ kt: "kotlin",
37
+ rb: "ruby",
38
+ php: "php",
39
+ swift: "swift",
40
+ c: "c",
41
+ cpp: "c++",
42
+ h: "c",
43
+ hpp: "c++",
44
+ cs: "c#",
45
+ sql: "sql",
46
+ sh: "shell",
47
+ bash: "shell",
48
+ zsh: "shell",
49
+ css: "css",
50
+ scss: "css",
51
+ less: "css",
52
+ html: "html",
53
+ vue: "vue",
54
+ svelte: "svelte",
55
+ dart: "dart",
56
+ lua: "lua",
57
+ r: "r",
58
+ R: "r",
59
+ md: "markdown",
60
+ json: "json",
61
+ yaml: "yaml",
62
+ yml: "yaml",
63
+ toml: "toml",
64
+ xml: "xml",
65
+ proto: "protobuf",
66
+ graphql: "graphql",
67
+ gql: "graphql",
68
+ tf: "terraform",
69
+ hcl: "terraform",
70
+ sol: "solidity",
71
+ zig: "zig",
72
+ nim: "nim",
73
+ ex: "elixir",
74
+ exs: "elixir",
75
+ erl: "erlang",
76
+ hs: "haskell",
77
+ ml: "ocaml",
78
+ scala: "scala",
79
+ clj: "clojure",
80
+ };
81
+ const MONOREPO_MARKERS = [
82
+ "pnpm-workspace.yaml",
83
+ "turbo.json",
84
+ "nx.json",
85
+ "lerna.json",
86
+ ];
87
+ const WORKSPACE_MARKERS = [
88
+ "pnpm-workspace.yaml",
89
+ "lerna.json",
90
+ ];
91
+ const ENTRY_POINT_DIRS = [
92
+ "src",
93
+ "app",
94
+ "lib",
95
+ "cmd",
96
+ "pkg",
97
+ "internal",
98
+ "main",
99
+ "server",
100
+ "api",
101
+ ];
102
+ export async function scanFileTree(workspaceRoot, options) {
103
+ const maxFiles = options?.maxFiles ?? 5000;
104
+ const maxDepth = options?.maxDepth ?? 4;
105
+ const extraIgnore = new Set(options?.extraIgnorePatterns ?? []);
106
+ const ignoreSet = new Set([...DEFAULT_IGNORE, ...extraIgnore]);
107
+ const allFiles = [];
108
+ const languageLOC = new Map();
109
+ const filesByExtension = new Map();
110
+ const largestFiles = [];
111
+ let totalDirectories = 0;
112
+ let fileCount = 0;
113
+ async function walk(dir, depth) {
114
+ if (fileCount >= maxFiles)
115
+ return;
116
+ let entries;
117
+ try {
118
+ entries = await readdir(dir, { withFileTypes: true });
119
+ }
120
+ catch {
121
+ return;
122
+ }
123
+ for (const entry of entries) {
124
+ if (fileCount >= maxFiles)
125
+ break;
126
+ if (ignoreSet.has(entry.name))
127
+ continue;
128
+ if (entry.name.startsWith(".") && entry.name !== ".github")
129
+ continue;
130
+ const fullPath = path.join(dir, entry.name);
131
+ const relativePath = path.relative(workspaceRoot, fullPath);
132
+ if (entry.isDirectory()) {
133
+ totalDirectories++;
134
+ await walk(fullPath, depth + 1);
135
+ }
136
+ else if (entry.isFile()) {
137
+ fileCount++;
138
+ allFiles.push(relativePath);
139
+ const ext = entry.name.split(".").pop()?.toLowerCase() ?? "";
140
+ const language = EXTENSION_TO_LANGUAGE[ext];
141
+ if (language) {
142
+ // Count LOC
143
+ try {
144
+ const content = await readFile(fullPath, "utf-8");
145
+ const lines = content.split("\n").filter((line) => line.trim() && !line.trim().startsWith("//") && !line.trim().startsWith("#")).length;
146
+ languageLOC.set(language, (languageLOC.get(language) ?? 0) + lines);
147
+ const existing = filesByExtension.get(ext) ?? [];
148
+ existing.push(relativePath);
149
+ filesByExtension.set(ext, existing);
150
+ // Track largest files
151
+ if (lines > 100) {
152
+ largestFiles.push({ path: relativePath, loc: lines });
153
+ }
154
+ }
155
+ catch {
156
+ // Skip unreadable files
157
+ }
158
+ }
159
+ }
160
+ }
161
+ }
162
+ await walk(workspaceRoot, 0);
163
+ // Sort largest files
164
+ largestFiles.sort((a, b) => b.loc - a.loc);
165
+ // Detect structure type
166
+ const structureType = detectStructureType(workspaceRoot);
167
+ // Detect workspaces
168
+ const workspaces = await detectWorkspaces(workspaceRoot);
169
+ // Detect entry points
170
+ const entryPoints = detectEntryPoints(workspaceRoot, allFiles);
171
+ // Build file tree summary
172
+ const fileTreeSummary = await buildFileTreeSummary(workspaceRoot, maxDepth, ignoreSet);
173
+ // Compute language percentages
174
+ const totalLOC = [...languageLOC.values()].reduce((sum, loc) => sum + loc, 0);
175
+ const languageBreakdown = new Map();
176
+ for (const [lang, loc] of languageLOC) {
177
+ if (totalLOC > 0) {
178
+ languageBreakdown.set(lang, Math.round((loc / totalLOC) * 100));
179
+ }
180
+ }
181
+ return {
182
+ totalFiles: fileCount,
183
+ totalDirectories,
184
+ languageBreakdown,
185
+ filesByExtension,
186
+ allFiles,
187
+ structureType,
188
+ workspaces,
189
+ entryPoints,
190
+ fileTreeSummary,
191
+ largestFiles: largestFiles.slice(0, 20),
192
+ };
193
+ }
194
+ function detectStructureType(workspaceRoot) {
195
+ for (const marker of MONOREPO_MARKERS) {
196
+ if (existsSync(path.join(workspaceRoot, marker))) {
197
+ return "monorepo";
198
+ }
199
+ }
200
+ // Check package.json workspaces field
201
+ try {
202
+ const pkgPath = path.join(workspaceRoot, "package.json");
203
+ if (existsSync(pkgPath)) {
204
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
205
+ if (pkg.workspaces) {
206
+ return "workspace";
207
+ }
208
+ }
209
+ }
210
+ catch {
211
+ // Not a problem
212
+ }
213
+ // Check for packages/ or apps/ directories
214
+ if (existsSync(path.join(workspaceRoot, "packages")) ||
215
+ existsSync(path.join(workspaceRoot, "apps"))) {
216
+ // Has packages/apps dirs but no workspace config — probably monorepo
217
+ if (existsSync(path.join(workspaceRoot, ".git"))) {
218
+ return "monorepo";
219
+ }
220
+ }
221
+ return "single";
222
+ }
223
+ async function detectWorkspaces(workspaceRoot) {
224
+ const workspaces = [];
225
+ // Check pnpm-workspace.yaml
226
+ const pnpmWorkspacePath = path.join(workspaceRoot, "pnpm-workspace.yaml");
227
+ if (existsSync(pnpmWorkspacePath)) {
228
+ try {
229
+ const content = await readFile(pnpmWorkspacePath, "utf-8");
230
+ // Simple YAML parsing for packages list
231
+ const matches = content.match(/- ['"]?([^'"*\n]+)/g);
232
+ if (matches) {
233
+ for (const match of matches) {
234
+ const wsPath = match.replace(/- ['"]?/, "").replace(/['"]$/, "").trim();
235
+ workspaces.push(wsPath);
236
+ }
237
+ }
238
+ }
239
+ catch {
240
+ // Skip
241
+ }
242
+ }
243
+ // Check package.json workspaces
244
+ try {
245
+ const pkgPath = path.join(workspaceRoot, "package.json");
246
+ if (existsSync(pkgPath)) {
247
+ const pkg = JSON.parse(await readFile(pkgPath, "utf-8"));
248
+ const ws = Array.isArray(pkg.workspaces)
249
+ ? pkg.workspaces
250
+ : Array.isArray(pkg.workspaces?.packages)
251
+ ? pkg.workspaces.packages
252
+ : [];
253
+ for (const w of ws) {
254
+ if (typeof w === "string" && !w.includes("*")) {
255
+ workspaces.push(w);
256
+ }
257
+ }
258
+ }
259
+ }
260
+ catch {
261
+ // Skip
262
+ }
263
+ // If we have glob patterns, resolve actual directories
264
+ if (workspaces.length === 0) {
265
+ for (const dir of ["packages", "apps"]) {
266
+ const dirPath = path.join(workspaceRoot, dir);
267
+ if (existsSync(dirPath)) {
268
+ try {
269
+ const entries = await readdir(dirPath, { withFileTypes: true });
270
+ for (const entry of entries) {
271
+ if (entry.isDirectory() && !entry.name.startsWith(".")) {
272
+ workspaces.push(`${dir}/${entry.name}`);
273
+ }
274
+ }
275
+ }
276
+ catch {
277
+ // Skip
278
+ }
279
+ }
280
+ }
281
+ }
282
+ return workspaces;
283
+ }
284
+ function detectEntryPoints(workspaceRoot, allFiles) {
285
+ const entryPoints = [];
286
+ for (const dir of ENTRY_POINT_DIRS) {
287
+ if (existsSync(path.join(workspaceRoot, dir))) {
288
+ entryPoints.push(`${dir}/`);
289
+ }
290
+ }
291
+ // Check for common entry files
292
+ const entryFiles = [
293
+ "index.ts",
294
+ "index.js",
295
+ "main.ts",
296
+ "main.js",
297
+ "main.go",
298
+ "main.py",
299
+ "main.rs",
300
+ "App.tsx",
301
+ "app.py",
302
+ "manage.py",
303
+ ];
304
+ for (const file of entryFiles) {
305
+ if (allFiles.some((f) => f === file || f.endsWith(`/${file}`))) {
306
+ const found = allFiles.find((f) => f === file || f.endsWith(`/src/${file}`));
307
+ if (found) {
308
+ entryPoints.push(found);
309
+ }
310
+ }
311
+ }
312
+ return [...new Set(entryPoints)].slice(0, 10);
313
+ }
314
+ async function buildFileTreeSummary(workspaceRoot, maxDepth, ignoreSet) {
315
+ const lines = [];
316
+ async function walk(dir, depth, prefix) {
317
+ if (depth > maxDepth || lines.length >= 40)
318
+ return;
319
+ let entries;
320
+ try {
321
+ entries = await readdir(dir, { withFileTypes: true });
322
+ }
323
+ catch {
324
+ return;
325
+ }
326
+ // Sort: directories first, then files
327
+ const dirs = entries.filter((e) => e.isDirectory() && !ignoreSet.has(e.name) && !e.name.startsWith("."));
328
+ const files = entries.filter((e) => e.isFile() && !e.name.startsWith("."));
329
+ for (const d of dirs.sort((a, b) => a.name.localeCompare(b.name))) {
330
+ if (lines.length >= 40)
331
+ break;
332
+ const childPath = path.join(dir, d.name);
333
+ let childEntries = [];
334
+ try {
335
+ childEntries = await readdir(childPath);
336
+ }
337
+ catch {
338
+ childEntries = [];
339
+ }
340
+ const count = childEntries.filter((e) => !ignoreSet.has(e)).length;
341
+ lines.push(`${prefix}${d.name}/ (${count} items)`);
342
+ await walk(childPath, depth + 1, prefix + " ");
343
+ }
344
+ // Only show files at top level or if few
345
+ if (depth <= 1 && files.length > 0) {
346
+ const configFiles = files.filter((f) => /\.(json|ya?ml|toml|lock|config\.\w+)$/.test(f.name) ||
347
+ f.name.startsWith("."));
348
+ if (configFiles.length > 0 && configFiles.length <= 5) {
349
+ for (const f of configFiles) {
350
+ if (lines.length >= 40)
351
+ break;
352
+ lines.push(`${prefix}${f.name}`);
353
+ }
354
+ }
355
+ }
356
+ }
357
+ await walk(workspaceRoot, 0, "");
358
+ return lines.join("\n");
359
+ }
360
+ //# sourceMappingURL=scanner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanner.js","sourceRoot":"","sources":["../../src/profiler/scanner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAQ,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,cAAc;IACd,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,aAAa;IACb,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,WAAW;IACX,OAAO;IACP,SAAS;CACV,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAA2B;IACpD,EAAE,EAAE,YAAY;IAChB,GAAG,EAAE,YAAY;IACjB,EAAE,EAAE,YAAY;IAChB,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,YAAY;IACjB,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,IAAI;IACR,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I,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Serialize a CodebaseProfile into compact markdown for context injection.
3
+ * Must stay under ~2000 tokens.
4
+ */
5
+ import type { CodebaseProfile } from "./types.js";
6
+ export declare function formatCodebaseProfileForInjection(profile: CodebaseProfile): string;
7
+ //# sourceMappingURL=serializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../../src/profiler/serializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,wBAAgB,iCAAiC,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAoHlF"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Serialize a CodebaseProfile into compact markdown for context injection.
3
+ * Must stay under ~2000 tokens.
4
+ */
5
+ export function formatCodebaseProfileForInjection(profile) {
6
+ const sections = [];
7
+ sections.push("## Codebase DNA");
8
+ // Stack line
9
+ const langs = profile.techStack.languages
10
+ .filter((l) => l.percentage >= 2)
11
+ .map((l) => `${l.name} (${l.percentage}%)`)
12
+ .join(", ");
13
+ const frameworks = profile.techStack.frameworks.join(", ");
14
+ const stackParts = [langs];
15
+ if (frameworks)
16
+ stackParts.push(frameworks);
17
+ if (profile.techStack.packageManager && profile.techStack.packageManager !== "unknown") {
18
+ stackParts.push(profile.techStack.packageManager);
19
+ }
20
+ if (profile.techStack.buildTools.length > 0) {
21
+ stackParts.push(profile.techStack.buildTools.join(", "));
22
+ }
23
+ sections.push(`**Stack:** ${stackParts.join(" · ")}`);
24
+ // Runtime / DB / Deploy / Test line
25
+ const metaParts = [];
26
+ if (profile.techStack.runtime && profile.techStack.runtime !== "unknown") {
27
+ metaParts.push(`**Runtime:** ${profile.techStack.runtime}`);
28
+ }
29
+ if (profile.techStack.database.length > 0) {
30
+ metaParts.push(`**DB:** ${profile.techStack.database.join(", ")}`);
31
+ }
32
+ if (profile.techStack.deployment.length > 0) {
33
+ metaParts.push(`**Deploy:** ${profile.techStack.deployment.join(", ")}`);
34
+ }
35
+ if (profile.techStack.testing.length > 0) {
36
+ metaParts.push(`**Test:** ${profile.techStack.testing.join(", ")}`);
37
+ }
38
+ if (metaParts.length > 0) {
39
+ sections.push(metaParts.join(" · "));
40
+ }
41
+ // Structure line
42
+ const structParts = [];
43
+ const structTypeLabel = profile.structure.type === "monorepo"
44
+ ? `Monorepo${profile.structure.workspaces?.length ? ` (${profile.structure.workspaces.length} workspaces)` : ""}`
45
+ : profile.structure.type === "workspace"
46
+ ? "Workspace"
47
+ : "Single project";
48
+ structParts.push(structTypeLabel);
49
+ structParts.push(`${profile.structure.totalFiles} files`);
50
+ if (profile.structure.totalDirectories > 0) {
51
+ structParts.push(`${profile.structure.totalDirectories} dirs`);
52
+ }
53
+ sections.push(`**Structure:** ${structParts.join(" · ")}`);
54
+ // Workspaces
55
+ if (profile.structure.workspaces && profile.structure.workspaces.length > 0) {
56
+ sections.push(`**Workspaces:** ${profile.structure.workspaces.join(", ")}`);
57
+ }
58
+ // Architecture
59
+ if (profile.architecture.summary) {
60
+ sections.push("");
61
+ sections.push(`**Architecture:** ${profile.architecture.summary}`);
62
+ }
63
+ if (profile.architecture.patterns.length > 0) {
64
+ sections.push(`**Patterns:** ${profile.architecture.patterns.join(", ")}`);
65
+ }
66
+ if (profile.architecture.conventions.length > 0) {
67
+ sections.push(`**Conventions:** ${profile.architecture.conventions.join(", ")}`);
68
+ }
69
+ // Hotspots
70
+ if (profile.hotspots.length > 0) {
71
+ sections.push("");
72
+ sections.push("**Hotspot files:**");
73
+ for (const hotspot of profile.hotspots.slice(0, 8)) {
74
+ const metricStr = hotspot.metric
75
+ ? hotspot.reason === "most-changed"
76
+ ? `${hotspot.metric} commits`
77
+ : hotspot.reason === "largest"
78
+ ? `${hotspot.metric >= 1000 ? `${(hotspot.metric / 1000).toFixed(1)}k` : hotspot.metric} LOC`
79
+ : hotspot.reason === "most-imported"
80
+ ? `${hotspot.metric} imports`
81
+ : ""
82
+ : "";
83
+ const detail = [metricStr, hotspot.reason.replace("-", " ")].filter(Boolean).join(", ");
84
+ sections.push(`- ${hotspot.path}${detail ? ` (${detail})` : ""}`);
85
+ }
86
+ }
87
+ // Dependencies
88
+ if (profile.dependencies.topDirect.length > 0) {
89
+ sections.push("");
90
+ sections.push(`**Top deps:** ${profile.dependencies.topDirect.join(", ")}`);
91
+ }
92
+ if (profile.dependencies.peerProjects && profile.dependencies.peerProjects.length > 0) {
93
+ sections.push(`**Cross-pkg:** ${profile.dependencies.peerProjects.join(", ")}`);
94
+ }
95
+ // Git
96
+ if (profile.git.totalCommits > 0) {
97
+ const gitParts = [];
98
+ gitParts.push(`${profile.git.totalCommits.toLocaleString()} commits`);
99
+ if (profile.git.activeContributors > 0) {
100
+ gitParts.push(`${profile.git.activeContributors} contributor${profile.git.activeContributors > 1 ? "s" : ""}`);
101
+ }
102
+ if (profile.git.branchingModel && profile.git.branchingModel !== "unknown") {
103
+ gitParts.push(`${profile.git.branchingModel}-based`);
104
+ }
105
+ if (profile.git.mostActiveDirectories.length > 0) {
106
+ gitParts.push(`active: ${profile.git.mostActiveDirectories.slice(0, 3).join(", ")}`);
107
+ }
108
+ sections.push(`**Git:** ${gitParts.join(" · ")}`);
109
+ }
110
+ return sections.join("\n") + "\n";
111
+ }
112
+ //# sourceMappingURL=serializer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../src/profiler/serializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,UAAU,iCAAiC,CAAC,OAAwB;IACxE,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAEjC,aAAa;IACb,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,SAAS;SACtC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,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ACvF,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,YAAY,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACpC,CAAC"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Codebase Profiler Types
3
+ *
4
+ * Data model for the "Codebase DNA" feature — a compact structural
5
+ * summary of the user's codebase injected into every agent session.
6
+ */
7
+ export interface CodebaseProfile {
8
+ version: 1;
9
+ generatedAt: string;
10
+ generatedFromCommit?: string;
11
+ workspaceRoot: string;
12
+ techStack: TechStack;
13
+ structure: {
14
+ type: "monorepo" | "single" | "workspace";
15
+ entryPoints: string[];
16
+ workspaces?: string[];
17
+ totalFiles: number;
18
+ totalDirectories: number;
19
+ fileTreeSummary: string;
20
+ };
21
+ hotspots: Array<{
22
+ path: string;
23
+ reason: "most-changed" | "largest" | "most-imported" | "entry-point";
24
+ metric?: number;
25
+ }>;
26
+ dependencies: {
27
+ topDirect: string[];
28
+ peerProjects?: string[];
29
+ };
30
+ git: GitAnalysis;
31
+ architecture: {
32
+ summary: string;
33
+ patterns: string[];
34
+ conventions: string[];
35
+ };
36
+ }
37
+ export interface TechStack {
38
+ languages: Array<{
39
+ name: string;
40
+ percentage: number;
41
+ }>;
42
+ frameworks: string[];
43
+ runtime: string;
44
+ packageManager: string;
45
+ buildTools: string[];
46
+ testing: string[];
47
+ database: string[];
48
+ deployment: string[];
49
+ }
50
+ export interface ScanResult {
51
+ totalFiles: number;
52
+ totalDirectories: number;
53
+ languageBreakdown: Map<string, number>;
54
+ filesByExtension: Map<string, string[]>;
55
+ allFiles: string[];
56
+ structureType: "monorepo" | "single" | "workspace";
57
+ workspaces: string[];
58
+ entryPoints: string[];
59
+ fileTreeSummary: string;
60
+ largestFiles: Array<{
61
+ path: string;
62
+ loc: number;
63
+ }>;
64
+ }
65
+ export interface GitAnalysis {
66
+ totalCommits: number;
67
+ activeContributors: number;
68
+ mostActiveDirectories: string[];
69
+ branchingModel?: "trunk" | "gitflow" | "unknown";
70
+ }
71
+ export interface GitAnalysisResult extends GitAnalysis {
72
+ hotspots: Array<{
73
+ path: string;
74
+ commits: number;
75
+ }>;
76
+ }
77
+ export interface ImportAnalysis {
78
+ topImports: Array<{
79
+ module: string;
80
+ count: number;
81
+ }>;
82
+ mostImportedFiles: Array<{
83
+ path: string;
84
+ importCount: number;
85
+ }>;
86
+ }
87
+ export interface ProfileConfig {
88
+ /** Skip LLM summarization. Default: true (MVP has no LLM). */
89
+ skipLLM?: boolean;
90
+ /** Max files to scan. Default: 5000 */
91
+ maxFiles?: number;
92
+ /** Max depth for tree summary. Default: 4 */
93
+ maxDepth?: number;
94
+ /** Additional ignore patterns (gitignore-style). */
95
+ extraIgnorePatterns?: string[];
96
+ /** Force full rescan even if cached profile exists. */
97
+ force?: boolean;
98
+ }
99
+ export interface ScanOptions {
100
+ maxFiles?: number;
101
+ maxDepth?: number;
102
+ extraIgnorePatterns?: string[];
103
+ }
104
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/profiler/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,CAAC,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IAEtB,SAAS,EAAE,SAAS,CAAC;IAErB,SAAS,EAAE;QACT,IAAI,EAAE,UAAU,GAAG,QAAQ,GAAG,WAAW,CAAC;QAC1C,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,UAAU,EAAE,MAAM,CAAC;QACnB,gBAAgB,EAAE,MAAM,CAAC;QACzB,eAAe,EAAE,MAAM,CAAC;KACzB,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*
4
+ * Data model for the "Codebase DNA" feature — a compact structural
5
+ * summary of the user's codebase injected into every agent session.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/profiler/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Stable workspace ID derivation from git remote URL or path hash.
3
+ */
4
+ export declare function deriveWorkspaceId(workspaceRoot: string): string;
5
+ //# sourceMappingURL=workspace-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-id.d.ts","sourceRoot":"","sources":["../../src/profiler/workspace-id.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAc/D"}