anycodex 0.0.26 → 0.0.27

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.
@@ -4,33 +4,22 @@ import {
4
4
  ModelID,
5
5
  ProviderID,
6
6
  Todo,
7
- iife
8
- } from "./chunk-4SPBQLA5.js";
9
- import {
10
- Identifier,
11
- MessageID,
12
- PartID
13
- } from "./chunk-6Q6QFZOB.js";
14
- import {
15
- Flag,
16
- NamedError,
17
7
  basename,
18
- consoleLogger,
19
8
  dirname,
20
9
  extname,
21
10
  isAbsolute,
22
11
  join,
23
12
  relative,
24
13
  resolve
25
- } from "./chunk-NRFXEZ7N.js";
14
+ } from "./chunk-47OV6PTE.js";
26
15
  import {
27
- Schema_exports,
16
+ Identifier,
17
+ MessageID,
18
+ PartID,
28
19
  __callDispose,
29
20
  __using,
30
- external_exports,
31
- withStatics,
32
21
  zod_default
33
- } from "./chunk-M6C7CWX3.js";
22
+ } from "./chunk-RKAEZ54R.js";
34
23
  import {
35
24
  __commonJS
36
25
  } from "./chunk-77HVPD4G.js";
@@ -5080,32 +5069,32 @@ var require_URL = __commonJS({
5080
5069
  else
5081
5070
  return basepath.substring(0, lastslash + 1) + refpath;
5082
5071
  }
5083
- function remove_dot_segments(path) {
5084
- if (!path) return path;
5072
+ function remove_dot_segments(path3) {
5073
+ if (!path3) return path3;
5085
5074
  var output = "";
5086
- while (path.length > 0) {
5087
- if (path === "." || path === "..") {
5088
- path = "";
5075
+ while (path3.length > 0) {
5076
+ if (path3 === "." || path3 === "..") {
5077
+ path3 = "";
5089
5078
  break;
5090
5079
  }
5091
- var twochars = path.substring(0, 2);
5092
- var threechars = path.substring(0, 3);
5093
- var fourchars = path.substring(0, 4);
5080
+ var twochars = path3.substring(0, 2);
5081
+ var threechars = path3.substring(0, 3);
5082
+ var fourchars = path3.substring(0, 4);
5094
5083
  if (threechars === "../") {
5095
- path = path.substring(3);
5084
+ path3 = path3.substring(3);
5096
5085
  } else if (twochars === "./") {
5097
- path = path.substring(2);
5086
+ path3 = path3.substring(2);
5098
5087
  } else if (threechars === "/./") {
5099
- path = "/" + path.substring(3);
5100
- } else if (twochars === "/." && path.length === 2) {
5101
- path = "/";
5102
- } else if (fourchars === "/../" || threechars === "/.." && path.length === 3) {
5103
- path = "/" + path.substring(4);
5088
+ path3 = "/" + path3.substring(3);
5089
+ } else if (twochars === "/." && path3.length === 2) {
5090
+ path3 = "/";
5091
+ } else if (fourchars === "/../" || threechars === "/.." && path3.length === 3) {
5092
+ path3 = "/" + path3.substring(4);
5104
5093
  output = output.replace(/\/?[^\/]*$/, "");
5105
5094
  } else {
5106
- var segment = path.match(/(\/?([^\/]*))/)[0];
5095
+ var segment = path3.match(/(\/?([^\/]*))/)[0];
5107
5096
  output += segment;
5108
- path = path.substring(segment.length);
5097
+ path3 = path3.substring(segment.length);
5109
5098
  }
5110
5099
  }
5111
5100
  return output;
@@ -16695,6 +16684,714 @@ var require_lib = __commonJS({
16695
16684
  }
16696
16685
  });
16697
16686
 
16687
+ // ../utils/dist/index.js
16688
+ import fs from "fs/promises";
16689
+ import { existsSync, statSync, readdirSync } from "fs";
16690
+ import path from "path";
16691
+ import { spawn } from "child_process";
16692
+ import { spawn as spawn2 } from "child_process";
16693
+ import fs2 from "fs/promises";
16694
+ import path2 from "path";
16695
+ import fs3 from "fs";
16696
+ import nodePath from "path";
16697
+ var consoleLogger = {
16698
+ debug: console.debug.bind(console),
16699
+ info: console.info.bind(console),
16700
+ warn: console.warn.bind(console),
16701
+ error: console.error.bind(console)
16702
+ };
16703
+ var SqliteNoSqlDb = class {
16704
+ constructor(raw) {
16705
+ this.raw = raw;
16706
+ }
16707
+ insert(table, row) {
16708
+ const cols = Object.keys(row);
16709
+ const placeholders = cols.map(() => "?").join(", ");
16710
+ const sql = `INSERT INTO "${table}" (${cols.map((c) => `"${c}"`).join(", ")}) VALUES (${placeholders})`;
16711
+ this.raw.run(sql, cols.map((c) => serialize(row[c])));
16712
+ }
16713
+ upsert(table, row, conflictKeys, updateFields) {
16714
+ const cols = Object.keys(row);
16715
+ const placeholders = cols.map(() => "?").join(", ");
16716
+ const conflict = conflictKeys.map((k) => `"${k}"`).join(", ");
16717
+ const updates = Object.keys(updateFields).map((k) => `"${k}" = ?`).join(", ");
16718
+ const sql = `INSERT INTO "${table}" (${cols.map((c) => `"${c}"`).join(", ")}) VALUES (${placeholders}) ON CONFLICT (${conflict}) DO UPDATE SET ${updates}`;
16719
+ const params = [
16720
+ ...cols.map((c) => serialize(row[c])),
16721
+ ...Object.keys(updateFields).map((k) => serialize(updateFields[k]))
16722
+ ];
16723
+ this.raw.run(sql, params);
16724
+ }
16725
+ findOne(table, filter, options) {
16726
+ const fields = options?.select?.map((f) => `"${f}"`).join(", ") ?? "*";
16727
+ const { clause, params } = filter ? buildWhere(filter) : { clause: "", params: [] };
16728
+ const where = clause ? ` WHERE ${clause}` : "";
16729
+ const sql = `SELECT ${fields} FROM "${table}"${where} LIMIT 1`;
16730
+ const row = this.raw.get(sql, params);
16731
+ return row ? deserializeRow(row) : void 0;
16732
+ }
16733
+ findMany(table, options) {
16734
+ const fields = options?.select?.map((f) => `"${f}"`).join(", ") ?? "*";
16735
+ const { clause, params } = options?.filter ? buildWhere(options.filter) : { clause: "", params: [] };
16736
+ const where = clause ? ` WHERE ${clause}` : "";
16737
+ let orderClause = "";
16738
+ if (options?.orderBy?.length) {
16739
+ const parts = options.orderBy.map(
16740
+ (o) => `"${o.field}" ${o.direction === "desc" ? "DESC" : "ASC"}`
16741
+ );
16742
+ orderClause = ` ORDER BY ${parts.join(", ")}`;
16743
+ }
16744
+ const limitClause = options?.limit != null ? ` LIMIT ${options.limit}` : "";
16745
+ const sql = `SELECT ${fields} FROM "${table}"${where}${orderClause}${limitClause}`;
16746
+ return this.raw.all(sql, params).map(deserializeRow);
16747
+ }
16748
+ update(table, filter, set) {
16749
+ const setCols = Object.keys(set);
16750
+ const setClause = setCols.map((k) => `"${k}" = ?`).join(", ");
16751
+ const { clause, params } = buildWhere(filter);
16752
+ const sql = `UPDATE "${table}" SET ${setClause} WHERE ${clause} RETURNING *`;
16753
+ const setParams = setCols.map((k) => serialize(set[k]));
16754
+ const row = this.raw.get(sql, [...setParams, ...params]);
16755
+ return row ? deserializeRow(row) : void 0;
16756
+ }
16757
+ remove(table, filter) {
16758
+ const { clause, params } = buildWhere(filter);
16759
+ this.raw.run(`DELETE FROM "${table}" WHERE ${clause}`, params);
16760
+ }
16761
+ transaction(fn) {
16762
+ this.raw.transaction(() => {
16763
+ fn(this);
16764
+ });
16765
+ }
16766
+ };
16767
+ function buildWhere(filter) {
16768
+ switch (filter.op) {
16769
+ case "eq":
16770
+ return { clause: `"${filter.field}" = ?`, params: [serialize(filter.value)] };
16771
+ case "ne":
16772
+ return { clause: `"${filter.field}" != ?`, params: [serialize(filter.value)] };
16773
+ case "gt":
16774
+ return { clause: `"${filter.field}" > ?`, params: [serialize(filter.value)] };
16775
+ case "gte":
16776
+ return { clause: `"${filter.field}" >= ?`, params: [serialize(filter.value)] };
16777
+ case "lt":
16778
+ return { clause: `"${filter.field}" < ?`, params: [serialize(filter.value)] };
16779
+ case "like":
16780
+ return { clause: `"${filter.field}" LIKE ?`, params: [filter.value] };
16781
+ case "isNull":
16782
+ return { clause: `"${filter.field}" IS NULL`, params: [] };
16783
+ case "in": {
16784
+ const placeholders = filter.values.map(() => "?").join(", ");
16785
+ return { clause: `"${filter.field}" IN (${placeholders})`, params: filter.values.map(serialize) };
16786
+ }
16787
+ case "and": {
16788
+ const parts = filter.conditions.map(buildWhere);
16789
+ return {
16790
+ clause: parts.map((p) => `(${p.clause})`).join(" AND "),
16791
+ params: parts.flatMap((p) => p.params)
16792
+ };
16793
+ }
16794
+ case "or": {
16795
+ const parts = filter.conditions.map(buildWhere);
16796
+ return {
16797
+ clause: parts.map((p) => `(${p.clause})`).join(" OR "),
16798
+ params: parts.flatMap((p) => p.params)
16799
+ };
16800
+ }
16801
+ }
16802
+ }
16803
+ function serialize(value) {
16804
+ if (value === void 0) return null;
16805
+ if (value === null) return null;
16806
+ if (typeof value === "object" && !(value instanceof Buffer) && !(value instanceof Uint8Array)) {
16807
+ return JSON.stringify(value);
16808
+ }
16809
+ return value;
16810
+ }
16811
+ function deserializeRow(row) {
16812
+ const result = {};
16813
+ for (const [key, value] of Object.entries(row)) {
16814
+ if (typeof value === "string" && (value.startsWith("{") || value.startsWith("["))) {
16815
+ try {
16816
+ result[key] = JSON.parse(value);
16817
+ } catch {
16818
+ result[key] = value;
16819
+ }
16820
+ } else {
16821
+ result[key] = value;
16822
+ }
16823
+ }
16824
+ return result;
16825
+ }
16826
+ var NodeFS = class {
16827
+ async exists(p) {
16828
+ return existsSync(p);
16829
+ }
16830
+ async stat(p) {
16831
+ try {
16832
+ const s = statSync(p);
16833
+ return {
16834
+ size: typeof s.size === "bigint" ? Number(s.size) : s.size,
16835
+ isDirectory: s.isDirectory(),
16836
+ isFile: s.isFile(),
16837
+ mtimeMs: s.mtimeMs
16838
+ };
16839
+ } catch {
16840
+ return void 0;
16841
+ }
16842
+ }
16843
+ async isDir(p) {
16844
+ const s = await this.stat(p);
16845
+ return s?.isDirectory ?? false;
16846
+ }
16847
+ async readText(p) {
16848
+ return fs.readFile(p, "utf-8");
16849
+ }
16850
+ async readBytes(p) {
16851
+ return fs.readFile(p);
16852
+ }
16853
+ async readJson(p) {
16854
+ return JSON.parse(await this.readText(p));
16855
+ }
16856
+ async readDir(p) {
16857
+ const entries = readdirSync(p, { withFileTypes: true });
16858
+ return entries.map((e) => ({
16859
+ name: e.name,
16860
+ isDirectory: e.isDirectory(),
16861
+ isFile: e.isFile()
16862
+ }));
16863
+ }
16864
+ async write(p, content) {
16865
+ try {
16866
+ await fs.writeFile(p, content);
16867
+ } catch (e) {
16868
+ if (e?.code === "ENOENT") {
16869
+ await fs.mkdir(path.dirname(p), { recursive: true });
16870
+ await fs.writeFile(p, content);
16871
+ return;
16872
+ }
16873
+ throw e;
16874
+ }
16875
+ }
16876
+ async writeJson(p, data) {
16877
+ await this.write(p, JSON.stringify(data, null, 2));
16878
+ }
16879
+ async mkdir(p) {
16880
+ await fs.mkdir(p, { recursive: true });
16881
+ }
16882
+ async remove(p) {
16883
+ await fs.unlink(p).catch(() => {
16884
+ });
16885
+ }
16886
+ async grep(pattern, searchPath, options) {
16887
+ return new Promise((resolve2) => {
16888
+ const args = [
16889
+ "--json",
16890
+ "--line-number",
16891
+ "--column",
16892
+ "--no-heading",
16893
+ ...options?.maxResults ? ["--max-count", String(options.maxResults)] : [],
16894
+ ...options?.include?.flatMap((g) => ["--glob", g]) ?? [],
16895
+ pattern,
16896
+ searchPath
16897
+ ];
16898
+ const rg = spawn("rg", args, { stdio: ["ignore", "pipe", "pipe"] });
16899
+ let output = "";
16900
+ rg.stdout.on("data", (data) => {
16901
+ output += data.toString();
16902
+ });
16903
+ rg.on("close", () => {
16904
+ const results = [];
16905
+ for (const line of output.split("\n")) {
16906
+ if (!line.trim()) continue;
16907
+ try {
16908
+ const parsed = JSON.parse(line);
16909
+ if (parsed.type === "match") {
16910
+ results.push({
16911
+ file: parsed.data.path.text,
16912
+ line: parsed.data.line_number,
16913
+ column: parsed.data.submatches?.[0]?.start ?? 0,
16914
+ content: parsed.data.lines.text.trimEnd()
16915
+ });
16916
+ }
16917
+ } catch {
16918
+ }
16919
+ }
16920
+ resolve2(results);
16921
+ });
16922
+ rg.on("error", () => resolve2([]));
16923
+ });
16924
+ }
16925
+ async glob(pattern, options = {}) {
16926
+ const searchPath = options.cwd ?? process.cwd();
16927
+ const { glob: fsGlob } = await import("fs/promises").catch(() => ({ glob: void 0 }));
16928
+ if (fsGlob) {
16929
+ try {
16930
+ const results = [];
16931
+ for await (const entry of fsGlob(pattern, { cwd: searchPath })) {
16932
+ if (options.absolute) {
16933
+ results.push(path.resolve(searchPath, entry));
16934
+ } else {
16935
+ results.push(entry);
16936
+ }
16937
+ }
16938
+ return results;
16939
+ } catch {
16940
+ }
16941
+ }
16942
+ return new Promise((resolve2) => {
16943
+ const rg = spawn("rg", ["--files", "--glob", pattern, searchPath], {
16944
+ stdio: ["ignore", "pipe", "pipe"]
16945
+ });
16946
+ let output = "";
16947
+ rg.stdout.on("data", (data) => {
16948
+ output += data.toString();
16949
+ });
16950
+ rg.on("close", () => {
16951
+ resolve2(
16952
+ output.split("\n").map((l) => l.trim()).filter(Boolean)
16953
+ );
16954
+ });
16955
+ rg.on("error", () => resolve2([]));
16956
+ });
16957
+ }
16958
+ };
16959
+ var NodeSearchProvider = class {
16960
+ async grep(options) {
16961
+ options.signal?.throwIfAborted();
16962
+ return new Promise((resolve2, reject) => {
16963
+ const args = ["-rnH", "--color=never"];
16964
+ if (options.include) {
16965
+ args.push(`--include=${options.include}`);
16966
+ }
16967
+ args.push("--exclude-dir=.git");
16968
+ args.push("-E");
16969
+ args.push("--", options.pattern, options.path);
16970
+ const proc = spawn2("grep", args, {
16971
+ stdio: ["ignore", "pipe", "pipe"],
16972
+ signal: options.signal
16973
+ });
16974
+ let output = "";
16975
+ proc.stdout.on("data", (data) => {
16976
+ output += data.toString();
16977
+ });
16978
+ proc.on("close", () => {
16979
+ const results = [];
16980
+ for (const line of output.split("\n")) {
16981
+ if (!line.trim()) continue;
16982
+ const match = line.match(/^(.+?):(\d+):(.*)$/);
16983
+ if (match) {
16984
+ let content = match[3];
16985
+ if (options.maxLineLength !== void 0 && content.length > options.maxLineLength) {
16986
+ content = content.slice(0, options.maxLineLength) + "...";
16987
+ }
16988
+ results.push({
16989
+ file: match[1],
16990
+ line: parseInt(match[2], 10),
16991
+ column: 0,
16992
+ content
16993
+ });
16994
+ }
16995
+ }
16996
+ resolve2(results);
16997
+ });
16998
+ proc.on("error", (error) => {
16999
+ reject(error);
17000
+ });
17001
+ });
17002
+ }
17003
+ async listFiles(options) {
17004
+ options.signal?.throwIfAborted();
17005
+ const showHidden = options.hidden === true;
17006
+ const results = [];
17007
+ const limit = options.limit ?? Infinity;
17008
+ const excludePatterns = [".git"];
17009
+ const includePatterns = [];
17010
+ for (const g of options.glob ?? []) {
17011
+ if (g.startsWith("!")) {
17012
+ excludePatterns.push(g.slice(1).replace(/[/*]+$/, ""));
17013
+ } else {
17014
+ includePatterns.push(g);
17015
+ }
17016
+ }
17017
+ const walk = async (dir, depth) => {
17018
+ if (results.length >= limit) return;
17019
+ if (options.maxDepth !== void 0 && depth > options.maxDepth) return;
17020
+ options.signal?.throwIfAborted();
17021
+ let entries;
17022
+ try {
17023
+ entries = await fs2.readdir(dir, { withFileTypes: true });
17024
+ } catch {
17025
+ return;
17026
+ }
17027
+ for (const entry of entries) {
17028
+ if (results.length >= limit) return;
17029
+ const name = entry.name;
17030
+ if (!showHidden && name.startsWith(".")) continue;
17031
+ const fullPath = path2.join(dir, name);
17032
+ const relativePath = path2.relative(options.cwd, fullPath);
17033
+ if (excludePatterns.some((p) => relativePath.startsWith(p) || name === p)) continue;
17034
+ const isDir = entry.isDirectory() || options.follow && entry.isSymbolicLink();
17035
+ if (isDir) {
17036
+ await walk(fullPath, depth + 1);
17037
+ } else if (entry.isFile()) {
17038
+ if (includePatterns.length > 0) {
17039
+ const matches = includePatterns.some((p) => simpleGlobMatch(name, p));
17040
+ if (!matches) continue;
17041
+ }
17042
+ results.push(relativePath);
17043
+ }
17044
+ }
17045
+ };
17046
+ await walk(options.cwd, 0);
17047
+ return results;
17048
+ }
17049
+ async tree(options) {
17050
+ const limit = options.limit ?? 50;
17051
+ const files = await this.listFiles({ cwd: options.cwd, signal: options.signal });
17052
+ function dir(node, name) {
17053
+ const existing = node.children.get(name);
17054
+ if (existing) return existing;
17055
+ const next2 = { name, children: /* @__PURE__ */ new Map() };
17056
+ node.children.set(name, next2);
17057
+ return next2;
17058
+ }
17059
+ const root2 = { name: "", children: /* @__PURE__ */ new Map() };
17060
+ for (const file of files) {
17061
+ if (file.includes(".opencode")) continue;
17062
+ const parts = file.split(/[\/\\]/);
17063
+ if (parts.length < 2) continue;
17064
+ let node = root2;
17065
+ for (const part of parts.slice(0, -1)) {
17066
+ node = dir(node, part);
17067
+ }
17068
+ }
17069
+ function count(node) {
17070
+ let total2 = 0;
17071
+ for (const child of node.children.values()) {
17072
+ total2 += 1 + count(child);
17073
+ }
17074
+ return total2;
17075
+ }
17076
+ const total = count(root2);
17077
+ const lines = [];
17078
+ const queue = [];
17079
+ for (const child of Array.from(root2.children.values()).sort((a, b) => a.name.localeCompare(b.name))) {
17080
+ queue.push({ node: child, path: child.name });
17081
+ }
17082
+ let used = 0;
17083
+ for (let i = 0; i < queue.length && used < limit; i++) {
17084
+ const { node, path: p } = queue[i];
17085
+ lines.push(p);
17086
+ used++;
17087
+ for (const child of Array.from(node.children.values()).sort((a, b) => a.name.localeCompare(b.name))) {
17088
+ queue.push({ node: child, path: `${p}/${child.name}` });
17089
+ }
17090
+ }
17091
+ if (total > used) lines.push(`[${total - used} truncated]`);
17092
+ return lines.join("\n");
17093
+ }
17094
+ };
17095
+ function simpleGlobMatch(filename, pattern) {
17096
+ if (pattern === "*") return true;
17097
+ if (pattern.startsWith("*.")) {
17098
+ const ext = pattern.slice(1);
17099
+ if (ext.startsWith(".{") && ext.endsWith("}")) {
17100
+ const exts = ext.slice(2, -1).split(",");
17101
+ return exts.some((e) => filename.endsWith(`.${e}`));
17102
+ }
17103
+ return filename.endsWith(ext);
17104
+ }
17105
+ return filename === pattern;
17106
+ }
17107
+ var INITIAL_MIGRATION = `-- project table
17108
+ CREATE TABLE IF NOT EXISTS "project" (
17109
+ "id" TEXT PRIMARY KEY NOT NULL,
17110
+ "worktree" TEXT NOT NULL,
17111
+ "vcs" TEXT,
17112
+ "name" TEXT,
17113
+ "icon_url" TEXT,
17114
+ "icon_color" TEXT,
17115
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
17116
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
17117
+ "time_initialized" INTEGER,
17118
+ "sandboxes" TEXT NOT NULL DEFAULT '[]',
17119
+ "commands" TEXT
17120
+ );
17121
+
17122
+ -- session table
17123
+ CREATE TABLE IF NOT EXISTS "session" (
17124
+ "id" TEXT PRIMARY KEY NOT NULL,
17125
+ "project_id" TEXT NOT NULL REFERENCES "project"("id") ON DELETE CASCADE,
17126
+ "workspace_id" TEXT,
17127
+ "parent_id" TEXT,
17128
+ "slug" TEXT NOT NULL,
17129
+ "directory" TEXT NOT NULL,
17130
+ "title" TEXT NOT NULL,
17131
+ "version" TEXT NOT NULL,
17132
+ "share_url" TEXT,
17133
+ "summary_additions" INTEGER,
17134
+ "summary_deletions" INTEGER,
17135
+ "summary_files" INTEGER,
17136
+ "summary_diffs" TEXT,
17137
+ "revert" TEXT,
17138
+ "permission" TEXT,
17139
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
17140
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
17141
+ "time_compacting" INTEGER,
17142
+ "time_archived" INTEGER
17143
+ );
17144
+ CREATE INDEX IF NOT EXISTS "session_project_idx" ON "session"("project_id");
17145
+ CREATE INDEX IF NOT EXISTS "session_workspace_idx" ON "session"("workspace_id");
17146
+ CREATE INDEX IF NOT EXISTS "session_parent_idx" ON "session"("parent_id");
17147
+
17148
+ -- message table
17149
+ CREATE TABLE IF NOT EXISTS "message" (
17150
+ "id" TEXT PRIMARY KEY NOT NULL,
17151
+ "session_id" TEXT NOT NULL REFERENCES "session"("id") ON DELETE CASCADE,
17152
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
17153
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
17154
+ "data" TEXT NOT NULL
17155
+ );
17156
+ CREATE INDEX IF NOT EXISTS "message_session_time_created_id_idx" ON "message"("session_id", "time_created", "id");
17157
+
17158
+ -- part table
17159
+ CREATE TABLE IF NOT EXISTS "part" (
17160
+ "id" TEXT PRIMARY KEY NOT NULL,
17161
+ "message_id" TEXT NOT NULL REFERENCES "message"("id") ON DELETE CASCADE,
17162
+ "session_id" TEXT NOT NULL,
17163
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
17164
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
17165
+ "data" TEXT NOT NULL
17166
+ );
17167
+ CREATE INDEX IF NOT EXISTS "part_message_id_id_idx" ON "part"("message_id", "id");
17168
+ CREATE INDEX IF NOT EXISTS "part_session_idx" ON "part"("session_id");
17169
+
17170
+ -- todo table
17171
+ CREATE TABLE IF NOT EXISTS "todo" (
17172
+ "session_id" TEXT NOT NULL REFERENCES "session"("id") ON DELETE CASCADE,
17173
+ "content" TEXT NOT NULL,
17174
+ "status" TEXT NOT NULL,
17175
+ "priority" TEXT NOT NULL,
17176
+ "position" INTEGER NOT NULL,
17177
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
17178
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
17179
+ PRIMARY KEY ("session_id", "position")
17180
+ );
17181
+ CREATE INDEX IF NOT EXISTS "todo_session_idx" ON "todo"("session_id");
17182
+
17183
+ -- permission table
17184
+ CREATE TABLE IF NOT EXISTS "permission" (
17185
+ "project_id" TEXT PRIMARY KEY NOT NULL REFERENCES "project"("id") ON DELETE CASCADE,
17186
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
17187
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
17188
+ "data" TEXT NOT NULL
17189
+ );
17190
+
17191
+ -- session_share table
17192
+ CREATE TABLE IF NOT EXISTS "session_share" (
17193
+ "session_id" TEXT PRIMARY KEY NOT NULL REFERENCES "session"("id") ON DELETE CASCADE,
17194
+ "id" TEXT NOT NULL,
17195
+ "secret" TEXT NOT NULL,
17196
+ "url" TEXT NOT NULL,
17197
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
17198
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000)
17199
+ );
17200
+
17201
+ -- workspace table
17202
+ CREATE TABLE IF NOT EXISTS "workspace" (
17203
+ "id" TEXT PRIMARY KEY NOT NULL,
17204
+ "type" TEXT NOT NULL,
17205
+ "branch" TEXT,
17206
+ "name" TEXT,
17207
+ "directory" TEXT,
17208
+ "extra" TEXT,
17209
+ "project_id" TEXT NOT NULL REFERENCES "project"("id") ON DELETE CASCADE
17210
+ );
17211
+
17212
+ -- account table
17213
+ CREATE TABLE IF NOT EXISTS "account" (
17214
+ "id" TEXT PRIMARY KEY NOT NULL,
17215
+ "email" TEXT NOT NULL,
17216
+ "url" TEXT NOT NULL,
17217
+ "access_token" TEXT NOT NULL,
17218
+ "refresh_token" TEXT NOT NULL,
17219
+ "token_expiry" INTEGER,
17220
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
17221
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000)
17222
+ );
17223
+
17224
+ -- account_state table
17225
+ CREATE TABLE IF NOT EXISTS "account_state" (
17226
+ "id" INTEGER PRIMARY KEY,
17227
+ "active_account_id" TEXT REFERENCES "account"("id") ON DELETE SET NULL,
17228
+ "active_org_id" TEXT
17229
+ );
17230
+
17231
+ -- control_account table (legacy)
17232
+ CREATE TABLE IF NOT EXISTS "control_account" (
17233
+ "email" TEXT NOT NULL,
17234
+ "url" TEXT NOT NULL,
17235
+ "access_token" TEXT NOT NULL,
17236
+ "refresh_token" TEXT NOT NULL,
17237
+ "token_expiry" INTEGER,
17238
+ "active" INTEGER NOT NULL DEFAULT 0,
17239
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
17240
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
17241
+ PRIMARY KEY ("email", "url")
17242
+ );`;
17243
+ function getDefaultMigrations() {
17244
+ return [
17245
+ { sql: INITIAL_MIGRATION, timestamp: Date.UTC(2024, 0, 1), name: "20240101000000_initial" }
17246
+ ];
17247
+ }
17248
+ var SqlJsStorage = class {
17249
+ db = null;
17250
+ noSqlDb = null;
17251
+ dbPath;
17252
+ flushTimer = null;
17253
+ migrations;
17254
+ constructor(dbPath, migrations) {
17255
+ this.dbPath = dbPath ?? null;
17256
+ this.migrations = migrations ?? getDefaultMigrations();
17257
+ }
17258
+ async connect() {
17259
+ if (this.noSqlDb) return this.noSqlDb;
17260
+ const initSqlJs = (await import("sql.js")).default;
17261
+ const SQL = await initSqlJs();
17262
+ if (this.dbPath && fs3.existsSync(this.dbPath)) {
17263
+ const buffer = fs3.readFileSync(this.dbPath);
17264
+ this.db = new SQL.Database(new Uint8Array(buffer));
17265
+ } else {
17266
+ this.db = new SQL.Database();
17267
+ }
17268
+ this.db.run("PRAGMA foreign_keys = ON");
17269
+ this.applyMigrations(this.migrations);
17270
+ this.flushSync();
17271
+ const raw = this.createRawDb();
17272
+ this.noSqlDb = new SqliteNoSqlDb(raw);
17273
+ return this.noSqlDb;
17274
+ }
17275
+ // ── Flush to disk ──────────────────────────────────────────────
17276
+ /** Schedule an async flush (debounced 100ms). */
17277
+ scheduleFlush() {
17278
+ if (!this.dbPath) return;
17279
+ if (this.flushTimer) return;
17280
+ this.flushTimer = setTimeout(() => {
17281
+ this.flushTimer = null;
17282
+ this.flushSync();
17283
+ }, 100);
17284
+ }
17285
+ /** Synchronously write the entire database to disk. */
17286
+ flushSync() {
17287
+ if (!this.dbPath || !this.db) return;
17288
+ const dir = nodePath.dirname(this.dbPath);
17289
+ fs3.mkdirSync(dir, { recursive: true });
17290
+ const data = this.db.export();
17291
+ fs3.writeFileSync(this.dbPath, Buffer.from(data));
17292
+ }
17293
+ // ── RawSqliteDb wrapper ────────────────────────────────────────
17294
+ createRawDb() {
17295
+ const db = this.db;
17296
+ const self = this;
17297
+ return {
17298
+ run(sql, params) {
17299
+ db.run(sql, params);
17300
+ self.scheduleFlush();
17301
+ },
17302
+ get(sql, params) {
17303
+ const stmt = db.prepare(sql);
17304
+ if (params) stmt.bind(params);
17305
+ if (!stmt.step()) {
17306
+ stmt.free();
17307
+ return void 0;
17308
+ }
17309
+ const result = stmt.getAsObject();
17310
+ stmt.free();
17311
+ return result;
17312
+ },
17313
+ all(sql, params) {
17314
+ const stmt = db.prepare(sql);
17315
+ if (params) stmt.bind(params);
17316
+ const results = [];
17317
+ while (stmt.step()) {
17318
+ results.push(stmt.getAsObject());
17319
+ }
17320
+ stmt.free();
17321
+ return results;
17322
+ },
17323
+ transaction(fn) {
17324
+ db.run("BEGIN TRANSACTION");
17325
+ try {
17326
+ fn();
17327
+ db.run("COMMIT");
17328
+ self.scheduleFlush();
17329
+ } catch (e) {
17330
+ db.run("ROLLBACK");
17331
+ throw e;
17332
+ }
17333
+ }
17334
+ };
17335
+ }
17336
+ // ── Migrations ─────────────────────────────────────────────────
17337
+ applyMigrations(entries) {
17338
+ if (!this.db) throw new Error("SqlJsStorage: db not initialized");
17339
+ this.db.run(`
17340
+ CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (
17341
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
17342
+ hash TEXT NOT NULL,
17343
+ created_at INTEGER
17344
+ )
17345
+ `);
17346
+ const applied = /* @__PURE__ */ new Set();
17347
+ const rows = this.db.exec(`SELECT hash FROM "__drizzle_migrations"`);
17348
+ if (rows.length > 0) {
17349
+ for (const row of rows[0].values) {
17350
+ applied.add(row[0]);
17351
+ }
17352
+ }
17353
+ for (const entry of entries) {
17354
+ const hash = entry.name;
17355
+ if (applied.has(hash)) continue;
17356
+ this.db.run(entry.sql);
17357
+ this.db.run(
17358
+ `INSERT INTO "__drizzle_migrations" (hash, created_at) VALUES (?, ?)`,
17359
+ [hash, entry.timestamp]
17360
+ );
17361
+ }
17362
+ }
17363
+ /** Run raw SQL (for server-specific DDL like extra tables). */
17364
+ exec(sql) {
17365
+ if (!this.db) throw new Error("SqlJsStorage: db not initialized");
17366
+ this.db.run(sql);
17367
+ this.scheduleFlush();
17368
+ }
17369
+ /** Run a SELECT query and return rows as objects. */
17370
+ query(sql, params) {
17371
+ if (!this.db) throw new Error("SqlJsStorage: db not initialized");
17372
+ const stmt = this.db.prepare(sql);
17373
+ if (params) stmt.bind(params);
17374
+ const results = [];
17375
+ while (stmt.step()) {
17376
+ results.push(stmt.getAsObject());
17377
+ }
17378
+ stmt.free();
17379
+ return results;
17380
+ }
17381
+ close() {
17382
+ if (this.flushTimer) {
17383
+ clearTimeout(this.flushTimer);
17384
+ this.flushTimer = null;
17385
+ }
17386
+ this.flushSync();
17387
+ if (this.db) {
17388
+ this.db.close();
17389
+ this.db = null;
17390
+ }
17391
+ this.noSqlDb = null;
17392
+ }
17393
+ };
17394
+
16698
17395
  // ../../node_modules/.pnpm/diff@8.0.2/node_modules/diff/libesm/diff/base.js
16699
17396
  var Diff = class {
16700
17397
  diff(oldStr, newStr, options = {}) {
@@ -16795,16 +17492,16 @@ var Diff = class {
16795
17492
  }
16796
17493
  }
16797
17494
  }
16798
- addToPath(path, added, removed, oldPosInc, options) {
16799
- const last = path.lastComponent;
17495
+ addToPath(path3, added, removed, oldPosInc, options) {
17496
+ const last = path3.lastComponent;
16800
17497
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
16801
17498
  return {
16802
- oldPos: path.oldPos + oldPosInc,
17499
+ oldPos: path3.oldPos + oldPosInc,
16803
17500
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
16804
17501
  };
16805
17502
  } else {
16806
17503
  return {
16807
- oldPos: path.oldPos + oldPosInc,
17504
+ oldPos: path3.oldPos + oldPosInc,
16808
17505
  lastComponent: { count: 1, added, removed, previousComponent: last }
16809
17506
  };
16810
17507
  }
@@ -17718,7 +18415,7 @@ TurndownService.prototype = {
17718
18415
  );
17719
18416
  }
17720
18417
  if (input === "") return "";
17721
- var output = process.call(this, new RootNode(input, this.options));
18418
+ var output = process2.call(this, new RootNode(input, this.options));
17722
18419
  return postProcess.call(this, output);
17723
18420
  },
17724
18421
  /**
@@ -17785,7 +18482,7 @@ TurndownService.prototype = {
17785
18482
  }, string);
17786
18483
  }
17787
18484
  };
17788
- function process(parentNode) {
18485
+ function process2(parentNode) {
17789
18486
  var self = this;
17790
18487
  return reduce.call(parentNode.childNodes, function(output, node) {
17791
18488
  node = new Node(node, self.options);
@@ -17809,7 +18506,7 @@ function postProcess(output) {
17809
18506
  }
17810
18507
  function replacementForNode(node) {
17811
18508
  var rule = this.rules.forNode(node);
17812
- var content = process.call(this, node);
18509
+ var content = process2.call(this, node);
17813
18510
  var whitespace = node.flankingWhitespace;
17814
18511
  if (whitespace.leading || whitespace.trailing) content = content.trim();
17815
18512
  return whitespace.leading + rule.replacement(content, node, this.options) + whitespace.trailing;
@@ -17826,9 +18523,7 @@ function canConvert(input) {
17826
18523
  }
17827
18524
  var turndown_es_default = TurndownService;
17828
18525
 
17829
- // ../agent/dist/chunk-MD6BEIK2.js
17830
- import { pathToFileURL as pathToFileURL2 } from "url";
17831
- import { pathToFileURL } from "url";
18526
+ // ../agent/dist/chunk-HV5GDH4X.js
17832
18527
  var SchedulerService = class {
17833
18528
  tasks = /* @__PURE__ */ new Map();
17834
18529
  timers = /* @__PURE__ */ new Map();
@@ -17875,14 +18570,10 @@ var Scheduler;
17875
18570
  }
17876
18571
  Scheduler2.register = register;
17877
18572
  })(Scheduler || (Scheduler = {}));
17878
- var toolIdSchema = Schema_exports.String.pipe(Schema_exports.brand("ToolID"));
17879
- var ToolID = toolIdSchema.pipe(
17880
- withStatics((schema) => ({
17881
- make: (id) => schema.makeUnsafe(id),
17882
- ascending: (id) => schema.makeUnsafe(Identifier.ascending("tool", id)),
17883
- zod: Identifier.schema("tool").pipe(zod_default.custom())
17884
- }))
17885
- );
18573
+ var ToolID = {
18574
+ make: (id) => id,
18575
+ ascending: (id) => Identifier.ascending("tool", id)
18576
+ };
17886
18577
  var Truncate;
17887
18578
  ((Truncate2) => {
17888
18579
  Truncate2.MAX_LINES = 2e3;
@@ -18051,8 +18742,8 @@ var PlanExitTool = Tool.define("plan_exit", {
18051
18742
  agent: "build",
18052
18743
  model
18053
18744
  };
18054
- await ctx.session.updateMessage(userMsg);
18055
- await ctx.session.updatePart({
18745
+ await ctx.memory.updateMessage(userMsg);
18746
+ await ctx.memory.updatePart({
18056
18747
  id: PartID.ascending(),
18057
18748
  messageID: userMsg.id,
18058
18749
  sessionID: ctx.sessionID,
@@ -18067,6 +18758,130 @@ var PlanExitTool = Tool.define("plan_exit", {
18067
18758
  };
18068
18759
  }
18069
18760
  });
18761
+ var _env = {};
18762
+ function truthy(key) {
18763
+ const value = _env[key]?.toLowerCase();
18764
+ return value === "true" || value === "1";
18765
+ }
18766
+ function falsy(key) {
18767
+ const value = _env[key]?.toLowerCase();
18768
+ return value === "false" || value === "0";
18769
+ }
18770
+ function number(key) {
18771
+ const value = _env[key];
18772
+ if (!value) return void 0;
18773
+ const parsed = Number(value);
18774
+ return Number.isInteger(parsed) && parsed > 0 ? parsed : void 0;
18775
+ }
18776
+ var Flag;
18777
+ ((Flag2) => {
18778
+ function init(env) {
18779
+ _env = env;
18780
+ Flag2.OPENCODE_AUTO_SHARE = truthy("OPENCODE_AUTO_SHARE");
18781
+ Flag2.OPENCODE_GIT_BASH_PATH = _env["OPENCODE_GIT_BASH_PATH"];
18782
+ Flag2.OPENCODE_CONFIG = _env["OPENCODE_CONFIG"];
18783
+ Flag2.OPENCODE_CONFIG_CONTENT = _env["OPENCODE_CONFIG_CONTENT"];
18784
+ Flag2.OPENCODE_DISABLE_AUTOUPDATE = truthy("OPENCODE_DISABLE_AUTOUPDATE");
18785
+ Flag2.OPENCODE_DISABLE_PRUNE = truthy("OPENCODE_DISABLE_PRUNE");
18786
+ Flag2.OPENCODE_DISABLE_TERMINAL_TITLE = truthy("OPENCODE_DISABLE_TERMINAL_TITLE");
18787
+ Flag2.OPENCODE_PERMISSION = _env["OPENCODE_PERMISSION"];
18788
+ Flag2.OPENCODE_DISABLE_DEFAULT_PLUGINS = truthy("OPENCODE_DISABLE_DEFAULT_PLUGINS");
18789
+ Flag2.OPENCODE_DISABLE_LSP_DOWNLOAD = truthy("OPENCODE_DISABLE_LSP_DOWNLOAD");
18790
+ Flag2.OPENCODE_ENABLE_EXPERIMENTAL_MODELS = truthy("OPENCODE_ENABLE_EXPERIMENTAL_MODELS");
18791
+ Flag2.OPENCODE_DISABLE_AUTOCOMPACT = truthy("OPENCODE_DISABLE_AUTOCOMPACT");
18792
+ Flag2.OPENCODE_DISABLE_MODELS_FETCH = truthy("OPENCODE_DISABLE_MODELS_FETCH");
18793
+ Flag2.OPENCODE_DISABLE_CLAUDE_CODE = truthy("OPENCODE_DISABLE_CLAUDE_CODE");
18794
+ Flag2.OPENCODE_DISABLE_CLAUDE_CODE_PROMPT = Flag2.OPENCODE_DISABLE_CLAUDE_CODE || truthy("OPENCODE_DISABLE_CLAUDE_CODE_PROMPT");
18795
+ Flag2.OPENCODE_DISABLE_CLAUDE_CODE_SKILLS = Flag2.OPENCODE_DISABLE_CLAUDE_CODE || truthy("OPENCODE_DISABLE_CLAUDE_CODE_SKILLS");
18796
+ Flag2.OPENCODE_DISABLE_EXTERNAL_SKILLS = Flag2.OPENCODE_DISABLE_CLAUDE_CODE_SKILLS || truthy("OPENCODE_DISABLE_EXTERNAL_SKILLS");
18797
+ Flag2.OPENCODE_FAKE_VCS = _env["OPENCODE_FAKE_VCS"];
18798
+ Flag2.OPENCODE_SERVER_PASSWORD = _env["OPENCODE_SERVER_PASSWORD"];
18799
+ Flag2.OPENCODE_SERVER_USERNAME = _env["OPENCODE_SERVER_USERNAME"];
18800
+ Flag2.OPENCODE_ENABLE_QUESTION_TOOL = truthy("OPENCODE_ENABLE_QUESTION_TOOL");
18801
+ Flag2.OPENCODE_EXPERIMENTAL = truthy("OPENCODE_EXPERIMENTAL");
18802
+ Flag2.OPENCODE_EXPERIMENTAL_FILEWATCHER = truthy("OPENCODE_EXPERIMENTAL_FILEWATCHER");
18803
+ Flag2.OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER = truthy("OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER");
18804
+ Flag2.OPENCODE_EXPERIMENTAL_ICON_DISCOVERY = Flag2.OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_ICON_DISCOVERY");
18805
+ Flag2.OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT = (() => {
18806
+ const copy = _env["OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT"];
18807
+ return copy === void 0 ? false : truthy("OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT");
18808
+ })();
18809
+ Flag2.OPENCODE_ENABLE_EXA = truthy("OPENCODE_ENABLE_EXA") || Flag2.OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_EXA");
18810
+ Flag2.OPENCODE_EXPERIMENTAL_BASH_DEFAULT_TIMEOUT_MS = number("OPENCODE_EXPERIMENTAL_BASH_DEFAULT_TIMEOUT_MS");
18811
+ Flag2.OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX = number("OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX");
18812
+ Flag2.OPENCODE_EXPERIMENTAL_OXFMT = Flag2.OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_OXFMT");
18813
+ Flag2.OPENCODE_EXPERIMENTAL_LSP_TY = truthy("OPENCODE_EXPERIMENTAL_LSP_TY");
18814
+ Flag2.OPENCODE_EXPERIMENTAL_LSP_TOOL = Flag2.OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_LSP_TOOL");
18815
+ Flag2.OPENCODE_DISABLE_FILETIME_CHECK = truthy("OPENCODE_DISABLE_FILETIME_CHECK");
18816
+ Flag2.OPENCODE_EXPERIMENTAL_PLAN_MODE = Flag2.OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_PLAN_MODE");
18817
+ Flag2.OPENCODE_EXPERIMENTAL_WORKSPACES = Flag2.OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_WORKSPACES");
18818
+ Flag2.OPENCODE_EXPERIMENTAL_MARKDOWN = !falsy("OPENCODE_EXPERIMENTAL_MARKDOWN");
18819
+ Flag2.OPENCODE_MODELS_URL = _env["OPENCODE_MODELS_URL"];
18820
+ Flag2.OPENCODE_MODELS_PATH = _env["OPENCODE_MODELS_PATH"];
18821
+ Flag2.OPENCODE_DISABLE_CHANNEL_DB = truthy("OPENCODE_DISABLE_CHANNEL_DB");
18822
+ Flag2.OPENCODE_SKIP_MIGRATIONS = truthy("OPENCODE_SKIP_MIGRATIONS");
18823
+ Flag2.OPENCODE_STRICT_CONFIG_DEPS = truthy("OPENCODE_STRICT_CONFIG_DEPS");
18824
+ }
18825
+ Flag2.init = init;
18826
+ Flag2.OPENCODE_AUTO_SHARE = false;
18827
+ Flag2.OPENCODE_DISABLE_AUTOUPDATE = false;
18828
+ Flag2.OPENCODE_DISABLE_PRUNE = false;
18829
+ Flag2.OPENCODE_DISABLE_TERMINAL_TITLE = false;
18830
+ Flag2.OPENCODE_DISABLE_DEFAULT_PLUGINS = false;
18831
+ Flag2.OPENCODE_DISABLE_LSP_DOWNLOAD = false;
18832
+ Flag2.OPENCODE_ENABLE_EXPERIMENTAL_MODELS = false;
18833
+ Flag2.OPENCODE_DISABLE_AUTOCOMPACT = false;
18834
+ Flag2.OPENCODE_DISABLE_MODELS_FETCH = false;
18835
+ Flag2.OPENCODE_DISABLE_CLAUDE_CODE = false;
18836
+ Flag2.OPENCODE_DISABLE_CLAUDE_CODE_PROMPT = false;
18837
+ Flag2.OPENCODE_DISABLE_CLAUDE_CODE_SKILLS = false;
18838
+ Flag2.OPENCODE_DISABLE_EXTERNAL_SKILLS = false;
18839
+ Flag2.OPENCODE_ENABLE_QUESTION_TOOL = false;
18840
+ Flag2.OPENCODE_EXPERIMENTAL = false;
18841
+ Flag2.OPENCODE_EXPERIMENTAL_FILEWATCHER = false;
18842
+ Flag2.OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER = false;
18843
+ Flag2.OPENCODE_EXPERIMENTAL_ICON_DISCOVERY = false;
18844
+ Flag2.OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT = false;
18845
+ Flag2.OPENCODE_ENABLE_EXA = false;
18846
+ Flag2.OPENCODE_EXPERIMENTAL_OXFMT = false;
18847
+ Flag2.OPENCODE_EXPERIMENTAL_LSP_TY = false;
18848
+ Flag2.OPENCODE_EXPERIMENTAL_LSP_TOOL = false;
18849
+ Flag2.OPENCODE_DISABLE_FILETIME_CHECK = false;
18850
+ Flag2.OPENCODE_EXPERIMENTAL_PLAN_MODE = false;
18851
+ Flag2.OPENCODE_EXPERIMENTAL_WORKSPACES = false;
18852
+ Flag2.OPENCODE_EXPERIMENTAL_MARKDOWN = true;
18853
+ Flag2.OPENCODE_DISABLE_CHANNEL_DB = false;
18854
+ Flag2.OPENCODE_SKIP_MIGRATIONS = false;
18855
+ Flag2.OPENCODE_STRICT_CONFIG_DEPS = false;
18856
+ })(Flag || (Flag = {}));
18857
+ Object.defineProperty(Flag, "OPENCODE_DISABLE_PROJECT_CONFIG", {
18858
+ get() {
18859
+ return truthy("OPENCODE_DISABLE_PROJECT_CONFIG");
18860
+ },
18861
+ enumerable: true,
18862
+ configurable: false
18863
+ });
18864
+ Object.defineProperty(Flag, "OPENCODE_TUI_CONFIG", {
18865
+ get() {
18866
+ return _env["OPENCODE_TUI_CONFIG"];
18867
+ },
18868
+ enumerable: true,
18869
+ configurable: false
18870
+ });
18871
+ Object.defineProperty(Flag, "OPENCODE_CONFIG_DIR", {
18872
+ get() {
18873
+ return _env["OPENCODE_CONFIG_DIR"];
18874
+ },
18875
+ enumerable: true,
18876
+ configurable: false
18877
+ });
18878
+ Object.defineProperty(Flag, "OPENCODE_CLIENT", {
18879
+ get() {
18880
+ return _env["OPENCODE_CLIENT"] ?? "cli";
18881
+ },
18882
+ enumerable: true,
18883
+ configurable: false
18884
+ });
18070
18885
  var DESCRIPTION = `Executes a given bash command in a persistent shell session with optional timeout, ensuring proper handling and security measures.
18071
18886
 
18072
18887
  All commands run in \${directory} by default. Use the \`workdir\` parameter if you need to run a command in a different directory. AVOID using \`cd <directory> && <command>\` patterns - use \`workdir\` instead.
@@ -18377,64 +19192,6 @@ var BashTool = Tool.define("bash", async (initCtx) => {
18377
19192
  }
18378
19193
  };
18379
19194
  });
18380
- var LSP;
18381
- ((LSP2) => {
18382
- LSP2.Diagnostic = {
18383
- pretty(d) {
18384
- return `${d.range.start.line}:${d.range.start.character} ${d.severity === 1 ? "error" : "warning"}: ${d.message}`;
18385
- }
18386
- };
18387
- async function init() {
18388
- }
18389
- LSP2.init = init;
18390
- async function touchFile(_filepath, _wait) {
18391
- }
18392
- LSP2.touchFile = touchFile;
18393
- async function diagnostics() {
18394
- return /* @__PURE__ */ new Map();
18395
- }
18396
- LSP2.diagnostics = diagnostics;
18397
- async function hasClients(_file) {
18398
- return false;
18399
- }
18400
- LSP2.hasClients = hasClients;
18401
- async function definition(_position) {
18402
- return [];
18403
- }
18404
- LSP2.definition = definition;
18405
- async function references(_position) {
18406
- return [];
18407
- }
18408
- LSP2.references = references;
18409
- async function hover(_position) {
18410
- return null;
18411
- }
18412
- LSP2.hover = hover;
18413
- async function documentSymbol(_uri) {
18414
- return [];
18415
- }
18416
- LSP2.documentSymbol = documentSymbol;
18417
- async function workspaceSymbol(_query) {
18418
- return [];
18419
- }
18420
- LSP2.workspaceSymbol = workspaceSymbol;
18421
- async function implementation(_position) {
18422
- return [];
18423
- }
18424
- LSP2.implementation = implementation;
18425
- async function prepareCallHierarchy(_position) {
18426
- return [];
18427
- }
18428
- LSP2.prepareCallHierarchy = prepareCallHierarchy;
18429
- async function incomingCalls(_position) {
18430
- return [];
18431
- }
18432
- LSP2.incomingCalls = incomingCalls;
18433
- async function outgoingCalls(_position) {
18434
- return [];
18435
- }
18436
- LSP2.outgoingCalls = outgoingCalls;
18437
- })(LSP || (LSP = {}));
18438
19195
  async function assertExternalDirectory(ctx, target, options) {
18439
19196
  if (!target) return;
18440
19197
  if (options?.bypass) return;
@@ -18463,7 +19220,6 @@ Usage:
18463
19220
  - The edit will FAIL if \`oldString\` is found multiple times in the file with an error "Found multiple matches for oldString. Provide more surrounding lines in oldString to identify the correct match." Either provide a larger string with more surrounding context to make it unique or use \`replaceAll\` to change every instance of \`oldString\`.
18464
19221
  - Use \`replaceAll\` for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.
18465
19222
  `;
18466
- var MAX_DIAGNOSTICS_PER_FILE = 20;
18467
19223
  function normalizeLineEndings(text) {
18468
19224
  return text.replaceAll("\r\n", "\n");
18469
19225
  }
@@ -18561,25 +19317,9 @@ var EditTool = Tool.define("edit", {
18561
19317
  }
18562
19318
  });
18563
19319
  let output = "Edit applied successfully.";
18564
- await LSP.touchFile(filePath, true);
18565
- const diagnostics = await LSP.diagnostics();
18566
- const normalizedFilePath = filePath;
18567
- const issues = diagnostics.get(normalizedFilePath) ?? [];
18568
- const errors = issues.filter((item) => item.severity === 1);
18569
- if (errors.length > 0) {
18570
- const limited = errors.slice(0, MAX_DIAGNOSTICS_PER_FILE);
18571
- const suffix = errors.length > MAX_DIAGNOSTICS_PER_FILE ? `
18572
- ... and ${errors.length - MAX_DIAGNOSTICS_PER_FILE} more` : "";
18573
- output += `
18574
-
18575
- LSP errors detected in this file, please fix:
18576
- <diagnostics file="${filePath}">
18577
- ${limited.map(LSP.Diagnostic.pretty).join("\n")}${suffix}
18578
- </diagnostics>`;
18579
- }
18580
19320
  return {
18581
19321
  metadata: {
18582
- diagnostics,
19322
+ diagnostics: {},
18583
19323
  diff,
18584
19324
  filediff
18585
19325
  },
@@ -19189,8 +19929,8 @@ var BatchTool = Tool.define("batch", async () => {
19189
19929
  }),
19190
19930
  formatValidationError(error) {
19191
19931
  const formattedErrors = error.issues.map((issue) => {
19192
- const path = issue.path.length > 0 ? issue.path.join(".") : "root";
19193
- return ` - ${path}: ${issue.message}`;
19932
+ const path3 = issue.path.length > 0 ? issue.path.join(".") : "root";
19933
+ return ` - ${path3}: ${issue.message}`;
19194
19934
  }).join("\n");
19195
19935
  return `Invalid parameters for tool 'batch':
19196
19936
  ${formattedErrors}
@@ -19199,11 +19939,11 @@ Expected payload format:
19199
19939
  [{"tool": "tool_name", "parameters": {...}}, {...}]`;
19200
19940
  },
19201
19941
  async execute(params, ctx) {
19202
- const { Session } = await import("./session-3H7MDN6G-ILPE3VAH.js");
19203
- const { PartID: PartID2 } = await import("./schema-2CACIKZR-3CAWV3IP.js");
19942
+ const { Session } = await import("./session-636PXOZA-R22RGDNY.js");
19943
+ const { PartID: PartID2 } = await import("./schema-5YFIZCUA-MSI3TUIK.js");
19204
19944
  const toolCalls = params.tool_calls.slice(0, 25);
19205
19945
  const discardedCalls = params.tool_calls.slice(25);
19206
- const { ToolRegistry: ToolRegistry2 } = await import("./registry-N6XVTLPC-H2PNFK4G.js");
19946
+ const { ToolRegistry } = await import("./registry-QKGWHOWL-MO5OSMIR.js");
19207
19947
  const availableTools = await ctx.toolRegistry.tools({ modelID: ModelID.make(""), providerID: ProviderID.make("") });
19208
19948
  const toolMap = new Map(availableTools.map((t) => [t.id, t]));
19209
19949
  const executeCall = async (call) => {
@@ -19223,7 +19963,7 @@ Expected payload format:
19223
19963
  );
19224
19964
  }
19225
19965
  const validatedParams = tool.parameters.parse(call.parameters);
19226
- await ctx.session.updatePart({
19966
+ await ctx.memory.updatePart({
19227
19967
  id: partID,
19228
19968
  messageID: ctx.messageID,
19229
19969
  sessionID: ctx.sessionID,
@@ -19245,7 +19985,7 @@ Expected payload format:
19245
19985
  sessionID: ctx.sessionID,
19246
19986
  messageID: ctx.messageID
19247
19987
  }));
19248
- await ctx.session.updatePart({
19988
+ await ctx.memory.updatePart({
19249
19989
  id: partID,
19250
19990
  messageID: ctx.messageID,
19251
19991
  sessionID: ctx.sessionID,
@@ -19267,7 +20007,7 @@ Expected payload format:
19267
20007
  });
19268
20008
  return { success: true, tool: call.tool, result };
19269
20009
  } catch (error) {
19270
- await ctx.session.updatePart({
20010
+ await ctx.memory.updatePart({
19271
20011
  id: partID,
19272
20012
  messageID: ctx.messageID,
19273
20013
  sessionID: ctx.sessionID,
@@ -19291,7 +20031,7 @@ Expected payload format:
19291
20031
  const now = Date.now();
19292
20032
  for (const call of discardedCalls) {
19293
20033
  const partID = PartID2.ascending();
19294
- await ctx.session.updatePart({
20034
+ await ctx.memory.updatePart({
19295
20035
  id: partID,
19296
20036
  messageID: ctx.messageID,
19297
20037
  sessionID: ctx.sessionID,
@@ -19504,7 +20244,6 @@ ${suggestions.join("\n")}`);
19504
20244
  (End of file - total ${totalLines} lines)`;
19505
20245
  }
19506
20246
  output += "\n</content>";
19507
- LSP.touchFile(filepath, false);
19508
20247
  ctx.fileTime.read(ctx.sessionID, filepath);
19509
20248
  return {
19510
20249
  title,
@@ -19964,8 +20703,6 @@ Usage:
19964
20703
  - NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.
19965
20704
  - Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.
19966
20705
  `;
19967
- var MAX_DIAGNOSTICS_PER_FILE2 = 20;
19968
- var MAX_PROJECT_DIAGNOSTICS_FILES = 5;
19969
20706
  var WriteTool = Tool.define("write", {
19970
20707
  description: DESCRIPTION7,
19971
20708
  parameters: zod_default.object({
@@ -19991,39 +20728,11 @@ var WriteTool = Tool.define("write", {
19991
20728
  await ctx.fs.write(filepath, params.content);
19992
20729
  ctx.emit("file.edited", { file: filepath });
19993
20730
  ctx.fileTime.read(ctx.sessionID, filepath);
19994
- let output = "Wrote file successfully.";
19995
- await LSP.touchFile(filepath, true);
19996
- const diagnostics = await LSP.diagnostics();
19997
- const normalizedFilepath = filepath;
19998
- let projectDiagnosticsCount = 0;
19999
- for (const [file, issues] of Object.entries(diagnostics)) {
20000
- const errors = issues.filter((item) => item.severity === 1);
20001
- if (errors.length === 0) continue;
20002
- const limited = errors.slice(0, MAX_DIAGNOSTICS_PER_FILE2);
20003
- const suffix = errors.length > MAX_DIAGNOSTICS_PER_FILE2 ? `
20004
- ... and ${errors.length - MAX_DIAGNOSTICS_PER_FILE2} more` : "";
20005
- if (file === normalizedFilepath) {
20006
- output += `
20007
-
20008
- LSP errors detected in this file, please fix:
20009
- <diagnostics file="${filepath}">
20010
- ${limited.map(LSP.Diagnostic.pretty).join("\n")}${suffix}
20011
- </diagnostics>`;
20012
- continue;
20013
- }
20014
- if (projectDiagnosticsCount >= MAX_PROJECT_DIAGNOSTICS_FILES) continue;
20015
- projectDiagnosticsCount++;
20016
- output += `
20017
-
20018
- LSP errors detected in other files:
20019
- <diagnostics file="${file}">
20020
- ${limited.map(LSP.Diagnostic.pretty).join("\n")}${suffix}
20021
- </diagnostics>`;
20022
- }
20731
+ const output = "Wrote file successfully.";
20023
20732
  return {
20024
20733
  title: relative(ctx.worktree, filepath),
20025
20734
  metadata: {
20026
- diagnostics,
20735
+ diagnostics: {},
20027
20736
  filepath,
20028
20737
  exists
20029
20738
  },
@@ -20045,274 +20754,6 @@ var InvalidTool = Tool.define("invalid", {
20045
20754
  };
20046
20755
  }
20047
20756
  });
20048
- function parseFrontmatter(input) {
20049
- const match = input.match(/^---\r?\n([\s\S]*?)\r?\n---/);
20050
- if (!match) return { data: {}, content: input };
20051
- const yaml = match[1];
20052
- const data = {};
20053
- for (const line of yaml.split(/\r?\n/)) {
20054
- const kv = line.match(/^([a-zA-Z_]\w*)\s*:\s*(.*)$/);
20055
- if (kv) data[kv[1]] = kv[2].trim().replace(/^["']|["']$/g, "");
20056
- }
20057
- const content = input.slice(match[0].length).replace(/^\r?\n/, "");
20058
- return { data, content };
20059
- }
20060
- var ConfigMarkdown;
20061
- ((ConfigMarkdown2) => {
20062
- ConfigMarkdown2.FILE_REGEX = /(?<![\w`])@(\.?[^\s`,.]*(?:\.[^\s`,.]+)*)/g;
20063
- ConfigMarkdown2.SHELL_REGEX = /!`([^`]+)`/g;
20064
- function files(template) {
20065
- return Array.from(template.matchAll(ConfigMarkdown2.FILE_REGEX));
20066
- }
20067
- ConfigMarkdown2.files = files;
20068
- function shell(template) {
20069
- return Array.from(template.matchAll(ConfigMarkdown2.SHELL_REGEX));
20070
- }
20071
- ConfigMarkdown2.shell = shell;
20072
- function fallbackSanitization(content) {
20073
- const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
20074
- if (!match) return content;
20075
- const frontmatter = match[1];
20076
- const lines = frontmatter.split(/\r?\n/);
20077
- const result = [];
20078
- for (const line of lines) {
20079
- if (line.trim().startsWith("#") || line.trim() === "") {
20080
- result.push(line);
20081
- continue;
20082
- }
20083
- if (line.match(/^\s+/)) {
20084
- result.push(line);
20085
- continue;
20086
- }
20087
- const kvMatch = line.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*:\s*(.*)$/);
20088
- if (!kvMatch) {
20089
- result.push(line);
20090
- continue;
20091
- }
20092
- const key = kvMatch[1];
20093
- const value = kvMatch[2].trim();
20094
- if (value === "" || value === ">" || value === "|" || value.startsWith('"') || value.startsWith("'")) {
20095
- result.push(line);
20096
- continue;
20097
- }
20098
- if (value.includes(":")) {
20099
- result.push(`${key}: |-`);
20100
- result.push(` ${value}`);
20101
- continue;
20102
- }
20103
- result.push(line);
20104
- }
20105
- const processed = result.join("\n");
20106
- return content.replace(frontmatter, () => processed);
20107
- }
20108
- ConfigMarkdown2.fallbackSanitization = fallbackSanitization;
20109
- async function parse(context, filePath) {
20110
- const template = await context.fs.readText(filePath);
20111
- try {
20112
- return parseFrontmatter(template);
20113
- } catch {
20114
- try {
20115
- return parseFrontmatter(fallbackSanitization(template));
20116
- } catch (err) {
20117
- throw new ConfigMarkdown2.FrontmatterError(
20118
- {
20119
- path: filePath,
20120
- message: `${filePath}: Failed to parse YAML frontmatter: ${err instanceof Error ? err.message : String(err)}`
20121
- },
20122
- { cause: err }
20123
- );
20124
- }
20125
- }
20126
- }
20127
- ConfigMarkdown2.parse = parse;
20128
- ConfigMarkdown2.FrontmatterError = NamedError.create(
20129
- "ConfigFrontmatterError",
20130
- external_exports.object({
20131
- path: external_exports.string(),
20132
- message: external_exports.string()
20133
- })
20134
- );
20135
- })(ConfigMarkdown || (ConfigMarkdown = {}));
20136
- var Skill;
20137
- ((Skill2) => {
20138
- Skill2.Info = zod_default.object({
20139
- name: zod_default.string(),
20140
- description: zod_default.string(),
20141
- location: zod_default.string(),
20142
- content: zod_default.string()
20143
- });
20144
- const SKILL_DIRS = [".claude", ".agents", ".opencode"];
20145
- const SKILL_GLOB = "skills/**/SKILL.md";
20146
- const ANY_SKILL_GLOB = "**/SKILL.md";
20147
- class SkillService {
20148
- _promise;
20149
- constructor(context) {
20150
- this._promise = discover(context);
20151
- }
20152
- async get(name) {
20153
- return (await this._promise).skills[name];
20154
- }
20155
- async all() {
20156
- return Object.values((await this._promise).skills);
20157
- }
20158
- async dirs() {
20159
- return (await this._promise).dirs;
20160
- }
20161
- }
20162
- Skill2.SkillService = SkillService;
20163
- async function discover(context) {
20164
- const log = context.log.create({ service: "skill" });
20165
- const skills = {};
20166
- const dirs = /* @__PURE__ */ new Set();
20167
- const addSkill = async (match) => {
20168
- const md = await ConfigMarkdown.parse(context, match).catch((err) => {
20169
- log.error("failed to load skill", { skill: match, err });
20170
- return void 0;
20171
- });
20172
- if (!md) return;
20173
- const parsed = Skill2.Info.pick({ name: true, description: true }).safeParse(md.data);
20174
- if (!parsed.success) return;
20175
- if (skills[parsed.data.name]) {
20176
- log.warn("duplicate skill", { name: parsed.data.name, existing: skills[parsed.data.name].location, duplicate: match });
20177
- }
20178
- dirs.add(dirname(match));
20179
- skills[parsed.data.name] = {
20180
- name: parsed.data.name,
20181
- description: parsed.data.description,
20182
- location: match,
20183
- content: md.content
20184
- };
20185
- };
20186
- const scan = async (pattern, cwd) => {
20187
- const matches = await context.fs.glob(pattern, { cwd, absolute: true, dot: true, follow: true, nodir: true }).catch(() => []);
20188
- await Promise.all(matches.map(addSkill));
20189
- };
20190
- let current = context.directory;
20191
- while (true) {
20192
- for (const target of SKILL_DIRS) {
20193
- const search = join(current, target);
20194
- if (await context.fs.exists(search)) await scan(SKILL_GLOB, search);
20195
- }
20196
- if (context.worktree === current) break;
20197
- const parent = dirname(current);
20198
- if (parent === current) break;
20199
- current = parent;
20200
- }
20201
- for (const skillPath of context.config.skills?.paths ?? []) {
20202
- const resolved = isAbsolute(skillPath) ? skillPath : join(context.directory, skillPath);
20203
- if (!await context.fs.isDir(resolved)) {
20204
- log.warn("skill path not found", { path: resolved });
20205
- continue;
20206
- }
20207
- await scan(ANY_SKILL_GLOB, resolved);
20208
- }
20209
- return { skills, dirs: Array.from(dirs) };
20210
- }
20211
- function fmt(list, opts) {
20212
- if (list.length === 0) return "No skills are currently available.";
20213
- if (opts.verbose) {
20214
- return [
20215
- "<available_skills>",
20216
- ...list.flatMap((s) => [
20217
- ` <skill>`,
20218
- ` <name>${s.name}</name>`,
20219
- ` <description>${s.description}</description>`,
20220
- ` <location>${pathToFileURL(s.location).href}</location>`,
20221
- ` </skill>`
20222
- ]),
20223
- "</available_skills>"
20224
- ].join("\n");
20225
- }
20226
- return ["## Available Skills", ...list.map((s) => `- **${s.name}**: ${s.description}`)].join("\n");
20227
- }
20228
- Skill2.fmt = fmt;
20229
- })(Skill || (Skill = {}));
20230
- var SkillTool = Tool.define("skill", async (ctx) => {
20231
- const list = await ctx?.agentContext?.skill.all() ?? [];
20232
- const description = list.length === 0 ? "Load a specialized skill that provides domain-specific instructions and workflows. No skills are currently available." : [
20233
- "Load a specialized skill that provides domain-specific instructions and workflows.",
20234
- "",
20235
- "When you recognize that a task matches one of the available skills listed below, use this tool to load the full skill instructions.",
20236
- "",
20237
- "The skill will inject detailed instructions, workflows, and access to bundled resources (scripts, references, templates) into the conversation context.",
20238
- "",
20239
- 'Tool output includes a `<skill_content name="...">` block with the loaded content.',
20240
- "",
20241
- "The following skills provide specialized sets of instructions for particular tasks",
20242
- "Invoke this tool to load a skill when a task matches one of the available skills listed below:",
20243
- "",
20244
- Skill.fmt(list, { verbose: false })
20245
- ].join("\n");
20246
- const examples = list.map((skill) => `'${skill.name}'`).slice(0, 3).join(", ");
20247
- const hint = examples.length > 0 ? ` (e.g., ${examples}, ...)` : "";
20248
- const parameters = zod_default.object({
20249
- name: zod_default.string().describe(`The name of the skill from available_skills${hint}`)
20250
- });
20251
- return {
20252
- description,
20253
- parameters,
20254
- async execute(params, ctx2) {
20255
- const skill = await ctx2.skill.get(params.name);
20256
- if (!skill) {
20257
- const available = await ctx2.skill.all().then((x) => x.map((skill2) => skill2.name).join(", "));
20258
- throw new Error(`Skill "${params.name}" not found. Available skills: ${available || "none"}`);
20259
- }
20260
- await ctx2.ask({
20261
- permission: "skill",
20262
- patterns: [params.name],
20263
- always: [params.name],
20264
- metadata: {}
20265
- });
20266
- const dir = dirname(skill.location);
20267
- const base = pathToFileURL2(dir).href;
20268
- const limit = 10;
20269
- const files = await iife(async () => {
20270
- if (!ctx2.search) throw new Error("Search provider is required for the skill tool");
20271
- const filePaths = await ctx2.search.listFiles({
20272
- cwd: dir,
20273
- follow: false,
20274
- hidden: true,
20275
- limit: limit + 1,
20276
- // Extra to filter out SKILL.md
20277
- signal: ctx2.abort
20278
- });
20279
- const arr = [];
20280
- for (const file of filePaths) {
20281
- if (file.includes("SKILL.md")) {
20282
- continue;
20283
- }
20284
- arr.push(resolve(dir, file));
20285
- if (arr.length >= limit) {
20286
- break;
20287
- }
20288
- }
20289
- return arr;
20290
- }).then((f) => f.map((file) => `<file>${file}</file>`).join("\n"));
20291
- return {
20292
- title: `Loaded skill: ${skill.name}`,
20293
- output: [
20294
- `<skill_content name="${skill.name}">`,
20295
- `# Skill: ${skill.name}`,
20296
- "",
20297
- skill.content.trim(),
20298
- "",
20299
- `Base directory for this skill: ${base}`,
20300
- "Relative paths in this skill (e.g., scripts/, reference/) are relative to this base directory.",
20301
- "Note: file list is sampled.",
20302
- "",
20303
- "<skill_files>",
20304
- files,
20305
- "</skill_files>",
20306
- "</skill_content>"
20307
- ].join("\n"),
20308
- metadata: {
20309
- name: skill.name,
20310
- dir
20311
- }
20312
- };
20313
- }
20314
- };
20315
- });
20316
20757
  var DESCRIPTION8 = `- Search the web using Exa AI - performs real-time web searches and can scrape content from specific URLs
20317
20758
  - Provides up-to-date information for current events and recent data
20318
20759
  - Supports configurable result counts and returns the content from the most relevant websites
@@ -21199,12 +21640,6 @@ var ApplyPatchTool = Tool.define("apply_patch", {
21199
21640
  ctx.emit("file.edited", { file: edited });
21200
21641
  }
21201
21642
  }
21202
- for (const change of fileChanges) {
21203
- if (change.type === "delete") continue;
21204
- const target = change.movePath ?? change.filePath;
21205
- await LSP.touchFile(target, true);
21206
- }
21207
- const diagnostics = await LSP.diagnostics();
21208
21643
  const summaryLines = fileChanges.map((change) => {
21209
21644
  if (change.type === "add") {
21210
21645
  return `A ${relative(ctx.worktree, change.filePath).replaceAll("\\", "/")}`;
@@ -21215,91 +21650,35 @@ var ApplyPatchTool = Tool.define("apply_patch", {
21215
21650
  const target = change.movePath ?? change.filePath;
21216
21651
  return `M ${relative(ctx.worktree, target).replaceAll("\\", "/")}`;
21217
21652
  });
21218
- let output = `Success. Updated the following files:
21653
+ const output = `Success. Updated the following files:
21219
21654
  ${summaryLines.join("\n")}`;
21220
- const MAX_DIAGNOSTICS_PER_FILE3 = 20;
21221
- for (const change of fileChanges) {
21222
- if (change.type === "delete") continue;
21223
- const target = change.movePath ?? change.filePath;
21224
- const normalized = target;
21225
- const issues = diagnostics.get(normalized) ?? [];
21226
- const errors = issues.filter((item) => item.severity === 1);
21227
- if (errors.length > 0) {
21228
- const limited = errors.slice(0, MAX_DIAGNOSTICS_PER_FILE3);
21229
- const suffix = errors.length > MAX_DIAGNOSTICS_PER_FILE3 ? `
21230
- ... and ${errors.length - MAX_DIAGNOSTICS_PER_FILE3} more` : "";
21231
- output += `
21232
-
21233
- LSP errors detected in ${relative(ctx.worktree, target).replaceAll("\\", "/")}, please fix:
21234
- <diagnostics file="${target}">
21235
- ${limited.map(LSP.Diagnostic.pretty).join("\n")}${suffix}
21236
- </diagnostics>`;
21237
- }
21238
- }
21239
21655
  return {
21240
21656
  title: output,
21241
21657
  metadata: {
21242
21658
  diff: totalDiff,
21243
21659
  files,
21244
- diagnostics
21660
+ diagnostics: {}
21245
21661
  },
21246
21662
  output
21247
21663
  };
21248
21664
  }
21249
21665
  });
21250
- var ToolRegistry;
21251
- ((ToolRegistry2) => {
21252
- class ToolRegistryService {
21253
- _promise;
21254
- context;
21255
- constructor(context) {
21256
- this.context = context;
21257
- this._promise = initTools(context);
21258
- }
21259
- async register(tool) {
21260
- const { custom } = await this._promise;
21261
- const idx = custom.findIndex((t) => t.id === tool.id);
21262
- if (idx >= 0) {
21263
- custom.splice(idx, 1, tool);
21264
- return;
21265
- }
21266
- custom.push(tool);
21267
- }
21268
- async tools(model) {
21269
- return ToolRegistry2.tools(this.context, model);
21270
- }
21666
+ var ToolRegistryService = class {
21667
+ _custom = [];
21668
+ context;
21669
+ constructor(context) {
21670
+ this.context = context;
21271
21671
  }
21272
- ToolRegistry2.ToolRegistryService = ToolRegistryService;
21273
- async function initTools(context) {
21274
- const custom = [];
21275
- return { custom };
21276
- }
21277
- function fromPlugin(id, def) {
21278
- return {
21279
- id,
21280
- init: async (initCtx) => ({
21281
- parameters: zod_default.object(def.args),
21282
- description: def.description,
21283
- execute: async (args, ctx) => {
21284
- const pluginCtx = {
21285
- ...ctx,
21286
- directory: ctx.directory,
21287
- worktree: ctx.worktree
21288
- };
21289
- const result = await def.execute(args, pluginCtx);
21290
- const out = await Truncate.output(ctx, result, {});
21291
- return {
21292
- title: "",
21293
- output: out.truncated ? out.content : result,
21294
- metadata: { truncated: out.truncated, outputPath: out.truncated ? out.outputPath : void 0 }
21295
- };
21296
- }
21297
- })
21298
- };
21672
+ async register(tool) {
21673
+ const idx = this._custom.findIndex((t) => t.id === tool.id);
21674
+ if (idx >= 0) {
21675
+ this._custom.splice(idx, 1, tool);
21676
+ return;
21677
+ }
21678
+ this._custom.push(tool);
21299
21679
  }
21300
- async function all(context) {
21301
- const custom = await context.toolRegistry._promise.then((x) => x.custom);
21302
- const config = context.config;
21680
+ all() {
21681
+ const config = this.context.config;
21303
21682
  return [
21304
21683
  InvalidTool,
21305
21684
  BashTool,
@@ -21313,22 +21692,21 @@ var ToolRegistry;
21313
21692
  // TodoReadTool,
21314
21693
  WebSearchTool,
21315
21694
  CodeSearchTool,
21316
- SkillTool,
21317
21695
  ApplyPatchTool,
21318
- ...context.tools ?? [],
21696
+ ...this.context.tools ?? [],
21319
21697
  ...config.experimental?.batch_tool === true ? [BatchTool] : [],
21320
21698
  ...Flag.OPENCODE_EXPERIMENTAL_PLAN_MODE && Flag.OPENCODE_CLIENT === "cli" ? [PlanExitTool] : [],
21321
- ...custom
21699
+ ...this._custom
21322
21700
  ];
21323
21701
  }
21324
- async function ids(context) {
21325
- return all(context).then((x) => x.map((t) => t.id));
21702
+ async ids() {
21703
+ return this.all().map((t) => t.id);
21326
21704
  }
21327
- ToolRegistry2.ids = ids;
21328
- async function tools(context, model) {
21329
- const tools2 = await all(context);
21705
+ async tools(model) {
21706
+ const tools = this.all();
21707
+ const context = this.context;
21330
21708
  const result = await Promise.all(
21331
- tools2.filter((t) => {
21709
+ tools.filter((t) => {
21332
21710
  if (t.id === "codesearch" || t.id === "websearch") {
21333
21711
  return model.providerID === ProviderID.opencode || Flag.OPENCODE_ENABLE_EXA;
21334
21712
  }
@@ -21360,17 +21738,18 @@ var ToolRegistry;
21360
21738
  );
21361
21739
  return result;
21362
21740
  }
21363
- ToolRegistry2.tools = tools;
21364
- })(ToolRegistry || (ToolRegistry = {}));
21741
+ };
21365
21742
 
21366
21743
  export {
21744
+ consoleLogger,
21745
+ NodeFS,
21746
+ NodeSearchProvider,
21747
+ SqlJsStorage,
21367
21748
  SchedulerService,
21368
21749
  Tool,
21369
- LSP,
21750
+ Flag,
21370
21751
  ReadTool,
21371
- ConfigMarkdown,
21372
- Skill,
21373
- ToolRegistry
21752
+ ToolRegistryService
21374
21753
  };
21375
21754
  /*! Bundled license information:
21376
21755