@thanh01.pmt/domain-kit 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 (108) hide show
  1. package/README.md +1101 -0
  2. package/dist/assembly/index.cjs +213 -0
  3. package/dist/assembly/index.cjs.map +1 -0
  4. package/dist/assembly/index.d.cts +66 -0
  5. package/dist/assembly/index.d.ts +66 -0
  6. package/dist/assembly/index.mjs +4 -0
  7. package/dist/assembly/index.mjs.map +1 -0
  8. package/dist/chunk-3H2HX7PR.mjs +324 -0
  9. package/dist/chunk-3H2HX7PR.mjs.map +1 -0
  10. package/dist/chunk-3VVPSRAM.mjs +1297 -0
  11. package/dist/chunk-3VVPSRAM.mjs.map +1 -0
  12. package/dist/chunk-DRVOV5ZD.mjs +314 -0
  13. package/dist/chunk-DRVOV5ZD.mjs.map +1 -0
  14. package/dist/chunk-F4RZNBOE.mjs +3 -0
  15. package/dist/chunk-F4RZNBOE.mjs.map +1 -0
  16. package/dist/chunk-GEUDHZE7.mjs +446 -0
  17. package/dist/chunk-GEUDHZE7.mjs.map +1 -0
  18. package/dist/chunk-HH4UX65C.mjs +100 -0
  19. package/dist/chunk-HH4UX65C.mjs.map +1 -0
  20. package/dist/chunk-KMYENICQ.mjs +3 -0
  21. package/dist/chunk-KMYENICQ.mjs.map +1 -0
  22. package/dist/chunk-KNDBODUQ.mjs +153 -0
  23. package/dist/chunk-KNDBODUQ.mjs.map +1 -0
  24. package/dist/chunk-MM2RWYNW.mjs +3 -0
  25. package/dist/chunk-MM2RWYNW.mjs.map +1 -0
  26. package/dist/chunk-MOKNFLUD.mjs +851 -0
  27. package/dist/chunk-MOKNFLUD.mjs.map +1 -0
  28. package/dist/chunk-ONQHJ4OH.mjs +211 -0
  29. package/dist/chunk-ONQHJ4OH.mjs.map +1 -0
  30. package/dist/chunk-PM42MMDJ.mjs +516 -0
  31. package/dist/chunk-PM42MMDJ.mjs.map +1 -0
  32. package/dist/chunk-RKRNOVKO.mjs +166 -0
  33. package/dist/chunk-RKRNOVKO.mjs.map +1 -0
  34. package/dist/chunk-VFART56O.mjs +884 -0
  35. package/dist/chunk-VFART56O.mjs.map +1 -0
  36. package/dist/chunk-XMHKWHVK.mjs +218 -0
  37. package/dist/chunk-XMHKWHVK.mjs.map +1 -0
  38. package/dist/conceptEscalator-YfMKIKCZ.d.ts +40 -0
  39. package/dist/conceptEscalator-ltRLtPhf.d.cts +40 -0
  40. package/dist/concepts/index.cjs +155 -0
  41. package/dist/concepts/index.cjs.map +1 -0
  42. package/dist/concepts/index.d.cts +79 -0
  43. package/dist/concepts/index.d.ts +79 -0
  44. package/dist/concepts/index.mjs +4 -0
  45. package/dist/concepts/index.mjs.map +1 -0
  46. package/dist/curriculumFeedSchema-TEeQg2bY.d.cts +549 -0
  47. package/dist/curriculumFeedSchema-TEeQg2bY.d.ts +549 -0
  48. package/dist/detector/index.cjs +889 -0
  49. package/dist/detector/index.cjs.map +1 -0
  50. package/dist/detector/index.d.cts +112 -0
  51. package/dist/detector/index.d.ts +112 -0
  52. package/dist/detector/index.mjs +3 -0
  53. package/dist/detector/index.mjs.map +1 -0
  54. package/dist/domainProfileSchema-CwT3Ffsw.d.cts +105 -0
  55. package/dist/domainProfileSchema-CwT3Ffsw.d.ts +105 -0
  56. package/dist/extractors/index.cjs +387 -0
  57. package/dist/extractors/index.cjs.map +1 -0
  58. package/dist/extractors/index.d.cts +46 -0
  59. package/dist/extractors/index.d.ts +46 -0
  60. package/dist/extractors/index.mjs +4 -0
  61. package/dist/extractors/index.mjs.map +1 -0
  62. package/dist/feed/index.cjs +421 -0
  63. package/dist/feed/index.cjs.map +1 -0
  64. package/dist/feed/index.d.cts +23 -0
  65. package/dist/feed/index.d.ts +23 -0
  66. package/dist/feed/index.mjs +4 -0
  67. package/dist/feed/index.mjs.map +1 -0
  68. package/dist/graph/index.cjs +2167 -0
  69. package/dist/graph/index.cjs.map +1 -0
  70. package/dist/graph/index.d.cts +226 -0
  71. package/dist/graph/index.d.ts +226 -0
  72. package/dist/graph/index.mjs +4 -0
  73. package/dist/graph/index.mjs.map +1 -0
  74. package/dist/graphVerifier-DsTP9uAN.d.ts +37 -0
  75. package/dist/graphVerifier-QjgDAJce.d.cts +37 -0
  76. package/dist/hybridGraphSchema-BCgXicgA.d.cts +2840 -0
  77. package/dist/hybridGraphSchema-BCgXicgA.d.ts +2840 -0
  78. package/dist/index.cjs +5539 -0
  79. package/dist/index.cjs.map +1 -0
  80. package/dist/index.d.cts +18 -0
  81. package/dist/index.d.ts +18 -0
  82. package/dist/index.mjs +17 -0
  83. package/dist/index.mjs.map +1 -0
  84. package/dist/keywordExtractor-CKaXqSku.d.ts +34 -0
  85. package/dist/keywordExtractor-zPAz2isq.d.cts +34 -0
  86. package/dist/llmClient-ysPhLjcH.d.cts +16 -0
  87. package/dist/llmClient-ysPhLjcH.d.ts +16 -0
  88. package/dist/parsers/index.cjs +323 -0
  89. package/dist/parsers/index.cjs.map +1 -0
  90. package/dist/parsers/index.d.cts +98 -0
  91. package/dist/parsers/index.d.ts +98 -0
  92. package/dist/parsers/index.mjs +4 -0
  93. package/dist/parsers/index.mjs.map +1 -0
  94. package/dist/pipeline/index.cjs +2166 -0
  95. package/dist/pipeline/index.cjs.map +1 -0
  96. package/dist/pipeline/index.d.cts +45 -0
  97. package/dist/pipeline/index.d.ts +45 -0
  98. package/dist/pipeline/index.mjs +8 -0
  99. package/dist/pipeline/index.mjs.map +1 -0
  100. package/dist/projectGraphSchema-DnD7orZV.d.cts +2581 -0
  101. package/dist/projectGraphSchema-DnD7orZV.d.ts +2581 -0
  102. package/dist/schemas/index.cjs +675 -0
  103. package/dist/schemas/index.cjs.map +1 -0
  104. package/dist/schemas/index.d.cts +253 -0
  105. package/dist/schemas/index.d.ts +253 -0
  106. package/dist/schemas/index.mjs +4 -0
  107. package/dist/schemas/index.mjs.map +1 -0
  108. package/package.json +71 -0
@@ -0,0 +1,387 @@
1
+ 'use strict';
2
+
3
+ // src/extractors/keywordExtractor.ts
4
+ var STDLIB_MODULES = /* @__PURE__ */ new Set([
5
+ // Python
6
+ "os",
7
+ "sys",
8
+ "typing",
9
+ "json",
10
+ "re",
11
+ "math",
12
+ "random",
13
+ "time",
14
+ "datetime",
15
+ "pathlib",
16
+ "dataclasses",
17
+ "enum",
18
+ "collections",
19
+ "itertools",
20
+ "functools",
21
+ "logging",
22
+ "argparse",
23
+ "subprocess",
24
+ "threading",
25
+ "multiprocessing",
26
+ "asyncio",
27
+ "socket",
28
+ "http",
29
+ "urllib",
30
+ "ssl",
31
+ "hashlib",
32
+ "base64",
33
+ "csv",
34
+ "sqlite3",
35
+ "pickle",
36
+ "tempfile",
37
+ "shutil",
38
+ "glob",
39
+ "io",
40
+ "string",
41
+ "struct",
42
+ "uuid",
43
+ "abc",
44
+ "copy",
45
+ "decimal",
46
+ "fractions",
47
+ "statistics",
48
+ "queue",
49
+ "signal",
50
+ "traceback",
51
+ "warnings",
52
+ "weakref",
53
+ "contextlib",
54
+ "unittest",
55
+ "pytest",
56
+ "tkinter",
57
+ "tk",
58
+ "ttk",
59
+ "types",
60
+ "inspect",
61
+ "platform",
62
+ // Common third-party generic plumbing
63
+ "requests",
64
+ "urllib3",
65
+ "pydantic",
66
+ "dotenv",
67
+ "yaml",
68
+ "tomllib"
69
+ ]);
70
+ function platformFromPath(filePath) {
71
+ if (!filePath) return "app";
72
+ const fp = filePath.toLowerCase();
73
+ if (fp.endsWith(".ino") || fp.endsWith(".cpp") || fp.endsWith(".h") || fp.endsWith(".hpp") || fp.endsWith(".c")) {
74
+ if (fp.endsWith(".ino")) return "esp32";
75
+ if (fp.includes("firmware") || fp.includes("esp")) return "esp32";
76
+ return "app";
77
+ }
78
+ return "app";
79
+ }
80
+ function extractKeywords(sourceContext, basicAnalysis, repoDir, options) {
81
+ const keywords = [];
82
+ const effectiveStdlib = new Set(STDLIB_MODULES);
83
+ if (options?.extraStdlibModules) {
84
+ for (const m of options.extraStdlibModules) effectiveStdlib.add(m.toLowerCase());
85
+ }
86
+ if (options?.unskipModules) {
87
+ for (const m of options.unskipModules) effectiveStdlib.delete(m.toLowerCase());
88
+ }
89
+ if ("imports" in sourceContext) {
90
+ for (const imp of sourceContext.imports) {
91
+ let module;
92
+ let count = 1;
93
+ let platform = "app";
94
+ if (typeof imp === "string") {
95
+ module = imp;
96
+ } else if (imp && typeof imp === "object" && "module" in imp) {
97
+ const impObj = imp;
98
+ module = impObj.module;
99
+ count = impObj.count || 1;
100
+ platform = platformFromPath(impObj.file || "");
101
+ } else {
102
+ continue;
103
+ }
104
+ if (effectiveStdlib.has(module.toLowerCase())) continue;
105
+ keywords.push({
106
+ keyword: module,
107
+ source: "import",
108
+ platform,
109
+ weight: 1 + (count - 1) * 0.1,
110
+ context: `Imported ${count} times`
111
+ });
112
+ }
113
+ }
114
+ if ("types" in sourceContext) {
115
+ for (const typeDecl of sourceContext.types) {
116
+ const name = typeDecl.name;
117
+ const kind = typeDecl.kind;
118
+ const platform = platformFromPath(typeDecl.file || "");
119
+ if (["View", "Model", "ViewModel", "Controller", "Service", "Manager"].includes(name)) continue;
120
+ keywords.push({
121
+ keyword: name,
122
+ source: "type_declaration",
123
+ platform,
124
+ weight: 1.5,
125
+ context: `${kind} declaration`
126
+ });
127
+ }
128
+ }
129
+ if ("functions" in sourceContext) {
130
+ for (const func of sourceContext.functions) {
131
+ const name = func.name;
132
+ const platform = platformFromPath(func.file || "");
133
+ if (["init", "setup", "configure", "initialize"].includes(name)) continue;
134
+ keywords.push({
135
+ keyword: name,
136
+ source: "function_signature",
137
+ platform,
138
+ weight: 1.2,
139
+ context: "Function signature"
140
+ });
141
+ }
142
+ }
143
+ if ("docstrings" in sourceContext && Array.isArray(sourceContext.docstrings)) {
144
+ for (const doc of sourceContext.docstrings) {
145
+ const firstSentence = doc.trim().split("\n")[0].slice(0, 120);
146
+ if (firstSentence.length > 15) {
147
+ keywords.push({
148
+ keyword: firstSentence,
149
+ source: "docstring",
150
+ platform: "app",
151
+ weight: 1.8,
152
+ context: "Docstring (domain intent)"
153
+ });
154
+ }
155
+ }
156
+ }
157
+ if ("frameworks_used" in sourceContext && Array.isArray(sourceContext.frameworks_used)) {
158
+ for (const fw of sourceContext.frameworks_used) {
159
+ const fwName = typeof fw === "string" ? fw : fw.framework || "";
160
+ if (fwName) {
161
+ keywords.push({
162
+ keyword: fwName,
163
+ source: "framework_usage",
164
+ platform: "app",
165
+ weight: 1.4,
166
+ context: "Framework usage (real practice)"
167
+ });
168
+ }
169
+ }
170
+ }
171
+ if ("property_wrappers" in sourceContext && Array.isArray(sourceContext.property_wrappers)) {
172
+ for (const wrapper of sourceContext.property_wrappers) {
173
+ const wrapperName = typeof wrapper === "string" ? wrapper : wrapper.wrapper || "";
174
+ if (wrapperName) {
175
+ keywords.push({
176
+ keyword: `@${wrapperName}`,
177
+ source: "property_wrapper",
178
+ platform: "app",
179
+ weight: 2,
180
+ context: "Property wrapper"
181
+ });
182
+ }
183
+ }
184
+ }
185
+ const errorPatterns = "error_handling" in sourceContext ? sourceContext.error_handling : "error_handling_patterns" in sourceContext ? sourceContext.error_handling_patterns || [] : [];
186
+ for (const error of errorPatterns) {
187
+ let pattern;
188
+ let platform = "app";
189
+ if (typeof error === "string") {
190
+ pattern = error;
191
+ } else if (error && typeof error === "object" && "pattern" in error) {
192
+ const errObj = error;
193
+ pattern = errObj.pattern;
194
+ platform = platformFromPath(errObj.file || "");
195
+ } else {
196
+ continue;
197
+ }
198
+ keywords.push({
199
+ keyword: pattern,
200
+ source: "error_handling",
201
+ platform,
202
+ weight: 1.3,
203
+ context: "Error handling pattern"
204
+ });
205
+ }
206
+ const seen = /* @__PURE__ */ new Set();
207
+ const uniqueKeywords = [];
208
+ for (const kw of keywords) {
209
+ const key = kw.keyword.toLowerCase();
210
+ if (!seen.has(key)) {
211
+ seen.add(key);
212
+ uniqueKeywords.push(kw);
213
+ }
214
+ }
215
+ return uniqueKeywords;
216
+ }
217
+
218
+ // src/extractors/fileRelevanceScorer.ts
219
+ var MAIN_DIRS = /* @__PURE__ */ new Set([
220
+ "src",
221
+ "app",
222
+ "lib",
223
+ "sources",
224
+ "packages",
225
+ "features",
226
+ "screens",
227
+ "views",
228
+ "components",
229
+ "models",
230
+ "services",
231
+ "viewmodels",
232
+ "controllers",
233
+ "repositories",
234
+ "utils",
235
+ "helpers"
236
+ ]);
237
+ var LOW_RELEVANCE_DIRS = /* @__PURE__ */ new Set([
238
+ "test",
239
+ "tests",
240
+ "__tests__",
241
+ "testutils",
242
+ "fixtures",
243
+ "mocks",
244
+ "demo",
245
+ "sample",
246
+ "example",
247
+ "playground",
248
+ "docs",
249
+ "documentation",
250
+ "docc",
251
+ ".build",
252
+ "node_modules",
253
+ "Pods",
254
+ "DerivedData"
255
+ ]);
256
+ var ENTRY_NAMES = ["app.swift", "appdelegate.swift", "app.tsx", "app.jsx", "app.py", "index.ts", "index.tsx", "index.js", "main.py", "main.cpp", "main.swift"];
257
+ var CORE_PATTERNS = ["model", "service", "client", "manager", "controller", "repository", "viewmodel", "coordinator", "router", "store", "state", "auth", "api", "network", "database", "db"];
258
+ var NOISE_PATTERNS = ["test", "mock", "stub", "fake", "preview", "generated"];
259
+ function scoreByPath(relPath) {
260
+ let score = 0;
261
+ const signals = [];
262
+ const parts = relPath.toLowerCase().split(/[\\/]/);
263
+ const filename = parts[parts.length - 1] || "";
264
+ const basename = filename.replace(/\.[^.]+$/, "");
265
+ const isInMainDir = parts.some((p) => MAIN_DIRS.has(p));
266
+ const isInLowDir = parts.some((p) => LOW_RELEVANCE_DIRS.has(p));
267
+ if (isInMainDir) {
268
+ score += 3;
269
+ signals.push("main_dir");
270
+ }
271
+ if (isInLowDir) {
272
+ score -= 3;
273
+ signals.push("low_dir");
274
+ }
275
+ if (ENTRY_NAMES.some((n) => filename.includes(n))) {
276
+ score += 2;
277
+ signals.push("entry_point");
278
+ }
279
+ const coreHits = CORE_PATTERNS.filter((p) => basename.includes(p));
280
+ if (coreHits.length > 0) {
281
+ score += Math.min(coreHits.length, 3);
282
+ signals.push(`core(${coreHits.join(",")})`);
283
+ }
284
+ const noiseHits = NOISE_PATTERNS.filter((p) => basename.includes(p));
285
+ if (noiseHits.length > 0) {
286
+ score -= Math.min(noiseHits.length, 2);
287
+ signals.push(`noise(${noiseHits.join(",")})`);
288
+ }
289
+ if (parts.length > 5) {
290
+ score -= 1;
291
+ signals.push("deep_path");
292
+ }
293
+ return { path: relPath, score, signals };
294
+ }
295
+ function scoreByContent(relPath, content, parseResult, importCounts) {
296
+ const base = scoreByPath(relPath);
297
+ let score = base.score;
298
+ const signals = [...base.signals];
299
+ if (parseResult) {
300
+ const imports = "imports" in parseResult && Array.isArray(parseResult.imports) ? parseResult.imports.length : 0;
301
+ const types = "types" in parseResult && Array.isArray(parseResult.types) ? parseResult.types.length : 0;
302
+ const functions = "functions" in parseResult && Array.isArray(parseResult.functions) ? parseResult.functions.length : 0;
303
+ const totalSignals = imports + types + functions;
304
+ const signalScore = Math.min(totalSignals / 3, 5);
305
+ score += signalScore;
306
+ if (totalSignals > 5) signals.push(`ast_dense(${totalSignals})`);
307
+ }
308
+ const lines = content.split("\n").length;
309
+ if (lines > 200) {
310
+ score += 1;
311
+ signals.push("large_file");
312
+ }
313
+ if (lines > 500) {
314
+ score += 1;
315
+ signals.push("very_large");
316
+ }
317
+ const importCount = importCounts.get(relPath) || 0;
318
+ if (importCount >= 2) {
319
+ score += 1;
320
+ signals.push(`imported(${importCount})`);
321
+ }
322
+ if (importCount >= 5) {
323
+ score += 2;
324
+ signals.push("hub_file");
325
+ }
326
+ return { path: relPath, score, signals };
327
+ }
328
+ function selectRelevantFiles(filePaths, maxFiles = 40) {
329
+ const scores = filePaths.map((p) => scoreByPath(p));
330
+ scores.sort((a, b) => b.score - a.score);
331
+ const selected = scores.slice(0, maxFiles).map((s) => s.path);
332
+ return { selected, scores };
333
+ }
334
+ function scoreFiles(fileContentsMap, parseResults, _goal) {
335
+ const parseResultMap = /* @__PURE__ */ new Map();
336
+ for (const pr of parseResults) {
337
+ const filePath = extractFilePath(pr);
338
+ if (filePath) parseResultMap.set(filePath, pr);
339
+ }
340
+ const importCounts = /* @__PURE__ */ new Map();
341
+ for (const pr of parseResults) {
342
+ const imports = extractImports(pr);
343
+ for (const imp of imports) {
344
+ for (const [relPath] of fileContentsMap) {
345
+ if (relPath.includes(imp) || imp.includes(relPath.replace(/\.[^.]+$/, ""))) {
346
+ importCounts.set(relPath, (importCounts.get(relPath) || 0) + 1);
347
+ }
348
+ }
349
+ }
350
+ }
351
+ const scores = [];
352
+ for (const [relPath, content] of fileContentsMap) {
353
+ scores.push(scoreByContent(relPath, content, parseResultMap.get(relPath), importCounts));
354
+ }
355
+ scores.sort((a, b) => b.score - a.score);
356
+ return scores;
357
+ }
358
+ function extractFilePath(pr) {
359
+ if ("file" in pr && typeof pr.file === "string") {
360
+ return pr.file;
361
+ }
362
+ const imports = "imports" in pr && Array.isArray(pr.imports) ? pr.imports : [];
363
+ for (const imp of imports) {
364
+ if (imp && typeof imp === "object" && "file" in imp) {
365
+ return imp.file;
366
+ }
367
+ }
368
+ return null;
369
+ }
370
+ function extractImports(pr) {
371
+ if (!("imports" in pr) || !Array.isArray(pr.imports)) return [];
372
+ return pr.imports.map((imp) => {
373
+ if (typeof imp === "string") return imp;
374
+ if (imp && typeof imp === "object" && "module" in imp) {
375
+ return imp.module;
376
+ }
377
+ return "";
378
+ }).filter(Boolean);
379
+ }
380
+
381
+ exports.extractKeywords = extractKeywords;
382
+ exports.scoreByContent = scoreByContent;
383
+ exports.scoreByPath = scoreByPath;
384
+ exports.scoreFiles = scoreFiles;
385
+ exports.selectRelevantFiles = selectRelevantFiles;
386
+ //# sourceMappingURL=index.cjs.map
387
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/extractors/keywordExtractor.ts","../../src/extractors/fileRelevanceScorer.ts"],"names":[],"mappings":";;;AAgCA,IAAM,cAAA,uBAAqB,GAAA,CAAI;AAAA;AAAA,EAE7B,IA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,EAAA,CAA+B,SAAS,QAAA,EAAU;AAC5E,IAAA,OAAQ,EAAA,CAA8B,IAAA;AAAA,EACxC;AACA,EAAA,MAAM,OAAA,GAAW,SAAA,IAAa,EAAA,IAAM,KAAA,CAAM,OAAA,CAAQ,GAAG,OAAO,CAAA,GAAK,EAAA,CAAG,OAAA,GAAU,EAAC;AAC/E,EAAA,KAAA,MAAW,OAAO,OAAA,EAAS;AACzB,IAAA,IAAI,GAAA,IAAO,OAAO,GAAA,KAAQ,QAAA,IAAY,UAAU,GAAA,EAAK;AACnD,MAAA,OAAQ,GAAA,CAAyB,IAAA;AAAA,IACnC;AAAA,EACF;AACA,EAAA,OAAO,IAAA;AACT;AAEA,SAAS,eAAe,EAAA,EAA6B;AACnD,EAAA,IAAI,EAAE,SAAA,IAAa,EAAA,CAAA,IAAO,CAAC,KAAA,CAAM,QAAQ,EAAA,CAAG,OAAO,CAAA,EAAG,OAAO,EAAC;AAC9D,EAAA,OAAO,EAAA,CAAG,OAAA,CAAQ,GAAA,CAAI,CAAC,GAAA,KAAQ;AAC7B,IAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,EAAU,OAAO,GAAA;AACpC,IAAA,IAAI,GAAA,IAAO,OAAO,GAAA,KAAQ,QAAA,IAAY,YAAY,GAAA,EAAK;AACrD,MAAA,OAAQ,GAAA,CAA2B,MAAA;AAAA,IACrC;AACA,IAAA,OAAO,EAAA;AAAA,EACT,CAAC,CAAA,CAAE,MAAA,CAAO,OAAO,CAAA;AACnB","file":"index.cjs","sourcesContent":["/**\n * Keyword extraction logic — combines AST parser results into structured keywords\n * with source, weight, and context metadata.\n *\n * Ported from knowledge-tree/extract_project_keywords.py extract_keywords()\n */\n\nimport type { SwiftParseResult } from '../parsers/swift';\nimport type { TsParseResult } from '../parsers/typescript';\nimport type { PythonParseResult } from '../parsers/python';\nimport type { CppParseResult } from '../parsers/cpp';\n\nexport interface Keyword {\n keyword: string;\n source: string;\n platform: string;\n weight: number;\n context: string;\n}\n\nexport type SourceContext = SwiftParseResult | TsParseResult | PythonParseResult | CppParseResult;\n\nexport interface ExtractKeywordsOptions {\n /** Additional stdlib modules to skip (merged with defaults) */\n extraStdlibModules?: string[];\n /** Modules to un-skip even if in stdlib (e.g., 'math' for scientific projects) */\n unskipModules?: string[];\n}\n\n/**\n * Standard library modules that carry no domain signal — skip as keywords.\n */\nconst STDLIB_MODULES = new Set([\n // Python\n 'os', 'sys', 'typing', 'json', 're', 'math', 'random', 'time', 'datetime',\n 'pathlib', 'dataclasses', 'enum', 'collections', 'itertools', 'functools',\n 'logging', 'argparse', 'subprocess', 'threading', 'multiprocessing', 'asyncio',\n 'socket', 'http', 'urllib', 'ssl', 'hashlib', 'base64', 'csv', 'sqlite3',\n 'pickle', 'tempfile', 'shutil', 'glob', 'io', 'string', 'struct', 'uuid',\n 'abc', 'copy', 'decimal', 'fractions', 'statistics', 'queue', 'signal',\n 'traceback', 'warnings', 'weakref', 'contextlib', 'unittest', 'pytest',\n 'tkinter', 'tk', 'ttk', 'types', 'inspect', 'platform',\n // Common third-party generic plumbing\n 'requests', 'urllib3', 'pydantic', 'dotenv', 'yaml', 'tomllib',\n]);\n\n/**\n * Map file path → platform (multi-codebase project: Swift app vs ESP32 firmware).\n */\nfunction platformFromPath(filePath: string): string {\n if (!filePath) return 'app';\n const fp = filePath.toLowerCase();\n if (fp.endsWith('.ino') || fp.endsWith('.cpp') || fp.endsWith('.h') || fp.endsWith('.hpp') || fp.endsWith('.c')) {\n if (fp.endsWith('.ino')) return 'esp32';\n if (fp.includes('firmware') || fp.includes('esp')) return 'esp32';\n return 'app';\n }\n return 'app';\n}\n\n/**\n * Extract structured keywords from source context and basic analysis.\n *\n * Multi-target: each keyword is tagged with platform (app/esp32) from its source file,\n * so downstream SIO generation produces correct keywords for each codebase.\n */\nexport function extractKeywords(\n sourceContext: SourceContext,\n basicAnalysis?: { config_files?: string[] },\n repoDir?: string,\n options?: ExtractKeywordsOptions,\n): Keyword[] {\n const keywords: Keyword[] = [];\n\n // Build effective stdlib set with overrides\n const effectiveStdlib = new Set(STDLIB_MODULES);\n if (options?.extraStdlibModules) {\n for (const m of options.extraStdlibModules) effectiveStdlib.add(m.toLowerCase());\n }\n if (options?.unskipModules) {\n for (const m of options.unskipModules) effectiveStdlib.delete(m.toLowerCase());\n }\n\n // Source 1: Import statements → framework keywords\n if ('imports' in sourceContext) {\n for (const imp of sourceContext.imports) {\n let module: string;\n let count = 1;\n let platform = 'app';\n\n if (typeof imp === 'string') {\n module = imp;\n } else if (imp && typeof imp === 'object' && 'module' in imp) {\n const impObj = imp as { module: string; count?: number; file?: string };\n module = impObj.module;\n count = impObj.count || 1;\n platform = platformFromPath(impObj.file || '');\n } else {\n continue;\n }\n\n // Skip standard library / generic plumbing — no domain signal\n if (effectiveStdlib.has(module.toLowerCase())) continue;\n\n keywords.push({\n keyword: module,\n source: 'import',\n platform,\n weight: 1.0 + (count - 1) * 0.1,\n context: `Imported ${count} times`,\n });\n }\n }\n\n // Source 2: Type declarations → domain concepts\n if ('types' in sourceContext) {\n for (const typeDecl of sourceContext.types) {\n const name = typeDecl.name;\n const kind = typeDecl.kind;\n const platform = platformFromPath(typeDecl.file || '');\n\n // Skip generic/framework types\n if (['View', 'Model', 'ViewModel', 'Controller', 'Service', 'Manager'].includes(name)) continue;\n\n keywords.push({\n keyword: name,\n source: 'type_declaration',\n platform,\n weight: 1.5,\n context: `${kind} declaration`,\n });\n }\n }\n\n // Source 3: Function signatures → business logic\n if ('functions' in sourceContext) {\n for (const func of sourceContext.functions) {\n const name = func.name;\n const platform = platformFromPath(func.file || '');\n\n // Skip generic helpers\n if (['init', 'setup', 'configure', 'initialize'].includes(name)) continue;\n\n keywords.push({\n keyword: name,\n source: 'function_signature',\n platform,\n weight: 1.2,\n context: 'Function signature',\n });\n }\n }\n\n // Source 3.5: Docstrings → domain intent (high signal) — Python only\n if ('docstrings' in sourceContext && Array.isArray(sourceContext.docstrings)) {\n for (const doc of sourceContext.docstrings) {\n const firstSentence = doc.trim().split('\\n')[0].slice(0, 120);\n if (firstSentence.length > 15) {\n keywords.push({\n keyword: firstSentence,\n source: 'docstring',\n platform: 'app',\n weight: 1.8,\n context: 'Docstring (domain intent)',\n });\n }\n }\n }\n\n // Source 3.6: Framework usage → real practice keywords — Swift only\n if ('frameworks_used' in sourceContext && Array.isArray(sourceContext.frameworks_used)) {\n for (const fw of sourceContext.frameworks_used) {\n const fwName = typeof fw === 'string' ? fw : (fw as { framework?: string }).framework || '';\n if (fwName) {\n keywords.push({\n keyword: fwName,\n source: 'framework_usage',\n platform: 'app',\n weight: 1.4,\n context: 'Framework usage (real practice)',\n });\n }\n }\n }\n\n // Source 4: Property wrappers → state management patterns — Swift only\n if ('property_wrappers' in sourceContext && Array.isArray(sourceContext.property_wrappers)) {\n for (const wrapper of sourceContext.property_wrappers) {\n const wrapperName = typeof wrapper === 'string' ? wrapper : (wrapper as { wrapper?: string }).wrapper || '';\n if (wrapperName) {\n keywords.push({\n keyword: `@${wrapperName}`,\n source: 'property_wrapper',\n platform: 'app',\n weight: 2.0,\n context: 'Property wrapper',\n });\n }\n }\n }\n\n // Source 5: Error handling patterns → reliability concerns\n const errorPatterns = 'error_handling' in sourceContext\n ? sourceContext.error_handling\n : 'error_handling_patterns' in sourceContext\n ? (sourceContext as { error_handling_patterns?: Array<{ pattern: string; count?: number; file?: string }> }).error_handling_patterns || []\n : [];\n\n for (const error of errorPatterns) {\n let pattern: string;\n let platform = 'app';\n\n if (typeof error === 'string') {\n pattern = error;\n } else if (error && typeof error === 'object' && 'pattern' in error) {\n const errObj = error as { pattern: string; file?: string };\n pattern = errObj.pattern;\n platform = platformFromPath(errObj.file || '');\n } else {\n continue;\n }\n\n keywords.push({\n keyword: pattern,\n source: 'error_handling',\n platform,\n weight: 1.3,\n context: 'Error handling pattern',\n });\n }\n\n // Deduplicate by keyword (case-insensitive)\n const seen = new Set<string>();\n const uniqueKeywords: Keyword[] = [];\n for (const kw of keywords) {\n const key = kw.keyword.toLowerCase();\n if (!seen.has(key)) {\n seen.add(key);\n uniqueKeywords.push(kw);\n }\n }\n\n return uniqueKeywords;\n}\n","/**\n * File Relevance Scorer — determines which source files are most relevant\n * to the project goal, for pre-filtering before LLM calls.\n *\n * Inspired by knowledge-tree's 2-pass approach:\n * Pass 1: file tree (names only) → score by path heuristics → select top-K\n * Pass 2: only selected files → read content → AST parse → LLM\n *\n * Two scoring modes:\n * - scoreByPath(): lightweight, works on file names only (no content read)\n * - scoreByContent(): heavier, uses AST signals + import centrality\n */\n\nimport type { SourceContext } from './keywordExtractor';\n\nexport interface FileRelevanceScore {\n path: string;\n score: number;\n signals: string[];\n}\n\nconst MAIN_DIRS = new Set([\n 'src', 'app', 'lib', 'sources', 'packages',\n 'features', 'screens', 'views', 'components', 'models', 'services',\n 'viewmodels', 'controllers', 'repositories', 'utils', 'helpers',\n]);\n\nconst LOW_RELEVANCE_DIRS = new Set([\n 'test', 'tests', '__tests__', 'testutils', 'fixtures', 'mocks',\n 'demo', 'sample', 'example', 'playground',\n 'docs', 'documentation', 'docc',\n '.build', 'node_modules', 'Pods', 'DerivedData',\n]);\n\nconst ENTRY_NAMES = ['app.swift', 'appdelegate.swift', 'app.tsx', 'app.jsx', 'app.py', 'index.ts', 'index.tsx', 'index.js', 'main.py', 'main.cpp', 'main.swift'];\n\nconst CORE_PATTERNS = ['model', 'service', 'client', 'manager', 'controller', 'repository', 'viewmodel', 'coordinator', 'router', 'store', 'state', 'auth', 'api', 'network', 'database', 'db'];\n\nconst NOISE_PATTERNS = ['test', 'mock', 'stub', 'fake', 'preview', 'generated'];\n\n/**\n * Score a file by PATH ONLY — no content reading needed.\n * Used in Pass 1 (before any file content is loaded).\n */\nexport function scoreByPath(relPath: string): FileRelevanceScore {\n let score = 0;\n const signals: string[] = [];\n const parts = relPath.toLowerCase().split(/[\\\\/]/);\n const filename = parts[parts.length - 1] || '';\n const basename = filename.replace(/\\.[^.]+$/, '');\n\n const isInMainDir = parts.some(p => MAIN_DIRS.has(p));\n const isInLowDir = parts.some(p => LOW_RELEVANCE_DIRS.has(p));\n if (isInMainDir) { score += 3; signals.push('main_dir'); }\n if (isInLowDir) { score -= 3; signals.push('low_dir'); }\n\n if (ENTRY_NAMES.some(n => filename.includes(n))) {\n score += 2; signals.push('entry_point');\n }\n\n const coreHits = CORE_PATTERNS.filter(p => basename.includes(p));\n if (coreHits.length > 0) {\n score += Math.min(coreHits.length, 3);\n signals.push(`core(${coreHits.join(',')})`);\n }\n\n const noiseHits = NOISE_PATTERNS.filter(p => basename.includes(p));\n if (noiseHits.length > 0) {\n score -= Math.min(noiseHits.length, 2);\n signals.push(`noise(${noiseHits.join(',')})`);\n }\n\n if (parts.length > 5) { score -= 1; signals.push('deep_path'); }\n\n return { path: relPath, score, signals };\n}\n\n/**\n * Score a file by CONTENT — uses AST signals + import centrality.\n * Used in Pass 2 (after file content is loaded for selected files).\n */\nexport function scoreByContent(\n relPath: string,\n content: string,\n parseResult: SourceContext | undefined,\n importCounts: Map<string, number>,\n): FileRelevanceScore {\n const base = scoreByPath(relPath);\n let score = base.score;\n const signals = [...base.signals];\n\n if (parseResult) {\n const imports = ('imports' in parseResult && Array.isArray(parseResult.imports)) ? parseResult.imports.length : 0;\n const types = ('types' in parseResult && Array.isArray(parseResult.types)) ? parseResult.types.length : 0;\n const functions = ('functions' in parseResult && Array.isArray(parseResult.functions)) ? parseResult.functions.length : 0;\n const totalSignals = imports + types + functions;\n const signalScore = Math.min(totalSignals / 3, 5);\n score += signalScore;\n if (totalSignals > 5) signals.push(`ast_dense(${totalSignals})`);\n }\n\n const lines = content.split('\\n').length;\n if (lines > 200) { score += 1; signals.push('large_file'); }\n if (lines > 500) { score += 1; signals.push('very_large'); }\n\n const importCount = importCounts.get(relPath) || 0;\n if (importCount >= 2) { score += 1; signals.push(`imported(${importCount})`); }\n if (importCount >= 5) { score += 2; signals.push('hub_file'); }\n\n return { path: relPath, score, signals };\n}\n\n/**\n * Select top-K files by path scoring — NO content reading.\n * This is Pass 1: fast, lightweight, works on file tree only.\n */\nexport function selectRelevantFiles(\n filePaths: string[],\n maxFiles: number = 40,\n): { selected: string[]; scores: FileRelevanceScore[] } {\n const scores = filePaths.map(p => scoreByPath(p));\n scores.sort((a, b) => b.score - a.score);\n const selected = scores.slice(0, maxFiles).map(s => s.path);\n return { selected, scores };\n}\n\n/**\n * Score all files by content (Pass 2) — for use after content is loaded.\n */\nexport function scoreFiles(\n fileContentsMap: Map<string, string>,\n parseResults: SourceContext[],\n _goal: string,\n): FileRelevanceScore[] {\n const parseResultMap = new Map<string, SourceContext>();\n for (const pr of parseResults) {\n const filePath = extractFilePath(pr);\n if (filePath) parseResultMap.set(filePath, pr);\n }\n\n const importCounts = new Map<string, number>();\n for (const pr of parseResults) {\n const imports = extractImports(pr);\n for (const imp of imports) {\n for (const [relPath] of fileContentsMap) {\n if (relPath.includes(imp) || imp.includes(relPath.replace(/\\.[^.]+$/, ''))) {\n importCounts.set(relPath, (importCounts.get(relPath) || 0) + 1);\n }\n }\n }\n }\n\n const scores: FileRelevanceScore[] = [];\n for (const [relPath, content] of fileContentsMap) {\n scores.push(scoreByContent(relPath, content, parseResultMap.get(relPath), importCounts));\n }\n\n scores.sort((a, b) => b.score - a.score);\n return scores;\n}\n\nfunction extractFilePath(pr: SourceContext): string | null {\n if ('file' in pr && typeof (pr as Record<string, unknown>).file === 'string') {\n return (pr as Record<string, string>).file;\n }\n const imports = ('imports' in pr && Array.isArray(pr.imports)) ? pr.imports : [];\n for (const imp of imports) {\n if (imp && typeof imp === 'object' && 'file' in imp) {\n return (imp as { file: string }).file;\n }\n }\n return null;\n}\n\nfunction extractImports(pr: SourceContext): string[] {\n if (!('imports' in pr) || !Array.isArray(pr.imports)) return [];\n return pr.imports.map((imp) => {\n if (typeof imp === 'string') return imp;\n if (imp && typeof imp === 'object' && 'module' in imp) {\n return (imp as { module: string }).module;\n }\n return '';\n }).filter(Boolean);\n}\n"]}
@@ -0,0 +1,46 @@
1
+ import { S as SourceContext } from '../keywordExtractor-zPAz2isq.cjs';
2
+ export { K as Keyword, e as extractKeywords } from '../keywordExtractor-zPAz2isq.cjs';
3
+ import '../parsers/index.cjs';
4
+
5
+ /**
6
+ * File Relevance Scorer — determines which source files are most relevant
7
+ * to the project goal, for pre-filtering before LLM calls.
8
+ *
9
+ * Inspired by knowledge-tree's 2-pass approach:
10
+ * Pass 1: file tree (names only) → score by path heuristics → select top-K
11
+ * Pass 2: only selected files → read content → AST parse → LLM
12
+ *
13
+ * Two scoring modes:
14
+ * - scoreByPath(): lightweight, works on file names only (no content read)
15
+ * - scoreByContent(): heavier, uses AST signals + import centrality
16
+ */
17
+
18
+ interface FileRelevanceScore {
19
+ path: string;
20
+ score: number;
21
+ signals: string[];
22
+ }
23
+ /**
24
+ * Score a file by PATH ONLY — no content reading needed.
25
+ * Used in Pass 1 (before any file content is loaded).
26
+ */
27
+ declare function scoreByPath(relPath: string): FileRelevanceScore;
28
+ /**
29
+ * Score a file by CONTENT — uses AST signals + import centrality.
30
+ * Used in Pass 2 (after file content is loaded for selected files).
31
+ */
32
+ declare function scoreByContent(relPath: string, content: string, parseResult: SourceContext | undefined, importCounts: Map<string, number>): FileRelevanceScore;
33
+ /**
34
+ * Select top-K files by path scoring — NO content reading.
35
+ * This is Pass 1: fast, lightweight, works on file tree only.
36
+ */
37
+ declare function selectRelevantFiles(filePaths: string[], maxFiles?: number): {
38
+ selected: string[];
39
+ scores: FileRelevanceScore[];
40
+ };
41
+ /**
42
+ * Score all files by content (Pass 2) — for use after content is loaded.
43
+ */
44
+ declare function scoreFiles(fileContentsMap: Map<string, string>, parseResults: SourceContext[], _goal: string): FileRelevanceScore[];
45
+
46
+ export { type FileRelevanceScore, SourceContext, scoreByContent, scoreByPath, scoreFiles, selectRelevantFiles };
@@ -0,0 +1,46 @@
1
+ import { S as SourceContext } from '../keywordExtractor-CKaXqSku.js';
2
+ export { K as Keyword, e as extractKeywords } from '../keywordExtractor-CKaXqSku.js';
3
+ import '../parsers/index.js';
4
+
5
+ /**
6
+ * File Relevance Scorer — determines which source files are most relevant
7
+ * to the project goal, for pre-filtering before LLM calls.
8
+ *
9
+ * Inspired by knowledge-tree's 2-pass approach:
10
+ * Pass 1: file tree (names only) → score by path heuristics → select top-K
11
+ * Pass 2: only selected files → read content → AST parse → LLM
12
+ *
13
+ * Two scoring modes:
14
+ * - scoreByPath(): lightweight, works on file names only (no content read)
15
+ * - scoreByContent(): heavier, uses AST signals + import centrality
16
+ */
17
+
18
+ interface FileRelevanceScore {
19
+ path: string;
20
+ score: number;
21
+ signals: string[];
22
+ }
23
+ /**
24
+ * Score a file by PATH ONLY — no content reading needed.
25
+ * Used in Pass 1 (before any file content is loaded).
26
+ */
27
+ declare function scoreByPath(relPath: string): FileRelevanceScore;
28
+ /**
29
+ * Score a file by CONTENT — uses AST signals + import centrality.
30
+ * Used in Pass 2 (after file content is loaded for selected files).
31
+ */
32
+ declare function scoreByContent(relPath: string, content: string, parseResult: SourceContext | undefined, importCounts: Map<string, number>): FileRelevanceScore;
33
+ /**
34
+ * Select top-K files by path scoring — NO content reading.
35
+ * This is Pass 1: fast, lightweight, works on file tree only.
36
+ */
37
+ declare function selectRelevantFiles(filePaths: string[], maxFiles?: number): {
38
+ selected: string[];
39
+ scores: FileRelevanceScore[];
40
+ };
41
+ /**
42
+ * Score all files by content (Pass 2) — for use after content is loaded.
43
+ */
44
+ declare function scoreFiles(fileContentsMap: Map<string, string>, parseResults: SourceContext[], _goal: string): FileRelevanceScore[];
45
+
46
+ export { type FileRelevanceScore, SourceContext, scoreByContent, scoreByPath, scoreFiles, selectRelevantFiles };
@@ -0,0 +1,4 @@
1
+ export { scoreByContent, scoreByPath, scoreFiles, selectRelevantFiles } from '../chunk-RKRNOVKO.mjs';
2
+ export { extractKeywords } from '../chunk-XMHKWHVK.mjs';
3
+ //# sourceMappingURL=index.mjs.map
4
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}