Skip to content

Open source file-system and knowledge based agent template. Build AI agents that stay up to date with your knowledge base

feat: replace `@savoir/logger` with evlog

Hugo Richard3056df54c0c5
diff --git a/apps/chat/nuxt.config.ts b/apps/chat/nuxt.config.ts
index 9bbab64..c26c263 100644
--- a/apps/chat/nuxt.config.ts
+++ b/apps/chat/nuxt.config.ts
@@ -6,8 +6,18 @@ export default defineNuxtConfig({
'@nuxthub/core',
'nuxt-auth-utils',
'workflow/nuxt',
+ 'evlog/nuxt',
],
+ evlog: {
+ env: {
+ service: 'savoir',
+ environment: process.env.NODE_ENV ?? 'development',
+ commitHash: process.env.COMMIT_SHA,
+ version: '0.1.0',
+ },
+ },
+
devtools: { enabled: true },
$development: {
diff --git a/apps/chat/package.json b/apps/chat/package.json
index 2c5545b..8f51d78 100644
--- a/apps/chat/package.json
+++ b/apps/chat/package.json
@@ -18,7 +18,6 @@
"snapshot:create": "curl -X POST http://localhost:3000/api/sandbox/snapshot"
},
"dependencies": {
- "@savoir/logger": "workspace:*",
"@ai-sdk/gateway": "^3.0.22",
"@ai-sdk/vue": "^3.0.49",
"@iconify-json/logos": "^1.2.10",
@@ -32,13 +31,14 @@
"@vercel/blob": "^2.0.1",
"@vercel/functions": "^3.3.6",
"@vercel/sandbox": "^1.3.1",
- "giget": "^3.1.1",
- "pathe": "^2.0.3",
"ai": "^6.0.49",
"date-fns": "^4.1.0",
"drizzle-orm": "^0.45.1",
+ "evlog": "^1.0.0",
+ "giget": "^3.1.1",
"nuxt": "^4.3.0",
"nuxt-auth-utils": "^0.5.27",
+ "pathe": "^2.0.3",
"shiki-stream": "^0.1.4",
"workflow": "4.0.1-beta.50",
"zod": "^4.3.6"
diff --git a/apps/chat/server/api/chats/[id].post.ts b/apps/chat/server/api/chats/[id].post.ts
index 79a4c49..ec797e9 100644
--- a/apps/chat/server/api/chats/[id].post.ts
+++ b/apps/chat/server/api/chats/[id].post.ts
@@ -3,7 +3,7 @@ import { z } from 'zod'
import { db, schema } from '@nuxthub/db'
import { and, eq } from 'drizzle-orm'
import { createSavoir } from '@savoir/sdk'
-import { getLogger } from '@savoir/logger'
+import { log, useLogger } from 'evlog'
import { generateTitle } from '../../utils/generate-title'
const SYSTEM_PROMPT = `You are an AI assistant specialized in the Nuxt/Nitro ecosystem.
@@ -53,10 +53,10 @@ defineRouteMeta({
})
export default defineEventHandler(async (event) => {
- const logger = getLogger()
+ const requestLog = useLogger(event)
const requestId = crypto.randomUUID().slice(0, 8)
- const log = logger.request({
+ requestLog.set({
requestId,
path: '/api/chats/[id]',
method: 'POST',
@@ -64,18 +64,18 @@ export default defineEventHandler(async (event) => {
try {
const session = await getUserSession(event)
- log.set({ userId: session.user?.id || session.id })
+ requestLog.set({ userId: session.user?.id || session.id })
const { id } = await getValidatedRouterParams(event, z.object({
id: z.string(),
}).parse)
- log.set({ chatId: id })
+ requestLog.set({ chatId: id })
const { model, messages } = await readValidatedBody(event, z.object({
model: z.string(),
messages: z.array(z.custom<UIMessage>()),
}).parse)
- log.set({ model, messageCount: messages.length })
+ requestLog.set({ model, messageCount: messages.length })
const chat = await db.query.chats.findFirst({
where: () => and(
@@ -87,11 +87,11 @@ export default defineEventHandler(async (event) => {
},
})
if (!chat) {
- log.error('Chat not found')
- log.emit({ outcome: 'error' })
+ requestLog.error(new Error('Chat not found'))
+ requestLog.set({ outcome: 'error' })
throw createError({ statusCode: 404, statusMessage: 'Chat not found' })
}
- log.set({ existingMessages: chat.messages.length })
+ requestLog.set({ existingMessages: chat.messages.length })
const lastMessage = messages[messages.length - 1]
if (lastMessage?.role === 'user' && messages.length > 1) {
@@ -114,7 +114,7 @@ export default defineEventHandler(async (event) => {
let totalInputTokens = 0
let totalOutputTokens = 0
- logger.log('chat', `[${requestId}] Starting agent with ${model}`)
+ log.info('chat', `[${requestId}] Starting agent with ${model}`)
const agent = new ToolLoopAgent({
model,
@@ -131,12 +131,12 @@ export default defineEventHandler(async (event) => {
if (stepResult.toolCalls && stepResult.toolCalls.length > 0) {
toolCallCount += stepResult.toolCalls.length
const tools = stepResult.toolCalls.map(c => c.toolName).join(', ')
- logger.log('chat', `[${requestId}] Step ${stepCount}: ${tools}`)
+ log.info('chat', `[${requestId}] Step ${stepCount}: ${tools}`)
}
},
onFinish: (result) => {
- log.set({
+ requestLog.set({
finishReason: result.finishReason,
totalInputTokens,
totalOutputTokens,
@@ -144,7 +144,7 @@ export default defineEventHandler(async (event) => {
stepCount,
toolCallCount,
})
- logger.log('chat', `[${requestId}] Finished: ${result.finishReason}`)
+ log.info('chat', `[${requestId}] Finished: ${result.finishReason}`)
},
})
@@ -171,20 +171,18 @@ export default defineEventHandler(async (event) => {
})))
const dbDurationMs = Date.now() - dbStartTime
- log.set({
+ requestLog.set({
outcome: 'success',
responseMessageCount: responseMessages.length,
dbInsertMs: dbDurationMs,
})
-
- log.emit()
},
})
return createUIMessageStreamResponse({ stream })
} catch (error) {
- log.error(error instanceof Error ? error : new Error(String(error)))
- log.emit({ outcome: 'error' })
+ requestLog.error(error instanceof Error ? error : new Error(String(error)))
+ requestLog.set({ outcome: 'error' })
throw error
}
})
diff --git a/apps/chat/server/lib/sandbox/git.ts b/apps/chat/server/lib/sandbox/git.ts
index b42ad52..6a081be 100644
--- a/apps/chat/server/lib/sandbox/git.ts
+++ b/apps/chat/server/lib/sandbox/git.ts
@@ -1,5 +1,5 @@
import type { Sandbox } from '@vercel/sandbox'
-import { createError } from '@savoir/logger'
+import { createError } from 'evlog'
import type { SyncSourceResult } from '../../workflows/sync-docs/types'
export interface GitConfig {
diff --git a/apps/chat/server/lib/sandbox/manager.ts b/apps/chat/server/lib/sandbox/manager.ts
index 848109c..d68559c 100644
--- a/apps/chat/server/lib/sandbox/manager.ts
+++ b/apps/chat/server/lib/sandbox/manager.ts
@@ -1,5 +1,5 @@
import { Sandbox } from '@vercel/sandbox'
-import { createError, getLogger } from '@savoir/logger'
+import { createError, log } from 'evlog'
import type { ActiveSandbox, FileContent, SearchAndReadResult, SearchResult, SandboxManagerConfig, SnapshotMetadata } from './types'
import { getCurrentSnapshot, setCurrentSnapshot } from './snapshot'
import { deleteSession, generateSessionId, getSession, setSession, touchSession } from './session'
@@ -43,9 +43,7 @@ function getGitSourceOptions(repoUrl: string, branch: string, githubToken?: stri
/** Creates and initializes sandbox from snapshot ID */
async function createSandboxFromSnapshot(snapshotId: string): Promise<Sandbox> {
- const logger = getLogger()
-
- logger.log('sandbox', `Creating sandbox from snapshot: ${snapshotId}`)
+ log.info('sandbox', `Creating sandbox from snapshot: ${snapshotId}`)
const sandbox = await Sandbox.create({
source: {
@@ -56,7 +54,7 @@ async function createSandboxFromSnapshot(snapshotId: string): Promise<Sandbox> {
runtime: 'node24',
})
- logger.log('sandbox', `Sandbox created: ${sandbox.sandboxId}`)
+ log.info('sandbox', `Sandbox created: ${sandbox.sandboxId}`)
return sandbox
}
@@ -78,9 +76,8 @@ async function getSandboxById(sandboxId: string): Promise<Sandbox | null> {
/** Creates sandbox from git repository and returns snapshot ID */
export async function createSnapshotFromRepo(repoUrl: string, branch: string = 'main'): Promise<string> {
const config = getConfig()
- const logger = getLogger()
- logger.log('sandbox', `Creating sandbox from repo: ${repoUrl}#${branch}`)
+ log.info('sandbox', `Creating sandbox from repo: ${repoUrl}#${branch}`)
const sandbox = await Sandbox.create({
source: getGitSourceOptions(repoUrl, branch, config.githubToken),
@@ -88,18 +85,17 @@ export async function createSnapshotFromRepo(repoUrl: string, branch: string = '
runtime: 'node24',
})
- logger.log('sandbox', `Sandbox created: ${sandbox.sandboxId}, taking snapshot...`)
+ log.info('sandbox', `Sandbox created: ${sandbox.sandboxId}, taking snapshot...`)
// Take snapshot (this also stops the sandbox)
const snapshot = await sandbox.snapshot()
- logger.log('sandbox', `Snapshot created: ${snapshot.snapshotId}`)
+ log.info('sandbox', `Snapshot created: ${snapshot.snapshotId}`)
return snapshot.snapshotId
}
/** Returns current snapshot ID or creates one from configured repo */
async function getOrCreateSnapshot(): Promise<string> {
- const logger = getLogger()
const config = getConfig()
// Check if snapshot exists
@@ -128,13 +124,12 @@ async function getOrCreateSnapshot(): Promise<string> {
}
await setCurrentSnapshot(metadata)
- logger.log('sandbox', `Snapshot created and saved: ${snapshotId}`)
+ log.info('sandbox', `Snapshot created and saved: ${snapshotId}`)
return snapshotId
}
/** Returns active sandbox for session, reusing existing or creating new. Auto-creates snapshot if needed */
export async function getOrCreateSandbox(sessionId?: string): Promise<ActiveSandbox> {
- const logger = getLogger()
const config = getConfig()
// If session ID provided, try to get existing sandbox
@@ -143,7 +138,7 @@ export async function getOrCreateSandbox(sessionId?: string): Promise<ActiveSand
if (session) {
const sandbox = await getSandboxById(session.sandboxId)
if (sandbox) {
- logger.log('sandbox', `Reusing sandbox ${sandbox.sandboxId} for session ${sessionId}`)
+ log.info('sandbox', `Reusing sandbox ${sandbox.sandboxId} for session ${sessionId}`)
await touchSession(sessionId, config.sessionTtlMs)
return { sandbox, session, sessionId }
}
@@ -177,8 +172,7 @@ export async function search(
query: string,
limit: number = 20,
): Promise<SearchResult[]> {
- const logger = getLogger()
- logger.log('sandbox', `Searching for: ${query}`)
+ log.info('sandbox', `Searching for: ${query}`)
// Use grep for searching (-r recursive, -n line numbers, -i case insensitive, -l list files)
const result = await sandbox.runCommand({
@@ -204,7 +198,7 @@ export async function search(
const stderr = await result.stderr()
if (stderr) {
- logger.log('sandbox', `grep stderr: ${stderr}`)
+ log.error('sandbox', `grep stderr: ${stderr}`)
}
const lines = stdout.split('\n').filter(Boolean).slice(0, limit)
@@ -222,7 +216,7 @@ export async function search(
}
}
- logger.log('sandbox', `Found ${results.length} matches`)
+ log.info('sandbox', `Found ${results.length} matches`)
return results
}
@@ -231,8 +225,7 @@ export async function read(
sandbox: Sandbox,
paths: string[],
): Promise<FileContent[]> {
- const logger = getLogger()
- logger.log('sandbox', `Reading ${paths.length} files`)
+ log.info('sandbox', `Reading ${paths.length} files`)
const files: FileContent[] = []
@@ -250,11 +243,11 @@ export async function read(
})
}
} catch {
- logger.log('sandbox', `Failed to read file: ${path}`)
+ log.error('sandbox', `Failed to read file: ${path}`)
}
}
- logger.log('sandbox', `Read ${files.length} files successfully`)
+ log.info('sandbox', `Read ${files.length} files successfully`)
return files
}
diff --git a/apps/chat/server/lib/sandbox/source-sync.ts b/apps/chat/server/lib/sandbox/source-sync.ts
index acd2d3f..178b732 100644
--- a/apps/chat/server/lib/sandbox/source-sync.ts
+++ b/apps/chat/server/lib/sandbox/source-sync.ts
@@ -1,5 +1,5 @@
import type { Sandbox } from '@vercel/sandbox'
-import { createError } from '@savoir/logger'
+import { createError } from 'evlog'
import type { GitHubSource, SyncSourceResult } from '../../workflows/sync-docs/types'
/** Syncs GitHub source to sandbox, returns result with file count and status */
diff --git a/apps/chat/server/plugins/logger.ts b/apps/chat/server/plugins/logger.ts
deleted file mode 100644
index 828e403..0000000
--- a/apps/chat/server/plugins/logger.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { createLogger } from '@savoir/logger'
-
-/**
- * Initialize the logger when the server starts
- */
-export default defineNitroPlugin(() => {
- createLogger({
- env: {
- service: 'savoir',
- environment: process.env.NODE_ENV ?? 'development',
- commitHash: process.env.COMMIT_SHA,
- version: '0.1.0',
- },
- })
-})
diff --git a/apps/chat/server/utils/generate-title.ts b/apps/chat/server/utils/generate-title.ts
index 06e1bd1..45b3d40 100644
--- a/apps/chat/server/utils/generate-title.ts
+++ b/apps/chat/server/utils/generate-title.ts
@@ -2,7 +2,7 @@ import type { UIMessage, UIMessageStreamWriter } from 'ai'
import { generateText } from 'ai'
import { db, schema } from '@nuxthub/db'
import { eq } from 'drizzle-orm'
-import { getLogger } from '@savoir/logger'
+import { log } from 'evlog'
interface GenerateTitleOptions {
firstMessage: UIMessage
@@ -16,7 +16,6 @@ interface GenerateTitleOptions {
*/
export function generateTitle(options: GenerateTitleOptions): void {
const { firstMessage, chatId, requestId, writer } = options
- const logger = getLogger()
generateText({
model: 'google/gemini-3-flash',
@@ -35,8 +34,8 @@ export function generateTitle(options: GenerateTitleOptions): void {
})
await db.update(schema.chats).set({ title }).where(eq(schema.chats.id, chatId))
- logger.log('chat', `[${requestId}] Title: ${title}`)
+ log.info('chat', `${requestId} Title: ${title}`)
}).catch(() => {
- logger.log('chat', `[${requestId}] Title generation failed`)
+ log.error('chat', `${requestId} Title generation failed`)
})
}
diff --git a/apps/chat/server/workflows/create-snapshot/steps/create-and-snapshot.ts b/apps/chat/server/workflows/create-snapshot/steps/create-and-snapshot.ts
index 613e288..c794f93 100644
--- a/apps/chat/server/workflows/create-snapshot/steps/create-and-snapshot.ts
+++ b/apps/chat/server/workflows/create-snapshot/steps/create-and-snapshot.ts
@@ -1,6 +1,6 @@
/** Creates sandbox from repository and takes snapshot */
-import { getLogger } from '@savoir/logger'
+import { log } from 'evlog'
import type { SnapshotConfig } from '../types'
import { createSandbox } from '../../../lib/sandbox/context'
@@ -12,14 +12,12 @@ export interface SnapshotResult {
export async function stepCreateAndSnapshot(config: SnapshotConfig): Promise<SnapshotResult> {
'use step'
- const logger = getLogger()
-
- logger.log('snapshot', `Creating sandbox from ${config.snapshotRepo}#${config.snapshotBranch}`)
+ log.info('snapshot', `Creating sandbox from ${config.snapshotRepo}#${config.snapshotBranch}`)
const sandbox = await createSandbox(config, 2 * 60 * 1000)
- logger.log('snapshot', `Sandbox created: ${sandbox.sandboxId}`)
+ log.info('snapshot', `Sandbox created: ${sandbox.sandboxId}`)
const snapshot = await sandbox.snapshot()
- logger.log('snapshot', `✓ Snapshot created: ${snapshot.snapshotId}`)
+ log.info('snapshot', `✓ Snapshot created: ${snapshot.snapshotId}`)
return {
snapshotId: snapshot.snapshotId,
diff --git a/apps/chat/server/workflows/create-snapshot/workflow.ts b/apps/chat/server/workflows/create-snapshot/workflow.ts
index 4f1f5b6..92a11b8 100644
--- a/apps/chat/server/workflows/create-snapshot/workflow.ts
+++ b/apps/chat/server/workflows/create-snapshot/workflow.ts
@@ -5,16 +5,14 @@
* Returns the snapshot ID - API route handles KV storage.
*/
-import { getLogger } from '@savoir/logger'
import { FatalError } from 'workflow'
+import { log } from 'evlog'
import type { SnapshotConfig, SnapshotResult } from './types'
import { stepCreateAndSnapshot } from './steps'
export async function createSnapshot(config: SnapshotConfig): Promise<SnapshotResult> {
'use workflow'
- const logger = getLogger()
-
if (!config.snapshotRepo) {
throw new FatalError('NUXT_GITHUB_SNAPSHOT_REPO is not configured')
}
@@ -22,7 +20,7 @@ export async function createSnapshot(config: SnapshotConfig): Promise<SnapshotRe
try {
const { snapshotId } = await stepCreateAndSnapshot(config)
- logger.log('snapshot', `✓ Workflow completed: ${snapshotId}`)
+ log.info('snapshot', `✓ Workflow completed: ${snapshotId}`)
return {
success: true,
@@ -31,7 +29,7 @@ export async function createSnapshot(config: SnapshotConfig): Promise<SnapshotRe
}
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error)
- logger.log('snapshot', `✗ Workflow failed: ${errorMessage}`)
+ log.error('snapshot', `✗ Workflow failed: ${errorMessage}`)
return {
success: false,
diff --git a/apps/chat/server/workflows/sync-docs/steps/sync-all.ts b/apps/chat/server/workflows/sync-docs/steps/sync-all.ts
index 7515e00..52d64db 100644
--- a/apps/chat/server/workflows/sync-docs/steps/sync-all.ts
+++ b/apps/chat/server/workflows/sync-docs/steps/sync-all.ts
@@ -1,6 +1,6 @@
/** Performs complete sync workflow: create sandbox, sync sources, push to git, and take snapshot */
-import { getLogger } from '@savoir/logger'
+import { log } from 'evlog'
import type { GitHubSource, SyncConfig, SyncSourceResult } from '../types'
import { createSandbox, generateAuthRepoUrl } from '../../../lib/sandbox/context'
import { syncSources } from '../../../lib/sandbox/source-sync'
@@ -18,19 +18,17 @@ export async function stepSyncAll(
): Promise<SyncAllResult> {
'use step'
- const logger = getLogger()
-
- logger.log('sync', `Creating sandbox from ${config.snapshotRepo}#${config.snapshotBranch}`)
+ log.info('sync', `Creating sandbox from ${config.snapshotRepo}#${config.snapshotBranch}`)
const sandbox = await createSandbox(config)
- logger.log('sync', `Sandbox created: ${sandbox.sandboxId}`)
+ log.info('sync', `Sandbox created: ${sandbox.sandboxId}`)
const results = await syncSources(sandbox, sources)
for (const result of results) {
if (result.success) {
- logger.log('sync', `${result.sourceId}: synced ${result.fileCount} files`)
+ log.info('sync', `${result.sourceId}: synced ${result.fileCount} files`)
} else {
- logger.log('sync', `${result.sourceId}: failed - ${result.error}`)
+ log.error('sync', `${result.sourceId}: failed - ${result.error}`)
}
}
@@ -46,11 +44,11 @@ export async function stepSyncAll(
})
if (pushResult.success && pushResult.hasChanges) {
- logger.log('sync', '✓ Changes pushed to repository')
+ log.info('sync', '✓ Changes pushed to repository')
}
const snapshot = await sandbox.snapshot()
- logger.log('sync', `Snapshot created: ${snapshot.snapshotId}`)
+ log.info('sync', `Snapshot created: ${snapshot.snapshotId}`)
return {
snapshotId: snapshot.snapshotId,
diff --git a/apps/chat/server/workflows/sync-docs/workflow.ts b/apps/chat/server/workflows/sync-docs/workflow.ts
index 6d234d5..d9559e1 100644
--- a/apps/chat/server/workflows/sync-docs/workflow.ts
+++ b/apps/chat/server/workflows/sync-docs/workflow.ts
@@ -5,8 +5,8 @@
* pushes changes to git, then takes a snapshot for instant startup.
*/
-import { getLogger } from '@savoir/logger'
import { FatalError } from 'workflow'
+import { log } from 'evlog'
import type { GitHubSource, SyncConfig, SyncResult } from './types'
import { stepSyncAll } from './steps'
@@ -16,8 +16,6 @@ export async function syncDocumentation(
): Promise<SyncResult> {
'use workflow'
- const logger = getLogger()
-
if (!config.snapshotRepo) {
throw new FatalError('NUXT_GITHUB_SNAPSHOT_REPO is not configured')
}
@@ -32,7 +30,7 @@ export async function syncDocumentation(
const failCount = results.filter(r => !r.success).length
const status = failCount === 0 ? '✓' : '✗'
- logger.log('sync', `${status} Done: ${successCount}/${sources.length} sources, ${totalFiles} files`)
+ log.info('sync', `${status} Done: ${successCount}/${sources.length} sources, ${totalFiles} files`)
return {
success: failCount === 0,
diff --git a/bun.lock b/bun.lock
index a4b75e1..fa28dd5 100644
--- a/bun.lock
+++ b/bun.lock
@@ -21,7 +21,6 @@
"@nuxt/ui": "^4.4.0",
"@nuxthub/core": "^0.10.5",
"@nuxtjs/mdc": "^0.20.0",
- "@savoir/logger": "workspace:*",
"@upstash/redis": "^1.36.1",
"@vercel/blob": "^2.0.1",
"@vercel/functions": "^3.3.6",
@@ -29,6 +28,7 @@
"ai": "^6.0.49",
"date-fns": "^4.1.0",
"drizzle-orm": "^0.45.1",
+ "evlog": "^1.0.0",
"giget": "^3.1.1",
"nuxt": "^4.3.0",
"nuxt-auth-utils": "^0.5.27",
@@ -46,22 +46,12 @@
"vue-tsc": "^3.2.3",
},
},
- "packages/logger": {
- "name": "@savoir/logger",
- "version": "0.0.1",
- "devDependencies": {
- "@types/node": "^25.0.10",
- "eslint": "^9.39.2",
- "tsdown": "^0.20.1",
- "typescript": "^5.9.3",
- },
- },
"packages/sdk": {
"name": "@savoir/sdk",
"version": "0.0.1",
"dependencies": {
- "@savoir/logger": "workspace:*",
"ai": "^6.0.49",
+ "evlog": "^1.0.0",
"zod": "^4.3.6",
},
"devDependencies": {
@@ -789,8 +779,6 @@
"@savoir/chat": ["@savoir/chat@workspace:apps/chat"],
- "@savoir/logger": ["@savoir/logger@workspace:packages/logger"],
-
"@savoir/sdk": ["@savoir/sdk@workspace:packages/sdk"],
"@sec-ant/readable-stream": ["@sec-ant/[email protected]", "", {}, "sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg=="],
@@ -1657,6 +1645,8 @@
"eventsource-parser": ["[email protected]", "", {}, "sha512-Vo1ab+QXPzZ4tCa8SwIHJFaSzy4R6SHf7BY79rFBDf0idraZWAkYrDjDj8uWaSm3S2TK+hJ7/t1CEmZ7jXw+pg=="],
+ "evlog": ["[email protected]", "", { "dependencies": { "@nuxt/kit": "^4.3.0" }, "peerDependencies": { "h3": "^1.13.0", "nitropack": "^2.13.1", "ofetch": "^1.5.1" }, "optionalPeers": ["h3", "nitropack", "ofetch"] }, "sha512-VK7ayLR9cJZEuhGY4hieN+DD9tgUDWWGNJ4kmQTipa4il5GKfNnIk+vlay0lunfGoKK4mpRXT8vBTbbZDe8HxQ=="],
+
"execa": ["[email protected]", "", { "dependencies": { "@sindresorhus/merge-streams": "^4.0.0", "cross-spawn": "^7.0.6", "figures": "^6.1.0", "get-stream": "^9.0.0", "human-signals": "^8.0.1", "is-plain-obj": "^4.1.0", "is-stream": "^4.0.1", "npm-run-path": "^6.0.0", "pretty-ms": "^9.2.0", "signal-exit": "^4.1.0", "strip-final-newline": "^4.0.0", "yoctocolors": "^2.1.1" } }, "sha512-9Be3ZoN4LmYR90tUoVu2te2BsbzHfhJyfEiAVfz7N5/zv+jduIfLrV2xdQXOHbaD6KgpGdO9PRPM1Y4Q9QkPkA=="],
"exsolve": ["[email protected]", "", {}, "sha512-LmDxfWXwcTArk8fUEnOfSZpHOJ6zOMUJKOtFLFqJLoKJetuQG874Uc7/Kki7zFLzYybmZhp1M7+98pfMqeX8yA=="],
diff --git a/packages/logger/package.json b/packages/logger/package.json
deleted file mode 100644
index fcc5c43..0000000
--- a/packages/logger/package.json
+++ /dev/null
@@ -1,33 +0,0 @@
-{
- "name": "@savoir/logger",
- "version": "0.0.1",
- "description": "Logging utilities with context and timing support",
- "type": "module",
- "exports": {
- ".": {
- "types": "./dist/index.d.mts",
- "import": "./dist/index.mjs"
- }
- },
- "main": "./dist/index.mjs",
- "module": "./dist/index.mjs",
- "types": "./dist/index.d.mts",
- "sideEffects": false,
- "files": [
- "dist"
- ],
- "scripts": {
- "build": "tsdown",
- "dev": "tsdown --watch",
- "typecheck": "tsc --noEmit",
- "lint": "eslint .",
- "lint:fix": "eslint . --fix",
- "prepublishOnly": "bun run build"
- },
- "devDependencies": {
- "@types/node": "^25.0.10",
- "eslint": "^9.39.2",
- "tsdown": "^0.20.1",
- "typescript": "^5.9.3"
- }
-}
diff --git a/packages/logger/src/error.ts b/packages/logger/src/error.ts
deleted file mode 100644
index e6d3009..0000000
--- a/packages/logger/src/error.ts
+++ /dev/null
@@ -1,108 +0,0 @@
-export interface ErrorOptions {
- /** What actually happened */
- message: string
- /** Why this error occurred */
- why?: string
- /** How to fix this issue */
- fix?: string
- /** Link to documentation or more information */
- link?: string
- /** The original error that caused this */
- cause?: Error
-}
-
-/**
- * Structured error with context for better debugging
- *
- * @example
- * ```ts
- * throw new SavoirError({
- * message: 'Failed to sync repository',
- * why: 'GitHub API rate limit exceeded',
- * fix: 'Wait 1 hour or use a different token',
- * link: 'https://docs.github.com/en/rest/rate-limit',
- * cause: originalError,
- * })
- * ```
- */
-export class SavoirError extends Error {
-
- readonly why?: string
- readonly fix?: string
- readonly link?: string
-
- constructor(options: ErrorOptions | string) {
- const opts = typeof options === 'string' ? { message: options } : options
-
- super(opts.message, { cause: opts.cause })
-
- this.name = 'SavoirError'
- this.why = opts.why
- this.fix = opts.fix
- this.link = opts.link
-
- // Maintain proper stack trace in V8
- if (Error.captureStackTrace) {
- Error.captureStackTrace(this, SavoirError)
- }
- }
-
- /**
- * Format error for console output with colors
- */
- toString(): string {
- const red = '\x1b[31m'
- const yellow = '\x1b[33m'
- const cyan = '\x1b[36m'
- const dim = '\x1b[2m'
- const reset = '\x1b[0m'
- const bold = '\x1b[1m'
-
- const lines: string[] = []
-
- lines.push(`${red}${bold}Error:${reset} ${this.message}`)
-
- if (this.why) {
- lines.push(`${yellow}Why:${reset} ${this.why}`)
- }
-
- if (this.fix) {
- lines.push(`${cyan}Fix:${reset} ${this.fix}`)
- }
-
- if (this.link) {
- lines.push(`${dim}More info:${reset} ${this.link}`)
- }
-
- if (this.cause) {
- lines.push(`${dim}Caused by:${reset} ${(this.cause as Error).message}`)
- }
-
- return lines.join('\n')
- }
-
- /**
- * Convert to plain object for JSON serialization
- */
- toJSON(): Record<string, unknown> {
- return {
- name: this.name,
- message: this.message,
- why: this.why,
- fix: this.fix,
- link: this.link,
- cause: this.cause instanceof Error
- ? { name: this.cause.name, message: this.cause.message }
- : undefined,
- stack: this.stack,
- }
- }
-
-}
-
-/**
- * Create a SavoirError (functional alternative to `new SavoirError()`)
- */
-export function createError(options: ErrorOptions | string): SavoirError {
- return new SavoirError(options)
-}
diff --git a/packages/logger/src/index.ts b/packages/logger/src/index.ts
deleted file mode 100644
index 56f825c..0000000
--- a/packages/logger/src/index.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export { createLogger, getLogger, resetLogger } from './logger'
-export { SavoirError, createError } from './error'
-export type { ErrorOptions } from './error'
-export type {
- BaseWideEvent,
- EnvironmentContext,
- Logger,
- LoggerConfig,
- RequestLogger,
- WideEvent,
- WideEventBuilder,
-} from './types'
diff --git a/packages/logger/src/logger.ts b/packages/logger/src/logger.ts
deleted file mode 100644
index b30da50..0000000
--- a/packages/logger/src/logger.ts
+++ /dev/null
@@ -1,184 +0,0 @@
-import type { EnvironmentContext, Logger, LoggerConfig, RequestLogger, WideEvent } from './types'
-
-let globalLogger: Logger | null = null
-
-/**
- * Format duration in human-readable format
- * - < 1s: shows milliseconds (e.g., "42ms")
- * - >= 1s: shows seconds (e.g., "1.5s")
- */
-function formatDuration(ms: number): string {
- if (ms < 1000) {
- return `${Math.round(ms)}ms`
- }
- return `${(ms / 1000).toFixed(2)}s`
-}
-
-/**
- * Create the application logger (singleton)
- *
- * @example
- * ```ts
- * const logger = createLogger({
- * env: {
- * service: 'api',
- * environment: process.env.NODE_ENV ?? 'development',
- * },
- * })
- *
- * // Simple workflow-style logs
- * logger.log('workflow', 'Syncing nuxt-icon...')
- * logger.log('workflow', 'nuxt-icon: 1 files in 31ms')
- *
- * // Wide event for request logging
- * const log = logger.request({ method: 'POST', path: '/checkout' })
- * log.set({ user: { id: '123' } })
- * log.emit()
- * ```
- */
-export function createLogger(config: LoggerConfig): Logger {
- if (globalLogger) {
- return globalLogger
- }
-
- const { env, pretty = process.env.NODE_ENV !== 'production' } = config
-
- function formatEvent(level: 'info' | 'error', event: Record<string, unknown>): WideEvent {
- return {
- timestamp: new Date().toISOString(),
- level,
- service: env.service,
- environment: env.environment,
- ...(env.commitHash && { commitHash: env.commitHash }),
- ...(env.version && { version: env.version }),
- ...(env.region && { region: env.region }),
- ...event,
- }
- }
-
- function emitWideEvent(level: 'info' | 'error', event: Record<string, unknown>): void {
- const formatted = formatEvent(level, event)
-
- if (pretty) {
- const { timestamp, level: lvl, service, ...rest } = formatted
- const color = lvl === 'error' ? '\x1b[31m' : '\x1b[36m'
- const reset = '\x1b[0m'
- const dim = '\x1b[2m'
-
- console[lvl === 'error' ? 'error' : 'log'](
- `${dim}${timestamp}${reset} ${color}[${service}]${reset}`,
- JSON.stringify(rest, null, 2),
- )
- } else {
- console[level === 'error' ? 'error' : 'log'](JSON.stringify(formatted))
- }
- }
-
- /**
- * Simple log output: [tag] message
- * For workflow-style progress messages
- */
- function log(tag: string, message: string): void {
- const cyan = '\x1b[36m'
- const reset = '\x1b[0m'
-
- if (pretty) {
- console.log(`${cyan}[${tag}]${reset} ${message}`)
- } else {
- console.log(JSON.stringify({
- timestamp: new Date().toISOString(),
- level: 'info',
- service: env.service,
- tag,
- message,
- }))
- }
- }
-
- function createRequestLogger(initialContext: Record<string, unknown> = {}): RequestLogger {
- const startTime = performance.now()
- let context: Record<string, unknown> = { ...initialContext }
- let errorInfo: Record<string, unknown> | null = null
-
- return {
- set<T extends Record<string, unknown>>(newContext: T): void {
- context = { ...context, ...newContext }
- },
-
- error(error: Error | string, extraContext?: Record<string, unknown>): void {
- if (error instanceof Error) {
- errorInfo = {
- message: error.message,
- name: error.name,
- ...(error.stack && { stack: error.stack }),
- ...extraContext,
- }
- } else {
- errorInfo = { message: error, ...extraContext }
- }
- },
-
- emit(overrides?: Record<string, unknown>): void {
- const durationMs = performance.now() - startTime
- const level = errorInfo ? 'error' : 'info'
-
- emitWideEvent(level, {
- ...context,
- ...(errorInfo && { error: errorInfo }),
- ...overrides,
- duration: formatDuration(durationMs),
- durationMs: Math.round(durationMs * 100) / 100,
- })
- },
-
- getContext(): Record<string, unknown> {
- return { ...context }
- },
- }
- }
-
- globalLogger = {
- log,
-
- info(event: Record<string, unknown>): void {
- emitWideEvent('info', event)
- },
-
- error(event: Record<string, unknown>): void {
- emitWideEvent('error', event)
- },
-
- request: createRequestLogger,
-
- get env(): EnvironmentContext {
- return env
- },
- }
-
- return globalLogger
-}
-
-/**
- * Get the global logger instance
- * Auto-initializes with defaults if not already initialized
- */
-export function getLogger(): Logger {
- if (!globalLogger) {
- createLogger({
- env: {
- service: process.env.SERVICE_NAME ?? 'app',
- environment: process.env.NODE_ENV ?? 'development',
- commitHash: process.env.COMMIT_SHA,
- version: process.env.npm_package_version,
- },
- })
- }
- return globalLogger!
-}
-
-/**
- * Reset the global logger (useful for testing)
- */
-export function resetLogger(): void {
- globalLogger = null
-}
diff --git a/packages/logger/src/types.ts b/packages/logger/src/types.ts
deleted file mode 100644
index ca9018f..0000000
--- a/packages/logger/src/types.ts
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * Environment context automatically included in every log event
- */
-export interface EnvironmentContext {
- /** Service name (e.g., 'api', 'worker') */
- service: string
- /** Environment (e.g., 'production', 'staging', 'development') */
- environment: string
- /** Git commit hash for deployment tracking */
- commitHash?: string
- /** Service version */
- version?: string
- /** Region/datacenter identifier */
- region?: string
-}
-
-/**
- * Configuration options for the logger
- */
-export interface LoggerConfig {
- /** Environment context included in all events */
- env: EnvironmentContext
- /** Enable pretty printing for development (default: based on NODE_ENV) */
- pretty?: boolean
-}
-
-/**
- * Base fields for all wide events
- */
-export interface BaseWideEvent {
- /** ISO timestamp */
- timestamp: string
- /** Log level */
- level: 'info' | 'error'
- /** Service name */
- service: string
- /** Environment */
- environment: string
- /** Commit hash */
- commitHash?: string
- /** Service version */
- version?: string
- /** Region */
- region?: string
-}
-
-/**
- * A wide event with arbitrary additional context
- */
-export type WideEvent = BaseWideEvent & Record<string, unknown>
-
-/**
- * Context builder for accumulating wide event data
- */
-export interface WideEventBuilder {
- /** Add context to the wide event */
- set: <T extends Record<string, unknown>>(context: T) => void
- /** Get current accumulated context */
- getContext: () => Record<string, unknown>
- /** Emit the wide event (called automatically in finally block) */
- emit: (level?: 'info' | 'error') => void
-}
-
-/**
- * Request-scoped logger for building wide events
- */
-export interface RequestLogger {
- /** Add context to the current request's wide event */
- set: <T extends Record<string, unknown>>(context: T) => void
- /** Log an error (will be included in the wide event) */
- error: (error: Error | string, context?: Record<string, unknown>) => void
- /** Manually emit the wide event (usually done by middleware) */
- emit: (overrides?: Record<string, unknown>) => void
- /** Get the accumulated context */
- getContext: () => Record<string, unknown>
-}
-
-/**
- * Main logger interface - single instance per application
- */
-export interface Logger {
- /** Simple log: [tag] message - for workflow-style progress logs */
- log: (tag: string, message: string) => void
- /** Log an info-level wide event */
- info: (event: Record<string, unknown>) => void
- /** Log an error-level wide event */
- error: (event: Record<string, unknown>) => void
- /** Create a request-scoped logger for building a wide event */
- request: (initialContext?: Record<string, unknown>) => RequestLogger
- /** Get environment context */
- readonly env: EnvironmentContext
-}
diff --git a/packages/logger/tsconfig.json b/packages/logger/tsconfig.json
deleted file mode 100644
index cb6ef60..0000000
--- a/packages/logger/tsconfig.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "compilerOptions": {
- "target": "ES2022",
- "module": "ESNext",
- "moduleResolution": "Bundler",
- "strict": true,
- "declaration": true,
- "esModuleInterop": true,
- "skipLibCheck": true,
- "noEmit": true
- },
- "include": ["src"]
-}
diff --git a/packages/logger/tsdown.config.ts b/packages/logger/tsdown.config.ts
deleted file mode 100644
index 03c2d29..0000000
--- a/packages/logger/tsdown.config.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { defineConfig } from 'tsdown'
-
-export default defineConfig({
- entry: ['src/index.ts'],
- format: ['esm'],
- dts: {
- sourcemap: false,
- },
- clean: true,
- hash: false,
-})
diff --git a/packages/sdk/package.json b/packages/sdk/package.json
index e4bfd7a..2ba4784 100644
--- a/packages/sdk/package.json
+++ b/packages/sdk/package.json
@@ -25,8 +25,8 @@
"prepublishOnly": "bun run build"
},
"dependencies": {
- "@savoir/logger": "workspace:*",
"ai": "^6.0.49",
+ "evlog": "^1.0.0",
"zod": "^4.3.6"
},
"devDependencies": {
diff --git a/packages/sdk/src/client.ts b/packages/sdk/src/client.ts
index 843df0d..1e0834a 100644
--- a/packages/sdk/src/client.ts
+++ b/packages/sdk/src/client.ts
@@ -1,4 +1,4 @@
-import { createError } from '@savoir/logger'
+import { createError } from 'evlog'
import type {
ReadResponse,
SavoirConfig,