@opencode/util 0.0.0-dev-21581 → 0.0.0-dev-21590

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/flock.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { Effect } from "effect";
2
1
  export type FlockGlobal = {
3
2
  state: string;
4
3
  };
@@ -26,5 +25,4 @@ export declare namespace Flock {
26
25
  }
27
26
  function acquire(key: string, input?: Options): Promise<Lease>;
28
27
  function withLock<T>(key: string, fn: () => Promise<T>, input?: Options): Promise<T>;
29
- const effect: (key: string, input?: Options | undefined) => Effect.Effect<void, never, import("effect/Scope").Scope>;
30
28
  }
package/dist/flock.js CHANGED
@@ -3,7 +3,6 @@ import os from "os";
3
3
  import { randomBytes, randomUUID } from "crypto";
4
4
  import { mkdir, readFile, rm, stat, utimes, writeFile } from "fs/promises";
5
5
  import { Hash } from "./hash.js";
6
- import { Effect } from "effect";
7
6
  export var Flock;
8
7
  (function (Flock) {
9
8
  let global;
@@ -265,9 +264,4 @@ export var Flock;
265
264
  return await fn();
266
265
  }
267
266
  Flock.withLock = withLock;
268
- Flock.effect = Effect.fn("Flock.effect")(function* (key, input = {}) {
269
- return yield* Effect.acquireRelease(Effect.promise((signal) => Flock.acquire(key, { ...input, signal })).pipe(Effect.withSpan("Flock.acquire", {
270
- attributes: { key },
271
- })), (lock) => Effect.promise(() => lock.release()).pipe(Effect.withSpan("Flock.release"))).pipe(Effect.asVoid);
272
- });
273
267
  })(Flock || (Flock = {}));
package/dist/fs-util.d.ts CHANGED
@@ -42,97 +42,12 @@ export declare namespace FSUtil {
42
42
  const Service_base: Context.ServiceClass<Service, "@opencode/FSUtil", Interface>;
43
43
  export class Service extends Service_base {
44
44
  }
45
- export const use: {
46
- readonly access: (path: string, options?: {
47
- readonly ok?: boolean | undefined;
48
- readonly readable?: boolean | undefined;
49
- readonly writable?: boolean | undefined;
50
- } | undefined) => Effect.Effect<void, PlatformError, Service>;
51
- readonly copy: (fromPath: string, toPath: string, options?: {
52
- readonly overwrite?: boolean | undefined;
53
- readonly preserveTimestamps?: boolean | undefined;
54
- } | undefined) => Effect.Effect<void, PlatformError, Service>;
55
- readonly copyFile: (fromPath: string, toPath: string) => Effect.Effect<void, PlatformError, Service>;
56
- readonly chmod: (path: string, mode: number) => Effect.Effect<void, PlatformError, Service>;
57
- readonly chown: (path: string, uid: number, gid: number) => Effect.Effect<void, PlatformError, Service>;
58
- readonly glob: (pattern: string, options?: {
59
- readonly root?: string | undefined;
60
- readonly exclude?: ReadonlyArray<string> | undefined;
61
- } | undefined) => Effect.Effect<string[], PlatformError, Service>;
62
- readonly exists: (path: string) => Effect.Effect<boolean, PlatformError, Service>;
63
- readonly link: (fromPath: string, toPath: string) => Effect.Effect<void, PlatformError, Service>;
64
- readonly makeDirectory: (path: string, options?: {
65
- readonly recursive?: boolean | undefined;
66
- readonly mode?: number | undefined;
67
- } | undefined) => Effect.Effect<void, PlatformError, Service>;
68
- readonly makeTempDirectory: (options?: {
69
- readonly directory?: string | undefined;
70
- readonly prefix?: string | undefined;
71
- } | undefined) => Effect.Effect<string, PlatformError, Service>;
72
- readonly makeTempDirectoryScoped: (options?: {
73
- readonly directory?: string | undefined;
74
- readonly prefix?: string | undefined;
75
- } | undefined) => Effect.Effect<string, PlatformError, import("effect/Scope").Scope | Service>;
76
- readonly makeTempFile: (options?: {
77
- readonly directory?: string | undefined;
78
- readonly prefix?: string | undefined;
79
- readonly suffix?: string | undefined;
80
- } | undefined) => Effect.Effect<string, PlatformError, Service>;
81
- readonly makeTempFileScoped: (options?: {
82
- readonly directory?: string | undefined;
83
- readonly prefix?: string | undefined;
84
- readonly suffix?: string | undefined;
85
- } | undefined) => Effect.Effect<string, PlatformError, import("effect/Scope").Scope | Service>;
86
- readonly open: (path: string, options?: {
87
- readonly flag?: FileSystem.OpenFlag | undefined;
88
- readonly mode?: number | undefined;
89
- } | undefined) => Effect.Effect<FileSystem.File, PlatformError, import("effect/Scope").Scope | Service>;
90
- readonly readDirectory: (path: string, options?: {
91
- readonly recursive?: boolean | undefined;
92
- } | undefined) => Effect.Effect<string[], PlatformError, Service>;
93
- readonly readFile: (path: string) => Effect.Effect<Uint8Array<ArrayBufferLike>, PlatformError, Service>;
94
- readonly readFileString: (path: string, encoding?: string | undefined) => Effect.Effect<string, PlatformError, Service>;
95
- readonly readLink: (path: string) => Effect.Effect<string, PlatformError, Service>;
96
- readonly realPath: (path: string) => Effect.Effect<string, PlatformError, Service>;
97
- readonly remove: (path: string, options?: {
98
- readonly recursive?: boolean | undefined;
99
- readonly force?: boolean | undefined;
100
- } | undefined) => Effect.Effect<void, PlatformError, Service>;
101
- readonly rename: (oldPath: string, newPath: string) => Effect.Effect<void, PlatformError, Service>;
102
- readonly stat: (path: string) => Effect.Effect<FileSystem.File.Info, PlatformError, Service>;
103
- readonly symlink: (fromPath: string, toPath: string) => Effect.Effect<void, PlatformError, Service>;
104
- readonly truncate: (path: string, length?: number | undefined) => Effect.Effect<void, PlatformError, Service>;
105
- readonly utimes: (path: string, atime: number | Date, mtime: number | Date) => Effect.Effect<void, PlatformError, Service>;
106
- readonly writeFile: (path: string, data: Uint8Array<ArrayBufferLike>, options?: {
107
- readonly flag?: FileSystem.OpenFlag | undefined;
108
- readonly mode?: number | undefined;
109
- } | undefined) => Effect.Effect<void, PlatformError, Service>;
110
- readonly writeFileString: (path: string, data: string, options?: {
111
- readonly flag?: FileSystem.OpenFlag | undefined;
112
- readonly mode?: number | undefined;
113
- } | undefined) => Effect.Effect<void, PlatformError, Service>;
114
- readonly isDir: (path: string) => Effect.Effect<boolean, never, Service>;
115
- readonly isFile: (path: string) => Effect.Effect<boolean, never, Service>;
116
- readonly existsSafe: (path: string) => Effect.Effect<boolean, never, Service>;
117
- readonly readFileStringSafe: (path: string) => Effect.Effect<string | undefined, Error, Service>;
118
- readonly readJson: (path: string) => Effect.Effect<unknown, Error, Service>;
119
- readonly writeJson: (path: string, data: unknown, mode?: number | undefined) => Effect.Effect<void, Error, Service>;
120
- readonly ensureDir: (path: string) => Effect.Effect<void, Error, Service>;
121
- readonly writeWithDirs: (path: string, content: string | Uint8Array<ArrayBufferLike>, mode?: number | undefined) => Effect.Effect<void, Error, Service>;
122
- readonly readDirectoryEntries: (path: string) => Effect.Effect<DirEntry[], Error, Service>;
123
- readonly resolve: (path: string) => Effect.Effect<string, never, Service>;
124
- readonly findUp: (target: string, start: string, stop?: string | undefined) => Effect.Effect<string[], Error, Service>;
125
- readonly up: (options: UpOptions) => Effect.Effect<string[], Error, Service>;
126
- readonly globUp: (pattern: string, start: string, stop?: string | undefined) => Effect.Effect<string[], Error, Service>;
127
- readonly scan: (pattern: string, options?: Glob.Options | undefined) => Effect.Effect<string[], Error, Service>;
128
- };
129
45
  export const layer: Layer.Layer<Service, never, FileSystem.FileSystem>;
130
46
  export const node: import("./effect/layer-node.js").Provider<Service, never, import("./effect/layer-node.js").Tag<"global">>;
131
47
  /** Permission denial, including macOS sandbox and privacy denials that surface as Unknown with an EPERM cause. */
132
48
  export function isAccessDenied(error: PlatformError): boolean;
133
49
  export function mimeType(p: string): string;
134
50
  export function normalizePath(p: string): string;
135
- export function normalizePathPattern(p: string): string;
136
51
  export function resolve(p: string): string;
137
52
  export function windowsPath(p: string): string;
138
53
  export const ignoredDirectories: string[];
package/dist/fs-util.js CHANGED
@@ -4,7 +4,6 @@ import { readdir } from "fs/promises";
4
4
  import { lookup } from "mime-types";
5
5
  import { Context, Effect, FileSystem, Layer, Schema } from "effect";
6
6
  import { Glob } from "./glob.js";
7
- import { serviceUse } from "./effect/service-use.js";
8
7
  import { makeGlobalNode } from "./effect/app-node.js";
9
8
  import { filesystem } from "./effect/app-node-platform.js";
10
9
  import { sameDirectory } from "./path.js";
@@ -23,7 +22,6 @@ export var FSUtil;
23
22
  class Service extends Context.Service()("@opencode/FSUtil") {
24
23
  }
25
24
  FSUtil.Service = Service;
26
- FSUtil.use = serviceUse(Service);
27
25
  // Exported so simulation can wrap this layer and override the methods that
28
26
  // bypass the injected FileSystem (readDirectoryEntries, scan, globUp).
29
27
  FSUtil.layer = Layer.effect(Service, Effect.gen(function* () {
@@ -185,18 +183,6 @@ export var FSUtil;
185
183
  }
186
184
  }
187
185
  FSUtil.normalizePath = normalizePath;
188
- function normalizePathPattern(p) {
189
- if (process.platform !== "win32")
190
- return p;
191
- if (p === "*")
192
- return p;
193
- const match = p.match(/^(.*)[\\/]\*$/);
194
- if (!match)
195
- return normalizePath(p);
196
- const dir = /^[A-Za-z]:$/.test(match[1]) ? match[1] + "\\" : match[1];
197
- return join(normalizePath(dir), "*");
198
- }
199
- FSUtil.normalizePathPattern = normalizePathPattern;
200
186
  function resolve(p) {
201
187
  const resolved = path.resolve(windowsPath(p));
202
188
  try {
package/dist/glob.d.ts CHANGED
@@ -8,6 +8,5 @@ export declare namespace Glob {
8
8
  ignore?: string[];
9
9
  }
10
10
  function scan(pattern: string, options?: Options): Promise<string[]>;
11
- function scanSync(pattern: string, options?: Options): string[];
12
11
  function match(pattern: string, filepath: string): boolean;
13
12
  }
package/dist/glob.js CHANGED
@@ -1,4 +1,4 @@
1
- import { glob, globSync } from "glob";
1
+ import { glob } from "glob";
2
2
  import { minimatch } from "minimatch";
3
3
  export var Glob;
4
4
  (function (Glob) {
@@ -16,10 +16,6 @@ export var Glob;
16
16
  return glob(pattern, toGlobOptions(options));
17
17
  }
18
18
  Glob.scan = scan;
19
- function scanSync(pattern, options = {}) {
20
- return globSync(pattern, toGlobOptions(options));
21
- }
22
- Glob.scanSync = scanSync;
23
19
  function match(pattern, filepath) {
24
20
  return minimatch(filepath, pattern, { dot: true });
25
21
  }
package/dist/npm.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export * as Npm from "./npm.js";
2
2
  import { Effect, Schema, Context } from "effect";
3
3
  import { EffectFlock } from "./effect-flock.js";
4
- import { LayerNode } from "./effect/layer-node.js";
5
4
  declare const InstallFailedError_base: Schema.Class<InstallFailedError, Schema.TaggedStruct<"NpmInstallFailedError", {
6
5
  readonly add: Schema.optional<Schema.$Array<Schema.String>>;
7
6
  readonly dir: Schema.String;
@@ -29,9 +28,4 @@ export declare function sanitize(pkg: string): string;
29
28
  export declare function isRegistryPackage(pkg: string): Promise<boolean>;
30
29
  export declare function isInstallablePackage(pkg: string): Promise<boolean>;
31
30
  export declare function cacheKey(pkg: string): Promise<string>;
32
- export declare const node: LayerNode.Provider<Service, never, LayerNode.Tag<"global">>;
33
- export declare function add(...args: Parameters<Interface["add"]>): Promise<Package>;
34
- export declare function resolve(...args: Parameters<Interface["resolve"]>): Promise<Package>;
35
- export declare function check(...args: Parameters<Interface["check"]>): Promise<boolean>;
36
- export declare function update(...args: Parameters<Interface["update"]>): Promise<Package>;
37
- export declare function which(...args: Parameters<Interface["which"]>): Promise<string | undefined>;
31
+ export declare const node: import("./effect/layer-node.js").Provider<Service, never, import("./effect/layer-node.js").Tag<"global">>;
package/dist/npm.js CHANGED
@@ -7,8 +7,6 @@ import { Global } from "./global.js";
7
7
  import { EffectFlock } from "./effect-flock.js";
8
8
  import { makeGlobalNode } from "./effect/app-node.js";
9
9
  import { filesystem } from "./effect/app-node-platform.js";
10
- import { LayerNode } from "./effect/layer-node.js";
11
- import { makeRuntime } from "./effect/runtime.js";
12
10
  import { NpmConfig } from "./npm-config.js";
13
11
  export class InstallFailedError extends Schema.TaggedError()("NpmInstallFailedError", {
14
12
  add: Schema.Array(Schema.String).pipe(Schema.optional),
@@ -370,22 +368,6 @@ export const node = makeGlobalNode({
370
368
  layer: layer,
371
369
  deps: [FSUtil.node, Global.node, filesystem, EffectFlock.node],
372
370
  });
373
- const { runPromise } = makeRuntime(Service, LayerNode.compile(node));
374
- export async function add(...args) {
375
- return runPromise((svc) => svc.add(...args));
376
- }
377
- export async function resolve(...args) {
378
- return runPromise((svc) => svc.resolve(...args));
379
- }
380
- export async function check(...args) {
381
- return runPromise((svc) => svc.check(...args));
382
- }
383
- export async function update(...args) {
384
- return runPromise((svc) => svc.update(...args));
385
- }
386
- export async function which(...args) {
387
- return runPromise((svc) => svc.which(...args));
388
- }
389
371
  function gitRevision(resolved) {
390
372
  return resolved?.match(/#([a-f0-9]{40}|[a-f0-9]{64})(?=::|$)/i)?.[1];
391
373
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode/util",
4
- "version": "0.0.0-dev-21581",
4
+ "version": "0.0.0-dev-21590",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -1,2 +0,0 @@
1
- import { Layer } from "effect";
2
- export declare const memoMap: Layer.MemoMap;
@@ -1,2 +0,0 @@
1
- import { Layer } from "effect";
2
- export const memoMap = Layer.makeMemoMapUnsafe();
@@ -1,8 +0,0 @@
1
- import { Layer, type Context, type Effect } from "effect";
2
- export declare function makeRuntime<I, S, E>(service: Context.Service<I, S>, layer: Layer.Layer<I, E>): {
3
- runSync: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>) => A;
4
- runPromiseExit: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>, options?: Effect.RunOptions) => Promise<import("effect/Exit").Exit<A, E | Err>>;
5
- runPromise: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>, options?: Effect.RunOptions) => Promise<A>;
6
- runFork: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>) => import("effect/Fiber").Fiber<A, E | Err>;
7
- runCallback: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>) => (interruptor?: number | undefined) => void;
8
- };
@@ -1,16 +0,0 @@
1
- import { Layer, ManagedRuntime } from "effect";
2
- import { memoMap } from "./memo-map.js";
3
- import { Observability } from "../observability.js";
4
- export function makeRuntime(service, layer) {
5
- let rt;
6
- const getRuntime = () => (rt ??= ManagedRuntime.make(Layer.provideMerge(layer, Observability.layer()), {
7
- memoMap,
8
- }));
9
- return {
10
- runSync: (fn) => getRuntime().runSync(service.use(fn)),
11
- runPromiseExit: (fn, options) => getRuntime().runPromiseExit(service.use(fn), options),
12
- runPromise: (fn, options) => getRuntime().runPromise(service.use(fn), options),
13
- runFork: (fn) => getRuntime().runFork(service.use(fn)),
14
- runCallback: (fn) => getRuntime().runCallback(service.use(fn)),
15
- };
16
- }
@@ -1,7 +0,0 @@
1
- import { Context, Effect } from "effect";
2
- type EffectMethod = (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>;
3
- type ServiceUse<Identifier, Shape> = {
4
- readonly [Key in keyof Shape as Shape[Key] extends EffectMethod ? Key : never]: Shape[Key] extends (...args: infer Args) => infer Return ? Args extends ReadonlyArray<unknown> ? Return extends Effect.Effect<infer A, infer E, infer R> ? (...args: Args) => Effect.Effect<A, E, R | Identifier> : never : never : never;
5
- };
6
- export declare const serviceUse: <Identifier, Shape>(tag: Context.Service<Identifier, Shape>) => ServiceUse<Identifier, Shape>;
7
- export {};
@@ -1,27 +0,0 @@
1
- import { Context, Effect } from "effect";
2
- export const serviceUse = (tag) => {
3
- const cache = new Map();
4
- // This is the only dynamic boundary: TypeScript knows the accessor shape,
5
- // but Proxy property names are runtime values.
6
- const access = new Proxy({}, {
7
- get: (_, key) => {
8
- if (typeof key !== "string")
9
- return undefined;
10
- const cached = cache.get(key);
11
- if (cached)
12
- return cached;
13
- const accessor = (...args) => tag.use((service) => {
14
- // oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- Proxy keys are checked at runtime.
15
- const method = service[key];
16
- if (typeof method !== "function")
17
- return Effect.die(new Error(`Service method not found: ${key}`));
18
- // oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- ServiceUse exposes only Effect-returning methods.
19
- return method(...args);
20
- });
21
- cache.set(key, accessor);
22
- return accessor;
23
- },
24
- });
25
- // oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- Proxy implements the mapped accessor surface lazily.
26
- return access;
27
- };