refactor(core): replace legacy logger with Effect logging (#31310)

This commit is contained in:
Dax
2026-06-08 15:41:56 -04:00
committed by GitHub
parent 0a7cb20e66
commit c06ad7c881
152 changed files with 698 additions and 2243 deletions
+11 -18
View File
@@ -4,7 +4,6 @@ import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } fr
import { withTransientReadRetry } from "@/util/effect-http-client"
import { FSUtil } from "@opencode-ai/core/fs-util"
import { Global } from "@opencode-ai/core/global"
import * as Log from "@opencode-ai/core/util/log"
const skillConcurrency = 4
const fileConcurrency = 8
@@ -27,7 +26,6 @@ export class Service extends Context.Service<Service, Interface>()("@opencode/Sk
export const layer: Layer.Layer<Service, never, FSUtil.Service | Path.Path | HttpClient.HttpClient> = Layer.effect(
Service,
Effect.gen(function* () {
const log = Log.create({ service: "skill-discovery" })
const fs = yield* FSUtil.Service
const path = yield* Path.Path
const http = HttpClient.filterStatusOk(withTransientReadRetry(yield* HttpClient.HttpClient))
@@ -42,10 +40,7 @@ export const layer: Layer.Layer<Service, never, FSUtil.Service | Path.Path | Htt
Effect.flatMap((body) => fs.writeWithDirs(dest, new Uint8Array(body))),
Effect.as(true),
Effect.catch((err) =>
Effect.sync(() => {
log.error("failed to download", { url, err })
return false
}),
Effect.logError("failed to download", { url: url, error: err }).pipe(Effect.as(false)),
),
)
})
@@ -55,29 +50,27 @@ export const layer: Layer.Layer<Service, never, FSUtil.Service | Path.Path | Htt
const index = new URL("index.json", base).href
const host = base.slice(0, -1)
log.info("fetching index", { url: index })
yield* Effect.logInfo("fetching index", { url: index })
const data = yield* HttpClientRequest.get(index).pipe(
HttpClientRequest.acceptJson,
http.execute,
Effect.flatMap(HttpClientResponse.schemaBodyJson(Index)),
Effect.catch((err) =>
Effect.sync(() => {
log.error("failed to fetch index", { url: index, err })
return null
}),
Effect.logError("failed to fetch index", { url: index, error: err }).pipe(Effect.as(null)),
),
)
if (!data) return []
const list = data.skills.filter((skill) => {
if (!skill.files.includes("SKILL.md")) {
log.warn("skill entry missing SKILL.md", { url: index, skill: skill.name })
return false
}
return true
})
const missing = data.skills.filter((skill) => !skill.files.includes("SKILL.md"))
yield* Effect.forEach(
missing,
(skill) =>
Effect.logWarning("skill entry missing SKILL.md", { url: index, skill: skill.name }),
{ discard: true },
)
const list = data.skills.filter((skill) => skill.files.includes("SKILL.md"))
const dirs = yield* Effect.forEach(
list,