@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,18 @@
1
+ export { i as ArchEdgeSchema, A as ArchNodeSchema, x as ArchitectureDetail, j as ArchitectureDetailSchema, w as Capability, C as CapabilitySchema, z as DataIntegration, m as DataIntegrationSchema, G as Decomposition, s as DecompositionSchema, D as DevelopmentStageSchema, y as Experience, E as ExperienceComponentSchema, l as ExperienceSchema, d as Feature, F as FeatureSchema, B as Implementation, I as ImplementationSchema, e as JourneySchema, J as JourneyStepSchema, r as MilestoneDecompositionSchema, M as MissingGapSchema, N as NavigationSchema, v as Product, P as ProductGoalSchema, g as ProductSchema, f as ProductUserSchema, u as ProjectGraph, t as ProjectGraphSchema, h as ProjectInfoSchema, R as RequirementSchema, k as ScreenSchema, c as Step, S as StepEffortSchema, a as StepOutcomeSchema, b as StepSchema, n as TaskEffortSchema, o as TaskOutcomeSchema, p as TaskSchema, q as TechDebtSchema, T as TechStackSchema, U as UiStateSchema } from './projectGraphSchema-DnD7orZV.cjs';
2
+ export { b as Concept, d as ConceptCategory, c as ConceptCategorySchema, m as ConceptIntroduction, i as ConceptIntroductionSchema, C as ConceptSchema, l as DevelopmentPhase, D as DevelopmentPhaseSchema, j as HybridGraph, H as HybridGraphSchema, g as KnowledgeGraph, K as KnowledgeGraphSchema, f as LearningPathStep, L as LearningPathStepSchema, a as ProblemType, P as ProblemTypeSchema, k as ProjectConceptLink, h as ProjectConceptLinkSchema, e as SubjectInfo, S as SubjectInfoSchema } from './hybridGraphSchema-BCgXicgA.cjs';
3
+ export { HardwareFeatureExtensionSchema, HardwareStepSchema, HardwareTaskExtensionSchema, HardwareTechStackExtensionSchema, ShapeSchema, ThreeDesignFeatureExtensionSchema, ThreeDesignTaskExtensionSchema, ThreeDesignTechStackExtensionSchema, WiringSchema } from './schemas/index.cjs';
4
+ export { a as DetectionConfidenceSchema, e as DomainCategory, D as DomainCategorySchema, c as DomainProfile, b as DomainProfileSchema, g as GraphType, G as GraphTypeSchema, d as InputType, I as InputTypeSchema, f as LearningMode, L as LearningModeSchema } from './domainProfileSchema-CwT3Ffsw.cjs';
5
+ export { g as CurriculumFeed, C as CurriculumFeedSchema, i as FeedEdge, c as FeedEdgeSchema, j as FeedGrouping, d as FeedGroupingSchema, F as FeedKeywordsSchema, h as FeedNode, b as FeedNodeSchema, f as FeedPhase, e as FeedPhaseSchema, a as FeedScaffoldCandidateSchema, v as validateCurriculumFeed } from './curriculumFeedSchema-TEeQg2bY.cjs';
6
+ export { CppParseResult, PythonParseResult, SwiftParseResult, TsParseResult, mergeCppResults, mergePythonResults, mergeSwiftResults, mergeTsResults, parseCppFile, parsePythonFile, parseSwiftFile, parseTsFile } from './parsers/index.cjs';
7
+ export { K as Keyword, S as SourceContext, e as extractKeywords } from './keywordExtractor-zPAz2isq.cjs';
8
+ export { FileRelevanceScore, scoreByContent, scoreByPath, scoreFiles, selectRelevantFiles } from './extractors/index.cjs';
9
+ export { DetectDomainOptions, DetectDomainProfileOptions, DetectInputTypeOptions, DetectLearningModeOptions, DomainDetectionResult, InputTypeDetectionResult, LearningModeDetectionResult, detectDomain, detectDomainProfile, detectInputType, detectLearningMode } from './detector/index.cjs';
10
+ export { CIO_CODE_RE, CONCEPT_CODE_RE, DepthLayerAudit, ExtractOverviewOptions, ExtractScaffoldOptions, ExtractStepsOptions, HybridGraphPipelineOptions, HybridGraphPipelineResult, KnowledgeGraphPipelineOptions, KnowledgeGraphPipelineResult, LEARNER_CLAUSE, SIO_CODE_RE, ULO_CODE_RE, assignConceptCodes, auditDepthLayers, cioActionSlug, cioCode, conceptCodeFromName, extractFeatureSteps, extractFeatureStepsBatched, extractProjectOverview, extractScaffold, generateHybridGraph, generateKnowledgeGraph, sioCode, standardStatement, techTagFor, uloCode } from './graph/index.cjs';
11
+ export { H as Hallucination, V as VerifyOptions, v as verifyProjectGraph } from './graphVerifier-QjgDAJce.cjs';
12
+ export { C as ConceptMapping, E as EscalateOptions, e as escalateAndMapConcepts } from './conceptEscalator-ltRLtPhf.cjs';
13
+ export { ConceptMatch, ProposedConcept, ResolveConceptsOptions, ResolveConceptsResult, ResolvedConcept, resolveConcepts } from './concepts/index.cjs';
14
+ export { AssembleOptions, AssembledMilestone, AssembledPhase, AssembledRoadmap, assembleRoadmap } from './assembly/index.cjs';
15
+ export { EmitFeedOptions, emitCurriculumFeed } from './feed/index.cjs';
16
+ export { PipelineOptions, PipelineResult, runProjectGraphPipeline } from './pipeline/index.cjs';
17
+ import 'zod';
18
+ import './llmClient-ysPhLjcH.cjs';
@@ -0,0 +1,18 @@
1
+ export { i as ArchEdgeSchema, A as ArchNodeSchema, x as ArchitectureDetail, j as ArchitectureDetailSchema, w as Capability, C as CapabilitySchema, z as DataIntegration, m as DataIntegrationSchema, G as Decomposition, s as DecompositionSchema, D as DevelopmentStageSchema, y as Experience, E as ExperienceComponentSchema, l as ExperienceSchema, d as Feature, F as FeatureSchema, B as Implementation, I as ImplementationSchema, e as JourneySchema, J as JourneyStepSchema, r as MilestoneDecompositionSchema, M as MissingGapSchema, N as NavigationSchema, v as Product, P as ProductGoalSchema, g as ProductSchema, f as ProductUserSchema, u as ProjectGraph, t as ProjectGraphSchema, h as ProjectInfoSchema, R as RequirementSchema, k as ScreenSchema, c as Step, S as StepEffortSchema, a as StepOutcomeSchema, b as StepSchema, n as TaskEffortSchema, o as TaskOutcomeSchema, p as TaskSchema, q as TechDebtSchema, T as TechStackSchema, U as UiStateSchema } from './projectGraphSchema-DnD7orZV.js';
2
+ export { b as Concept, d as ConceptCategory, c as ConceptCategorySchema, m as ConceptIntroduction, i as ConceptIntroductionSchema, C as ConceptSchema, l as DevelopmentPhase, D as DevelopmentPhaseSchema, j as HybridGraph, H as HybridGraphSchema, g as KnowledgeGraph, K as KnowledgeGraphSchema, f as LearningPathStep, L as LearningPathStepSchema, a as ProblemType, P as ProblemTypeSchema, k as ProjectConceptLink, h as ProjectConceptLinkSchema, e as SubjectInfo, S as SubjectInfoSchema } from './hybridGraphSchema-BCgXicgA.js';
3
+ export { HardwareFeatureExtensionSchema, HardwareStepSchema, HardwareTaskExtensionSchema, HardwareTechStackExtensionSchema, ShapeSchema, ThreeDesignFeatureExtensionSchema, ThreeDesignTaskExtensionSchema, ThreeDesignTechStackExtensionSchema, WiringSchema } from './schemas/index.js';
4
+ export { a as DetectionConfidenceSchema, e as DomainCategory, D as DomainCategorySchema, c as DomainProfile, b as DomainProfileSchema, g as GraphType, G as GraphTypeSchema, d as InputType, I as InputTypeSchema, f as LearningMode, L as LearningModeSchema } from './domainProfileSchema-CwT3Ffsw.js';
5
+ export { g as CurriculumFeed, C as CurriculumFeedSchema, i as FeedEdge, c as FeedEdgeSchema, j as FeedGrouping, d as FeedGroupingSchema, F as FeedKeywordsSchema, h as FeedNode, b as FeedNodeSchema, f as FeedPhase, e as FeedPhaseSchema, a as FeedScaffoldCandidateSchema, v as validateCurriculumFeed } from './curriculumFeedSchema-TEeQg2bY.js';
6
+ export { CppParseResult, PythonParseResult, SwiftParseResult, TsParseResult, mergeCppResults, mergePythonResults, mergeSwiftResults, mergeTsResults, parseCppFile, parsePythonFile, parseSwiftFile, parseTsFile } from './parsers/index.js';
7
+ export { K as Keyword, S as SourceContext, e as extractKeywords } from './keywordExtractor-CKaXqSku.js';
8
+ export { FileRelevanceScore, scoreByContent, scoreByPath, scoreFiles, selectRelevantFiles } from './extractors/index.js';
9
+ export { DetectDomainOptions, DetectDomainProfileOptions, DetectInputTypeOptions, DetectLearningModeOptions, DomainDetectionResult, InputTypeDetectionResult, LearningModeDetectionResult, detectDomain, detectDomainProfile, detectInputType, detectLearningMode } from './detector/index.js';
10
+ export { CIO_CODE_RE, CONCEPT_CODE_RE, DepthLayerAudit, ExtractOverviewOptions, ExtractScaffoldOptions, ExtractStepsOptions, HybridGraphPipelineOptions, HybridGraphPipelineResult, KnowledgeGraphPipelineOptions, KnowledgeGraphPipelineResult, LEARNER_CLAUSE, SIO_CODE_RE, ULO_CODE_RE, assignConceptCodes, auditDepthLayers, cioActionSlug, cioCode, conceptCodeFromName, extractFeatureSteps, extractFeatureStepsBatched, extractProjectOverview, extractScaffold, generateHybridGraph, generateKnowledgeGraph, sioCode, standardStatement, techTagFor, uloCode } from './graph/index.js';
11
+ export { H as Hallucination, V as VerifyOptions, v as verifyProjectGraph } from './graphVerifier-DsTP9uAN.js';
12
+ export { C as ConceptMapping, E as EscalateOptions, e as escalateAndMapConcepts } from './conceptEscalator-YfMKIKCZ.js';
13
+ export { ConceptMatch, ProposedConcept, ResolveConceptsOptions, ResolveConceptsResult, ResolvedConcept, resolveConcepts } from './concepts/index.js';
14
+ export { AssembleOptions, AssembledMilestone, AssembledPhase, AssembledRoadmap, assembleRoadmap } from './assembly/index.js';
15
+ export { EmitFeedOptions, emitCurriculumFeed } from './feed/index.js';
16
+ export { PipelineOptions, PipelineResult, runProjectGraphPipeline } from './pipeline/index.js';
17
+ import 'zod';
18
+ import './llmClient-ysPhLjcH.js';
package/dist/index.mjs ADDED
@@ -0,0 +1,17 @@
1
+ export { emitCurriculumFeed } from './chunk-3H2HX7PR.mjs';
2
+ export { runProjectGraphPipeline } from './chunk-GEUDHZE7.mjs';
3
+ export { ArchEdgeSchema, ArchNodeSchema, ArchitectureDetailSchema, CapabilitySchema, ConceptCategorySchema, ConceptIntroductionSchema, ConceptSchema, DataIntegrationSchema, DecompositionSchema, DetectionConfidenceSchema, DevelopmentPhaseSchema, DevelopmentStageSchema, DomainCategorySchema, DomainProfileSchema, ExperienceComponentSchema, ExperienceSchema, FeatureSchema, GraphTypeSchema, HardwareFeatureExtensionSchema, HardwareStepSchema, HardwareTaskExtensionSchema, HardwareTechStackExtensionSchema, HybridGraphSchema, ImplementationSchema, InputTypeSchema, JourneySchema, JourneyStepSchema, KnowledgeGraphSchema, LearningModeSchema, LearningPathStepSchema, MilestoneDecompositionSchema, MissingGapSchema, NavigationSchema, ProblemTypeSchema, ProductGoalSchema, ProductSchema, ProductUserSchema, ProjectConceptLinkSchema, ProjectGraphSchema, ProjectInfoSchema, RequirementSchema, ScreenSchema, ShapeSchema, StepEffortSchema, StepOutcomeSchema, StepSchema, SubjectInfoSchema, TaskEffortSchema, TaskOutcomeSchema, TaskSchema, TechDebtSchema, TechStackSchema, ThreeDesignFeatureExtensionSchema, ThreeDesignTaskExtensionSchema, ThreeDesignTechStackExtensionSchema, UiStateSchema, WiringSchema } from './chunk-PM42MMDJ.mjs';
4
+ export { CurriculumFeedSchema, FeedEdgeSchema, FeedGroupingSchema, FeedKeywordsSchema, FeedNodeSchema, FeedPhaseSchema, FeedScaffoldCandidateSchema, validateCurriculumFeed } from './chunk-HH4UX65C.mjs';
5
+ import './chunk-F4RZNBOE.mjs';
6
+ export { mergeCppResults, mergePythonResults, mergeSwiftResults, mergeTsResults, parseCppFile, parsePythonFile, parseSwiftFile, parseTsFile } from './chunk-DRVOV5ZD.mjs';
7
+ export { scoreByContent, scoreByPath, scoreFiles, selectRelevantFiles } from './chunk-RKRNOVKO.mjs';
8
+ export { extractKeywords } from './chunk-XMHKWHVK.mjs';
9
+ export { detectDomain, detectDomainProfile, detectInputType, detectLearningMode } from './chunk-VFART56O.mjs';
10
+ export { CIO_CODE_RE, CONCEPT_CODE_RE, LEARNER_CLAUSE, SIO_CODE_RE, ULO_CODE_RE, assignConceptCodes, auditDepthLayers, cioActionSlug, cioCode, conceptCodeFromName, generateHybridGraph, generateKnowledgeGraph, sioCode, standardStatement, techTagFor, uloCode } from './chunk-3VVPSRAM.mjs';
11
+ export { escalateAndMapConcepts, extractFeatureSteps, extractFeatureStepsBatched, extractProjectOverview, extractScaffold, verifyProjectGraph } from './chunk-MOKNFLUD.mjs';
12
+ import './chunk-KMYENICQ.mjs';
13
+ export { resolveConcepts } from './chunk-KNDBODUQ.mjs';
14
+ import './chunk-MM2RWYNW.mjs';
15
+ export { assembleRoadmap } from './chunk-ONQHJ4OH.mjs';
16
+ //# sourceMappingURL=index.mjs.map
17
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
@@ -0,0 +1,34 @@
1
+ import { SwiftParseResult, TsParseResult, PythonParseResult, CppParseResult } from './parsers/index.js';
2
+
3
+ /**
4
+ * Keyword extraction logic — combines AST parser results into structured keywords
5
+ * with source, weight, and context metadata.
6
+ *
7
+ * Ported from knowledge-tree/extract_project_keywords.py extract_keywords()
8
+ */
9
+
10
+ interface Keyword {
11
+ keyword: string;
12
+ source: string;
13
+ platform: string;
14
+ weight: number;
15
+ context: string;
16
+ }
17
+ type SourceContext = SwiftParseResult | TsParseResult | PythonParseResult | CppParseResult;
18
+ interface ExtractKeywordsOptions {
19
+ /** Additional stdlib modules to skip (merged with defaults) */
20
+ extraStdlibModules?: string[];
21
+ /** Modules to un-skip even if in stdlib (e.g., 'math' for scientific projects) */
22
+ unskipModules?: string[];
23
+ }
24
+ /**
25
+ * Extract structured keywords from source context and basic analysis.
26
+ *
27
+ * Multi-target: each keyword is tagged with platform (app/esp32) from its source file,
28
+ * so downstream SIO generation produces correct keywords for each codebase.
29
+ */
30
+ declare function extractKeywords(sourceContext: SourceContext, basicAnalysis?: {
31
+ config_files?: string[];
32
+ }, repoDir?: string, options?: ExtractKeywordsOptions): Keyword[];
33
+
34
+ export { type Keyword as K, type SourceContext as S, extractKeywords as e };
@@ -0,0 +1,34 @@
1
+ import { SwiftParseResult, TsParseResult, PythonParseResult, CppParseResult } from './parsers/index.cjs';
2
+
3
+ /**
4
+ * Keyword extraction logic — combines AST parser results into structured keywords
5
+ * with source, weight, and context metadata.
6
+ *
7
+ * Ported from knowledge-tree/extract_project_keywords.py extract_keywords()
8
+ */
9
+
10
+ interface Keyword {
11
+ keyword: string;
12
+ source: string;
13
+ platform: string;
14
+ weight: number;
15
+ context: string;
16
+ }
17
+ type SourceContext = SwiftParseResult | TsParseResult | PythonParseResult | CppParseResult;
18
+ interface ExtractKeywordsOptions {
19
+ /** Additional stdlib modules to skip (merged with defaults) */
20
+ extraStdlibModules?: string[];
21
+ /** Modules to un-skip even if in stdlib (e.g., 'math' for scientific projects) */
22
+ unskipModules?: string[];
23
+ }
24
+ /**
25
+ * Extract structured keywords from source context and basic analysis.
26
+ *
27
+ * Multi-target: each keyword is tagged with platform (app/esp32) from its source file,
28
+ * so downstream SIO generation produces correct keywords for each codebase.
29
+ */
30
+ declare function extractKeywords(sourceContext: SourceContext, basicAnalysis?: {
31
+ config_files?: string[];
32
+ }, repoDir?: string, options?: ExtractKeywordsOptions): Keyword[];
33
+
34
+ export { type Keyword as K, type SourceContext as S, extractKeywords as e };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * LLM client wrapper — provides a unified interface for LLM calls
3
+ * used by the graph generation pipeline.
4
+ *
5
+ * Supports OpenAI-compatible APIs via environment variables:
6
+ * LLM_API_KEY, LLM_BASE_URL, LLM_MODEL (or LLM_TIER_FAST / LLM_TIER_STRONG)
7
+ */
8
+ interface LlmClientConfig {
9
+ apiKey?: string;
10
+ baseUrl?: string;
11
+ model?: string;
12
+ temperature?: number;
13
+ maxTokens?: number;
14
+ }
15
+
16
+ export type { LlmClientConfig as L };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * LLM client wrapper — provides a unified interface for LLM calls
3
+ * used by the graph generation pipeline.
4
+ *
5
+ * Supports OpenAI-compatible APIs via environment variables:
6
+ * LLM_API_KEY, LLM_BASE_URL, LLM_MODEL (or LLM_TIER_FAST / LLM_TIER_STRONG)
7
+ */
8
+ interface LlmClientConfig {
9
+ apiKey?: string;
10
+ baseUrl?: string;
11
+ model?: string;
12
+ temperature?: number;
13
+ maxTokens?: number;
14
+ }
15
+
16
+ export type { LlmClientConfig as L };
@@ -0,0 +1,323 @@
1
+ 'use strict';
2
+
3
+ // src/parsers/swift.ts
4
+ var IMPORT_RE = /^import\s+(\w+)/gm;
5
+ var TYPE_RE = /\b(class|struct|enum|protocol)\s+(\w+)(?:\s*:\s*([^{]+))?/g;
6
+ var FUNC_RE = /\bfunc\s+(\w+)\s*\(([^)]*)\)(?:\s*->\s*([^{]+))?/g;
7
+ var WRAPPER_RE = /@(State|Binding|ObservedObject|StateObject|Published|Environment|EnvironmentObject|AppStorage|SceneStorage|FocusState|Observable)\b/g;
8
+ var FRAMEWORK_USAGE_RE = /\b(URLSession|URLRequest|JSONSerialization|JSONDecoder|JSONEncoder|Task|DispatchQueue|Timer|NotificationCenter|UserDefaults|FileManager|Bundle)\b/g;
9
+ function parseSwiftFile(filepath, content) {
10
+ const result = {
11
+ imports: [],
12
+ types: [],
13
+ functions: [],
14
+ property_wrappers: [],
15
+ error_handling: [],
16
+ frameworks_used: []
17
+ };
18
+ let match;
19
+ while ((match = IMPORT_RE.exec(content)) !== null) {
20
+ result.imports.push(match[1]);
21
+ }
22
+ const fwSeen = /* @__PURE__ */ new Set();
23
+ while ((match = FRAMEWORK_USAGE_RE.exec(content)) !== null) {
24
+ if (!fwSeen.has(match[1])) {
25
+ fwSeen.add(match[1]);
26
+ result.frameworks_used.push(match[1]);
27
+ }
28
+ }
29
+ while ((match = TYPE_RE.exec(content)) !== null) {
30
+ const conforms = (match[3] || "").split(",").map((p) => p.trim()).filter(Boolean);
31
+ result.types.push({
32
+ kind: match[1],
33
+ name: match[2],
34
+ conforms_to: conforms,
35
+ file: filepath
36
+ });
37
+ }
38
+ while ((match = FUNC_RE.exec(content)) !== null) {
39
+ const name = match[1];
40
+ if (name.startsWith("_")) continue;
41
+ result.functions.push({
42
+ name,
43
+ params: (match[2] || "").trim(),
44
+ returns: (match[3] || "").trim(),
45
+ file: filepath
46
+ });
47
+ }
48
+ const wrapperSet = /* @__PURE__ */ new Set();
49
+ while ((match = WRAPPER_RE.exec(content)) !== null) {
50
+ wrapperSet.add(match[1]);
51
+ }
52
+ result.property_wrappers = Array.from(wrapperSet);
53
+ if (content.includes("do {") || content.includes("do{")) {
54
+ result.error_handling.push("do-catch");
55
+ }
56
+ if (content.includes("throws")) {
57
+ result.error_handling.push("throws");
58
+ }
59
+ if (content.includes("Result<")) {
60
+ result.error_handling.push("Result type");
61
+ }
62
+ if (content.includes("try?")) {
63
+ result.error_handling.push("try?");
64
+ }
65
+ if (content.includes("try!")) {
66
+ result.error_handling.push("try!");
67
+ }
68
+ return result;
69
+ }
70
+ function mergeSwiftResults(results) {
71
+ const merged = {
72
+ imports: [],
73
+ types: [],
74
+ functions: [],
75
+ property_wrappers: [],
76
+ error_handling: [],
77
+ frameworks_used: []
78
+ };
79
+ const importCounts = /* @__PURE__ */ new Map();
80
+ const wrapperCounts = /* @__PURE__ */ new Map();
81
+ const errorCounts = /* @__PURE__ */ new Map();
82
+ const frameworkSet = /* @__PURE__ */ new Set();
83
+ for (const r of results) {
84
+ for (const imp of r.imports) {
85
+ importCounts.set(imp, (importCounts.get(imp) || 0) + 1);
86
+ }
87
+ merged.types.push(...r.types);
88
+ merged.functions.push(...r.functions);
89
+ for (const w of r.property_wrappers) {
90
+ wrapperCounts.set(w, (wrapperCounts.get(w) || 0) + 1);
91
+ }
92
+ for (const e of r.error_handling) {
93
+ errorCounts.set(e, (errorCounts.get(e) || 0) + 1);
94
+ }
95
+ for (const fw of r.frameworks_used) {
96
+ frameworkSet.add(fw);
97
+ }
98
+ }
99
+ merged.imports = Array.from(importCounts.entries()).sort((a, b) => b[1] - a[1]).slice(0, 20).map(([mod, count]) => mod);
100
+ merged.property_wrappers = Array.from(wrapperCounts.entries()).sort((a, b) => b[1] - a[1]).slice(0, 10).map(([w]) => w);
101
+ merged.error_handling = Array.from(errorCounts.entries()).sort((a, b) => b[1] - a[1]).slice(0, 10).map(([p]) => p);
102
+ merged.frameworks_used = Array.from(frameworkSet).sort();
103
+ merged.types = merged.types.slice(0, 100);
104
+ merged.functions = merged.functions.slice(0, 100);
105
+ return merged;
106
+ }
107
+
108
+ // src/parsers/typescript.ts
109
+ var IMPORT_RE2 = /import\s+.*?from\s+['"]([^'"]+)['"]/g;
110
+ var TYPE_RE2 = /\b(interface|type|class|enum)\s+(\w+)/g;
111
+ var FUNC_RE2 = /\bfunction\s+(\w+)\s*\(([^)]*)\)/g;
112
+ var ARROW_RE = /\bconst\s+(\w+)\s*=\s*\([^)]*\)\s*(?::\s*\w+)?\s*=>/g;
113
+ function parseTsFile(filepath, content) {
114
+ const result = {
115
+ imports: [],
116
+ types: [],
117
+ functions: [],
118
+ error_handling: []
119
+ };
120
+ let match;
121
+ while ((match = IMPORT_RE2.exec(content)) !== null) {
122
+ result.imports.push(match[1]);
123
+ }
124
+ while ((match = TYPE_RE2.exec(content)) !== null) {
125
+ result.types.push({
126
+ kind: match[1],
127
+ name: match[2],
128
+ file: filepath
129
+ });
130
+ }
131
+ while ((match = FUNC_RE2.exec(content)) !== null) {
132
+ result.functions.push({
133
+ name: match[1],
134
+ params: (match[2] || "").trim(),
135
+ file: filepath
136
+ });
137
+ }
138
+ while ((match = ARROW_RE.exec(content)) !== null) {
139
+ result.functions.push({
140
+ name: match[1],
141
+ params: "",
142
+ file: filepath
143
+ });
144
+ }
145
+ if (content.includes("try {") || content.includes("try{")) {
146
+ result.error_handling.push("try-catch");
147
+ }
148
+ if (content.includes("Promise")) {
149
+ result.error_handling.push("Promise");
150
+ }
151
+ if (content.includes(".catch(")) {
152
+ result.error_handling.push(".catch()");
153
+ }
154
+ return result;
155
+ }
156
+ function mergeTsResults(results) {
157
+ const merged = {
158
+ imports: [],
159
+ types: [],
160
+ functions: [],
161
+ error_handling: []
162
+ };
163
+ const importCounts = /* @__PURE__ */ new Map();
164
+ const errorCounts = /* @__PURE__ */ new Map();
165
+ for (const r of results) {
166
+ for (const imp of r.imports) {
167
+ importCounts.set(imp, (importCounts.get(imp) || 0) + 1);
168
+ }
169
+ merged.types.push(...r.types);
170
+ merged.functions.push(...r.functions);
171
+ for (const e of r.error_handling) {
172
+ errorCounts.set(e, (errorCounts.get(e) || 0) + 1);
173
+ }
174
+ }
175
+ merged.imports = Array.from(importCounts.entries()).sort((a, b) => b[1] - a[1]).slice(0, 20).map(([mod]) => mod);
176
+ merged.error_handling = Array.from(errorCounts.entries()).sort((a, b) => b[1] - a[1]).slice(0, 10).map(([p]) => p);
177
+ merged.types = merged.types.slice(0, 100);
178
+ merged.functions = merged.functions.slice(0, 100);
179
+ return merged;
180
+ }
181
+
182
+ // src/parsers/python.ts
183
+ var IMPORT_RE3 = /^(?:import|from)\s+(\w+)/gm;
184
+ var CLASS_RE = /\bclass\s+(\w+)(?:\s*\(([^)]+)\))?/g;
185
+ var FUNC_RE3 = /\bdef\s+(\w+)\s*\(([^)]*)\)/g;
186
+ var DOCSTRING_RE = /"""([^"]{20,300})"""/g;
187
+ function parsePythonFile(filepath, content) {
188
+ const result = {
189
+ imports: [],
190
+ types: [],
191
+ functions: [],
192
+ docstrings: [],
193
+ error_handling: []
194
+ };
195
+ let match;
196
+ while ((match = IMPORT_RE3.exec(content)) !== null) {
197
+ result.imports.push(match[1]);
198
+ }
199
+ while ((match = DOCSTRING_RE.exec(content)) !== null) {
200
+ const firstSentence = match[1].trim().split("\n")[0].slice(0, 120);
201
+ if (firstSentence.length > 15) {
202
+ result.docstrings.push(firstSentence);
203
+ }
204
+ }
205
+ while ((match = CLASS_RE.exec(content)) !== null) {
206
+ const bases = (match[2] || "").split(",").map((b) => b.trim()).filter(Boolean);
207
+ result.types.push({
208
+ kind: "class",
209
+ name: match[1],
210
+ bases,
211
+ file: filepath
212
+ });
213
+ }
214
+ while ((match = FUNC_RE3.exec(content)) !== null) {
215
+ const name = match[1];
216
+ if (name.startsWith("__") && name.endsWith("__")) continue;
217
+ result.functions.push({
218
+ name,
219
+ params: (match[2] || "").trim(),
220
+ file: filepath
221
+ });
222
+ }
223
+ if (content.includes("try:")) {
224
+ result.error_handling.push("try-except");
225
+ }
226
+ if (content.includes("raise")) {
227
+ result.error_handling.push("raise");
228
+ }
229
+ return result;
230
+ }
231
+ function mergePythonResults(results) {
232
+ const merged = {
233
+ imports: [],
234
+ types: [],
235
+ functions: [],
236
+ docstrings: [],
237
+ error_handling: []
238
+ };
239
+ const importCounts = /* @__PURE__ */ new Map();
240
+ const errorCounts = /* @__PURE__ */ new Map();
241
+ for (const r of results) {
242
+ for (const imp of r.imports) {
243
+ importCounts.set(imp, (importCounts.get(imp) || 0) + 1);
244
+ }
245
+ merged.types.push(...r.types);
246
+ merged.functions.push(...r.functions);
247
+ merged.docstrings.push(...r.docstrings);
248
+ for (const e of r.error_handling) {
249
+ errorCounts.set(e, (errorCounts.get(e) || 0) + 1);
250
+ }
251
+ }
252
+ merged.imports = Array.from(importCounts.entries()).sort((a, b) => b[1] - a[1]).slice(0, 20).map(([mod]) => mod);
253
+ merged.error_handling = Array.from(errorCounts.entries()).sort((a, b) => b[1] - a[1]).slice(0, 10).map(([p]) => p);
254
+ merged.types = merged.types.slice(0, 100);
255
+ merged.functions = merged.functions.slice(0, 100);
256
+ merged.docstrings = merged.docstrings.slice(0, 20);
257
+ return merged;
258
+ }
259
+
260
+ // src/parsers/cpp.ts
261
+ var INCLUDE_RE = /#include\s*[<"]([^>"]+)[>"]/g;
262
+ var TYPE_RE3 = /\b(?:class|struct|enum)\s+(\w+)/g;
263
+ var FUNC_RE4 = /\b(?:void|int|float|double|char|bool|String|uint8_t|uint16_t|uint32_t)\s+(\w+)\s*\(/g;
264
+ function parseCppFile(filepath, content) {
265
+ const result = {
266
+ imports: [],
267
+ types: [],
268
+ functions: [],
269
+ error_handling: []
270
+ };
271
+ let match;
272
+ while ((match = INCLUDE_RE.exec(content)) !== null) {
273
+ result.imports.push(match[1]);
274
+ }
275
+ while ((match = TYPE_RE3.exec(content)) !== null) {
276
+ result.types.push({
277
+ kind: "cpp",
278
+ name: match[1],
279
+ file: filepath
280
+ });
281
+ }
282
+ while ((match = FUNC_RE4.exec(content)) !== null) {
283
+ result.functions.push({
284
+ name: match[1],
285
+ file: filepath
286
+ });
287
+ }
288
+ if (/\btry\b|\bthrow\b|\bcatch\b/.test(content)) {
289
+ result.error_handling.push("try/throw/catch");
290
+ }
291
+ return result;
292
+ }
293
+ function mergeCppResults(results) {
294
+ const merged = {
295
+ imports: [],
296
+ types: [],
297
+ functions: [],
298
+ error_handling: []
299
+ };
300
+ const importCounts = /* @__PURE__ */ new Map();
301
+ for (const r of results) {
302
+ for (const imp of r.imports) {
303
+ importCounts.set(imp, (importCounts.get(imp) || 0) + 1);
304
+ }
305
+ merged.types.push(...r.types);
306
+ merged.functions.push(...r.functions);
307
+ merged.error_handling.push(...r.error_handling);
308
+ }
309
+ merged.imports = Array.from(importCounts.entries()).sort((a, b) => b[1] - a[1]).slice(0, 20).map(([mod]) => mod);
310
+ merged.error_handling = [...new Set(merged.error_handling)];
311
+ return merged;
312
+ }
313
+
314
+ exports.mergeCppResults = mergeCppResults;
315
+ exports.mergePythonResults = mergePythonResults;
316
+ exports.mergeSwiftResults = mergeSwiftResults;
317
+ exports.mergeTsResults = mergeTsResults;
318
+ exports.parseCppFile = parseCppFile;
319
+ exports.parsePythonFile = parsePythonFile;
320
+ exports.parseSwiftFile = parseSwiftFile;
321
+ exports.parseTsFile = parseTsFile;
322
+ //# sourceMappingURL=index.cjs.map
323
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/parsers/swift.ts","../../src/parsers/typescript.ts","../../src/parsers/python.ts","../../src/parsers/cpp.ts"],"names":["IMPORT_RE","TYPE_RE","FUNC_RE"],"mappings":";;;AA0BA,IAAM,SAAA,GAAY,mBAAA;AAClB,IAAM,OAAA,GAAU,4DAAA;AAChB,IAAM,OAAA,GAAU,mDAAA;AAChB,IAAM,UAAA,GAAa,sIAAA;AACnB,IAAM,kBAAA,GAAqB,oJAAA;AAEpB,SAAS,cAAA,CAAe,UAAkB,OAAA,EAAmC;AAClF,EAAA,MAAM,MAAA,GAA2B;AAAA,IAC/B,SAAS,EAAC;AAAA,IACV,OAAO,EAAC;AAAA,IACR,WAAW,EAAC;AAAA,IACZ,mBAAmB,EAAC;AAAA,IACpB,gBAAgB,EAAC;AAAA,IACjB,iBAAiB;AAAC,GACpB;AAGA,EAAA,IAAI,KAAA;AACJ,EAAA,OAAA,CAAQ,KAAA,GAAQ,SAAA,CAAU,IAAA,CAAK,OAAO,OAAO,IAAA,EAAM;AACjD,IAAA,MAAA,CAAO,OAAA,CAAQ,IAAA,CAAK,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,CAAa,IAAI,GAAA,EAAA,CAAM,YAAA,CAAa,IAAI,GAAG,CAAA,IAAK,KAAK,CAAC,CAAA;AAAA,IACxD;AACA,IAAA,MAAA,CAAO,KAAA,CAAM,IAAA,CAAK,GAAG,CAAA,CAAE,KAAK,CAAA;AAC5B,IAAA,MAAA,CAAO,SAAA,CAAU,IAAA,CAAK,GAAG,CAAA,CAAE,SAAS,CAAA;AACpC,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,CAAK,GAAG,CAAA,CAAE,cAAc,CAAA;AAAA,EAChD;AAEA,EAAA,MAAA,CAAO,OAAA,GAAU,KAAA,CAAM,IAAA,CAAK,YAAA,CAAa,OAAA,EAAS,CAAA,CAC/C,IAAA,CAAK,CAAC,CAAA,EAAG,CAAA,KAAM,CAAA,CAAE,CAAC,CAAA,GAAI,CAAA,CAAE,CAAC,CAAC,CAAA,CAC1B,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA,CACX,GAAA,CAAI,CAAC,CAAC,GAAG,CAAA,KAAM,GAAG,CAAA;AAGrB,EAAA,MAAA,CAAO,iBAAiB,CAAC,GAAG,IAAI,GAAA,CAAI,MAAA,CAAO,cAAc,CAAC,CAAA;AAE1D,EAAA,OAAO,MAAA;AACT","file":"index.cjs","sourcesContent":["/**\n * Swift AST-level parser — extracts imports, types, functions, property wrappers,\n * error handling patterns, and framework usage from Swift source files.\n *\n * Ported from knowledge-tree/extract_project_keywords.py parse_swift_file()\n */\n\nexport interface SwiftParseResult {\n imports: string[];\n types: Array<{\n kind: string;\n name: string;\n conforms_to: string[];\n file: string;\n }>;\n functions: Array<{\n name: string;\n params: string;\n returns: string;\n file: string;\n }>;\n property_wrappers: string[];\n error_handling: string[];\n frameworks_used: string[];\n}\n\nconst IMPORT_RE = /^import\\s+(\\w+)/gm;\nconst TYPE_RE = /\\b(class|struct|enum|protocol)\\s+(\\w+)(?:\\s*:\\s*([^{]+))?/g;\nconst FUNC_RE = /\\bfunc\\s+(\\w+)\\s*\\(([^)]*)\\)(?:\\s*->\\s*([^{]+))?/g;\nconst WRAPPER_RE = /@(State|Binding|ObservedObject|StateObject|Published|Environment|EnvironmentObject|AppStorage|SceneStorage|FocusState|Observable)\\b/g;\nconst FRAMEWORK_USAGE_RE = /\\b(URLSession|URLRequest|JSONSerialization|JSONDecoder|JSONEncoder|Task|DispatchQueue|Timer|NotificationCenter|UserDefaults|FileManager|Bundle)\\b/g;\n\nexport function parseSwiftFile(filepath: string, content: string): SwiftParseResult {\n const result: SwiftParseResult = {\n imports: [],\n types: [],\n functions: [],\n property_wrappers: [],\n error_handling: [],\n frameworks_used: [],\n };\n\n // Extract imports\n let match: RegExpExecArray | null;\n while ((match = IMPORT_RE.exec(content)) !== null) {\n result.imports.push(match[1]);\n }\n\n // Extract framework usage (types used in body, not declarations)\n const fwSeen = new Set<string>();\n while ((match = FRAMEWORK_USAGE_RE.exec(content)) !== null) {\n if (!fwSeen.has(match[1])) {\n fwSeen.add(match[1]);\n result.frameworks_used.push(match[1]);\n }\n }\n\n // Extract type declarations\n while ((match = TYPE_RE.exec(content)) !== null) {\n const conforms = (match[3] || '')\n .split(',')\n .map(p => p.trim())\n .filter(Boolean);\n result.types.push({\n kind: match[1],\n name: match[2],\n conforms_to: conforms,\n file: filepath,\n });\n }\n\n // Extract function signatures\n while ((match = FUNC_RE.exec(content)) !== null) {\n const name = match[1];\n if (name.startsWith('_')) continue;\n result.functions.push({\n name,\n params: (match[2] || '').trim(),\n returns: (match[3] || '').trim(),\n file: filepath,\n });\n }\n\n // Extract property wrappers\n const wrapperSet = new Set<string>();\n while ((match = WRAPPER_RE.exec(content)) !== null) {\n wrapperSet.add(match[1]);\n }\n result.property_wrappers = Array.from(wrapperSet);\n\n // Extract error handling patterns\n if (content.includes('do {') || content.includes('do{')) {\n result.error_handling.push('do-catch');\n }\n if (content.includes('throws')) {\n result.error_handling.push('throws');\n }\n if (content.includes('Result<')) {\n result.error_handling.push('Result type');\n }\n if (content.includes('try?')) {\n result.error_handling.push('try?');\n }\n if (content.includes('try!')) {\n result.error_handling.push('try!');\n }\n\n return result;\n}\n\nexport function mergeSwiftResults(results: SwiftParseResult[]): SwiftParseResult {\n const merged: SwiftParseResult = {\n imports: [],\n types: [],\n functions: [],\n property_wrappers: [],\n error_handling: [],\n frameworks_used: [],\n };\n\n const importCounts = new Map<string, number>();\n const wrapperCounts = new Map<string, number>();\n const errorCounts = new Map<string, number>();\n const frameworkSet = new Set<string>();\n\n for (const r of results) {\n for (const imp of r.imports) {\n importCounts.set(imp, (importCounts.get(imp) || 0) + 1);\n }\n merged.types.push(...r.types);\n merged.functions.push(...r.functions);\n for (const w of r.property_wrappers) {\n wrapperCounts.set(w, (wrapperCounts.get(w) || 0) + 1);\n }\n for (const e of r.error_handling) {\n errorCounts.set(e, (errorCounts.get(e) || 0) + 1);\n }\n for (const fw of r.frameworks_used) {\n frameworkSet.add(fw);\n }\n }\n\n // Sort imports by count descending, top 20\n merged.imports = Array.from(importCounts.entries())\n .sort((a, b) => b[1] - a[1])\n .slice(0, 20)\n .map(([mod, count]) => mod);\n\n // Sort wrappers by count, top 10\n merged.property_wrappers = Array.from(wrapperCounts.entries())\n .sort((a, b) => b[1] - a[1])\n .slice(0, 10)\n .map(([w]) => w);\n\n // Sort errors by count, top 10\n merged.error_handling = Array.from(errorCounts.entries())\n .sort((a, b) => b[1] - a[1])\n .slice(0, 10)\n .map(([p]) => p);\n\n merged.frameworks_used = Array.from(frameworkSet).sort();\n\n // Limit types and functions\n merged.types = merged.types.slice(0, 100);\n merged.functions = merged.functions.slice(0, 100);\n\n return merged;\n}\n","/**\n * TypeScript/JavaScript AST-level parser — extracts imports, types, functions,\n * and error handling patterns.\n *\n * Ported from knowledge-tree/extract_project_keywords.py parse_ts_file()\n */\n\nexport interface TsParseResult {\n imports: string[];\n types: Array<{\n kind: string;\n name: string;\n file: string;\n }>;\n functions: Array<{\n name: string;\n params: string;\n file: string;\n }>;\n error_handling: string[];\n}\n\nconst IMPORT_RE = /import\\s+.*?from\\s+['\"]([^'\"]+)['\"]/g;\nconst TYPE_RE = /\\b(interface|type|class|enum)\\s+(\\w+)/g;\nconst FUNC_RE = /\\bfunction\\s+(\\w+)\\s*\\(([^)]*)\\)/g;\nconst ARROW_RE = /\\bconst\\s+(\\w+)\\s*=\\s*\\([^)]*\\)\\s*(?::\\s*\\w+)?\\s*=>/g;\n\nexport function parseTsFile(filepath: string, content: string): TsParseResult {\n const result: TsParseResult = {\n imports: [],\n types: [],\n functions: [],\n error_handling: [],\n };\n\n let match: RegExpExecArray | null;\n\n // Extract imports\n while ((match = IMPORT_RE.exec(content)) !== null) {\n result.imports.push(match[1]);\n }\n\n // Extract type/interface/class/enum declarations\n while ((match = TYPE_RE.exec(content)) !== null) {\n result.types.push({\n kind: match[1],\n name: match[2],\n file: filepath,\n });\n }\n\n // Extract function declarations\n while ((match = FUNC_RE.exec(content)) !== null) {\n result.functions.push({\n name: match[1],\n params: (match[2] || '').trim(),\n file: filepath,\n });\n }\n\n // Extract arrow functions\n while ((match = ARROW_RE.exec(content)) !== null) {\n result.functions.push({\n name: match[1],\n params: '',\n file: filepath,\n });\n }\n\n // Extract error handling patterns\n if (content.includes('try {') || content.includes('try{')) {\n result.error_handling.push('try-catch');\n }\n if (content.includes('Promise')) {\n result.error_handling.push('Promise');\n }\n if (content.includes('.catch(')) {\n result.error_handling.push('.catch()');\n }\n\n return result;\n}\n\nexport function mergeTsResults(results: TsParseResult[]): TsParseResult {\n const merged: TsParseResult = {\n imports: [],\n types: [],\n functions: [],\n error_handling: [],\n };\n\n const importCounts = new Map<string, number>();\n const errorCounts = new Map<string, number>();\n\n for (const r of results) {\n for (const imp of r.imports) {\n importCounts.set(imp, (importCounts.get(imp) || 0) + 1);\n }\n merged.types.push(...r.types);\n merged.functions.push(...r.functions);\n for (const e of r.error_handling) {\n errorCounts.set(e, (errorCounts.get(e) || 0) + 1);\n }\n }\n\n merged.imports = Array.from(importCounts.entries())\n .sort((a, b) => b[1] - a[1])\n .slice(0, 20)\n .map(([mod]) => mod);\n\n merged.error_handling = Array.from(errorCounts.entries())\n .sort((a, b) => b[1] - a[1])\n .slice(0, 10)\n .map(([p]) => p);\n\n merged.types = merged.types.slice(0, 100);\n merged.functions = merged.functions.slice(0, 100);\n\n return merged;\n}\n","/**\n * Python AST-level parser — extracts imports, classes, functions, docstrings,\n * and error handling patterns.\n *\n * Ported from knowledge-tree/extract_project_keywords.py parse_python_file()\n */\n\nexport interface PythonParseResult {\n imports: string[];\n types: Array<{\n kind: string;\n name: string;\n bases: string[];\n file: string;\n }>;\n functions: Array<{\n name: string;\n params: string;\n file: string;\n }>;\n docstrings: string[];\n error_handling: string[];\n}\n\nconst IMPORT_RE = /^(?:import|from)\\s+(\\w+)/gm;\nconst CLASS_RE = /\\bclass\\s+(\\w+)(?:\\s*\\(([^)]+)\\))?/g;\nconst FUNC_RE = /\\bdef\\s+(\\w+)\\s*\\(([^)]*)\\)/g;\nconst DOCSTRING_RE = /\"\"\"([^\"]{20,300})\"\"\"/g;\n\nexport function parsePythonFile(filepath: string, content: string): PythonParseResult {\n const result: PythonParseResult = {\n imports: [],\n types: [],\n functions: [],\n docstrings: [],\n error_handling: [],\n };\n\n let match: RegExpExecArray | null;\n\n // Extract imports\n while ((match = IMPORT_RE.exec(content)) !== null) {\n result.imports.push(match[1]);\n }\n\n // Extract docstrings (module, class, function level) — high-signal domain intent\n while ((match = DOCSTRING_RE.exec(content)) !== null) {\n const firstSentence = match[1].trim().split('\\n')[0].slice(0, 120);\n if (firstSentence.length > 15) {\n result.docstrings.push(firstSentence);\n }\n }\n\n // Extract class declarations\n while ((match = CLASS_RE.exec(content)) !== null) {\n const bases = (match[2] || '')\n .split(',')\n .map(b => b.trim())\n .filter(Boolean);\n result.types.push({\n kind: 'class',\n name: match[1],\n bases,\n file: filepath,\n });\n }\n\n // Extract function declarations\n while ((match = FUNC_RE.exec(content)) !== null) {\n const name = match[1];\n // Skip dunder methods (__init__, __str__)\n if (name.startsWith('__') && name.endsWith('__')) continue;\n result.functions.push({\n name,\n params: (match[2] || '').trim(),\n file: filepath,\n });\n }\n\n // Extract error handling patterns\n if (content.includes('try:')) {\n result.error_handling.push('try-except');\n }\n if (content.includes('raise')) {\n result.error_handling.push('raise');\n }\n\n return result;\n}\n\nexport function mergePythonResults(results: PythonParseResult[]): PythonParseResult {\n const merged: PythonParseResult = {\n imports: [],\n types: [],\n functions: [],\n docstrings: [],\n error_handling: [],\n };\n\n const importCounts = new Map<string, number>();\n const errorCounts = new Map<string, number>();\n\n for (const r of results) {\n for (const imp of r.imports) {\n importCounts.set(imp, (importCounts.get(imp) || 0) + 1);\n }\n merged.types.push(...r.types);\n merged.functions.push(...r.functions);\n merged.docstrings.push(...r.docstrings);\n for (const e of r.error_handling) {\n errorCounts.set(e, (errorCounts.get(e) || 0) + 1);\n }\n }\n\n merged.imports = Array.from(importCounts.entries())\n .sort((a, b) => b[1] - a[1])\n .slice(0, 20)\n .map(([mod]) => mod);\n\n merged.error_handling = Array.from(errorCounts.entries())\n .sort((a, b) => b[1] - a[1])\n .slice(0, 10)\n .map(([p]) => p);\n\n merged.types = merged.types.slice(0, 100);\n merged.functions = merged.functions.slice(0, 100);\n merged.docstrings = merged.docstrings.slice(0, 20);\n\n return merged;\n}\n","/**\n * C++/Arduino AST-level parser — extracts #include, types, functions,\n * and error handling patterns.\n *\n * Ported from knowledge-tree/extract_project_keywords.py parse_cpp_file()\n */\n\nexport interface CppParseResult {\n imports: string[];\n types: Array<{\n kind: string;\n name: string;\n file: string;\n }>;\n functions: Array<{\n name: string;\n file: string;\n }>;\n error_handling: string[];\n}\n\nconst INCLUDE_RE = /#include\\s*[<\"]([^>\"]+)[>\"]/g;\nconst TYPE_RE = /\\b(?:class|struct|enum)\\s+(\\w+)/g;\nconst FUNC_RE = /\\b(?:void|int|float|double|char|bool|String|uint8_t|uint16_t|uint32_t)\\s+(\\w+)\\s*\\(/g;\n\nexport function parseCppFile(filepath: string, content: string): CppParseResult {\n const result: CppParseResult = {\n imports: [],\n types: [],\n functions: [],\n error_handling: [],\n };\n\n let match: RegExpExecArray | null;\n\n // Extract #include\n while ((match = INCLUDE_RE.exec(content)) !== null) {\n result.imports.push(match[1]);\n }\n\n // Extract type declarations\n while ((match = TYPE_RE.exec(content)) !== null) {\n result.types.push({\n kind: 'cpp',\n name: match[1],\n file: filepath,\n });\n }\n\n // Extract function declarations\n while ((match = FUNC_RE.exec(content)) !== null) {\n result.functions.push({\n name: match[1],\n file: filepath,\n });\n }\n\n // Extract error handling patterns\n if (/\\btry\\b|\\bthrow\\b|\\bcatch\\b/.test(content)) {\n result.error_handling.push('try/throw/catch');\n }\n\n return result;\n}\n\nexport function mergeCppResults(results: CppParseResult[]): CppParseResult {\n const merged: CppParseResult = {\n imports: [],\n types: [],\n functions: [],\n error_handling: [],\n };\n\n const importCounts = new Map<string, number>();\n\n for (const r of results) {\n for (const imp of r.imports) {\n importCounts.set(imp, (importCounts.get(imp) || 0) + 1);\n }\n merged.types.push(...r.types);\n merged.functions.push(...r.functions);\n merged.error_handling.push(...r.error_handling);\n }\n\n merged.imports = Array.from(importCounts.entries())\n .sort((a, b) => b[1] - a[1])\n .slice(0, 20)\n .map(([mod]) => mod);\n\n // Deduplicate error handling\n merged.error_handling = [...new Set(merged.error_handling)];\n\n return merged;\n}\n"]}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Swift AST-level parser — extracts imports, types, functions, property wrappers,
3
+ * error handling patterns, and framework usage from Swift source files.
4
+ *
5
+ * Ported from knowledge-tree/extract_project_keywords.py parse_swift_file()
6
+ */
7
+ interface SwiftParseResult {
8
+ imports: string[];
9
+ types: Array<{
10
+ kind: string;
11
+ name: string;
12
+ conforms_to: string[];
13
+ file: string;
14
+ }>;
15
+ functions: Array<{
16
+ name: string;
17
+ params: string;
18
+ returns: string;
19
+ file: string;
20
+ }>;
21
+ property_wrappers: string[];
22
+ error_handling: string[];
23
+ frameworks_used: string[];
24
+ }
25
+ declare function parseSwiftFile(filepath: string, content: string): SwiftParseResult;
26
+ declare function mergeSwiftResults(results: SwiftParseResult[]): SwiftParseResult;
27
+
28
+ /**
29
+ * TypeScript/JavaScript AST-level parser — extracts imports, types, functions,
30
+ * and error handling patterns.
31
+ *
32
+ * Ported from knowledge-tree/extract_project_keywords.py parse_ts_file()
33
+ */
34
+ interface TsParseResult {
35
+ imports: string[];
36
+ types: Array<{
37
+ kind: string;
38
+ name: string;
39
+ file: string;
40
+ }>;
41
+ functions: Array<{
42
+ name: string;
43
+ params: string;
44
+ file: string;
45
+ }>;
46
+ error_handling: string[];
47
+ }
48
+ declare function parseTsFile(filepath: string, content: string): TsParseResult;
49
+ declare function mergeTsResults(results: TsParseResult[]): TsParseResult;
50
+
51
+ /**
52
+ * Python AST-level parser — extracts imports, classes, functions, docstrings,
53
+ * and error handling patterns.
54
+ *
55
+ * Ported from knowledge-tree/extract_project_keywords.py parse_python_file()
56
+ */
57
+ interface PythonParseResult {
58
+ imports: string[];
59
+ types: Array<{
60
+ kind: string;
61
+ name: string;
62
+ bases: string[];
63
+ file: string;
64
+ }>;
65
+ functions: Array<{
66
+ name: string;
67
+ params: string;
68
+ file: string;
69
+ }>;
70
+ docstrings: string[];
71
+ error_handling: string[];
72
+ }
73
+ declare function parsePythonFile(filepath: string, content: string): PythonParseResult;
74
+ declare function mergePythonResults(results: PythonParseResult[]): PythonParseResult;
75
+
76
+ /**
77
+ * C++/Arduino AST-level parser — extracts #include, types, functions,
78
+ * and error handling patterns.
79
+ *
80
+ * Ported from knowledge-tree/extract_project_keywords.py parse_cpp_file()
81
+ */
82
+ interface CppParseResult {
83
+ imports: string[];
84
+ types: Array<{
85
+ kind: string;
86
+ name: string;
87
+ file: string;
88
+ }>;
89
+ functions: Array<{
90
+ name: string;
91
+ file: string;
92
+ }>;
93
+ error_handling: string[];
94
+ }
95
+ declare function parseCppFile(filepath: string, content: string): CppParseResult;
96
+ declare function mergeCppResults(results: CppParseResult[]): CppParseResult;
97
+
98
+ export { type CppParseResult, type PythonParseResult, type SwiftParseResult, type TsParseResult, mergeCppResults, mergePythonResults, mergeSwiftResults, mergeTsResults, parseCppFile, parsePythonFile, parseSwiftFile, parseTsFile };