Skip to content

Commit e0bc6c9

Browse files
committed
fix: missing exported functions and variables
1 parent 90cc89d commit e0bc6c9

File tree

10 files changed

+148
-28
lines changed

10 files changed

+148
-28
lines changed

eslint.config.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ export default [
8585
format: ['camelCase'],
8686
leadingUnderscore: 'allow',
8787
},
88+
{
89+
selector: ['variable'],
90+
modifiers: ['exported'],
91+
format: ['PascalCase','camelCase'],
92+
},
8893
{
8994
selector: 'class',
9095
format: ['PascalCase'],
@@ -119,7 +124,7 @@ export default [
119124
selector: ['variable', 'function'],
120125
modifiers: ['exported'],
121126
format: ['PascalCase'],
122-
prefix: ['ax']
127+
prefix: ['Ax']
123128
},
124129
{
125130
selector: ['class', 'interface', 'typeAlias', 'enum', 'typeParameter'],

scripts/generateIndex.ts

+46-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env tsx
2-
import * as fs from 'fs'
3-
import * as path from 'path'
2+
import * as fs from 'node:fs'
3+
import * as path from 'node:path'
44

55
import * as ts from 'typescript'
66

@@ -32,7 +32,7 @@ function processExportDeclaration(node: ts.ExportDeclaration): ExportInfo[] {
3232
const exportsMap = new Map<string, ExportInfo>()
3333

3434
if (node.exportClause && ts.isNamedExports(node.exportClause)) {
35-
node.exportClause.elements.forEach((element) => {
35+
for (const element of node.exportClause.elements) {
3636
const originalName = element.name.text
3737
if (hasValidPrefix(originalName)) {
3838
// Only add if not already present
@@ -45,7 +45,7 @@ function processExportDeclaration(node: ts.ExportDeclaration): ExportInfo[] {
4545
})
4646
}
4747
}
48-
})
48+
}
4949
}
5050

5151
return Array.from(exportsMap.values())
@@ -104,6 +104,34 @@ function processDeclaration(
104104
return exports
105105
}
106106

107+
/**
108+
* Processes a variable statement node to extract exported variables with valid prefixes
109+
*/
110+
function processVariableStatement(node: ts.VariableStatement): ExportInfo[] {
111+
const exports: ExportInfo[] = []
112+
// Check if the variable statement has an export modifier
113+
if (
114+
!node.modifiers ||
115+
!node.modifiers.some((m) => m.kind === ts.SyntaxKind.ExportKeyword)
116+
) {
117+
return exports
118+
}
119+
120+
for (const declaration of node.declarationList.declarations) {
121+
if (ts.isIdentifier(declaration.name)) {
122+
const originalName = declaration.name.text
123+
if (hasValidPrefix(originalName)) {
124+
exports.push({
125+
originalName,
126+
prefixedName: originalName,
127+
kind: 'value',
128+
})
129+
}
130+
}
131+
}
132+
return exports
133+
}
134+
107135
/**
108136
* Processes a TypeScript source file to extract all exports with valid prefixes
109137
*/
@@ -126,6 +154,8 @@ function processFile(
126154
exports.push(...processExportDeclaration(node))
127155
} else if (ts.isExportAssignment(node)) {
128156
exports.push(...processExportAssignment(node))
157+
} else if (ts.isVariableStatement(node)) {
158+
exports.push(...processVariableStatement(node))
129159
} else if (
130160
ts.isClassDeclaration(node) ||
131161
ts.isInterfaceDeclaration(node) ||
@@ -169,7 +199,8 @@ function findTsFiles(dir: string): string[] {
169199
const fullPath = path.join(dir, entry.name)
170200
if (entry.isDirectory()) {
171201
return findTsFiles(fullPath)
172-
} else if (isTargetTsFile(entry.name)) {
202+
}
203+
if (isTargetTsFile(entry.name)) {
173204
return [fullPath]
174205
}
175206
return []
@@ -245,8 +276,8 @@ function generateExportStatements(exportMap: Map<string, ExportInfo[]>): {
245276
const valueExports: string[] = []
246277
const typeExports: string[] = []
247278

248-
exportMap.forEach((exports) => {
249-
exports.forEach((exp) => {
279+
for (const [, exports] of exportMap) {
280+
for (const exp of exports) {
250281
if (exp.kind === 'type') {
251282
typeExports.push(`export type { ${exp.originalName} };`)
252283
} else {
@@ -255,8 +286,8 @@ function generateExportStatements(exportMap: Map<string, ExportInfo[]>): {
255286
: `export { ${exp.originalName} };`
256287
valueExports.push(exportLine)
257288
}
258-
})
259-
})
289+
}
290+
}
260291

261292
return {
262293
valueExports: valueExports.sort(),
@@ -276,19 +307,17 @@ function generateIndexContent(exportMap: Map<string, ExportInfo[]>): string {
276307
.map(([filePath, exports]) => generateImportStatement(filePath, exports))
277308
.filter(Boolean)
278309
.sort()
279-
content += imports.join('\n') + '\n\n'
310+
content = `${content}${imports.join('\n')}\n\n`
280311

281312
// Generate exports
282313
const { valueExports, typeExports } = generateExportStatements(exportMap)
283314

284315
if (valueExports.length > 0) {
285-
content += '// Value exports\n'
286-
content += valueExports.join('\n') + '\n\n'
316+
content = `${content}// Value exports\n${valueExports.join('\n')}\n\n`
287317
}
288318

289319
if (typeExports.length > 0) {
290-
content += '// Type exports\n'
291-
content += typeExports.join('\n') + '\n'
320+
content = `${content}// Type exports\n${typeExports.join('\n')}\n`
292321
}
293322

294323
return content
@@ -303,7 +332,9 @@ function generateIndex(): void {
303332

304333
// Find and process all TypeScript files
305334
const tsFiles = findTsFiles(currentDir)
306-
tsFiles.forEach((file) => processFile(file, currentDir, exportMap))
335+
for (const file of tsFiles) {
336+
processFile(file, currentDir, exportMap)
337+
}
307338

308339
if (exportMap.size === 0) {
309340
console.log('No ax/Ax exports found')

src/ax/docs/reranker.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { AxAIService } from '../ai/types.js'
22
import { AxGen, type AxGenOptions } from '../dsp/generate.js'
33
import type { AxProgramForwardOptions } from '../dsp/program.js'
4-
import { axStringUtil } from '../dsp/strutil.js'
4+
import { AxStringUtil } from '../dsp/strutil.js'
55

66
import type { AxRerankerIn, AxRerankerOut } from './manager.js'
77

@@ -24,7 +24,7 @@ export class AxDefaultResultReranker extends AxGen<
2424
const { rankedItems } = await super.forward(ai, input, options)
2525

2626
const sortedIndexes: number[] = rankedItems.map((item) => {
27-
const { id: index } = axStringUtil.extractIdAndText(item)
27+
const { id: index } = AxStringUtil.extractIdAndText(item)
2828
return index
2929
})
3030

src/ax/dsp/eval.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function novelF1ScoreOptimized(
140140
return returnRecall ? recall : f1
141141
}
142142

143-
export const axEvalUtil = {
143+
export const AxEvalUtil = {
144144
emScore,
145145
f1Score,
146146
novelF1ScoreOptimized,

src/ax/dsp/strutil.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const batchArray = <T>(arr: readonly T[], size: number): T[][] => {
6363
return chunkedArr
6464
}
6565

66-
export const axStringUtil = {
66+
export const AxStringUtil = {
6767
trimNonAlphaNum,
6868
splitIntoTwo,
6969
dedup,

src/ax/index.ts

+85-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from './ai/wrap.js';
1010
import {
1111
AxAIAnthropic,
12+
axAIAnthropicDefaultConfig,
1213
type AxAIAnthropicArgs
1314
} from './ai/anthropic/api.js';
1415
import {
@@ -31,11 +32,17 @@ import {
3132
} from './ai/anthropic/types.js';
3233
import {
3334
AxAIAzureOpenAI,
35+
axAIAzureOpenAIBestConfig,
36+
axAIAzureOpenAICreativeConfig,
37+
axAIAzureOpenAIDefaultConfig,
38+
axAIAzureOpenAIFastConfig,
3439
type AxAIAzureOpenAIArgs,
3540
type AxAIAzureOpenAIConfig
3641
} from './ai/azure-openai/api.js';
3742
import {
3843
AxAICohere,
44+
axAICohereCreativeConfig,
45+
axAICohereDefaultConfig,
3946
type AxAICohereArgs
4047
} from './ai/cohere/api.js';
4148
import {
@@ -52,10 +59,14 @@ import {
5259
} from './ai/cohere/types.js';
5360
import {
5461
AxAIDeepSeek,
62+
axAIDeepSeekCodeConfig,
63+
axAIDeepSeekDefaultConfig,
5564
type AxAIDeepSeekArgs
5665
} from './ai/deepseek/api.js';
5766
import {
5867
AxAIGoogleGemini,
68+
axAIGoogleGeminiDefaultConfig,
69+
axAIGoogleGeminiDefaultCreativeConfig,
5970
type AxAIGoogleGeminiArgs,
6071
type AxAIGoogleGeminiOptionsTools
6172
} from './ai/google-gemini/api.js';
@@ -86,6 +97,8 @@ import {
8697
} from './ai/groq/api.js';
8798
import {
8899
AxAIHuggingFace,
100+
axAIHuggingFaceCreativeConfig,
101+
axAIHuggingFaceDefaultConfig,
89102
type AxAIHuggingFaceArgs
90103
} from './ai/huggingface/api.js';
91104
import {
@@ -96,6 +109,8 @@ import {
96109
} from './ai/huggingface/types.js';
97110
import {
98111
AxAIMistral,
112+
axAIMistralBestConfig,
113+
axAIMistralDefaultConfig,
99114
type AxAIMistralArgs
100115
} from './ai/mistral/api.js';
101116
import {
@@ -104,12 +119,18 @@ import {
104119
} from './ai/mistral/types.js';
105120
import {
106121
AxAIOllama,
122+
axAIOllamaDefaultConfig,
123+
axAIOllamaDefaultCreativeConfig,
107124
type AxAIOllamaAIConfig,
108125
type AxAIOllamaArgs
109126
} from './ai/ollama/api.js';
110127
import {
111128
AxAIOpenAI,
112129
AxAIOpenAIBase,
130+
axAIOpenAIBestConfig,
131+
axAIOpenAICreativeConfig,
132+
axAIOpenAIDefaultConfig,
133+
axAIOpenAIFastConfig,
113134
type AxAIOpenAIArgs,
114135
type AxAIOpenAIBaseArgs
115136
} from './ai/openai/api.js';
@@ -128,6 +149,10 @@ import {
128149
} from './ai/openai/types.js';
129150
import {
130151
AxAIReka,
152+
axAIRekaBestConfig,
153+
axAIRekaCreativeConfig,
154+
axAIRekaDefaultConfig,
155+
axAIRekaFastConfig,
131156
type AxAIRekaArgs
132157
} from './ai/reka/api.js';
133158
import {
@@ -151,6 +176,7 @@ import {
151176
} from './util/apicall.js';
152177
import {
153178
AxAITogether,
179+
axAITogetherDefaultConfig,
154180
type AxAITogetherArgs
155181
} from './ai/together/api.js';
156182
import {
@@ -175,6 +201,8 @@ import {
175201
} from './ai/balance.js';
176202
import {
177203
AxBaseAI,
204+
axBaseAIDefaultConfig,
205+
axBaseAIDefaultCreativeConfig,
178206
type AxAIFeatures,
179207
type AxBaseAIArgs
180208
} from './ai/base.js';
@@ -252,7 +280,9 @@ import {
252280
} from './funcs/code.js';
253281
import {
254282
AxLLMRequestTypeValues,
255-
AxSpanKindValues
283+
AxSpanKindValues,
284+
axSpanAttributes,
285+
axSpanEvents
256286
} from './trace/trace.js';
257287
import {
258288
AxMockAIService,
@@ -342,13 +372,25 @@ import {AxChainOfThought} from './prompts/cot.js';
342372
import {AxDefaultQueryRewriter} from './docs/rewriter.js';
343373
import {AxDefaultResultReranker} from './docs/reranker.js';
344374
import {AxEmbeddingAdapter} from './funcs/embed.js';
375+
import {AxEvalUtil} from './dsp/eval.js';
345376
import {AxInstanceRegistry} from './dsp/registry.js';
346377
import {AxMCPClient} from './mcp/client.js';
347378
import {AxMCPHTTPTransport} from './mcp/httpTransport.js';
348379
import {AxMCPStdioTransport} from './mcp/stdioTransport.js';
349380
import {AxMemory} from './mem/memory.js';
350381
import {AxMultiServiceRouter} from './ai/multiservice.js';
351382
import {AxRAG} from './prompts/rag.js';
383+
import {AxStringUtil} from './dsp/strutil.js';
384+
import {axModelInfoAnthropic} from './ai/anthropic/info.js';
385+
import {axModelInfoCohere} from './ai/cohere/info.js';
386+
import {axModelInfoDeepSeek} from './ai/deepseek/info.js';
387+
import {axModelInfoGoogleGemini} from './ai/google-gemini/info.js';
388+
import {axModelInfoGroq} from './ai/groq/info.js';
389+
import {axModelInfoHuggingFace} from './ai/huggingface/info.js';
390+
import {axModelInfoMistral} from './ai/mistral/info.js';
391+
import {axModelInfoOpenAI} from './ai/openai/info.js';
392+
import {axModelInfoReka} from './ai/reka/info.js';
393+
import {axModelInfoTogether} from './ai/together/info.js';
352394
import {type AxAIMemory} from './mem/types.js';
353395
import {type AxMCPTransport} from './mcp/transport.js';
354396

@@ -408,6 +450,7 @@ export { AxDefaultQueryRewriter };
408450
export { AxDefaultResultReranker };
409451
export { AxDockerSession };
410452
export { AxEmbeddingAdapter };
453+
export { AxEvalUtil };
411454
export { AxFunctionError };
412455
export { AxFunctionProcessor };
413456
export { AxGen };
@@ -431,7 +474,48 @@ export { AxSignature };
431474
export { AxSimpleClassifier };
432475
export { AxSimpleClassifierClass };
433476
export { AxSpanKindValues };
477+
export { AxStringUtil };
434478
export { AxTestPrompt };
479+
export { axAIAnthropicDefaultConfig };
480+
export { axAIAzureOpenAIBestConfig };
481+
export { axAIAzureOpenAICreativeConfig };
482+
export { axAIAzureOpenAIDefaultConfig };
483+
export { axAIAzureOpenAIFastConfig };
484+
export { axAICohereCreativeConfig };
485+
export { axAICohereDefaultConfig };
486+
export { axAIDeepSeekCodeConfig };
487+
export { axAIDeepSeekDefaultConfig };
488+
export { axAIGoogleGeminiDefaultConfig };
489+
export { axAIGoogleGeminiDefaultCreativeConfig };
490+
export { axAIHuggingFaceCreativeConfig };
491+
export { axAIHuggingFaceDefaultConfig };
492+
export { axAIMistralBestConfig };
493+
export { axAIMistralDefaultConfig };
494+
export { axAIOllamaDefaultConfig };
495+
export { axAIOllamaDefaultCreativeConfig };
496+
export { axAIOpenAIBestConfig };
497+
export { axAIOpenAICreativeConfig };
498+
export { axAIOpenAIDefaultConfig };
499+
export { axAIOpenAIFastConfig };
500+
export { axAIRekaBestConfig };
501+
export { axAIRekaCreativeConfig };
502+
export { axAIRekaDefaultConfig };
503+
export { axAIRekaFastConfig };
504+
export { axAITogetherDefaultConfig };
505+
export { axBaseAIDefaultConfig };
506+
export { axBaseAIDefaultCreativeConfig };
507+
export { axModelInfoAnthropic };
508+
export { axModelInfoCohere };
509+
export { axModelInfoDeepSeek };
510+
export { axModelInfoGoogleGemini };
511+
export { axModelInfoGroq };
512+
export { axModelInfoHuggingFace };
513+
export { axModelInfoMistral };
514+
export { axModelInfoOpenAI };
515+
export { axModelInfoReka };
516+
export { axModelInfoTogether };
517+
export { axSpanAttributes };
518+
export { axSpanEvents };
435519

436520
// Type exports
437521
export type { AxAIAnthropicArgs };

0 commit comments

Comments
 (0)