@flagshark/core 1.0.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 (105) hide show
  1. package/dist/detection/config-adapter.d.ts +16 -0
  2. package/dist/detection/config-adapter.d.ts.map +1 -0
  3. package/dist/detection/config-adapter.js +60 -0
  4. package/dist/detection/config-adapter.js.map +1 -0
  5. package/dist/detection/detectors/cpp.d.ts +17 -0
  6. package/dist/detection/detectors/cpp.d.ts.map +1 -0
  7. package/dist/detection/detectors/cpp.js +113 -0
  8. package/dist/detection/detectors/cpp.js.map +1 -0
  9. package/dist/detection/detectors/csharp.d.ts +17 -0
  10. package/dist/detection/detectors/csharp.d.ts.map +1 -0
  11. package/dist/detection/detectors/csharp.js +258 -0
  12. package/dist/detection/detectors/csharp.js.map +1 -0
  13. package/dist/detection/detectors/go.d.ts +17 -0
  14. package/dist/detection/detectors/go.d.ts.map +1 -0
  15. package/dist/detection/detectors/go.js +319 -0
  16. package/dist/detection/detectors/go.js.map +1 -0
  17. package/dist/detection/detectors/index.d.ts +14 -0
  18. package/dist/detection/detectors/index.d.ts.map +1 -0
  19. package/dist/detection/detectors/index.js +14 -0
  20. package/dist/detection/detectors/index.js.map +1 -0
  21. package/dist/detection/detectors/java.d.ts +17 -0
  22. package/dist/detection/detectors/java.d.ts.map +1 -0
  23. package/dist/detection/detectors/java.js +264 -0
  24. package/dist/detection/detectors/java.js.map +1 -0
  25. package/dist/detection/detectors/javascript.d.ts +18 -0
  26. package/dist/detection/detectors/javascript.d.ts.map +1 -0
  27. package/dist/detection/detectors/javascript.js +32 -0
  28. package/dist/detection/detectors/javascript.js.map +1 -0
  29. package/dist/detection/detectors/kotlin.d.ts +17 -0
  30. package/dist/detection/detectors/kotlin.d.ts.map +1 -0
  31. package/dist/detection/detectors/kotlin.js +210 -0
  32. package/dist/detection/detectors/kotlin.js.map +1 -0
  33. package/dist/detection/detectors/objectivec.d.ts +17 -0
  34. package/dist/detection/detectors/objectivec.d.ts.map +1 -0
  35. package/dist/detection/detectors/objectivec.js +244 -0
  36. package/dist/detection/detectors/objectivec.js.map +1 -0
  37. package/dist/detection/detectors/php.d.ts +17 -0
  38. package/dist/detection/detectors/php.d.ts.map +1 -0
  39. package/dist/detection/detectors/php.js +210 -0
  40. package/dist/detection/detectors/php.js.map +1 -0
  41. package/dist/detection/detectors/python.d.ts +17 -0
  42. package/dist/detection/detectors/python.d.ts.map +1 -0
  43. package/dist/detection/detectors/python.js +284 -0
  44. package/dist/detection/detectors/python.js.map +1 -0
  45. package/dist/detection/detectors/ruby.d.ts +17 -0
  46. package/dist/detection/detectors/ruby.d.ts.map +1 -0
  47. package/dist/detection/detectors/ruby.js +259 -0
  48. package/dist/detection/detectors/ruby.js.map +1 -0
  49. package/dist/detection/detectors/rust.d.ts +17 -0
  50. package/dist/detection/detectors/rust.d.ts.map +1 -0
  51. package/dist/detection/detectors/rust.js +159 -0
  52. package/dist/detection/detectors/rust.js.map +1 -0
  53. package/dist/detection/detectors/swift.d.ts +17 -0
  54. package/dist/detection/detectors/swift.d.ts.map +1 -0
  55. package/dist/detection/detectors/swift.js +229 -0
  56. package/dist/detection/detectors/swift.js.map +1 -0
  57. package/dist/detection/detectors/typescript.d.ts +17 -0
  58. package/dist/detection/detectors/typescript.d.ts.map +1 -0
  59. package/dist/detection/detectors/typescript.js +350 -0
  60. package/dist/detection/detectors/typescript.js.map +1 -0
  61. package/dist/detection/feature-flag.d.ts +16 -0
  62. package/dist/detection/feature-flag.d.ts.map +1 -0
  63. package/dist/detection/feature-flag.js +2 -0
  64. package/dist/detection/feature-flag.js.map +1 -0
  65. package/dist/detection/helpers.d.ts +51 -0
  66. package/dist/detection/helpers.d.ts.map +1 -0
  67. package/dist/detection/helpers.js +266 -0
  68. package/dist/detection/helpers.js.map +1 -0
  69. package/dist/detection/index.d.ts +19 -0
  70. package/dist/detection/index.d.ts.map +1 -0
  71. package/dist/detection/index.js +53 -0
  72. package/dist/detection/index.js.map +1 -0
  73. package/dist/detection/interface.d.ts +76 -0
  74. package/dist/detection/interface.d.ts.map +1 -0
  75. package/dist/detection/interface.js +25 -0
  76. package/dist/detection/interface.js.map +1 -0
  77. package/dist/detection/polyglot-analyzer.d.ts +83 -0
  78. package/dist/detection/polyglot-analyzer.d.ts.map +1 -0
  79. package/dist/detection/polyglot-analyzer.js +245 -0
  80. package/dist/detection/polyglot-analyzer.js.map +1 -0
  81. package/dist/detection/registry.d.ts +31 -0
  82. package/dist/detection/registry.d.ts.map +1 -0
  83. package/dist/detection/registry.js +68 -0
  84. package/dist/detection/registry.js.map +1 -0
  85. package/dist/detection/yaml-config.d.ts +333 -0
  86. package/dist/detection/yaml-config.d.ts.map +1 -0
  87. package/dist/detection/yaml-config.js +215 -0
  88. package/dist/detection/yaml-config.js.map +1 -0
  89. package/dist/index.d.ts +8 -0
  90. package/dist/index.d.ts.map +1 -0
  91. package/dist/index.js +9 -0
  92. package/dist/index.js.map +1 -0
  93. package/dist/scan-repo.d.ts +67 -0
  94. package/dist/scan-repo.d.ts.map +1 -0
  95. package/dist/scan-repo.js +55 -0
  96. package/dist/scan-repo.js.map +1 -0
  97. package/dist/scanner.d.ts +18 -0
  98. package/dist/scanner.d.ts.map +1 -0
  99. package/dist/scanner.js +108 -0
  100. package/dist/scanner.js.map +1 -0
  101. package/dist/staleness.d.ts +30 -0
  102. package/dist/staleness.d.ts.map +1 -0
  103. package/dist/staleness.js +217 -0
  104. package/dist/staleness.js.map +1 -0
  105. package/package.json +37 -0
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Shared detection helper utilities.
3
+ * Ported from Go: internal/languages/helpers/helpers.go
4
+ */
5
+ import type { FeatureFlag } from './feature-flag.js';
6
+ import type { MethodConfig, FeatureFlagProvider, Language } from './interface.js';
7
+ /** Extracts method names from a list of MethodConfig. */
8
+ export declare function extractMethodNames(methods: MethodConfig[]): string[];
9
+ /** Returns the flagKeyIndex from the first method, or 0 if empty. */
10
+ export declare function getDefaultKeyIndex(methods: MethodConfig[]): number;
11
+ /**
12
+ * Deduplicates feature flags based on filePath + name + lineNumber.
13
+ * Keeps the first occurrence.
14
+ */
15
+ export declare function deduplicateFlags(flags: FeatureFlag[]): FeatureFlag[];
16
+ /**
17
+ * Extracts a string argument from a method call at a given parameter index.
18
+ * Handles both single-quoted and double-quoted strings, and backtick template literals.
19
+ *
20
+ * @param callText - The full method call text (e.g., `client.variation("flag-key", ctx, false)`)
21
+ * @param paramIndex - The 0-based index of the parameter to extract
22
+ * @returns The extracted string value (without quotes), or null if not found
23
+ */
24
+ export declare function extractStringArgument(callText: string, paramIndex: number): string | null;
25
+ /**
26
+ * Splits a comma-separated argument list, respecting nested parentheses,
27
+ * brackets, braces, and string literals.
28
+ */
29
+ export declare function splitArguments(argsStr: string): string[];
30
+ /**
31
+ * Builds a regex pattern that matches any of the given method names being called.
32
+ * Supports both dot-notation (obj.method) and standalone function calls.
33
+ *
34
+ * @returns A RegExp that captures the full call expression, including the first string argument.
35
+ */
36
+ export declare function buildMethodCallPattern(methodNames: string[]): RegExp;
37
+ /** Escapes special regex characters in a string. */
38
+ export declare function escapeRegExp(str: string): string;
39
+ /**
40
+ * Detects feature flags in source code using regex-based pattern matching.
41
+ * This is used by all language detectors as the primary detection mechanism.
42
+ */
43
+ export declare function detectFlagsWithRegex(filename: string, content: string, language: Language, providers: FeatureFlagProvider[]): FeatureFlag[];
44
+ /** Checks whether a string looks like a valid feature flag key. */
45
+ export declare function isValidFlagKey(key: string): boolean;
46
+ /**
47
+ * Merges custom providers with defaults.
48
+ * Custom providers override defaults with the same import pattern.
49
+ */
50
+ export declare function mergeProviders(defaults: FeatureFlagProvider[], custom: FeatureFlagProvider[]): FeatureFlagProvider[];
51
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/detection/helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEjF,yDAAyD;AACzD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,EAAE,CAEpE;AAED,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,CAKlE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,CAapE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAwBzF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAkDxD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,MAAM,CAQpE;AAED,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,mBAAmB,EAAE,GAC/B,WAAW,EAAE,CA6Df;AAkDD,mEAAmE;AACnE,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAanD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,mBAAmB,EAAE,EAC/B,MAAM,EAAE,mBAAmB,EAAE,GAC5B,mBAAmB,EAAE,CAuBvB"}
@@ -0,0 +1,266 @@
1
+ /**
2
+ * Shared detection helper utilities.
3
+ * Ported from Go: internal/languages/helpers/helpers.go
4
+ */
5
+ import { getImportPattern } from './interface.js';
6
+ /** Extracts method names from a list of MethodConfig. */
7
+ export function extractMethodNames(methods) {
8
+ return methods.map((m) => m.name);
9
+ }
10
+ /** Returns the flagKeyIndex from the first method, or 0 if empty. */
11
+ export function getDefaultKeyIndex(methods) {
12
+ if (methods.length > 0) {
13
+ return methods[0].flagKeyIndex;
14
+ }
15
+ return 0;
16
+ }
17
+ /**
18
+ * Deduplicates feature flags based on filePath + name + lineNumber.
19
+ * Keeps the first occurrence.
20
+ */
21
+ export function deduplicateFlags(flags) {
22
+ const seen = new Set();
23
+ const result = [];
24
+ for (const flag of flags) {
25
+ const key = `${flag.filePath}:${flag.name}:${flag.lineNumber}`;
26
+ if (!seen.has(key)) {
27
+ seen.add(key);
28
+ result.push(flag);
29
+ }
30
+ }
31
+ return result;
32
+ }
33
+ /**
34
+ * Extracts a string argument from a method call at a given parameter index.
35
+ * Handles both single-quoted and double-quoted strings, and backtick template literals.
36
+ *
37
+ * @param callText - The full method call text (e.g., `client.variation("flag-key", ctx, false)`)
38
+ * @param paramIndex - The 0-based index of the parameter to extract
39
+ * @returns The extracted string value (without quotes), or null if not found
40
+ */
41
+ export function extractStringArgument(callText, paramIndex) {
42
+ // Find the opening parenthesis
43
+ const parenStart = callText.indexOf('(');
44
+ if (parenStart === -1) {
45
+ return null;
46
+ }
47
+ const parenEnd = callText.lastIndexOf(')');
48
+ if (parenEnd === -1) {
49
+ return null;
50
+ }
51
+ const argsStr = callText.slice(parenStart + 1, parenEnd);
52
+ const args = splitArguments(argsStr);
53
+ if (paramIndex < 0 || paramIndex >= args.length) {
54
+ return null;
55
+ }
56
+ const arg = args[paramIndex].trim();
57
+ // Match quoted strings: "value", 'value', or `value`
58
+ const match = arg.match(/^["'`](.*)["'`]$/);
59
+ return match ? match[1] : null;
60
+ }
61
+ /**
62
+ * Splits a comma-separated argument list, respecting nested parentheses,
63
+ * brackets, braces, and string literals.
64
+ */
65
+ export function splitArguments(argsStr) {
66
+ const args = [];
67
+ let depth = 0;
68
+ let current = '';
69
+ let inString = null;
70
+ for (let i = 0; i < argsStr.length; i++) {
71
+ const ch = argsStr[i];
72
+ const prev = i > 0 ? argsStr[i - 1] : '';
73
+ if (inString) {
74
+ current += ch;
75
+ if (ch === inString && prev !== '\\') {
76
+ inString = null;
77
+ }
78
+ continue;
79
+ }
80
+ if (ch === '"' || ch === "'" || ch === '`') {
81
+ inString = ch;
82
+ current += ch;
83
+ continue;
84
+ }
85
+ if (ch === '(' || ch === '[' || ch === '{') {
86
+ depth++;
87
+ current += ch;
88
+ continue;
89
+ }
90
+ if (ch === ')' || ch === ']' || ch === '}') {
91
+ depth--;
92
+ current += ch;
93
+ continue;
94
+ }
95
+ if (ch === ',' && depth === 0) {
96
+ args.push(current);
97
+ current = '';
98
+ continue;
99
+ }
100
+ current += ch;
101
+ }
102
+ if (current.trim().length > 0) {
103
+ args.push(current);
104
+ }
105
+ return args;
106
+ }
107
+ /**
108
+ * Builds a regex pattern that matches any of the given method names being called.
109
+ * Supports both dot-notation (obj.method) and standalone function calls.
110
+ *
111
+ * @returns A RegExp that captures the full call expression, including the first string argument.
112
+ */
113
+ export function buildMethodCallPattern(methodNames) {
114
+ if (methodNames.length === 0) {
115
+ return /(?!)/; // Never matches
116
+ }
117
+ const escaped = methodNames.map((n) => escapeRegExp(n));
118
+ const alternation = escaped.join('|');
119
+ // Match: optional_receiver.methodName( ... ) capturing the call
120
+ return new RegExp(`(?:^|[^\\w.])(?:\\w+\\.)?(?:${alternation})\\s*\\(`, 'gm');
121
+ }
122
+ /** Escapes special regex characters in a string. */
123
+ export function escapeRegExp(str) {
124
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
125
+ }
126
+ /**
127
+ * Detects feature flags in source code using regex-based pattern matching.
128
+ * This is used by all language detectors as the primary detection mechanism.
129
+ */
130
+ export function detectFlagsWithRegex(filename, content, language, providers) {
131
+ const flags = [];
132
+ const lines = content.split('\n');
133
+ for (const provider of providers) {
134
+ if (!provider.enabled) {
135
+ continue;
136
+ }
137
+ if (provider.methods.length === 0) {
138
+ continue;
139
+ }
140
+ const providerName = provider.name;
141
+ const importPat = getImportPattern(provider);
142
+ // Import check: skip this provider if file doesn't import its SDK.
143
+ // Providers with no importPattern (e.g., "Custom Feature Flags") are kept as fallbacks.
144
+ if (importPat) {
145
+ const hasImport = content.includes(importPat) || lines.some((line) => line.includes(importPat));
146
+ if (!hasImport) {
147
+ continue;
148
+ }
149
+ }
150
+ for (const method of provider.methods) {
151
+ // Skip methods that return all flags (flagKeyIndex = -1)
152
+ if (method.flagKeyIndex < 0) {
153
+ continue;
154
+ }
155
+ const pattern = buildSingleMethodPattern(method.name);
156
+ for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
157
+ const line = lines[lineIdx];
158
+ let match;
159
+ while ((match = pattern.exec(line)) !== null) {
160
+ const callStart = match.index;
161
+ // Extract the full call from this position
162
+ const restOfContent = getCallExpression(lines, lineIdx, callStart);
163
+ if (!restOfContent) {
164
+ continue;
165
+ }
166
+ const flagKey = extractStringArgument(restOfContent, method.flagKeyIndex);
167
+ if (flagKey && isValidFlagKey(flagKey)) {
168
+ flags.push({
169
+ name: flagKey,
170
+ filePath: filename,
171
+ lineNumber: lineIdx + 1,
172
+ language,
173
+ provider: importPat || providerName,
174
+ });
175
+ }
176
+ }
177
+ }
178
+ }
179
+ }
180
+ return deduplicateFlags(flags);
181
+ }
182
+ /** Builds a regex for a single method name that matches calls. */
183
+ function buildSingleMethodPattern(methodName) {
184
+ const escaped = escapeRegExp(methodName);
185
+ return new RegExp(`(?:^|[^\\w])(?:\\w+[.:])?${escaped}\\s*\\(`, 'g');
186
+ }
187
+ /**
188
+ * Extracts a full call expression starting from a match position,
189
+ * handling multi-line calls by tracking parenthesis depth.
190
+ */
191
+ function getCallExpression(lines, startLine, startCol) {
192
+ let result = lines[startLine].slice(startCol);
193
+ let depth = 0;
194
+ let foundOpen = false;
195
+ for (let i = 0; i < result.length; i++) {
196
+ if (result[i] === '(') {
197
+ depth++;
198
+ foundOpen = true;
199
+ }
200
+ else if (result[i] === ')') {
201
+ depth--;
202
+ if (foundOpen && depth === 0) {
203
+ return result.slice(0, i + 1);
204
+ }
205
+ }
206
+ }
207
+ // Multi-line call: continue scanning subsequent lines (up to 10)
208
+ const maxLines = Math.min(startLine + 10, lines.length);
209
+ for (let lineIdx = startLine + 1; lineIdx < maxLines; lineIdx++) {
210
+ const line = lines[lineIdx];
211
+ result += '\n' + line;
212
+ for (let i = 0; i < line.length; i++) {
213
+ if (line[i] === '(') {
214
+ depth++;
215
+ foundOpen = true;
216
+ }
217
+ else if (line[i] === ')') {
218
+ depth--;
219
+ if (foundOpen && depth === 0) {
220
+ return result;
221
+ }
222
+ }
223
+ }
224
+ }
225
+ return foundOpen ? result : null;
226
+ }
227
+ /** Checks whether a string looks like a valid feature flag key. */
228
+ export function isValidFlagKey(key) {
229
+ if (key.length === 0 || key.length > 256) {
230
+ return false;
231
+ }
232
+ const invalidPrefixes = ['http://', 'https://', 'file://', '/'];
233
+ for (const prefix of invalidPrefixes) {
234
+ if (key.startsWith(prefix)) {
235
+ return false;
236
+ }
237
+ }
238
+ return true;
239
+ }
240
+ /**
241
+ * Merges custom providers with defaults.
242
+ * Custom providers override defaults with the same import pattern.
243
+ */
244
+ export function mergeProviders(defaults, custom) {
245
+ const result = [...defaults];
246
+ const byPattern = new Map();
247
+ for (let i = 0; i < result.length; i++) {
248
+ const pattern = getImportPattern(result[i]);
249
+ if (pattern) {
250
+ byPattern.set(pattern, i);
251
+ }
252
+ }
253
+ for (const customProvider of custom) {
254
+ const pattern = getImportPattern(customProvider);
255
+ const idx = byPattern.get(pattern);
256
+ if (idx !== undefined) {
257
+ result[idx] = customProvider;
258
+ }
259
+ else {
260
+ result.push(customProvider);
261
+ byPattern.set(pattern, result.length - 1);
262
+ }
263
+ }
264
+ return result;
265
+ }
266
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/detection/helpers.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AC;IACH,CAAC;IAED,KAAK,MAAM,cAAc,IAAI,MAAM,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAA;QAChD,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QAClC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,CAAC,GAAG,CAAC,GAAG,cAAc,CAAA;QAC9B,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;YAC3B,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAC3C,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Detection module barrel export.
3
+ * Re-exports registry, interfaces, and provides factory for a fully-loaded registry.
4
+ */
5
+ import { LanguageRegistry } from './registry.js';
6
+ export type { FeatureFlag } from './feature-flag.js';
7
+ export type { Language, LanguageDetector, FeatureFlagProvider, MethodConfig, DetectionResult, } from './interface.js';
8
+ export { Languages, getImportPattern } from './interface.js';
9
+ export { LanguageRegistry, getDefaultRegistry, resetDefaultRegistry } from './registry.js';
10
+ export { PolyglotAnalyzer, compareResults } from './polyglot-analyzer.js';
11
+ export type { FlagDetector, LanguageRegistry as PolyglotLanguageRegistry, FileAnalysisStatus, FileAnalysisResult, RepositoryAnalysisResult, AnalysisProgressCallback, FlagOccurrence, OccurrenceChange, ComparisonResult, Language as PolyglotLanguage, } from './polyglot-analyzer.js';
12
+ export { GoDetector, TypeScriptDetector, JavaScriptDetector, PythonDetector, JavaDetector, KotlinDetector, SwiftDetector, RubyDetector, CSharpDetector, PHPDetector, RustDetector, CPPDetector, ObjectiveCDetector, } from './detectors/index.js';
13
+ export { detectFlagsWithRegex, deduplicateFlags, extractStringArgument, splitArguments, buildMethodCallPattern, escapeRegExp, isValidFlagKey, mergeProviders, extractMethodNames, getDefaultKeyIndex, } from './helpers.js';
14
+ export { convertConfigProviders, languageToConfigLanguage, loadProvidersForLanguage, } from './config-adapter.js';
15
+ /**
16
+ * Creates a LanguageRegistry pre-loaded with all 13 language detectors.
17
+ */
18
+ export declare function createDefaultRegistry(): LanguageRegistry;
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/detection/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAGhD,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,YAAY,EACV,QAAQ,EACR,gBAAgB,EAChB,mBAAmB,EACnB,YAAY,EACZ,eAAe,GAChB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAG5D,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAG1F,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACzE,YAAY,EACV,YAAY,EACZ,gBAAgB,IAAI,wBAAwB,EAC5C,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,IAAI,gBAAgB,GAC7B,MAAM,wBAAwB,CAAA;AAG/B,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,cAAc,EACd,aAAa,EACb,YAAY,EACZ,cAAc,EACd,WAAW,EACX,YAAY,EACZ,WAAW,EACX,kBAAkB,GACnB,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,sBAAsB,EACtB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,cAAc,CAAA;AAGrB,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,qBAAqB,CAAA;AAE5B;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,gBAAgB,CAmBxD"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Detection module barrel export.
3
+ * Re-exports registry, interfaces, and provides factory for a fully-loaded registry.
4
+ */
5
+ import { CPPDetector } from './detectors/cpp.js';
6
+ import { CSharpDetector } from './detectors/csharp.js';
7
+ import { GoDetector } from './detectors/go.js';
8
+ import { JavaDetector } from './detectors/java.js';
9
+ import { JavaScriptDetector } from './detectors/javascript.js';
10
+ import { KotlinDetector } from './detectors/kotlin.js';
11
+ import { ObjectiveCDetector } from './detectors/objectivec.js';
12
+ import { PHPDetector } from './detectors/php.js';
13
+ import { PythonDetector } from './detectors/python.js';
14
+ import { RubyDetector } from './detectors/ruby.js';
15
+ import { RustDetector } from './detectors/rust.js';
16
+ import { SwiftDetector } from './detectors/swift.js';
17
+ import { TypeScriptDetector } from './detectors/typescript.js';
18
+ import { LanguageRegistry } from './registry.js';
19
+ export { Languages, getImportPattern } from './interface.js';
20
+ // Registry
21
+ export { LanguageRegistry, getDefaultRegistry, resetDefaultRegistry } from './registry.js';
22
+ // Polyglot analyzer
23
+ export { PolyglotAnalyzer, compareResults } from './polyglot-analyzer.js';
24
+ // All 13 detectors
25
+ export { GoDetector, TypeScriptDetector, JavaScriptDetector, PythonDetector, JavaDetector, KotlinDetector, SwiftDetector, RubyDetector, CSharpDetector, PHPDetector, RustDetector, CPPDetector, ObjectiveCDetector, } from './detectors/index.js';
26
+ // Helpers
27
+ export { detectFlagsWithRegex, deduplicateFlags, extractStringArgument, splitArguments, buildMethodCallPattern, escapeRegExp, isValidFlagKey, mergeProviders, extractMethodNames, getDefaultKeyIndex, } from './helpers.js';
28
+ // Config adapter
29
+ export { convertConfigProviders, languageToConfigLanguage, loadProvidersForLanguage, } from './config-adapter.js';
30
+ /**
31
+ * Creates a LanguageRegistry pre-loaded with all 13 language detectors.
32
+ */
33
+ export function createDefaultRegistry() {
34
+ const registry = new LanguageRegistry();
35
+ registry.register(new GoDetector());
36
+ registry.register(new TypeScriptDetector());
37
+ registry.register(new PythonDetector());
38
+ registry.register(new JavaDetector());
39
+ registry.register(new KotlinDetector());
40
+ registry.register(new SwiftDetector());
41
+ registry.register(new RubyDetector());
42
+ registry.register(new CSharpDetector());
43
+ registry.register(new PHPDetector());
44
+ registry.register(new RustDetector());
45
+ registry.register(new CPPDetector());
46
+ registry.register(new ObjectiveCDetector());
47
+ // JavaScriptDetector has its own provider list (different from TypeScript).
48
+ // Both can be registered since they have different language keys.
49
+ // TypeScriptDetector is checked first for .js files (first-match wins).
50
+ registry.register(new JavaScriptDetector());
51
+ return registry;
52
+ }
53
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/detection/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM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A;IACrC,QAAQ,CAAC,QAAQ,CAAC,IAAI,cAAc,EAAE,CAAC,CAAA;IACvC,QAAQ,CAAC,QAAQ,CAAC,IAAI,aAAa,EAAE,CAAC,CAAA;IACtC,QAAQ,CAAC,QAAQ,CAAC,IAAI,YAAY,EAAE,CAAC,CAAA;IACrC,QAAQ,CAAC,QAAQ,CAAC,IAAI,cAAc,EAAE,CAAC,CAAA;IACvC,QAAQ,CAAC,QAAQ,CAAC,IAAI,WAAW,EAAE,CAAC,CAAA;IACpC,QAAQ,CAAC,QAAQ,CAAC,IAAI,YAAY,EAAE,CAAC,CAAA;IACrC,QAAQ,CAAC,QAAQ,CAAC,IAAI,WAAW,EAAE,CAAC,CAAA;IACpC,QAAQ,CAAC,QAAQ,CAAC,IAAI,kBAAkB,EAAE,CAAC,CAAA;IAC3C,4EAA4E;IAC5E,kEAAkE;IAClE,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,CAAC,IAAI,kBAAkB,EAAE,CAAC,CAAA;IAC3C,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Language detection interfaces and types.
3
+ * Ported from Go: internal/languages/interface.go
4
+ */
5
+ import type { FeatureFlag } from './feature-flag.js';
6
+ /** Supported programming language identifiers. */
7
+ export type Language = 'go' | 'typescript' | 'javascript' | 'python' | 'java' | 'kotlin' | 'swift' | 'ruby' | 'csharp' | 'php' | 'rust' | 'cpp' | 'objc';
8
+ /** All supported language constants for convenience. */
9
+ export declare const Languages: {
10
+ readonly Go: Language;
11
+ readonly TypeScript: Language;
12
+ readonly JavaScript: Language;
13
+ readonly Python: Language;
14
+ readonly Java: Language;
15
+ readonly Kotlin: Language;
16
+ readonly Swift: Language;
17
+ readonly Ruby: Language;
18
+ readonly CSharp: Language;
19
+ readonly PHP: Language;
20
+ readonly Rust: Language;
21
+ readonly CPP: Language;
22
+ readonly ObjectiveC: Language;
23
+ };
24
+ /** Defines how to detect a specific feature flag method call. */
25
+ export interface MethodConfig {
26
+ /** Method name to match (e.g., "BoolVariation", "isEnabled") */
27
+ name: string;
28
+ /** Regex pattern override (optional; defaults to method name) */
29
+ pattern?: string;
30
+ /** Index of the flag key parameter in the method call (0-based) */
31
+ flagKeyIndex: number;
32
+ /** Index of the context parameter (optional) */
33
+ contextIndex?: number;
34
+ /** Example usages for documentation */
35
+ examples?: string[];
36
+ }
37
+ /** Represents a feature flag library/service provider for a language. */
38
+ export interface FeatureFlagProvider {
39
+ /** Display name (e.g., "LaunchDarkly Go SDK") */
40
+ name: string;
41
+ /** Import/package path for the SDK */
42
+ packagePath?: string;
43
+ /** Import pattern to match in source code */
44
+ importPattern?: string;
45
+ /** Methods to detect */
46
+ methods: MethodConfig[];
47
+ /** Human-readable description */
48
+ description?: string;
49
+ /** Whether detection is enabled for this provider */
50
+ enabled: boolean;
51
+ }
52
+ /** Returns the effective import pattern, supporting backward compatibility. */
53
+ export declare function getImportPattern(provider: FeatureFlagProvider): string;
54
+ /**
55
+ * LanguageDetector defines the interface for language-specific feature flag detection.
56
+ * Each supported language implements this interface.
57
+ */
58
+ export interface LanguageDetector {
59
+ /** Returns the language this detector supports. */
60
+ language(): Language;
61
+ /** Returns the file extensions this detector handles (e.g., [".go", ".py"]). */
62
+ fileExtensions(): string[];
63
+ /** Detects feature flags in the given source code. */
64
+ detectFlags(filename: string, content: string): FeatureFlag[];
65
+ /** Checks if this detector can handle the given file. */
66
+ supportsFile(filename: string): boolean;
67
+ /** Returns the feature flag providers supported by this language. */
68
+ getProviders(): FeatureFlagProvider[];
69
+ }
70
+ /** Detailed detection result with metadata. */
71
+ export interface DetectionResult {
72
+ flags: FeatureFlag[];
73
+ language: Language;
74
+ metadata?: Record<string, unknown>;
75
+ }
76
+ //# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/detection/interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,W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QAAQ,IAAI,QAAQ,CAAA;IAEpB,gFAAgF;IAChF,cAAc,IAAI,MAAM,EAAE,CAAA;IAE1B,sDAAsD;IACtD,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,CAAA;IAE7D,yDAAyD;IACzD,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;IAEvC,qEAAqE;IACrE,YAAY,IAAI,mBAAmB,EAAE,CAAA;CACtC;AAED,+CAA+C;AAC/C,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,WAAW,EAAE,CAAA;IACpB,QAAQ,EAAE,QAAQ,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Language detection interfaces and types.
3
+ * Ported from Go: internal/languages/interface.go
4
+ */
5
+ /** All supported language constants for convenience. */
6
+ export const Languages = {
7
+ Go: 'go',
8
+ TypeScript: 'typescript',
9
+ JavaScript: 'javascript',
10
+ Python: 'python',
11
+ Java: 'java',
12
+ Kotlin: 'kotlin',
13
+ Swift: 'swift',
14
+ Ruby: 'ruby',
15
+ CSharp: 'csharp',
16
+ PHP: 'php',
17
+ Rust: 'rust',
18
+ CPP: 'cpp',
19
+ ObjectiveC: 'objc',
20
+ };
21
+ /** Returns the effective import pattern, supporting backward compatibility. */
22
+ export function getImportPattern(provider) {
23
+ return provider.importPattern || provider.packagePath || '';
24
+ }
25
+ //# sourceMappingURL=interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/detection/interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoBH,wDAAwD;AACxD,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,EAAE,EAAE,IAAgB;IACpB,UAAU,EAAE,YAAwB;IACpC,UAAU,EAAE,YAAwB;IACpC,MAAM,EAAE,QAAoB;IAC5B,IAAI,EAAE,MAAkB;IACxB,MAAM,EAAE,QAAoB;IAC5B,KAAK,EAAE,OAAmB;IAC1B,IAAI,EAAE,MAAkB;IACxB,MAAM,EAAE,QAAoB;IAC5B,GAAG,EAAE,KAAiB;IACtB,IAAI,EAAE,MAAkB;IACxB,GAAG,EAAE,KAAiB;IACtB,UAAU,EAAE,MAAkB;CACtB,CAAA;AAgCV,+EAA+E;AAC/E,MAAM,UAAU,gBAAgB,CAAC,QAA6B;IAC5D,OAAO,QAAQ,CAAC,aAAa,IAAI,QAAQ,CAAC,WAAW,IAAI,EAAE,CAAA;AAC7D,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Polyglot Analyzer -- multi-language feature flag detection coordinator.
3
+ * Ported from Go: internal/processor/polyglot_analyzer.go
4
+ *
5
+ * This module coordinates analysis across multiple programming languages,
6
+ * delegating to language-specific detectors registered in a language registry.
7
+ */
8
+ import type { FeatureFlag } from './feature-flag.js';
9
+ interface Logger {
10
+ debug(...args: unknown[]): void;
11
+ info(...args: unknown[]): void;
12
+ warn(...args: unknown[]): void;
13
+ error(...args: unknown[]): void;
14
+ }
15
+ export type Language = string;
16
+ export interface FlagDetector {
17
+ language(): Language;
18
+ detectFlags(filePath: string, content: string): Promise<FeatureFlag[]> | FeatureFlag[];
19
+ }
20
+ export interface LanguageRegistry {
21
+ getDetectorForFile(filePath: string): FlagDetector | undefined;
22
+ getSupportedExtensions(): string[];
23
+ getSupportedLanguages(): Language[];
24
+ }
25
+ export type FileAnalysisStatus = 'ok' | 'partial' | 'skipped' | 'unsupported';
26
+ export interface FileAnalysisResult {
27
+ filePath: string;
28
+ language: Language;
29
+ flags: FeatureFlag[];
30
+ parseErrors: Error[];
31
+ status: FileAnalysisStatus;
32
+ skippedReason?: string;
33
+ }
34
+ export interface RepositoryAnalysisResult {
35
+ commitSha?: string;
36
+ files: Map<string, FileAnalysisResult>;
37
+ /** Map of flag name to all occurrences. */
38
+ totalFlags: Map<string, FeatureFlag[]>;
39
+ /** Count of files per language. */
40
+ languages: Map<Language, number>;
41
+ skippedFiles: string[];
42
+ partialFiles: string[];
43
+ }
44
+ export type AnalysisProgressCallback = (analyzed: number, total: number) => void;
45
+ export declare class PolyglotAnalyzer {
46
+ private registry;
47
+ private logger;
48
+ constructor(registry: LanguageRegistry, logger: Logger);
49
+ /** Analyzes multiple files using appropriate language detectors. */
50
+ analyzeFiles(files: Map<string, string>, signal?: AbortSignal): Promise<RepositoryAnalysisResult>;
51
+ /** Analyzes multiple files with progress reporting. */
52
+ analyzeFilesWithProgress(files: Map<string, string>, progressCallback?: AnalysisProgressCallback, signal?: AbortSignal): Promise<RepositoryAnalysisResult>;
53
+ /** Analyzes a single file using the appropriate language detector. */
54
+ analyzeSingleFile(filePath: string, content: string): Promise<FileAnalysisResult>;
55
+ /** Determines if a file should be analyzed based on language support. */
56
+ shouldAnalyzeFile(filePath: string, status: string): boolean;
57
+ /** Returns all supported file extensions. */
58
+ getSupportedExtensions(): string[];
59
+ private analyzeFile;
60
+ }
61
+ export interface FlagOccurrence {
62
+ name: string;
63
+ filePath: string;
64
+ lineNumber: number;
65
+ language: string;
66
+ provider?: string;
67
+ }
68
+ export interface OccurrenceChange {
69
+ flagName: string;
70
+ beforeCount: number;
71
+ afterCount: number;
72
+ addedIn: FlagOccurrence[];
73
+ removedFrom: FlagOccurrence[];
74
+ }
75
+ export interface ComparisonResult {
76
+ added: Map<string, FlagOccurrence[]>;
77
+ removed: Map<string, FlagOccurrence[]>;
78
+ occurrenceChanges: Map<string, OccurrenceChange>;
79
+ }
80
+ /** Compares two analysis results to find flag changes. */
81
+ export declare function compareResults(before: RepositoryAnalysisResult, after: RepositoryAnalysisResult): ComparisonResult;
82
+ export {};
83
+ //# sourceMappingURL=polyglot-analyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polyglot-analyzer.d.ts","sourceRoot":"","sources":["../../src/detection/polyglot-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA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