wiggum-cli 0.3.0 → 0.3.1
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.
- package/dist/ai/agents/codebase-analyst.d.ts.map +1 -1
- package/dist/ai/agents/codebase-analyst.js +23 -27
- package/dist/ai/agents/codebase-analyst.js.map +1 -1
- package/dist/ai/agents/orchestrator.d.ts +1 -1
- package/dist/ai/agents/orchestrator.d.ts.map +1 -1
- package/dist/ai/agents/orchestrator.js +18 -24
- package/dist/ai/agents/orchestrator.js.map +1 -1
- package/dist/ai/agents/stack-researcher.d.ts.map +1 -1
- package/dist/ai/agents/stack-researcher.js +21 -26
- package/dist/ai/agents/stack-researcher.js.map +1 -1
- package/dist/ai/enhancer.d.ts.map +1 -1
- package/dist/ai/enhancer.js +24 -32
- package/dist/ai/enhancer.js.map +1 -1
- package/dist/utils/json-repair.d.ts +14 -0
- package/dist/utils/json-repair.d.ts.map +1 -0
- package/dist/utils/json-repair.js +103 -0
- package/dist/utils/json-repair.js.map +1 -0
- package/dist/utils/tracing.d.ts +25 -0
- package/dist/utils/tracing.d.ts.map +1 -0
- package/dist/utils/tracing.js +64 -0
- package/dist/utils/tracing.js.map +1 -0
- package/package.json +3 -1
- package/src/ai/agents/codebase-analyst.ts +27 -30
- package/src/ai/agents/orchestrator.ts +22 -26
- package/src/ai/agents/stack-researcher.ts +23 -27
- package/src/ai/enhancer.ts +26 -34
- package/src/utils/json-repair.ts +113 -0
- package/src/utils/tracing.ts +76 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Braintrust Tracing Utility
|
|
3
|
+
* Provides AI call tracing for debugging and analysis
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { initLogger, wrapAISDK } from 'braintrust';
|
|
7
|
+
import * as ai from 'ai';
|
|
8
|
+
|
|
9
|
+
// Re-export traced utilities
|
|
10
|
+
export { traced, currentSpan, wrapTraced } from 'braintrust';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Initialize Braintrust logger if API key is available
|
|
14
|
+
*/
|
|
15
|
+
let loggerInitialized = false;
|
|
16
|
+
|
|
17
|
+
export function initTracing(): void {
|
|
18
|
+
if (loggerInitialized) return;
|
|
19
|
+
|
|
20
|
+
const apiKey = process.env.BRAINTRUST_API_KEY;
|
|
21
|
+
if (!apiKey) {
|
|
22
|
+
// Silently skip tracing if no API key
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
initLogger({
|
|
28
|
+
apiKey,
|
|
29
|
+
projectName: process.env.BRAINTRUST_PROJECT_NAME || 'wiggum-cli',
|
|
30
|
+
});
|
|
31
|
+
loggerInitialized = true;
|
|
32
|
+
} catch {
|
|
33
|
+
// Silently fail if tracing can't be initialized
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Check if tracing is enabled
|
|
39
|
+
*/
|
|
40
|
+
export function isTracingEnabled(): boolean {
|
|
41
|
+
return !!process.env.BRAINTRUST_API_KEY;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get wrapped AI SDK functions for automatic tracing
|
|
46
|
+
* Falls back to original functions if tracing not available
|
|
47
|
+
*/
|
|
48
|
+
export function getTracedAI() {
|
|
49
|
+
initTracing();
|
|
50
|
+
|
|
51
|
+
if (isTracingEnabled()) {
|
|
52
|
+
return wrapAISDK(ai);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Return original AI SDK functions if tracing not enabled
|
|
56
|
+
return ai;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Wrap a function with tracing
|
|
61
|
+
* No-op if tracing is not enabled
|
|
62
|
+
*/
|
|
63
|
+
export function maybeTraced<T extends (...args: unknown[]) => unknown>(
|
|
64
|
+
fn: T,
|
|
65
|
+
options: { type?: string; name?: string } = {}
|
|
66
|
+
): T {
|
|
67
|
+
if (!isTracingEnabled()) {
|
|
68
|
+
return fn;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const { wrapTraced } = require('braintrust');
|
|
72
|
+
return wrapTraced(fn, {
|
|
73
|
+
type: options.type || 'function',
|
|
74
|
+
name: options.name || fn.name || 'anonymous',
|
|
75
|
+
});
|
|
76
|
+
}
|