/** * Glob pattern matching service. * * @since 4.0.0 */ import * as Context from "effect/Context" import * as Data from "effect/Data" import * as Effect from "effect/Effect" import * as Layer from "effect/Layer" import * as GlobLib from "glob" /** * Error during glob pattern matching. * * @category errors * @since 4.0.0 */ export class GlobError extends Data.TaggedError("GlobError")<{ readonly pattern: string | ReadonlyArray readonly cause: unknown }> {} /** * Service for glob pattern matching. * * @category models * @since 4.0.0 */ export interface Glob { readonly glob: ( pattern: string | ReadonlyArray, options?: GlobLib.GlobOptions ) => Effect.Effect, GlobError> } /** * Service tag for glob pattern matching used by AI codegen tooling. * * @category services * @since 4.0.0 */ export const Glob: Context.Service = Context.Service("@effect/ai-codegen/Glob") /** * Layer providing the Glob service. * * @category layers * @since 4.0.0 */ export const layer: Layer.Layer = Layer.succeed(Glob, { glob: (pattern, options) => Effect.tryPromise({ try: () => GlobLib.glob(pattern as string | Array, options ?? {}) as Promise>, catch: (cause) => new GlobError({ pattern, cause }) }) })