alchemylab-opencode 1.0.18 → 1.0.19

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.
Files changed (68) hide show
  1. package/dist/{arktype-aI7TBD0R-HX4BR3RX.js → arktype-aI7TBD0R-LH6JTJZZ.js} +2 -2
  2. package/dist/{arktype-aI7TBD0R-HX4BR3RX.js.map → arktype-aI7TBD0R-LH6JTJZZ.js.map} +1 -1
  3. package/dist/chunk-2FM4SJ4F.js +506 -0
  4. package/dist/chunk-2FM4SJ4F.js.map +7 -0
  5. package/dist/{chunk-O5VWOPCL.js → chunk-4UCKACGO.js} +2 -2
  6. package/dist/{chunk-O5VWOPCL.js.map → chunk-4UCKACGO.js.map} +1 -1
  7. package/dist/{chunk-VL3RSEZ2.js → chunk-AHJSL352.js} +9 -9
  8. package/dist/{chunk-VL3RSEZ2.js.map → chunk-AHJSL352.js.map} +1 -1
  9. package/dist/{chunk-S3PMXQSO.js → chunk-ASJTXZ3G.js} +9 -7
  10. package/dist/{chunk-S3PMXQSO.js.map → chunk-ASJTXZ3G.js.map} +1 -1
  11. package/dist/{chunk-PWFRMDDF.js → chunk-BGADAZN4.js} +1 -1
  12. package/dist/{chunk-YX3AWX2A.js → chunk-E2D2QSW7.js} +67 -12
  13. package/dist/chunk-E2D2QSW7.js.map +7 -0
  14. package/dist/{chunk-3AF5MXLF.js → chunk-FXA7YNMN.js} +5 -5
  15. package/dist/{chunk-3AF5MXLF.js.map → chunk-FXA7YNMN.js.map} +1 -1
  16. package/dist/{chunk-FMP3YLWX.js → chunk-H5AN6PD4.js} +4 -4
  17. package/dist/{chunk-FMP3YLWX.js.map → chunk-H5AN6PD4.js.map} +1 -1
  18. package/dist/{chunk-6UDEKTJV.js → chunk-PV6JYN6T.js} +287 -24
  19. package/dist/chunk-PV6JYN6T.js.map +7 -0
  20. package/dist/{chunk-SNATISLF.js → chunk-RYVKLRJZ.js} +7 -5
  21. package/dist/{chunk-SNATISLF.js.map → chunk-RYVKLRJZ.js.map} +1 -1
  22. package/dist/{chunk-J4KUHHYM.js → chunk-SZM3G6UF.js} +151 -583
  23. package/dist/chunk-SZM3G6UF.js.map +7 -0
  24. package/dist/{chunk-Z6HKGDR4.js → chunk-WHJ5FGUS.js} +43 -15
  25. package/dist/chunk-WHJ5FGUS.js.map +7 -0
  26. package/dist/{default-u_dwuiYb-WOFHQQ3K.js → default-u_dwuiYb-644FBWJS.js} +5 -5
  27. package/dist/{effect-QlVUlMFu-UERLUUQW.js → effect-QlVUlMFu-GLKKNZAC.js} +3 -3
  28. package/dist/{effect-QlVUlMFu-UERLUUQW.js.map → effect-QlVUlMFu-GLKKNZAC.js.map} +1 -1
  29. package/dist/log-TOR3B2F5.js +19 -0
  30. package/dist/{mcp-4SNUY4OD.js → mcp-W2Z3DXFD.js} +4 -3
  31. package/dist/{registry-EQ7TBD6Z.js → registry-FWM7Q3YW.js} +5 -4
  32. package/dist/{run-XIMVXVMO.js → run-PMUMTYTZ.js} +13 -11
  33. package/dist/{run-XIMVXVMO.js.map → run-PMUMTYTZ.js.map} +1 -1
  34. package/dist/{run-service-RE7EK2UK.js → run-service-B4BDQWO3.js} +3 -2
  35. package/dist/run.js +1 -1
  36. package/dist/serve.js +5 -1
  37. package/dist/serve.js.map +2 -2
  38. package/dist/{server-P3JM3FFL.js → server-HETOVWO6.js} +11 -10
  39. package/dist/{session-FV32QIWG.js → session-37HDF4U2.js} +5 -4
  40. package/dist/{share-next-MK3GU4BJ.js → share-next-MP7REE74.js} +6 -5
  41. package/dist/share-next-MP7REE74.js.map +7 -0
  42. package/dist/{sury-CWZTCd75-XC3NCMTP.js → sury-CWZTCd75-SVV5EKIT.js} +3 -3
  43. package/dist/{sury-CWZTCd75-XC3NCMTP.js.map → sury-CWZTCd75-SVV5EKIT.js.map} +1 -1
  44. package/dist/{typebox-Dei93FPO-QOBKW4L7.js → typebox-Dei93FPO-LMTONO64.js} +2 -2
  45. package/dist/{typebox-Dei93FPO-QOBKW4L7.js.map → typebox-Dei93FPO-LMTONO64.js.map} +1 -1
  46. package/dist/{valibot--1zFm7rT-LHHLSLYY.js → valibot--1zFm7rT-HRT4VHTJ.js} +3 -3
  47. package/dist/{valibot--1zFm7rT-LHHLSLYY.js.map → valibot--1zFm7rT-HRT4VHTJ.js.map} +1 -1
  48. package/dist/{valibot-D_HTw1Gn-UR62BIDY.js → valibot-D_HTw1Gn-SZJR3J76.js} +5 -5
  49. package/dist/{valibot-D_HTw1Gn-UR62BIDY.js.map → valibot-D_HTw1Gn-SZJR3J76.js.map} +1 -1
  50. package/dist/{worktree-N3PSXGW4.js → worktree-ADWVQ6IR.js} +7 -6
  51. package/dist/{worktree-N3PSXGW4.js.map → worktree-ADWVQ6IR.js.map} +1 -1
  52. package/dist/{zod-Bwrt9trS-J2GOMA2R.js → zod-Bwrt9trS-5S7UQQDY.js} +3 -3
  53. package/dist/{zod-Bwrt9trS-J2GOMA2R.js.map → zod-Bwrt9trS-5S7UQQDY.js.map} +1 -1
  54. package/dist/{zod-DSgpEGAE-VTXQW6SB.js → zod-DSgpEGAE-X2KPFU7C.js} +7 -7
  55. package/dist/{zod-DSgpEGAE-VTXQW6SB.js.map → zod-DSgpEGAE-X2KPFU7C.js.map} +1 -1
  56. package/package.json +9 -4
  57. package/dist/chunk-6UDEKTJV.js.map +0 -7
  58. package/dist/chunk-J4KUHHYM.js.map +0 -7
  59. package/dist/chunk-YX3AWX2A.js.map +0 -7
  60. package/dist/chunk-Z6HKGDR4.js.map +0 -7
  61. /package/dist/{chunk-PWFRMDDF.js.map → chunk-BGADAZN4.js.map} +0 -0
  62. /package/dist/{default-u_dwuiYb-WOFHQQ3K.js.map → default-u_dwuiYb-644FBWJS.js.map} +0 -0
  63. /package/dist/{mcp-4SNUY4OD.js.map → log-TOR3B2F5.js.map} +0 -0
  64. /package/dist/{registry-EQ7TBD6Z.js.map → mcp-W2Z3DXFD.js.map} +0 -0
  65. /package/dist/{run-service-RE7EK2UK.js.map → registry-FWM7Q3YW.js.map} +0 -0
  66. /package/dist/{server-P3JM3FFL.js.map → run-service-B4BDQWO3.js.map} +0 -0
  67. /package/dist/{session-FV32QIWG.js.map → server-HETOVWO6.js.map} +0 -0
  68. /package/dist/{share-next-MK3GU4BJ.js.map → session-37HDF4U2.js.map} +0 -0
@@ -12,6 +12,12 @@ if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) =
12
12
  import {
13
13
  withStatics
14
14
  } from "./chunk-BI5OUHTQ.js";
15
+ import {
16
+ Filesystem,
17
+ Glob,
18
+ Global,
19
+ Log
20
+ } from "./chunk-2FM4SJ4F.js";
15
21
  import {
16
22
  __export,
17
23
  __reExport
@@ -36,445 +42,11 @@ async function disposeInstance(directory) {
36
42
  await Promise.allSettled([...disposers].map((disposer) => disposer(directory)));
37
43
  }
38
44
 
39
- // packages/opencode/src/util/filesystem.ts
40
- import { chmod, mkdir, readFile, stat as statFile, writeFile } from "fs/promises";
41
- import { createWriteStream, existsSync, statSync } from "fs";
42
- import { lookup } from "mime-types";
43
- import { realpathSync } from "fs";
44
- import { dirname, join, relative, resolve as pathResolve, win32 } from "path";
45
- import { Readable } from "stream";
46
- import { pipeline } from "stream/promises";
47
-
48
- // packages/opencode/src/util/glob.ts
49
- import { glob, globSync } from "glob";
50
- import { minimatch } from "minimatch";
51
- var Glob;
52
- ((Glob2) => {
53
- function toGlobOptions(options) {
54
- return {
55
- cwd: options.cwd,
56
- absolute: options.absolute,
57
- dot: options.dot,
58
- follow: options.symlink ?? false,
59
- nodir: options.include !== "all"
60
- };
61
- }
62
- async function scan(pattern, options = {}) {
63
- return glob(pattern, toGlobOptions(options));
64
- }
65
- Glob2.scan = scan;
66
- function scanSync(pattern, options = {}) {
67
- return globSync(pattern, toGlobOptions(options));
68
- }
69
- Glob2.scanSync = scanSync;
70
- function match(pattern, filepath) {
71
- return minimatch(filepath, pattern, { dot: true });
72
- }
73
- Glob2.match = match;
74
- })(Glob || (Glob = {}));
75
-
76
- // packages/opencode/src/util/filesystem.ts
77
- var Filesystem;
78
- ((Filesystem2) => {
79
- async function exists(p) {
80
- return existsSync(p);
81
- }
82
- Filesystem2.exists = exists;
83
- async function isDir(p) {
84
- try {
85
- return statSync(p).isDirectory();
86
- } catch {
87
- return false;
88
- }
89
- }
90
- Filesystem2.isDir = isDir;
91
- function stat(p) {
92
- return statSync(p, { throwIfNoEntry: false }) ?? void 0;
93
- }
94
- Filesystem2.stat = stat;
95
- async function statAsync(p) {
96
- return statFile(p).catch((e) => {
97
- if (isEnoent(e)) return void 0;
98
- throw e;
99
- });
100
- }
101
- Filesystem2.statAsync = statAsync;
102
- async function size(p) {
103
- const s = stat(p)?.size ?? 0;
104
- return typeof s === "bigint" ? Number(s) : s;
105
- }
106
- Filesystem2.size = size;
107
- async function readText(p) {
108
- return readFile(p, "utf-8");
109
- }
110
- Filesystem2.readText = readText;
111
- async function readJson(p) {
112
- return JSON.parse(await readFile(p, "utf-8"));
113
- }
114
- Filesystem2.readJson = readJson;
115
- async function readBytes(p) {
116
- return readFile(p);
117
- }
118
- Filesystem2.readBytes = readBytes;
119
- async function readArrayBuffer(p) {
120
- const buf = await readFile(p);
121
- return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
122
- }
123
- Filesystem2.readArrayBuffer = readArrayBuffer;
124
- function isEnoent(e) {
125
- return typeof e === "object" && e !== null && "code" in e && e.code === "ENOENT";
126
- }
127
- async function write(p, content, mode) {
128
- try {
129
- if (mode) {
130
- await writeFile(p, content, { mode });
131
- } else {
132
- await writeFile(p, content);
133
- }
134
- } catch (e) {
135
- if (isEnoent(e)) {
136
- await mkdir(dirname(p), { recursive: true });
137
- if (mode) {
138
- await writeFile(p, content, { mode });
139
- } else {
140
- await writeFile(p, content);
141
- }
142
- return;
143
- }
144
- throw e;
145
- }
146
- }
147
- Filesystem2.write = write;
148
- async function writeJson(p, data2, mode) {
149
- return write(p, JSON.stringify(data2, null, 2), mode);
150
- }
151
- Filesystem2.writeJson = writeJson;
152
- async function writeStream(p, stream, mode) {
153
- const dir = dirname(p);
154
- if (!existsSync(dir)) {
155
- await mkdir(dir, { recursive: true });
156
- }
157
- const nodeStream = stream instanceof ReadableStream ? Readable.fromWeb(stream) : stream;
158
- const writeStream2 = createWriteStream(p);
159
- await pipeline(nodeStream, writeStream2);
160
- if (mode) {
161
- await chmod(p, mode);
162
- }
163
- }
164
- Filesystem2.writeStream = writeStream;
165
- function mimeType(p) {
166
- return lookup(p) || "application/octet-stream";
167
- }
168
- Filesystem2.mimeType = mimeType;
169
- function normalizePath(p) {
170
- if (process.platform !== "win32") return p;
171
- const resolved = win32.normalize(win32.resolve(windowsPath(p)));
172
- try {
173
- return realpathSync.native(resolved);
174
- } catch {
175
- return resolved;
176
- }
177
- }
178
- Filesystem2.normalizePath = normalizePath;
179
- function normalizePathPattern(p) {
180
- if (process.platform !== "win32") return p;
181
- if (p === "*") return p;
182
- const match = p.match(/^(.*)[\\/]\*$/);
183
- if (!match) return normalizePath(p);
184
- const dir = /^[A-Za-z]:$/.test(match[1]) ? match[1] + "\\" : match[1];
185
- return join(normalizePath(dir), "*");
186
- }
187
- Filesystem2.normalizePathPattern = normalizePathPattern;
188
- function resolve(p) {
189
- const resolved = pathResolve(windowsPath(p));
190
- try {
191
- return normalizePath(realpathSync(resolved));
192
- } catch (e) {
193
- if (isEnoent(e)) return normalizePath(resolved);
194
- throw e;
195
- }
196
- }
197
- Filesystem2.resolve = resolve;
198
- function windowsPath(p) {
199
- if (process.platform !== "win32") return p;
200
- return p.replace(/^\/([a-zA-Z]):(?:[\\/]|$)/, (_, drive) => `${drive.toUpperCase()}:/`).replace(/^\/([a-zA-Z])(?:\/|$)/, (_, drive) => `${drive.toUpperCase()}:/`).replace(/^\/cygdrive\/([a-zA-Z])(?:\/|$)/, (_, drive) => `${drive.toUpperCase()}:/`).replace(/^\/mnt\/([a-zA-Z])(?:\/|$)/, (_, drive) => `${drive.toUpperCase()}:/`);
201
- }
202
- Filesystem2.windowsPath = windowsPath;
203
- function overlaps(a, b) {
204
- const relA = relative(a, b);
205
- const relB = relative(b, a);
206
- return !relA || !relA.startsWith("..") || !relB || !relB.startsWith("..");
207
- }
208
- Filesystem2.overlaps = overlaps;
209
- function contains(parent, child) {
210
- return !relative(parent, child).startsWith("..");
211
- }
212
- Filesystem2.contains = contains;
213
- async function findUp(target, start, stop, options) {
214
- const dirs = [start];
215
- let current = start;
216
- while (true) {
217
- if (stop === current) break;
218
- const parent = dirname(current);
219
- if (parent === current) break;
220
- dirs.push(parent);
221
- current = parent;
222
- }
223
- const targets = Array.isArray(target) ? target : [target];
224
- const result = [];
225
- for (const dir of options?.rootFirst ? dirs.toReversed() : dirs) {
226
- for (const item of targets) {
227
- const search = join(dir, item);
228
- if (await exists(search)) result.push(search);
229
- }
230
- }
231
- return result;
232
- }
233
- Filesystem2.findUp = findUp;
234
- async function* up(options) {
235
- const { targets, start, stop } = options;
236
- let current = start;
237
- while (true) {
238
- for (const target of targets) {
239
- const search = join(current, target);
240
- if (await exists(search)) yield search;
241
- }
242
- if (stop === current) break;
243
- const parent = dirname(current);
244
- if (parent === current) break;
245
- current = parent;
246
- }
247
- }
248
- Filesystem2.up = up;
249
- async function globUp(pattern, start, stop) {
250
- let current = start;
251
- const result = [];
252
- while (true) {
253
- try {
254
- const matches = await Glob.scan(pattern, {
255
- cwd: current,
256
- absolute: true,
257
- include: "file",
258
- dot: true
259
- });
260
- result.push(...matches);
261
- } catch {
262
- }
263
- if (stop === current) break;
264
- const parent = dirname(current);
265
- if (parent === current) break;
266
- current = parent;
267
- }
268
- return result;
269
- }
270
- Filesystem2.globUp = globUp;
271
- })(Filesystem || (Filesystem = {}));
272
-
273
45
  // packages/opencode/src/util/iife.ts
274
46
  function iife(fn) {
275
47
  return fn();
276
48
  }
277
49
 
278
- // packages/opencode/src/util/log.ts
279
- import path2 from "path";
280
- import fs2 from "fs/promises";
281
- import { createWriteStream as createWriteStream2 } from "fs";
282
-
283
- // packages/opencode/src/global/index.ts
284
- import fs from "fs/promises";
285
- import { xdgData, xdgCache, xdgConfig, xdgState } from "xdg-basedir";
286
- import path from "path";
287
- import os from "os";
288
- var app = "opencode";
289
- var customDataDir = process.env["OPENCODE_DATA_DIR"];
290
- var data = customDataDir || path.join(xdgData, app);
291
- var globalData = path.join(xdgData, app);
292
- var cache = path.join(xdgCache, app);
293
- var config = path.join(xdgConfig, app);
294
- var state = customDataDir ? path.join(customDataDir, "state") : path.join(xdgState, app);
295
- var Global;
296
- ((Global2) => {
297
- Global2.Path = {
298
- // Allow override via OPENCODE_TEST_HOME for test isolation
299
- get home() {
300
- return process.env.OPENCODE_TEST_HOME || os.homedir();
301
- },
302
- data,
303
- globalData,
304
- // user-global data dir (for auth, credentials — not affected by OPENCODE_DATA_DIR)
305
- bin: path.join(cache, "bin"),
306
- log: path.join(data, "log"),
307
- cache,
308
- config,
309
- state
310
- };
311
- })(Global || (Global = {}));
312
- await Promise.all([
313
- fs.mkdir(Global.Path.data, { recursive: true }),
314
- fs.mkdir(Global.Path.config, { recursive: true }),
315
- fs.mkdir(Global.Path.state, { recursive: true }),
316
- fs.mkdir(Global.Path.log, { recursive: true }),
317
- fs.mkdir(Global.Path.bin, { recursive: true })
318
- ]);
319
- var CACHE_VERSION = "21";
320
- var version = await Filesystem.readText(path.join(Global.Path.cache, "version")).catch(() => "0");
321
- if (version !== CACHE_VERSION) {
322
- try {
323
- const contents = await fs.readdir(Global.Path.cache);
324
- await Promise.all(
325
- contents.map(
326
- (item) => fs.rm(path.join(Global.Path.cache, item), {
327
- recursive: true,
328
- force: true
329
- })
330
- )
331
- );
332
- } catch (e) {
333
- }
334
- await Filesystem.write(path.join(Global.Path.cache, "version"), CACHE_VERSION);
335
- }
336
-
337
- // packages/opencode/src/util/log.ts
338
- import z from "zod";
339
- var Log;
340
- ((Log2) => {
341
- Log2.Level = z.enum(["DEBUG", "INFO", "WARN", "ERROR"]).meta({ ref: "LogLevel", description: "Log level" });
342
- const levelPriority = {
343
- DEBUG: 0,
344
- INFO: 1,
345
- WARN: 2,
346
- ERROR: 3
347
- };
348
- let level = "INFO";
349
- function shouldLog(input) {
350
- return levelPriority[input] >= levelPriority[level];
351
- }
352
- const loggers = /* @__PURE__ */ new Map();
353
- Log2.Default = create({ service: "default" });
354
- let logpath = "";
355
- function file() {
356
- return logpath;
357
- }
358
- Log2.file = file;
359
- let write = (msg) => {
360
- process.stderr.write(msg);
361
- return msg.length;
362
- };
363
- async function init2(options) {
364
- if (options.level) level = options.level;
365
- cleanup(Global.Path.log);
366
- if (options.print) return;
367
- logpath = path2.join(
368
- Global.Path.log,
369
- options.dev ? "dev.log" : (/* @__PURE__ */ new Date()).toISOString().split(".")[0].replace(/:/g, "") + ".log"
370
- );
371
- await fs2.truncate(logpath).catch(() => {
372
- });
373
- const stream = createWriteStream2(logpath, { flags: "a" });
374
- write = async (msg) => {
375
- return new Promise((resolve, reject) => {
376
- stream.write(msg, (err) => {
377
- if (err) reject(err);
378
- else resolve(msg.length);
379
- });
380
- });
381
- };
382
- }
383
- Log2.init = init2;
384
- async function cleanup(dir) {
385
- const files = await Glob.scan("????-??-??T??????.log", {
386
- cwd: dir,
387
- absolute: true,
388
- include: "file"
389
- });
390
- if (files.length <= 5) return;
391
- const filesToDelete = files.slice(0, -10);
392
- await Promise.all(filesToDelete.map((file2) => fs2.unlink(file2).catch(() => {
393
- })));
394
- }
395
- function formatError(error, depth = 0) {
396
- const result = error.message;
397
- return error.cause instanceof Error && depth < 10 ? result + " Caused by: " + formatError(error.cause, depth + 1) : result;
398
- }
399
- let last = Date.now();
400
- function create(tags) {
401
- tags = tags || {};
402
- const service = tags["service"];
403
- if (service && typeof service === "string") {
404
- const cached = loggers.get(service);
405
- if (cached) {
406
- return cached;
407
- }
408
- }
409
- function build(message, extra) {
410
- const prefix = Object.entries({
411
- ...tags,
412
- ...extra
413
- }).filter(([_, value]) => value !== void 0 && value !== null).map(([key, value]) => {
414
- const prefix2 = `${key}=`;
415
- if (value instanceof Error) return prefix2 + formatError(value);
416
- if (typeof value === "object") return prefix2 + JSON.stringify(value);
417
- return prefix2 + value;
418
- }).join(" ");
419
- const next = /* @__PURE__ */ new Date();
420
- const diff = next.getTime() - last;
421
- last = next.getTime();
422
- return [next.toISOString().split(".")[0], "+" + diff + "ms", prefix, message].filter(Boolean).join(" ") + "\n";
423
- }
424
- const result = {
425
- debug(message, extra) {
426
- if (shouldLog("DEBUG")) {
427
- write("DEBUG " + build(message, extra));
428
- }
429
- },
430
- info(message, extra) {
431
- if (shouldLog("INFO")) {
432
- write("INFO " + build(message, extra));
433
- }
434
- },
435
- error(message, extra) {
436
- if (shouldLog("ERROR")) {
437
- write("ERROR " + build(message, extra));
438
- }
439
- },
440
- warn(message, extra) {
441
- if (shouldLog("WARN")) {
442
- write("WARN " + build(message, extra));
443
- }
444
- },
445
- tag(key, value) {
446
- if (tags) tags[key] = value;
447
- return result;
448
- },
449
- clone() {
450
- return Log2.create({ ...tags });
451
- },
452
- time(message, extra) {
453
- const now = Date.now();
454
- result.info(message, { status: "started", ...extra });
455
- function stop() {
456
- result.info(message, {
457
- status: "completed",
458
- duration: Date.now() - now,
459
- ...extra
460
- });
461
- }
462
- return {
463
- stop,
464
- [Symbol.dispose]() {
465
- stop();
466
- }
467
- };
468
- }
469
- };
470
- if (service && typeof service === "string") {
471
- loggers.set(service, result);
472
- }
473
- return result;
474
- }
475
- Log2.create = create;
476
- })(Log || (Log = {}));
477
-
478
50
  // packages/opencode/src/util/context.ts
479
51
  import { AsyncLocalStorage } from "async_hooks";
480
52
  var Context;
@@ -506,7 +78,7 @@ var Context;
506
78
  })(Context || (Context = {}));
507
79
 
508
80
  // packages/opencode/src/project/project.ts
509
- import z6 from "zod";
81
+ import z5 from "zod";
510
82
 
511
83
  // packages/opencode/src/storage/db.ts
512
84
  var db_exports = {};
@@ -540,19 +112,19 @@ function lazy(fn) {
540
112
  }
541
113
 
542
114
  // packages/util/src/error.ts
543
- import z2 from "zod";
115
+ import z from "zod";
544
116
  var NamedError = class _NamedError extends Error {
545
- static create(name, data2) {
546
- const schema = z2.object({
547
- name: z2.literal(name),
548
- data: data2
117
+ static create(name, data) {
118
+ const schema = z.object({
119
+ name: z.literal(name),
120
+ data
549
121
  }).meta({
550
122
  ref: name
551
123
  });
552
124
  const result = class extends _NamedError {
553
- constructor(data3, options) {
125
+ constructor(data2, options) {
554
126
  super(name, options);
555
- this.data = data3;
127
+ this.data = data2;
556
128
  this.name = name;
557
129
  }
558
130
  data;
@@ -576,16 +148,16 @@ var NamedError = class _NamedError extends Error {
576
148
  }
577
149
  static Unknown = _NamedError.create(
578
150
  "UnknownError",
579
- z2.object({
580
- message: z2.string()
151
+ z.object({
152
+ message: z.string()
581
153
  })
582
154
  );
583
155
  };
584
156
 
585
157
  // packages/opencode/src/storage/db.ts
586
- import z3 from "zod";
587
- import path3 from "path";
588
- import { readFileSync, readdirSync, existsSync as existsSync2 } from "fs";
158
+ import z2 from "zod";
159
+ import path from "path";
160
+ import { readFileSync, readdirSync, existsSync } from "fs";
589
161
 
590
162
  // packages/opencode/src/flag/flag.ts
591
163
  import { Config } from "effect";
@@ -736,17 +308,17 @@ var InstanceState;
736
308
  });
737
309
  InstanceState2.directory = Effect.map(InstanceState2.context, (ctx) => ctx.directory);
738
310
  InstanceState2.make = (init2) => Effect.gen(function* () {
739
- const cache3 = yield* ScopedCache.make({
311
+ const cache2 = yield* ScopedCache.make({
740
312
  capacity: Number.POSITIVE_INFINITY,
741
313
  lookup: () => Effect.gen(function* () {
742
314
  return yield* init2(yield* InstanceState2.context);
743
315
  })
744
316
  });
745
- const off = registerDisposer((directory2) => Effect.runPromise(ScopedCache.invalidate(cache3, directory2)));
317
+ const off = registerDisposer((directory2) => Effect.runPromise(ScopedCache.invalidate(cache2, directory2)));
746
318
  yield* Effect.addFinalizer(() => Effect.sync(off));
747
319
  return {
748
320
  [TypeId]: TypeId,
749
- cache: cache3
321
+ cache: cache2
750
322
  };
751
323
  });
752
324
  InstanceState2.get = (self) => Effect.gen(function* () {
@@ -766,8 +338,8 @@ var InstanceState;
766
338
  // packages/opencode/src/storage/db.node.ts
767
339
  import { DatabaseSync } from "node:sqlite";
768
340
  import { drizzle } from "drizzle-orm/node-sqlite";
769
- function init(path5) {
770
- const sqlite = new DatabaseSync(path5);
341
+ function init(path3) {
342
+ const sqlite = new DatabaseSync(path3);
771
343
  const db = drizzle({ client: sqlite });
772
344
  return db;
773
345
  }
@@ -775,8 +347,8 @@ function init(path5) {
775
347
  // packages/opencode/src/storage/db.ts
776
348
  var NotFoundError = NamedError.create(
777
349
  "NotFoundError",
778
- z3.object({
779
- message: z3.string()
350
+ z2.object({
351
+ message: z2.string()
780
352
  })
781
353
  );
782
354
  var log = Log.create({ service: "db" });
@@ -784,15 +356,15 @@ var Database;
784
356
  ((Database2) => {
785
357
  function getChannelPath() {
786
358
  if (["latest", "beta"].includes(CHANNEL) || Flag.OPENCODE_DISABLE_CHANNEL_DB)
787
- return path3.join(Global.Path.data, "opencode.db");
359
+ return path.join(Global.Path.data, "opencode.db");
788
360
  const safe = CHANNEL.replace(/[^a-zA-Z0-9._-]/g, "-");
789
- return path3.join(Global.Path.data, `opencode-${safe}.db`);
361
+ return path.join(Global.Path.data, `opencode-${safe}.db`);
790
362
  }
791
363
  Database2.getChannelPath = getChannelPath;
792
364
  Database2.Path = iife(() => {
793
365
  if (Flag.OPENCODE_DB) {
794
- if (Flag.OPENCODE_DB === ":memory:" || path3.isAbsolute(Flag.OPENCODE_DB)) return Flag.OPENCODE_DB;
795
- return path3.join(Global.Path.data, Flag.OPENCODE_DB);
366
+ if (Flag.OPENCODE_DB === ":memory:" || path.isAbsolute(Flag.OPENCODE_DB)) return Flag.OPENCODE_DB;
367
+ return path.join(Global.Path.data, Flag.OPENCODE_DB);
796
368
  }
797
369
  return getChannelPath();
798
370
  });
@@ -811,8 +383,8 @@ var Database;
811
383
  function migrations(dir) {
812
384
  const dirs = readdirSync(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
813
385
  const sql = dirs.map((name) => {
814
- const file = path3.join(dir, name, "migration.sql");
815
- if (!existsSync2(file)) return;
386
+ const file = path.join(dir, name, "migration.sql");
387
+ if (!existsSync(file)) return;
816
388
  return {
817
389
  sql: readFileSync(file, "utf-8"),
818
390
  timestamp: time(name),
@@ -830,7 +402,7 @@ var Database;
830
402
  db.run("PRAGMA cache_size = -64000");
831
403
  db.run("PRAGMA foreign_keys = ON");
832
404
  db.run("PRAGMA wal_checkpoint(PASSIVE)");
833
- const migrationsDir = path3.join(import.meta.dirname, "../packages/opencode/migration");
405
+ const migrationsDir = path.join(import.meta.dirname, "../packages/opencode/migration");
834
406
  if (typeof OPENCODE_MIGRATIONS !== "undefined") {
835
407
  const entries = OPENCODE_MIGRATIONS;
836
408
  if (entries.length > 0) {
@@ -996,7 +568,7 @@ var PermissionTable = sqliteTable2("permission", {
996
568
  });
997
569
 
998
570
  // packages/opencode/src/bus/bus-event.ts
999
- import z4 from "zod";
571
+ import z3 from "zod";
1000
572
  var BusEvent;
1001
573
  ((BusEvent2) => {
1002
574
  const registry = /* @__PURE__ */ new Map();
@@ -1010,11 +582,11 @@ var BusEvent;
1010
582
  }
1011
583
  BusEvent2.define = define;
1012
584
  function payloads() {
1013
- return z4.discriminatedUnion(
585
+ return z3.discriminatedUnion(
1014
586
  "type",
1015
587
  registry.entries().map(([type, def]) => {
1016
- return z4.object({
1017
- type: z4.literal(type),
588
+ return z3.object({
589
+ type: z3.literal(type),
1018
590
  properties: def.properties
1019
591
  }).meta({
1020
592
  ref: "Event." + def.type
@@ -1029,10 +601,10 @@ var BusEvent;
1029
601
 
1030
602
  // packages/opencode/src/util/which.ts
1031
603
  import whichPkg from "which";
1032
- import path4 from "path";
604
+ import path2 from "path";
1033
605
  function which(cmd, env) {
1034
606
  const base = env?.PATH ?? env?.Path ?? process.env.PATH ?? process.env.Path ?? "";
1035
- const full = base ? base + path4.delimiter + Global.Path.bin : Global.Path.bin;
607
+ const full = base ? base + path2.delimiter + Global.Path.bin : Global.Path.bin;
1036
608
  const result = whichPkg.sync(cmd, {
1037
609
  nothrow: true,
1038
610
  path: full,
@@ -1043,13 +615,13 @@ function which(cmd, env) {
1043
615
 
1044
616
  // packages/opencode/src/project/schema.ts
1045
617
  import { Schema } from "effect";
1046
- import z5 from "zod";
618
+ import z4 from "zod";
1047
619
  var projectIdSchema = Schema.String.pipe(Schema.brand("ProjectID"));
1048
620
  var ProjectID = projectIdSchema.pipe(
1049
621
  withStatics((schema) => ({
1050
622
  global: schema.makeUnsafe("global"),
1051
623
  make: (id) => schema.makeUnsafe(id),
1052
- zod: z5.string().pipe(z5.custom())
624
+ zod: z4.string().pipe(z4.custom())
1053
625
  }))
1054
626
  );
1055
627
 
@@ -1060,10 +632,10 @@ import { NodePath as NodePath2 } from "@effect/platform-node";
1060
632
 
1061
633
  // packages/opencode/src/filesystem/index.ts
1062
634
  import { NodeFileSystem } from "@effect/platform-node";
1063
- import { dirname as dirname2, join as join2, relative as relative2, resolve as pathResolve2 } from "path";
1064
- import { realpathSync as realpathSync2 } from "fs";
635
+ import { dirname, join, relative, resolve as pathResolve } from "path";
636
+ import { realpathSync } from "fs";
1065
637
  import * as NFS from "fs/promises";
1066
- import { lookup as lookup2 } from "mime-types";
638
+ import { lookup } from "mime-types";
1067
639
  import { Effect as Effect2, FileSystem, Layer, Schema as Schema2, ServiceMap as ServiceMap3 } from "effect";
1068
640
  var AppFileSystem;
1069
641
  ((AppFileSystem2) => {
@@ -1079,16 +651,16 @@ var AppFileSystem;
1079
651
  AppFileSystem2.layer = Layer.effect(
1080
652
  Service,
1081
653
  Effect2.gen(function* () {
1082
- const fs3 = yield* FileSystem.FileSystem;
1083
- const existsSafe = Effect2.fn("FileSystem.existsSafe")(function* (path5) {
1084
- return yield* fs3.exists(path5).pipe(Effect2.orElseSucceed(() => false));
654
+ const fs = yield* FileSystem.FileSystem;
655
+ const existsSafe = Effect2.fn("FileSystem.existsSafe")(function* (path3) {
656
+ return yield* fs.exists(path3).pipe(Effect2.orElseSucceed(() => false));
1085
657
  });
1086
- const isDir = Effect2.fn("FileSystem.isDir")(function* (path5) {
1087
- const info = yield* fs3.stat(path5).pipe(Effect2.catch(() => Effect2.void));
658
+ const isDir = Effect2.fn("FileSystem.isDir")(function* (path3) {
659
+ const info = yield* fs.stat(path3).pipe(Effect2.catch(() => Effect2.void));
1088
660
  return info?.type === "Directory";
1089
661
  });
1090
- const isFile = Effect2.fn("FileSystem.isFile")(function* (path5) {
1091
- const info = yield* fs3.stat(path5).pipe(Effect2.catch(() => Effect2.void));
662
+ const isFile = Effect2.fn("FileSystem.isFile")(function* (path3) {
663
+ const info = yield* fs.stat(path3).pipe(Effect2.catch(() => Effect2.void));
1092
664
  return info?.type === "File";
1093
665
  });
1094
666
  const readDirectoryEntries = Effect2.fn("FileSystem.readDirectoryEntries")(function* (dirPath) {
@@ -1105,37 +677,37 @@ var AppFileSystem;
1105
677
  catch: (cause) => new FileSystemError({ method: "readDirectoryEntries", cause })
1106
678
  });
1107
679
  });
1108
- const readJson = Effect2.fn("FileSystem.readJson")(function* (path5) {
1109
- const text3 = yield* fs3.readFileString(path5);
680
+ const readJson = Effect2.fn("FileSystem.readJson")(function* (path3) {
681
+ const text3 = yield* fs.readFileString(path3);
1110
682
  return JSON.parse(text3);
1111
683
  });
1112
- const writeJson = Effect2.fn("FileSystem.writeJson")(function* (path5, data2, mode) {
1113
- const content = JSON.stringify(data2, null, 2);
1114
- const tmp = `${path5}.tmp-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
1115
- yield* fs3.writeFileString(tmp, content);
1116
- if (mode) yield* fs3.chmod(tmp, mode);
684
+ const writeJson = Effect2.fn("FileSystem.writeJson")(function* (path3, data, mode) {
685
+ const content = JSON.stringify(data, null, 2);
686
+ const tmp = `${path3}.tmp-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
687
+ yield* fs.writeFileString(tmp, content);
688
+ if (mode) yield* fs.chmod(tmp, mode);
1117
689
  yield* Effect2.tryPromise({
1118
- try: () => NFS.rename(tmp, path5),
690
+ try: () => NFS.rename(tmp, path3),
1119
691
  catch: (cause) => new FileSystemError({ method: "writeJson.rename", cause })
1120
692
  });
1121
693
  });
1122
- const ensureDir = Effect2.fn("FileSystem.ensureDir")(function* (path5) {
1123
- yield* fs3.makeDirectory(path5, { recursive: true });
694
+ const ensureDir = Effect2.fn("FileSystem.ensureDir")(function* (path3) {
695
+ yield* fs.makeDirectory(path3, { recursive: true });
1124
696
  });
1125
- const writeWithDirs = Effect2.fn("FileSystem.writeWithDirs")(function* (path5, content, mode) {
1126
- const write = typeof content === "string" ? fs3.writeFileString(path5, content) : fs3.writeFile(path5, content);
697
+ const writeWithDirs = Effect2.fn("FileSystem.writeWithDirs")(function* (path3, content, mode) {
698
+ const write = typeof content === "string" ? fs.writeFileString(path3, content) : fs.writeFile(path3, content);
1127
699
  yield* write.pipe(
1128
700
  Effect2.catchIf(
1129
701
  (e) => e.reason._tag === "NotFound",
1130
702
  () => Effect2.gen(function* () {
1131
- yield* fs3.makeDirectory(dirname2(path5), { recursive: true });
703
+ yield* fs.makeDirectory(dirname(path3), { recursive: true });
1132
704
  yield* write;
1133
705
  })
1134
706
  )
1135
707
  );
1136
- if (mode) yield* fs3.chmod(path5, mode);
708
+ if (mode) yield* fs.chmod(path3, mode);
1137
709
  });
1138
- const glob2 = Effect2.fn("FileSystem.glob")(function* (pattern, options) {
710
+ const glob = Effect2.fn("FileSystem.glob")(function* (pattern, options) {
1139
711
  return yield* Effect2.tryPromise({
1140
712
  try: () => Glob.scan(pattern, options),
1141
713
  catch: (cause) => new FileSystemError({ method: "glob", cause })
@@ -1145,10 +717,10 @@ var AppFileSystem;
1145
717
  const result = [];
1146
718
  let current = start;
1147
719
  while (true) {
1148
- const search = join2(current, target);
1149
- if (yield* fs3.exists(search)) result.push(search);
720
+ const search = join(current, target);
721
+ if (yield* fs.exists(search)) result.push(search);
1150
722
  if (stop === current) break;
1151
- const parent = dirname2(current);
723
+ const parent = dirname(current);
1152
724
  if (parent === current) break;
1153
725
  current = parent;
1154
726
  }
@@ -1159,11 +731,11 @@ var AppFileSystem;
1159
731
  let current = options.start;
1160
732
  while (true) {
1161
733
  for (const target of options.targets) {
1162
- const search = join2(current, target);
1163
- if (yield* fs3.exists(search)) result.push(search);
734
+ const search = join(current, target);
735
+ if (yield* fs.exists(search)) result.push(search);
1164
736
  }
1165
737
  if (options.stop === current) break;
1166
- const parent = dirname2(current);
738
+ const parent = dirname(current);
1167
739
  if (parent === current) break;
1168
740
  current = parent;
1169
741
  }
@@ -1173,19 +745,19 @@ var AppFileSystem;
1173
745
  const result = [];
1174
746
  let current = start;
1175
747
  while (true) {
1176
- const matches = yield* glob2(pattern, { cwd: current, absolute: true, include: "file", dot: true }).pipe(
748
+ const matches = yield* glob(pattern, { cwd: current, absolute: true, include: "file", dot: true }).pipe(
1177
749
  Effect2.catch(() => Effect2.succeed([]))
1178
750
  );
1179
751
  result.push(...matches);
1180
752
  if (stop === current) break;
1181
- const parent = dirname2(current);
753
+ const parent = dirname(current);
1182
754
  if (parent === current) break;
1183
755
  current = parent;
1184
756
  }
1185
757
  return result;
1186
758
  });
1187
759
  return Service.of({
1188
- ...fs3,
760
+ ...fs,
1189
761
  existsSafe,
1190
762
  isDir,
1191
763
  isFile,
@@ -1197,21 +769,21 @@ var AppFileSystem;
1197
769
  findUp,
1198
770
  up,
1199
771
  globUp,
1200
- glob: glob2,
772
+ glob,
1201
773
  globMatch: Glob.match
1202
774
  });
1203
775
  })
1204
776
  );
1205
777
  AppFileSystem2.defaultLayer = AppFileSystem2.layer.pipe(Layer.provide(NodeFileSystem.layer));
1206
778
  function mimeType(p) {
1207
- return lookup2(p) || "application/octet-stream";
779
+ return lookup(p) || "application/octet-stream";
1208
780
  }
1209
781
  AppFileSystem2.mimeType = mimeType;
1210
782
  function normalizePath(p) {
1211
783
  if (process.platform !== "win32") return p;
1212
- const resolved = pathResolve2(windowsPath(p));
784
+ const resolved = pathResolve(windowsPath(p));
1213
785
  try {
1214
- return realpathSync2.native(resolved);
786
+ return realpathSync.native(resolved);
1215
787
  } catch {
1216
788
  return resolved;
1217
789
  }
@@ -1223,13 +795,13 @@ var AppFileSystem;
1223
795
  const match = p.match(/^(.*)[\\/]\*$/);
1224
796
  if (!match) return normalizePath(p);
1225
797
  const dir = /^[A-Za-z]:$/.test(match[1]) ? match[1] + "\\" : match[1];
1226
- return join2(normalizePath(dir), "*");
798
+ return join(normalizePath(dir), "*");
1227
799
  }
1228
800
  AppFileSystem2.normalizePathPattern = normalizePathPattern;
1229
801
  function resolve(p) {
1230
- const resolved = pathResolve2(windowsPath(p));
802
+ const resolved = pathResolve(windowsPath(p));
1231
803
  try {
1232
- return normalizePath(realpathSync2(resolved));
804
+ return normalizePath(realpathSync(resolved));
1233
805
  } catch (e) {
1234
806
  if (e?.code === "ENOENT") return normalizePath(resolved);
1235
807
  throw e;
@@ -1242,13 +814,13 @@ var AppFileSystem;
1242
814
  }
1243
815
  AppFileSystem2.windowsPath = windowsPath;
1244
816
  function overlaps(a, b) {
1245
- const relA = relative2(a, b);
1246
- const relB = relative2(b, a);
817
+ const relA = relative(a, b);
818
+ const relB = relative(b, a);
1247
819
  return !relA || !relA.startsWith("..") || !relB || !relB.startsWith("..");
1248
820
  }
1249
821
  AppFileSystem2.overlaps = overlaps;
1250
822
  function contains(parent, child) {
1251
- return !relative2(parent, child).startsWith("..");
823
+ return !relative(parent, child).startsWith("..");
1252
824
  }
1253
825
  AppFileSystem2.contains = contains;
1254
826
  })(AppFileSystem || (AppFileSystem = {}));
@@ -1333,12 +905,12 @@ var toPlatformError = (method, err, command) => {
1333
905
  });
1334
906
  };
1335
907
  var make2 = Effect3.gen(function* () {
1336
- const fs3 = yield* FileSystem2.FileSystem;
1337
- const path5 = yield* Path.Path;
908
+ const fs = yield* FileSystem2.FileSystem;
909
+ const path3 = yield* Path.Path;
1338
910
  const cwd = Effect3.fnUntraced(function* (opts) {
1339
911
  if (Predicate.isUndefined(opts.cwd)) return void 0;
1340
- yield* fs3.access(opts.cwd);
1341
- return path5.resolve(opts.cwd);
912
+ yield* fs.access(opts.cwd);
913
+ return path3.resolve(opts.cwd);
1342
914
  });
1343
915
  const env = (opts) => opts.extendEnv ? { ...globalThis.process.env, ...opts.env } : opts.env;
1344
916
  const input = (x) => Stream.isStream(x) ? "pipe" : x;
@@ -1363,9 +935,9 @@ var make2 = Effect3.gen(function* () {
1363
935
  };
1364
936
  const fds = (opts) => {
1365
937
  if (Predicate.isUndefined(opts.additionalFds)) return [];
1366
- return Object.entries(opts.additionalFds).flatMap(([name, config2]) => {
938
+ return Object.entries(opts.additionalFds).flatMap(([name, config]) => {
1367
939
  const fd = ChildProcess.parseFdName(name);
1368
- return Predicate.isUndefined(fd) ? [] : [{ fd, config: config2 }];
940
+ return Predicate.isUndefined(fd) ? [] : [{ fd, config }];
1369
941
  }).toSorted((a, b) => a.fd - b.fd);
1370
942
  };
1371
943
  const stdios = (sin, sout, serr, extra) => {
@@ -1642,7 +1214,7 @@ var layer2 = Layer2.effect(
1642
1214
  );
1643
1215
  var defaultLayer = layer2.pipe(Layer2.provide(NodeFileSystem2.layer), Layer2.provide(NodePath.layer));
1644
1216
  var rt = lazy(async () => {
1645
- const { makeRuntime: makeRuntime2 } = await import("./run-service-RE7EK2UK.js");
1217
+ const { makeRuntime: makeRuntime2 } = await import("./run-service-B4BDQWO3.js");
1646
1218
  return makeRuntime2(ChildProcessSpawner, defaultLayer);
1647
1219
  });
1648
1220
  var runPromiseExit = async (...args) => (await rt()).runPromiseExit(...args);
@@ -1651,25 +1223,25 @@ var runPromiseExit = async (...args) => (await rt()).runPromiseExit(...args);
1651
1223
  var Project;
1652
1224
  ((Project2) => {
1653
1225
  const log2 = Log.create({ service: "project" });
1654
- Project2.Info = z6.object({
1226
+ Project2.Info = z5.object({
1655
1227
  id: ProjectID.zod,
1656
- worktree: z6.string(),
1657
- vcs: z6.literal("git").optional(),
1658
- name: z6.string().optional(),
1659
- icon: z6.object({
1660
- url: z6.string().optional(),
1661
- override: z6.string().optional(),
1662
- color: z6.string().optional()
1228
+ worktree: z5.string(),
1229
+ vcs: z5.literal("git").optional(),
1230
+ name: z5.string().optional(),
1231
+ icon: z5.object({
1232
+ url: z5.string().optional(),
1233
+ override: z5.string().optional(),
1234
+ color: z5.string().optional()
1663
1235
  }).optional(),
1664
- commands: z6.object({
1665
- start: z6.string().optional().describe("Startup script to run when creating a new workspace (worktree)")
1236
+ commands: z5.object({
1237
+ start: z5.string().optional().describe("Startup script to run when creating a new workspace (worktree)")
1666
1238
  }).optional(),
1667
- time: z6.object({
1668
- created: z6.number(),
1669
- updated: z6.number(),
1670
- initialized: z6.number().optional()
1239
+ time: z5.object({
1240
+ created: z5.number(),
1241
+ updated: z5.number(),
1242
+ initialized: z5.number().optional()
1671
1243
  }),
1672
- sandboxes: z6.array(z6.string())
1244
+ sandboxes: z5.array(z5.string())
1673
1245
  }).meta({
1674
1246
  ref: "Project"
1675
1247
  });
@@ -1694,9 +1266,9 @@ var Project;
1694
1266
  };
1695
1267
  }
1696
1268
  Project2.fromRow = fromRow;
1697
- Project2.UpdateInput = z6.object({
1269
+ Project2.UpdateInput = z5.object({
1698
1270
  projectID: ProjectID.zod,
1699
- name: z6.string().optional(),
1271
+ name: z5.string().optional(),
1700
1272
  icon: Project2.Info.shape.icon.optional(),
1701
1273
  commands: Project2.Info.shape.commands.optional()
1702
1274
  });
@@ -1706,7 +1278,7 @@ var Project;
1706
1278
  Project2.layer = Layer3.effect(
1707
1279
  Service,
1708
1280
  Effect4.gen(function* () {
1709
- const fs3 = yield* AppFileSystem.Service;
1281
+ const fs = yield* AppFileSystem.Service;
1710
1282
  const pathSvc = yield* Path3.Path;
1711
1283
  const spawner = yield* ChildProcessSpawner2.ChildProcessSpawner;
1712
1284
  const git = Effect4.fnUntraced(
@@ -1725,9 +1297,9 @@ var Project;
1725
1297
  Effect4.catch(() => Effect4.succeed({ code: 1, text: "", stderr: "" }))
1726
1298
  );
1727
1299
  const db = (fn) => Effect4.sync(() => Database.use(fn));
1728
- const emitUpdated = (data2) => Effect4.sync(
1300
+ const emitUpdated = (data) => Effect4.sync(
1729
1301
  () => GlobalBus.emit("event", {
1730
- payload: { type: Project2.Event.Updated.type, properties: data2 }
1302
+ payload: { type: Project2.Event.Updated.type, properties: data }
1731
1303
  })
1732
1304
  );
1733
1305
  const fakeVcs = Project2.Info.shape.vcs.parse(Flag.OPENCODE_FAKE_VCS);
@@ -1741,7 +1313,7 @@ var Project;
1741
1313
  };
1742
1314
  const scope = yield* Scope2.Scope;
1743
1315
  const readCachedProjectId = Effect4.fnUntraced(function* (dir) {
1744
- return yield* fs3.readFileString(pathSvc.join(dir, "opencode")).pipe(
1316
+ return yield* fs.readFileString(pathSvc.join(dir, "opencode")).pipe(
1745
1317
  Effect4.map((x) => x.trim()),
1746
1318
  Effect4.map(ProjectID.make),
1747
1319
  Effect4.catch(() => Effect4.succeed(void 0))
@@ -1749,8 +1321,8 @@ var Project;
1749
1321
  });
1750
1322
  const fromDirectory2 = Effect4.fn("Project.fromDirectory")(function* (directory) {
1751
1323
  log2.info("fromDirectory", { directory });
1752
- const data2 = yield* Effect4.gen(function* () {
1753
- const dotgitMatches = yield* fs3.up({ targets: [".git"], start: directory }).pipe(Effect4.orDie);
1324
+ const data = yield* Effect4.gen(function* () {
1325
+ const dotgitMatches = yield* fs.up({ targets: [".git"], start: directory }).pipe(Effect4.orDie);
1754
1326
  const dotgit = dotgitMatches[0];
1755
1327
  if (!dotgit) {
1756
1328
  return {
@@ -1792,7 +1364,7 @@ var Project;
1792
1364
  const roots = revList.text.split("\n").filter(Boolean).map((x) => x.trim()).toSorted();
1793
1365
  id = roots[0] ? ProjectID.make(roots[0]) : void 0;
1794
1366
  if (id) {
1795
- yield* fs3.writeFileString(pathSvc.join(worktree, ".git", "opencode"), id).pipe(Effect4.ignore);
1367
+ yield* fs.writeFileString(pathSvc.join(worktree, ".git", "opencode"), id).pipe(Effect4.ignore);
1796
1368
  }
1797
1369
  }
1798
1370
  if (!id) {
@@ -1810,11 +1382,11 @@ var Project;
1810
1382
  sandbox = resolveGitPath(sandbox, topLevel.text.trim());
1811
1383
  return { id, sandbox, worktree, vcs: "git" };
1812
1384
  });
1813
- const row = yield* db((d) => d.select().from(ProjectTable).where((0, db_exports.eq)(ProjectTable.id, data2.id)).get());
1385
+ const row = yield* db((d) => d.select().from(ProjectTable).where((0, db_exports.eq)(ProjectTable.id, data.id)).get());
1814
1386
  const existing = row ? fromRow(row) : {
1815
- id: data2.id,
1816
- worktree: data2.worktree,
1817
- vcs: data2.vcs,
1387
+ id: data.id,
1388
+ worktree: data.worktree,
1389
+ vcs: data.vcs,
1818
1390
  sandboxes: [],
1819
1391
  time: { created: Date.now(), updated: Date.now() }
1820
1392
  };
@@ -1822,15 +1394,15 @@ var Project;
1822
1394
  yield* discover2(existing).pipe(Effect4.ignore, Effect4.forkIn(scope));
1823
1395
  const result = {
1824
1396
  ...existing,
1825
- worktree: data2.worktree,
1826
- vcs: data2.vcs,
1397
+ worktree: data.worktree,
1398
+ vcs: data.vcs,
1827
1399
  time: { ...existing.time, updated: Date.now() }
1828
1400
  };
1829
- if (data2.sandbox !== result.worktree && !result.sandboxes.includes(data2.sandbox))
1830
- result.sandboxes.push(data2.sandbox);
1401
+ if (data.sandbox !== result.worktree && !result.sandboxes.includes(data.sandbox))
1402
+ result.sandboxes.push(data.sandbox);
1831
1403
  result.sandboxes = yield* Effect4.forEach(
1832
1404
  result.sandboxes,
1833
- (s) => fs3.exists(s).pipe(
1405
+ (s) => fs.exists(s).pipe(
1834
1406
  Effect4.orDie,
1835
1407
  Effect4.map((exists) => exists ? s : void 0)
1836
1408
  ),
@@ -1864,26 +1436,26 @@ var Project;
1864
1436
  }
1865
1437
  }).run()
1866
1438
  );
1867
- if (data2.id !== ProjectID.global) {
1439
+ if (data.id !== ProjectID.global) {
1868
1440
  yield* db(
1869
- (d) => d.update(SessionTable).set({ project_id: data2.id }).where((0, db_exports.and)((0, db_exports.eq)(SessionTable.project_id, ProjectID.global), (0, db_exports.eq)(SessionTable.directory, data2.worktree))).run()
1441
+ (d) => d.update(SessionTable).set({ project_id: data.id }).where((0, db_exports.and)((0, db_exports.eq)(SessionTable.project_id, ProjectID.global), (0, db_exports.eq)(SessionTable.directory, data.worktree))).run()
1870
1442
  );
1871
1443
  }
1872
1444
  yield* emitUpdated(result);
1873
- return { project: result, sandbox: data2.sandbox };
1445
+ return { project: result, sandbox: data.sandbox };
1874
1446
  });
1875
1447
  const discover2 = Effect4.fn("Project.discover")(function* (input) {
1876
1448
  if (input.vcs !== "git") return;
1877
1449
  if (input.icon?.override) return;
1878
1450
  if (input.icon?.url) return;
1879
- const matches = yield* fs3.glob("**/favicon.{ico,png,svg,jpg,jpeg,webp}", {
1451
+ const matches = yield* fs.glob("**/favicon.{ico,png,svg,jpg,jpeg,webp}", {
1880
1452
  cwd: input.worktree,
1881
1453
  absolute: true,
1882
1454
  include: "file"
1883
1455
  }).pipe(Effect4.orDie);
1884
1456
  const shortest = matches.sort((a, b) => a.length - b.length)[0];
1885
1457
  if (!shortest) return;
1886
- const buffer = yield* fs3.readFile(shortest).pipe(Effect4.orDie);
1458
+ const buffer = yield* fs.readFile(shortest).pipe(Effect4.orDie);
1887
1459
  const base64 = Buffer.from(buffer).toString("base64");
1888
1460
  const mime = AppFileSystem.mimeType(shortest);
1889
1461
  const url = `data:${mime};base64,${base64}`;
@@ -1907,9 +1479,9 @@ var Project;
1907
1479
  }).where((0, db_exports.eq)(ProjectTable.id, input.projectID)).returning().get()
1908
1480
  );
1909
1481
  if (!result) throw new Error(`Project not found: ${input.projectID}`);
1910
- const data2 = fromRow(result);
1911
- yield* emitUpdated(data2);
1912
- return data2;
1482
+ const data = fromRow(result);
1483
+ yield* emitUpdated(data);
1484
+ return data;
1913
1485
  });
1914
1486
  const initGit2 = Effect4.fn("Project.initGit")(function* (input) {
1915
1487
  if (input.project.vcs === "git") return input.project;
@@ -1929,10 +1501,10 @@ var Project;
1929
1501
  const sandboxes2 = Effect4.fn("Project.sandboxes")(function* (id) {
1930
1502
  const row = yield* db((d) => d.select().from(ProjectTable).where((0, db_exports.eq)(ProjectTable.id, id)).get());
1931
1503
  if (!row) return [];
1932
- const data2 = fromRow(row);
1504
+ const data = fromRow(row);
1933
1505
  return yield* Effect4.forEach(
1934
- data2.sandboxes,
1935
- (dir) => fs3.isDir(dir).pipe(
1506
+ data.sandboxes,
1507
+ (dir) => fs.isDir(dir).pipe(
1936
1508
  Effect4.orDie,
1937
1509
  Effect4.map((ok) => ok ? dir : void 0)
1938
1510
  ),
@@ -2043,12 +1615,12 @@ var State;
2043
1615
  }
2044
1616
  const exists = entries.get(init2);
2045
1617
  if (exists) return exists.state;
2046
- const state2 = init2();
1618
+ const state = init2();
2047
1619
  entries.set(init2, {
2048
- state: state2,
1620
+ state,
2049
1621
  dispose: dispose2
2050
1622
  });
2051
- return state2;
1623
+ return state;
2052
1624
  };
2053
1625
  }
2054
1626
  State2.create = create;
@@ -2069,7 +1641,7 @@ var State;
2069
1641
  for (const [init2, entry] of entries) {
2070
1642
  if (!entry.dispose) continue;
2071
1643
  const label = typeof init2 === "function" ? init2.name : String(init2);
2072
- const task = Promise.resolve(entry.state).then((state2) => entry.dispose(state2)).catch((error) => {
1644
+ const task = Promise.resolve(entry.state).then((state) => entry.dispose(state)).catch((error) => {
2073
1645
  log2.error("Error while disposing state:", { error, key, init: label });
2074
1646
  });
2075
1647
  tasks.push(task);
@@ -2085,7 +1657,7 @@ var State;
2085
1657
 
2086
1658
  // packages/opencode/src/project/instance.ts
2087
1659
  var context = Context.create("instance");
2088
- var cache2 = /* @__PURE__ */ new Map();
1660
+ var cache = /* @__PURE__ */ new Map();
2089
1661
  var disposal = {
2090
1662
  all: void 0
2091
1663
  };
@@ -2119,16 +1691,16 @@ function boot(input) {
2119
1691
  }
2120
1692
  function track(directory, next) {
2121
1693
  const task = next.catch((error) => {
2122
- if (cache2.get(directory) === task) cache2.delete(directory);
1694
+ if (cache.get(directory) === task) cache.delete(directory);
2123
1695
  throw error;
2124
1696
  });
2125
- cache2.set(directory, task);
1697
+ cache.set(directory, task);
2126
1698
  return task;
2127
1699
  }
2128
1700
  var Instance = {
2129
1701
  async provide(input) {
2130
1702
  const directory = Filesystem.resolve(input.directory);
2131
- let existing = cache2.get(directory);
1703
+ let existing = cache.get(directory);
2132
1704
  if (!existing) {
2133
1705
  Log.Default.info("creating instance", { directory });
2134
1706
  existing = track(
@@ -2190,7 +1762,7 @@ var Instance = {
2190
1762
  const directory = Filesystem.resolve(input.directory);
2191
1763
  Log.Default.info("reloading instance", { directory });
2192
1764
  await Promise.all([State.dispose(directory), disposeInstance(directory)]);
2193
- cache2.delete(directory);
1765
+ cache.delete(directory);
2194
1766
  const next = track(directory, boot({ ...input, directory }));
2195
1767
  emit(directory);
2196
1768
  return await next;
@@ -2199,25 +1771,25 @@ var Instance = {
2199
1771
  const directory = Instance.directory;
2200
1772
  Log.Default.info("disposing instance", { directory });
2201
1773
  await Promise.all([State.dispose(directory), disposeInstance(directory)]);
2202
- cache2.delete(directory);
1774
+ cache.delete(directory);
2203
1775
  emit(directory);
2204
1776
  },
2205
1777
  async disposeAll() {
2206
1778
  if (disposal.all) return disposal.all;
2207
1779
  disposal.all = iife(async () => {
2208
1780
  Log.Default.info("disposing all instances");
2209
- const entries = [...cache2.entries()];
1781
+ const entries = [...cache.entries()];
2210
1782
  for (const [key, value] of entries) {
2211
- if (cache2.get(key) !== value) continue;
1783
+ if (cache.get(key) !== value) continue;
2212
1784
  const ctx = await value.catch((error) => {
2213
1785
  Log.Default.warn("instance dispose failed", { key, error });
2214
1786
  return void 0;
2215
1787
  });
2216
1788
  if (!ctx) {
2217
- if (cache2.get(key) === value) cache2.delete(key);
1789
+ if (cache.get(key) === value) cache.delete(key);
2218
1790
  continue;
2219
1791
  }
2220
- if (cache2.get(key) !== value) continue;
1792
+ if (cache.get(key) !== value) continue;
2221
1793
  await context.provide(ctx, async () => {
2222
1794
  await Instance.dispose();
2223
1795
  });
@@ -2253,10 +1825,6 @@ function makeRuntime(service, layer3) {
2253
1825
  }
2254
1826
 
2255
1827
  export {
2256
- Glob,
2257
- Filesystem,
2258
- Global,
2259
- Log,
2260
1828
  GlobalBus,
2261
1829
  iife,
2262
1830
  lazy,
@@ -2286,4 +1854,4 @@ export {
2286
1854
  memoMap,
2287
1855
  makeRuntime
2288
1856
  };
2289
- //# sourceMappingURL=chunk-J4KUHHYM.js.map
1857
+ //# sourceMappingURL=chunk-SZM3G6UF.js.map