@kl-c/matrixos 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/config-manager/load-gateway-env.d.ts +10 -0
- package/dist/cli/config-manager/write-gateway-env.d.ts +7 -2
- package/dist/cli/gateway-set-token.d.ts +12 -0
- package/dist/cli/index.js +229 -87
- package/dist/cli-node/index.js +229 -87
- package/dist/index.js +678 -609
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13991,18 +13991,18 @@ __export(exports_storage, {
|
|
|
13991
13991
|
getStateFilePath: () => getStateFilePath,
|
|
13992
13992
|
clearState: () => clearState
|
|
13993
13993
|
});
|
|
13994
|
-
import { existsSync as
|
|
13995
|
-
import { dirname as dirname25, join as
|
|
13994
|
+
import { existsSync as existsSync75, readFileSync as readFileSync49, writeFileSync as writeFileSync18, unlinkSync as unlinkSync13, mkdirSync as mkdirSync18 } from "fs";
|
|
13995
|
+
import { dirname as dirname25, join as join87 } from "path";
|
|
13996
13996
|
function getStateFilePath(directory, customPath) {
|
|
13997
|
-
return customPath ?
|
|
13997
|
+
return customPath ? join87(directory, customPath) : join87(directory, DEFAULT_STATE_FILE);
|
|
13998
13998
|
}
|
|
13999
13999
|
function readState(directory, customPath) {
|
|
14000
14000
|
const filePath = getStateFilePath(directory, customPath);
|
|
14001
|
-
if (!
|
|
14001
|
+
if (!existsSync75(filePath)) {
|
|
14002
14002
|
return null;
|
|
14003
14003
|
}
|
|
14004
14004
|
try {
|
|
14005
|
-
const content =
|
|
14005
|
+
const content = readFileSync49(filePath, "utf-8");
|
|
14006
14006
|
const { data, body } = parseFrontmatter(content);
|
|
14007
14007
|
const active = data.active;
|
|
14008
14008
|
const iteration = data.iteration;
|
|
@@ -14049,7 +14049,7 @@ function writeState(directory, state3, customPath) {
|
|
|
14049
14049
|
const filePath = getStateFilePath(directory, customPath);
|
|
14050
14050
|
try {
|
|
14051
14051
|
const dir = dirname25(filePath);
|
|
14052
|
-
if (!
|
|
14052
|
+
if (!existsSync75(dir)) {
|
|
14053
14053
|
mkdirSync18(dir, { recursive: true });
|
|
14054
14054
|
}
|
|
14055
14055
|
const sessionIdLine = state3.session_id ? `session_id: "${state3.session_id}"
|
|
@@ -14094,7 +14094,7 @@ ${state3.prompt}
|
|
|
14094
14094
|
function clearState(directory, customPath) {
|
|
14095
14095
|
const filePath = getStateFilePath(directory, customPath);
|
|
14096
14096
|
try {
|
|
14097
|
-
if (
|
|
14097
|
+
if (existsSync75(filePath)) {
|
|
14098
14098
|
unlinkSync13(filePath);
|
|
14099
14099
|
}
|
|
14100
14100
|
return true;
|
|
@@ -57285,7 +57285,7 @@ var require_dist10 = __commonJS((exports, module) => {
|
|
|
57285
57285
|
var import_node_worker_threads2 = __require("worker_threads");
|
|
57286
57286
|
var import_collection2 = require_dist3();
|
|
57287
57287
|
var import_node_events = __require("events");
|
|
57288
|
-
var
|
|
57288
|
+
var import_node_path130 = __require("path");
|
|
57289
57289
|
var import_node_worker_threads = __require("worker_threads");
|
|
57290
57290
|
var import_collection = require_dist3();
|
|
57291
57291
|
var WorkerSendPayloadOp = /* @__PURE__ */ ((WorkerSendPayloadOp2) => {
|
|
@@ -57420,18 +57420,18 @@ var require_dist10 = __commonJS((exports, module) => {
|
|
|
57420
57420
|
resolveWorkerPath() {
|
|
57421
57421
|
const path28 = this.options.workerPath;
|
|
57422
57422
|
if (!path28) {
|
|
57423
|
-
return (0,
|
|
57423
|
+
return (0, import_node_path130.join)(__dirname, "defaultWorker.js");
|
|
57424
57424
|
}
|
|
57425
|
-
if ((0,
|
|
57425
|
+
if ((0, import_node_path130.isAbsolute)(path28)) {
|
|
57426
57426
|
return path28;
|
|
57427
57427
|
}
|
|
57428
57428
|
if (/^\.\.?[/\\]/.test(path28)) {
|
|
57429
|
-
return (0,
|
|
57429
|
+
return (0, import_node_path130.resolve)(path28);
|
|
57430
57430
|
}
|
|
57431
57431
|
try {
|
|
57432
57432
|
return __require.resolve(path28);
|
|
57433
57433
|
} catch {
|
|
57434
|
-
return (0,
|
|
57434
|
+
return (0, import_node_path130.resolve)(path28);
|
|
57435
57435
|
}
|
|
57436
57436
|
}
|
|
57437
57437
|
async waitForWorkerReady(worker) {
|
|
@@ -196791,7 +196791,7 @@ var require_filesystem = __commonJS((exports, module) => {
|
|
|
196791
196791
|
var LDD_PATH = "/usr/bin/ldd";
|
|
196792
196792
|
var SELF_PATH = "/proc/self/exe";
|
|
196793
196793
|
var MAX_LENGTH = 2048;
|
|
196794
|
-
var
|
|
196794
|
+
var readFileSync79 = (path28) => {
|
|
196795
196795
|
const fd = fs26.openSync(path28, "r");
|
|
196796
196796
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
196797
196797
|
const bytesRead = fs26.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
@@ -196814,7 +196814,7 @@ var require_filesystem = __commonJS((exports, module) => {
|
|
|
196814
196814
|
module.exports = {
|
|
196815
196815
|
LDD_PATH,
|
|
196816
196816
|
SELF_PATH,
|
|
196817
|
-
readFileSync:
|
|
196817
|
+
readFileSync: readFileSync79,
|
|
196818
196818
|
readFile: readFile14
|
|
196819
196819
|
};
|
|
196820
196820
|
});
|
|
@@ -196857,7 +196857,7 @@ var require_elf = __commonJS((exports, module) => {
|
|
|
196857
196857
|
var require_detect_libc = __commonJS((exports, module) => {
|
|
196858
196858
|
var childProcess3 = __require("child_process");
|
|
196859
196859
|
var { isLinux, getReport } = require_process();
|
|
196860
|
-
var { LDD_PATH, SELF_PATH, readFile: readFile14, readFileSync:
|
|
196860
|
+
var { LDD_PATH, SELF_PATH, readFile: readFile14, readFileSync: readFileSync79 } = require_filesystem();
|
|
196861
196861
|
var { interpreterPath } = require_elf();
|
|
196862
196862
|
var cachedFamilyInterpreter;
|
|
196863
196863
|
var cachedFamilyFilesystem;
|
|
@@ -196948,7 +196948,7 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
196948
196948
|
}
|
|
196949
196949
|
cachedFamilyFilesystem = null;
|
|
196950
196950
|
try {
|
|
196951
|
-
const lddContent =
|
|
196951
|
+
const lddContent = readFileSync79(LDD_PATH);
|
|
196952
196952
|
cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
|
|
196953
196953
|
} catch (e) {}
|
|
196954
196954
|
return cachedFamilyFilesystem;
|
|
@@ -196971,7 +196971,7 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
196971
196971
|
}
|
|
196972
196972
|
cachedFamilyInterpreter = null;
|
|
196973
196973
|
try {
|
|
196974
|
-
const selfContent =
|
|
196974
|
+
const selfContent = readFileSync79(SELF_PATH);
|
|
196975
196975
|
const path28 = interpreterPath(selfContent);
|
|
196976
196976
|
cachedFamilyInterpreter = familyFromInterpreterPath(path28);
|
|
196977
196977
|
} catch (e) {}
|
|
@@ -197033,7 +197033,7 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
197033
197033
|
}
|
|
197034
197034
|
cachedVersionFilesystem = null;
|
|
197035
197035
|
try {
|
|
197036
|
-
const lddContent =
|
|
197036
|
+
const lddContent = readFileSync79(LDD_PATH);
|
|
197037
197037
|
const versionMatch = lddContent.match(RE_GLIBC_VERSION);
|
|
197038
197038
|
if (versionMatch) {
|
|
197039
197039
|
cachedVersionFilesystem = versionMatch[1];
|
|
@@ -233073,7 +233073,7 @@ import * as Crypto from "crypto";
|
|
|
233073
233073
|
import { once } from "events";
|
|
233074
233074
|
import { createReadStream, createWriteStream, promises as fs26, WriteStream } from "fs";
|
|
233075
233075
|
import { tmpdir as tmpdir8 } from "os";
|
|
233076
|
-
import { join as
|
|
233076
|
+
import { join as join138 } from "path";
|
|
233077
233077
|
import { Readable as Readable2, Transform } from "stream";
|
|
233078
233078
|
import { URL as URL2 } from "url";
|
|
233079
233079
|
async function getMediaKeys(buffer2, mediaType) {
|
|
@@ -233151,7 +233151,7 @@ async function generateThumbnail(file2, mediaType, options) {
|
|
|
233151
233151
|
};
|
|
233152
233152
|
}
|
|
233153
233153
|
} else if (mediaType === "video") {
|
|
233154
|
-
const imgFilename =
|
|
233154
|
+
const imgFilename = join138(getTmpFilesDirectory(), generateMessageIDV2() + ".jpg");
|
|
233155
233155
|
try {
|
|
233156
233156
|
await extractVideoThumb(file2, imgFilename, "00:00:00", { width: 32, height: 32 });
|
|
233157
233157
|
const buff = await fs26.readFile(imgFilename);
|
|
@@ -233194,7 +233194,7 @@ var import_boom5, getTmpFilesDirectory = () => tmpdir8(), getImageProcessingLibr
|
|
|
233194
233194
|
const { stream: stream3 } = await getStream(media);
|
|
233195
233195
|
logger7?.debug("got stream for raw upload");
|
|
233196
233196
|
const hasher = Crypto.createHash("sha256");
|
|
233197
|
-
const filePath =
|
|
233197
|
+
const filePath = join138(tmpdir8(), mediaType + generateMessageIDV2());
|
|
233198
233198
|
const fileWriteStream = createWriteStream(filePath);
|
|
233199
233199
|
let fileLength = 0;
|
|
233200
233200
|
try {
|
|
@@ -233334,12 +233334,12 @@ var import_boom5, getTmpFilesDirectory = () => tmpdir8(), getImageProcessingLibr
|
|
|
233334
233334
|
logger7?.debug("fetched media stream");
|
|
233335
233335
|
const mediaKey = Crypto.randomBytes(32);
|
|
233336
233336
|
const { cipherKey, iv, macKey } = await getMediaKeys(mediaKey, mediaType);
|
|
233337
|
-
const encFilePath =
|
|
233337
|
+
const encFilePath = join138(getTmpFilesDirectory(), mediaType + generateMessageIDV2() + "-enc");
|
|
233338
233338
|
const encFileWriteStream = createWriteStream(encFilePath);
|
|
233339
233339
|
let originalFileStream;
|
|
233340
233340
|
let originalFilePath;
|
|
233341
233341
|
if (saveOriginalFileIfRequired) {
|
|
233342
|
-
originalFilePath =
|
|
233342
|
+
originalFilePath = join138(getTmpFilesDirectory(), mediaType + generateMessageIDV2() + "-original");
|
|
233343
233343
|
originalFileStream = createWriteStream(originalFilePath);
|
|
233344
233344
|
}
|
|
233345
233345
|
let fileLength = 0;
|
|
@@ -242744,7 +242744,7 @@ var init_auth_utils = __esm(() => {
|
|
|
242744
242744
|
|
|
242745
242745
|
// node_modules/.bun/@whiskeysockets+baileys@7.0.0-rc13+13d21a63c79191a3/node_modules/@whiskeysockets/baileys/lib/Utils/use-multi-file-auth-state.js
|
|
242746
242746
|
import { mkdir as mkdir11, readFile as readFile14, stat as stat8, unlink as unlink3, writeFile as writeFile4 } from "fs/promises";
|
|
242747
|
-
import { join as
|
|
242747
|
+
import { join as join139 } from "path";
|
|
242748
242748
|
var fileLocks, getFileLock = (path28) => {
|
|
242749
242749
|
let mutex = fileLocks.get(path28);
|
|
242750
242750
|
if (!mutex) {
|
|
@@ -242754,7 +242754,7 @@ var fileLocks, getFileLock = (path28) => {
|
|
|
242754
242754
|
return mutex;
|
|
242755
242755
|
}, useMultiFileAuthState = async (folder) => {
|
|
242756
242756
|
const writeData = async (data3, file2) => {
|
|
242757
|
-
const filePath =
|
|
242757
|
+
const filePath = join139(folder, fixFileName(file2));
|
|
242758
242758
|
const mutex = getFileLock(filePath);
|
|
242759
242759
|
return mutex.acquire().then(async (release2) => {
|
|
242760
242760
|
try {
|
|
@@ -242766,7 +242766,7 @@ var fileLocks, getFileLock = (path28) => {
|
|
|
242766
242766
|
};
|
|
242767
242767
|
const readData = async (file2) => {
|
|
242768
242768
|
try {
|
|
242769
|
-
const filePath =
|
|
242769
|
+
const filePath = join139(folder, fixFileName(file2));
|
|
242770
242770
|
const mutex = getFileLock(filePath);
|
|
242771
242771
|
return await mutex.acquire().then(async (release2) => {
|
|
242772
242772
|
try {
|
|
@@ -242782,7 +242782,7 @@ var fileLocks, getFileLock = (path28) => {
|
|
|
242782
242782
|
};
|
|
242783
242783
|
const removeData = async (file2) => {
|
|
242784
242784
|
try {
|
|
242785
|
-
const filePath =
|
|
242785
|
+
const filePath = join139(folder, fixFileName(file2));
|
|
242786
242786
|
const mutex = getFileLock(filePath);
|
|
242787
242787
|
return mutex.acquire().then(async (release2) => {
|
|
242788
242788
|
try {
|
|
@@ -263753,7 +263753,7 @@ var require_thread_stream = __commonJS((exports, module) => {
|
|
|
263753
263753
|
var { version: version2 } = require_package3();
|
|
263754
263754
|
var { EventEmitter: EventEmitter4 } = __require("events");
|
|
263755
263755
|
var { Worker } = __require("worker_threads");
|
|
263756
|
-
var { join:
|
|
263756
|
+
var { join: join140 } = __require("path");
|
|
263757
263757
|
var { pathToFileURL: pathToFileURL2 } = __require("url");
|
|
263758
263758
|
var { wait: wait2 } = require_wait2();
|
|
263759
263759
|
var {
|
|
@@ -263796,7 +263796,7 @@ var require_thread_stream = __commonJS((exports, module) => {
|
|
|
263796
263796
|
function createWorker(stream3, opts) {
|
|
263797
263797
|
const { filename, workerData } = opts;
|
|
263798
263798
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
263799
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
263799
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join140(__dirname, "lib", "worker.js");
|
|
263800
263800
|
const worker = new Worker(toExecute, {
|
|
263801
263801
|
...opts.workerOpts,
|
|
263802
263802
|
trackUnmanagedFds: false,
|
|
@@ -264197,7 +264197,7 @@ var require_transport = __commonJS((exports, module) => {
|
|
|
264197
264197
|
var __dirname = "/home/shiro/MaTrixOS/node_modules/.bun/pino@9.14.0/node_modules/pino/lib";
|
|
264198
264198
|
var { createRequire: createRequire4 } = __require("module");
|
|
264199
264199
|
var getCallers = require_caller();
|
|
264200
|
-
var { join:
|
|
264200
|
+
var { join: join140, isAbsolute: isAbsolute21, sep: sep3 } = __require("path");
|
|
264201
264201
|
var sleep3 = require_atomic_sleep();
|
|
264202
264202
|
var onExit = require_on_exit_leak_free();
|
|
264203
264203
|
var ThreadStream = require_thread_stream();
|
|
@@ -264260,7 +264260,7 @@ var require_transport = __commonJS((exports, module) => {
|
|
|
264260
264260
|
throw new Error("only one of target or targets can be specified");
|
|
264261
264261
|
}
|
|
264262
264262
|
if (targets) {
|
|
264263
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
264263
|
+
target = bundlerOverrides["pino-worker"] || join140(__dirname, "worker.js");
|
|
264264
264264
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
264265
264265
|
return {
|
|
264266
264266
|
...dest,
|
|
@@ -264277,7 +264277,7 @@ var require_transport = __commonJS((exports, module) => {
|
|
|
264277
264277
|
});
|
|
264278
264278
|
});
|
|
264279
264279
|
} else if (pipeline3) {
|
|
264280
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
264280
|
+
target = bundlerOverrides["pino-worker"] || join140(__dirname, "worker.js");
|
|
264281
264281
|
options.pipelines = [pipeline3.map((dest) => {
|
|
264282
264282
|
return {
|
|
264283
264283
|
...dest,
|
|
@@ -264299,7 +264299,7 @@ var require_transport = __commonJS((exports, module) => {
|
|
|
264299
264299
|
return origin;
|
|
264300
264300
|
}
|
|
264301
264301
|
if (origin === "pino/file") {
|
|
264302
|
-
return
|
|
264302
|
+
return join140(__dirname, "..", "file.js");
|
|
264303
264303
|
}
|
|
264304
264304
|
let fixTarget2;
|
|
264305
264305
|
for (const filePath of callers) {
|
|
@@ -265237,7 +265237,7 @@ var require_safe_stable_stringify = __commonJS((exports, module) => {
|
|
|
265237
265237
|
return circularValue;
|
|
265238
265238
|
}
|
|
265239
265239
|
let res = "";
|
|
265240
|
-
let
|
|
265240
|
+
let join140 = ",";
|
|
265241
265241
|
const originalIndentation = indentation;
|
|
265242
265242
|
if (Array.isArray(value)) {
|
|
265243
265243
|
if (value.length === 0) {
|
|
@@ -265251,7 +265251,7 @@ var require_safe_stable_stringify = __commonJS((exports, module) => {
|
|
|
265251
265251
|
indentation += spacer;
|
|
265252
265252
|
res += `
|
|
265253
265253
|
${indentation}`;
|
|
265254
|
-
|
|
265254
|
+
join140 = `,
|
|
265255
265255
|
${indentation}`;
|
|
265256
265256
|
}
|
|
265257
265257
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -265259,13 +265259,13 @@ ${indentation}`;
|
|
|
265259
265259
|
for (;i < maximumValuesToStringify - 1; i++) {
|
|
265260
265260
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
265261
265261
|
res += tmp2 !== undefined ? tmp2 : "null";
|
|
265262
|
-
res +=
|
|
265262
|
+
res += join140;
|
|
265263
265263
|
}
|
|
265264
265264
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
265265
265265
|
res += tmp !== undefined ? tmp : "null";
|
|
265266
265266
|
if (value.length - 1 > maximumBreadth) {
|
|
265267
265267
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
265268
|
-
res += `${
|
|
265268
|
+
res += `${join140}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
265269
265269
|
}
|
|
265270
265270
|
if (spacer !== "") {
|
|
265271
265271
|
res += `
|
|
@@ -265286,7 +265286,7 @@ ${originalIndentation}`;
|
|
|
265286
265286
|
let separator = "";
|
|
265287
265287
|
if (spacer !== "") {
|
|
265288
265288
|
indentation += spacer;
|
|
265289
|
-
|
|
265289
|
+
join140 = `,
|
|
265290
265290
|
${indentation}`;
|
|
265291
265291
|
whitespace = " ";
|
|
265292
265292
|
}
|
|
@@ -265300,13 +265300,13 @@ ${indentation}`;
|
|
|
265300
265300
|
const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
|
|
265301
265301
|
if (tmp !== undefined) {
|
|
265302
265302
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
265303
|
-
separator =
|
|
265303
|
+
separator = join140;
|
|
265304
265304
|
}
|
|
265305
265305
|
}
|
|
265306
265306
|
if (keyLength > maximumBreadth) {
|
|
265307
265307
|
const removedKeys = keyLength - maximumBreadth;
|
|
265308
265308
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
265309
|
-
separator =
|
|
265309
|
+
separator = join140;
|
|
265310
265310
|
}
|
|
265311
265311
|
if (spacer !== "" && separator.length > 1) {
|
|
265312
265312
|
res = `
|
|
@@ -265346,7 +265346,7 @@ ${originalIndentation}`;
|
|
|
265346
265346
|
}
|
|
265347
265347
|
const originalIndentation = indentation;
|
|
265348
265348
|
let res = "";
|
|
265349
|
-
let
|
|
265349
|
+
let join140 = ",";
|
|
265350
265350
|
if (Array.isArray(value)) {
|
|
265351
265351
|
if (value.length === 0) {
|
|
265352
265352
|
return "[]";
|
|
@@ -265359,7 +265359,7 @@ ${originalIndentation}`;
|
|
|
265359
265359
|
indentation += spacer;
|
|
265360
265360
|
res += `
|
|
265361
265361
|
${indentation}`;
|
|
265362
|
-
|
|
265362
|
+
join140 = `,
|
|
265363
265363
|
${indentation}`;
|
|
265364
265364
|
}
|
|
265365
265365
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -265367,13 +265367,13 @@ ${indentation}`;
|
|
|
265367
265367
|
for (;i < maximumValuesToStringify - 1; i++) {
|
|
265368
265368
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
265369
265369
|
res += tmp2 !== undefined ? tmp2 : "null";
|
|
265370
|
-
res +=
|
|
265370
|
+
res += join140;
|
|
265371
265371
|
}
|
|
265372
265372
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
265373
265373
|
res += tmp !== undefined ? tmp : "null";
|
|
265374
265374
|
if (value.length - 1 > maximumBreadth) {
|
|
265375
265375
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
265376
|
-
res += `${
|
|
265376
|
+
res += `${join140}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
265377
265377
|
}
|
|
265378
265378
|
if (spacer !== "") {
|
|
265379
265379
|
res += `
|
|
@@ -265386,7 +265386,7 @@ ${originalIndentation}`;
|
|
|
265386
265386
|
let whitespace = "";
|
|
265387
265387
|
if (spacer !== "") {
|
|
265388
265388
|
indentation += spacer;
|
|
265389
|
-
|
|
265389
|
+
join140 = `,
|
|
265390
265390
|
${indentation}`;
|
|
265391
265391
|
whitespace = " ";
|
|
265392
265392
|
}
|
|
@@ -265395,7 +265395,7 @@ ${indentation}`;
|
|
|
265395
265395
|
const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
|
|
265396
265396
|
if (tmp !== undefined) {
|
|
265397
265397
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
265398
|
-
separator =
|
|
265398
|
+
separator = join140;
|
|
265399
265399
|
}
|
|
265400
265400
|
}
|
|
265401
265401
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -265452,20 +265452,20 @@ ${originalIndentation}`;
|
|
|
265452
265452
|
indentation += spacer;
|
|
265453
265453
|
let res2 = `
|
|
265454
265454
|
${indentation}`;
|
|
265455
|
-
const
|
|
265455
|
+
const join141 = `,
|
|
265456
265456
|
${indentation}`;
|
|
265457
265457
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
265458
265458
|
let i = 0;
|
|
265459
265459
|
for (;i < maximumValuesToStringify - 1; i++) {
|
|
265460
265460
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
265461
265461
|
res2 += tmp2 !== undefined ? tmp2 : "null";
|
|
265462
|
-
res2 +=
|
|
265462
|
+
res2 += join141;
|
|
265463
265463
|
}
|
|
265464
265464
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
265465
265465
|
res2 += tmp !== undefined ? tmp : "null";
|
|
265466
265466
|
if (value.length - 1 > maximumBreadth) {
|
|
265467
265467
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
265468
|
-
res2 += `${
|
|
265468
|
+
res2 += `${join141}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
265469
265469
|
}
|
|
265470
265470
|
res2 += `
|
|
265471
265471
|
${originalIndentation}`;
|
|
@@ -265481,16 +265481,16 @@ ${originalIndentation}`;
|
|
|
265481
265481
|
return '"[Object]"';
|
|
265482
265482
|
}
|
|
265483
265483
|
indentation += spacer;
|
|
265484
|
-
const
|
|
265484
|
+
const join140 = `,
|
|
265485
265485
|
${indentation}`;
|
|
265486
265486
|
let res = "";
|
|
265487
265487
|
let separator = "";
|
|
265488
265488
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
265489
265489
|
if (isTypedArrayWithEntries(value)) {
|
|
265490
|
-
res += stringifyTypedArray(value,
|
|
265490
|
+
res += stringifyTypedArray(value, join140, maximumBreadth);
|
|
265491
265491
|
keys = keys.slice(value.length);
|
|
265492
265492
|
maximumPropertiesToStringify -= value.length;
|
|
265493
|
-
separator =
|
|
265493
|
+
separator = join140;
|
|
265494
265494
|
}
|
|
265495
265495
|
if (deterministic) {
|
|
265496
265496
|
keys = sort(keys, comparator);
|
|
@@ -265501,13 +265501,13 @@ ${indentation}`;
|
|
|
265501
265501
|
const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
|
|
265502
265502
|
if (tmp !== undefined) {
|
|
265503
265503
|
res += `${separator}${strEscape(key2)}: ${tmp}`;
|
|
265504
|
-
separator =
|
|
265504
|
+
separator = join140;
|
|
265505
265505
|
}
|
|
265506
265506
|
}
|
|
265507
265507
|
if (keyLength > maximumBreadth) {
|
|
265508
265508
|
const removedKeys = keyLength - maximumBreadth;
|
|
265509
265509
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
265510
|
-
separator =
|
|
265510
|
+
separator = join140;
|
|
265511
265511
|
}
|
|
265512
265512
|
if (separator !== "") {
|
|
265513
265513
|
res = `
|
|
@@ -266157,7 +266157,7 @@ var init_Defaults = __esm(() => {
|
|
|
266157
266157
|
import { createHash as createHash13 } from "crypto";
|
|
266158
266158
|
import { createWriteStream as createWriteStream2, promises as fs28 } from "fs";
|
|
266159
266159
|
import { tmpdir as tmpdir9 } from "os";
|
|
266160
|
-
import { join as
|
|
266160
|
+
import { join as join140 } from "path";
|
|
266161
266161
|
async function uploadingNecessaryImagesOfProduct(product, waUploadToServer, timeoutMs = 30000) {
|
|
266162
266162
|
product = {
|
|
266163
266163
|
...product,
|
|
@@ -266335,7 +266335,7 @@ var import_boom12, parseCatalogNode = (node) => {
|
|
|
266335
266335
|
}
|
|
266336
266336
|
const { stream: stream3 } = await getStream(img);
|
|
266337
266337
|
const hasher = createHash13("sha256");
|
|
266338
|
-
const filePath =
|
|
266338
|
+
const filePath = join140(tmpdir9(), "img" + generateMessageIDV2());
|
|
266339
266339
|
const encFileWriteStream = createWriteStream2(filePath);
|
|
266340
266340
|
for await (const block2 of stream3) {
|
|
266341
266341
|
hasher.update(block2);
|
|
@@ -297183,18 +297183,18 @@ var init_merge = __esm(() => {
|
|
|
297183
297183
|
});
|
|
297184
297184
|
|
|
297185
297185
|
// packages/omo-config-core/src/loader/types.ts
|
|
297186
|
-
import { existsSync as
|
|
297186
|
+
import { existsSync as existsSync116, lstatSync as lstatSync5, readFileSync as readFileSync79 } from "fs";
|
|
297187
297187
|
var DEFAULT_READ_FILE_SYSTEM;
|
|
297188
297188
|
var init_types7 = __esm(() => {
|
|
297189
297189
|
DEFAULT_READ_FILE_SYSTEM = {
|
|
297190
|
-
existsSync:
|
|
297190
|
+
existsSync: existsSync116,
|
|
297191
297191
|
lstatSync: lstatSync5,
|
|
297192
|
-
readFileSync:
|
|
297192
|
+
readFileSync: readFileSync79
|
|
297193
297193
|
};
|
|
297194
297194
|
});
|
|
297195
297195
|
|
|
297196
297196
|
// packages/omo-config-core/src/loader/paths.ts
|
|
297197
|
-
import { dirname as dirname45, isAbsolute as isAbsolute21, join as
|
|
297197
|
+
import { dirname as dirname45, isAbsolute as isAbsolute21, join as join141, relative as relative15, resolve as resolve42 } from "path";
|
|
297198
297198
|
function containsPath2(parent, child) {
|
|
297199
297199
|
const pathToChild = relative15(parent, child);
|
|
297200
297200
|
return pathToChild === "" || !pathToChild.startsWith("..") && !isAbsolute21(pathToChild);
|
|
@@ -297203,23 +297203,23 @@ function resolveHomeDir(env2 = process.env) {
|
|
|
297203
297203
|
return resolve42(env2.HOME ?? env2.USERPROFILE ?? process.cwd());
|
|
297204
297204
|
}
|
|
297205
297205
|
function resolveUserMatrixosConfigPath(env2 = process.env, platform4 = process.platform) {
|
|
297206
|
-
return
|
|
297206
|
+
return join141(resolveUserMatrixosConfigDirectory(env2, platform4), "omo.jsonc");
|
|
297207
297207
|
}
|
|
297208
297208
|
function resolveUserMatrixosConfigDirectory(env2 = process.env, platform4 = process.platform) {
|
|
297209
297209
|
if (platform4 === "win32" && env2.APPDATA !== undefined && env2.APPDATA.length > 0) {
|
|
297210
|
-
return
|
|
297210
|
+
return join141(env2.APPDATA, "omo");
|
|
297211
297211
|
}
|
|
297212
297212
|
if (env2.XDG_CONFIG_HOME !== undefined && env2.XDG_CONFIG_HOME.length > 0) {
|
|
297213
|
-
return
|
|
297213
|
+
return join141(env2.XDG_CONFIG_HOME, "omo");
|
|
297214
297214
|
}
|
|
297215
|
-
return
|
|
297215
|
+
return join141(resolveHomeDir(env2), ".config", "omo");
|
|
297216
297216
|
}
|
|
297217
297217
|
function detectUserOmoJsonPath(env2, platform4, fileSystem) {
|
|
297218
297218
|
const configDir = resolveUserMatrixosConfigDirectory(env2, platform4);
|
|
297219
|
-
const jsoncPath =
|
|
297219
|
+
const jsoncPath = join141(configDir, "omo.jsonc");
|
|
297220
297220
|
if (fileSystem.existsSync(jsoncPath))
|
|
297221
297221
|
return jsoncPath;
|
|
297222
|
-
const jsonPath =
|
|
297222
|
+
const jsonPath = join141(configDir, "omo.json");
|
|
297223
297223
|
return fileSystem.existsSync(jsonPath) ? jsonPath : jsoncPath;
|
|
297224
297224
|
}
|
|
297225
297225
|
function isSymlinkedProjectPath(path28, fileSystem) {
|
|
@@ -297237,13 +297237,13 @@ function isLoadableProjectConfigFile(path28, fileSystem) {
|
|
|
297237
297237
|
return fileSystem.existsSync(path28) && !isSymlinkedProjectPath(path28, fileSystem);
|
|
297238
297238
|
}
|
|
297239
297239
|
function detectOmoJsonPath(dir2, fileSystem) {
|
|
297240
|
-
const omoDir =
|
|
297240
|
+
const omoDir = join141(dir2, ".omo");
|
|
297241
297241
|
if (isSymlinkedProjectPath(omoDir, fileSystem))
|
|
297242
297242
|
return null;
|
|
297243
|
-
const jsoncPath =
|
|
297243
|
+
const jsoncPath = join141(omoDir, "omo.jsonc");
|
|
297244
297244
|
if (isLoadableProjectConfigFile(jsoncPath, fileSystem))
|
|
297245
297245
|
return jsoncPath;
|
|
297246
|
-
const jsonPath =
|
|
297246
|
+
const jsonPath = join141(omoDir, "omo.json");
|
|
297247
297247
|
return isLoadableProjectConfigFile(jsonPath, fileSystem) ? jsonPath : null;
|
|
297248
297248
|
}
|
|
297249
297249
|
function findProjectConfigPathsFarthestFirst(cwd, homeDir, fileSystem) {
|
|
@@ -297504,10 +297504,10 @@ var init_loader3 = __esm(() => {
|
|
|
297504
297504
|
// packages/omo-config-core/src/writer/types.ts
|
|
297505
297505
|
import {
|
|
297506
297506
|
copyFileSync as copyFileSync3,
|
|
297507
|
-
existsSync as
|
|
297507
|
+
existsSync as existsSync117,
|
|
297508
297508
|
lstatSync as lstatSync6,
|
|
297509
297509
|
mkdirSync as mkdirSync25,
|
|
297510
|
-
readFileSync as
|
|
297510
|
+
readFileSync as readFileSync80,
|
|
297511
297511
|
readdirSync as readdirSync29,
|
|
297512
297512
|
renameSync as renameSync10,
|
|
297513
297513
|
unlinkSync as unlinkSync17,
|
|
@@ -297517,10 +297517,10 @@ var DEFAULT_WRITE_FILE_SYSTEM, MatrixosConfigWriteError;
|
|
|
297517
297517
|
var init_types8 = __esm(() => {
|
|
297518
297518
|
DEFAULT_WRITE_FILE_SYSTEM = {
|
|
297519
297519
|
copyFileSync: copyFileSync3,
|
|
297520
|
-
existsSync:
|
|
297520
|
+
existsSync: existsSync117,
|
|
297521
297521
|
lstatSync: lstatSync6,
|
|
297522
297522
|
mkdirSync: mkdirSync25,
|
|
297523
|
-
readFileSync:
|
|
297523
|
+
readFileSync: readFileSync80,
|
|
297524
297524
|
readdirSync: readdirSync29,
|
|
297525
297525
|
renameSync: renameSync10,
|
|
297526
297526
|
unlinkSync: unlinkSync17,
|
|
@@ -297544,7 +297544,7 @@ var init_types8 = __esm(() => {
|
|
|
297544
297544
|
|
|
297545
297545
|
// packages/omo-config-core/src/writer/writer.ts
|
|
297546
297546
|
import { randomUUID as randomUUID13 } from "crypto";
|
|
297547
|
-
import { dirname as dirname46, join as
|
|
297547
|
+
import { dirname as dirname46, join as join142 } from "path";
|
|
297548
297548
|
function backupSuffix() {
|
|
297549
297549
|
return new Date().toISOString().replace(/[:.]/g, "-");
|
|
297550
297550
|
}
|
|
@@ -297575,13 +297575,13 @@ function resolveWritePath(options) {
|
|
|
297575
297575
|
const jsoncPath2 = resolveUserMatrixosConfigPath(options.env, options.platform ?? process.platform);
|
|
297576
297576
|
if (fileSystem.existsSync(jsoncPath2))
|
|
297577
297577
|
return jsoncPath2;
|
|
297578
|
-
const jsonPath2 =
|
|
297578
|
+
const jsonPath2 = join142(dirname46(jsoncPath2), "omo.json");
|
|
297579
297579
|
return fileSystem.existsSync(jsonPath2) ? jsonPath2 : jsoncPath2;
|
|
297580
297580
|
}
|
|
297581
|
-
const jsoncPath =
|
|
297581
|
+
const jsoncPath = join142(options.projectDir ?? process.cwd(), ".omo", "omo.jsonc");
|
|
297582
297582
|
if (fileSystem.existsSync(jsoncPath))
|
|
297583
297583
|
return jsoncPath;
|
|
297584
|
-
const jsonPath =
|
|
297584
|
+
const jsonPath = join142(dirname46(jsoncPath), "omo.json");
|
|
297585
297585
|
return fileSystem.existsSync(jsonPath) ? jsonPath : jsoncPath;
|
|
297586
297586
|
}
|
|
297587
297587
|
function writeAtomically(path28, content, fileSystem) {
|
|
@@ -297693,8 +297693,8 @@ var init_writer2 = __esm(() => {
|
|
|
297693
297693
|
});
|
|
297694
297694
|
|
|
297695
297695
|
// packages/omo-config-core/src/generator/mini-os-generator.ts
|
|
297696
|
-
import { existsSync as
|
|
297697
|
-
import { dirname as dirname47, join as
|
|
297696
|
+
import { existsSync as existsSync118, mkdirSync as mkdirSync26, writeFileSync as writeFileSync26 } from "fs";
|
|
297697
|
+
import { dirname as dirname47, join as join143 } from "path";
|
|
297698
297698
|
function generateMiniOS(options) {
|
|
297699
297699
|
const fs29 = options.fs ?? defaultFS;
|
|
297700
297700
|
const profile3 = options.profile;
|
|
@@ -297705,29 +297705,29 @@ function generateMiniOS(options) {
|
|
|
297705
297705
|
if (!fs29.existsSync(targetDir)) {
|
|
297706
297706
|
fs29.mkdirSync(targetDir, { recursive: true });
|
|
297707
297707
|
}
|
|
297708
|
-
const pkgPath =
|
|
297708
|
+
const pkgPath = join143(targetDir, "package.json");
|
|
297709
297709
|
writeIfMissing(fs29, pkgPath, TPL_PACKAGE_JSON(packageName, displayName, profile3.version, profile3.description, profile3.extends, profile3.baseAgent));
|
|
297710
297710
|
filesWritten.push(pkgPath);
|
|
297711
|
-
const srcDir =
|
|
297711
|
+
const srcDir = join143(targetDir, "src");
|
|
297712
297712
|
fs29.mkdirSync(srcDir, { recursive: true });
|
|
297713
|
-
const indexPath =
|
|
297713
|
+
const indexPath = join143(srcDir, "index.ts");
|
|
297714
297714
|
writeIfMissing(fs29, indexPath, TPL_INDEX_TS(profile3.name, displayName, profile3.description));
|
|
297715
297715
|
filesWritten.push(indexPath);
|
|
297716
|
-
const binDir =
|
|
297716
|
+
const binDir = join143(targetDir, "bin");
|
|
297717
297717
|
fs29.mkdirSync(binDir, { recursive: true });
|
|
297718
|
-
const binPath =
|
|
297718
|
+
const binPath = join143(binDir, "matrixos-mini.js");
|
|
297719
297719
|
writeIfMissing(fs29, binPath, TPL_BIN);
|
|
297720
297720
|
filesWritten.push(binPath);
|
|
297721
|
-
const scriptDir =
|
|
297721
|
+
const scriptDir = join143(targetDir, "script");
|
|
297722
297722
|
fs29.mkdirSync(scriptDir, { recursive: true });
|
|
297723
|
-
const buildPath =
|
|
297723
|
+
const buildPath = join143(scriptDir, "build.ts");
|
|
297724
297724
|
writeIfMissing(fs29, buildPath, TPL_BUILD_TS);
|
|
297725
297725
|
filesWritten.push(buildPath);
|
|
297726
297726
|
if (Object.keys(profile3.agents).length > 0) {
|
|
297727
|
-
const agentsDir =
|
|
297727
|
+
const agentsDir = join143(targetDir, "agents");
|
|
297728
297728
|
fs29.mkdirSync(agentsDir, { recursive: true });
|
|
297729
297729
|
for (const [agentName, agentDef] of Object.entries(profile3.agents)) {
|
|
297730
|
-
const agentFile =
|
|
297730
|
+
const agentFile = join143(agentsDir, `${agentName}.ts`);
|
|
297731
297731
|
const description2 = agentDef.description ?? `Custom ${displayName} agent: ${agentName}`;
|
|
297732
297732
|
writeIfMissing(fs29, agentFile, `// ${description2}
|
|
297733
297733
|
// Generated by MaTrixOS Mini-OS Profile Generator.
|
|
@@ -297738,10 +297738,10 @@ export const description = ${JSON.stringify(description2)}
|
|
|
297738
297738
|
}
|
|
297739
297739
|
}
|
|
297740
297740
|
if (profile3.skills.length > 0) {
|
|
297741
|
-
const skillsDir =
|
|
297741
|
+
const skillsDir = join143(targetDir, "skills");
|
|
297742
297742
|
fs29.mkdirSync(skillsDir, { recursive: true });
|
|
297743
297743
|
for (const skill2 of profile3.skills) {
|
|
297744
|
-
const skillFile =
|
|
297744
|
+
const skillFile = join143(skillsDir, `${skill2}.md`);
|
|
297745
297745
|
writeIfMissing(fs29, skillFile, `# ${skill2}
|
|
297746
297746
|
|
|
297747
297747
|
_Skill required by the ${displayName} profile. Implementation goes here._
|
|
@@ -297749,12 +297749,12 @@ _Skill required by the ${displayName} profile. Implementation goes here._
|
|
|
297749
297749
|
filesWritten.push(skillFile);
|
|
297750
297750
|
}
|
|
297751
297751
|
}
|
|
297752
|
-
const readmePath =
|
|
297752
|
+
const readmePath = join143(targetDir, "README.md");
|
|
297753
297753
|
const agentsList = Object.keys(profile3.agents);
|
|
297754
297754
|
const skillsList = profile3.skills;
|
|
297755
297755
|
writeIfMissing(fs29, readmePath, TPL_README(packageName, displayName, profile3.description, profile3.version, profile3.baseAgent, profile3.extends, agentsList, skillsList));
|
|
297756
297756
|
filesWritten.push(readmePath);
|
|
297757
|
-
const agentsMdPath =
|
|
297757
|
+
const agentsMdPath = join143(targetDir, "AGENTS.md");
|
|
297758
297758
|
writeIfMissing(fs29, agentsMdPath, TPL_AGENT_MD(displayName, profile3.description));
|
|
297759
297759
|
filesWritten.push(agentsMdPath);
|
|
297760
297760
|
return { packageName, packageDir: targetDir, filesWritten };
|
|
@@ -297906,7 +297906,7 @@ This profile is activated when the user mentions the profile name in their reque
|
|
|
297906
297906
|
- Profiles can be composed: multiple profiles in \`profiles: [...]\` are merged in order.
|
|
297907
297907
|
`;
|
|
297908
297908
|
var init_mini_os_generator = __esm(() => {
|
|
297909
|
-
defaultFS = { existsSync:
|
|
297909
|
+
defaultFS = { existsSync: existsSync118, mkdirSync: mkdirSync26, writeFileSync: writeFileSync26 };
|
|
297910
297910
|
});
|
|
297911
297911
|
|
|
297912
297912
|
// packages/omo-config-core/src/generator/index.ts
|
|
@@ -358357,6 +358357,16 @@ function initConfigContext(binary2, version) {
|
|
|
358357
358357
|
const paths = getOpenCodeConfigPaths({ binary: binary2, version });
|
|
358358
358358
|
configContext = { binary: binary2, version, paths };
|
|
358359
358359
|
}
|
|
358360
|
+
function getConfigContext() {
|
|
358361
|
+
if (!configContext) {
|
|
358362
|
+
const paths = getOpenCodeConfigPaths({ binary: "opencode", version: null });
|
|
358363
|
+
configContext = { binary: "opencode", version: null, paths };
|
|
358364
|
+
}
|
|
358365
|
+
return configContext;
|
|
358366
|
+
}
|
|
358367
|
+
function getConfigDir() {
|
|
358368
|
+
return getConfigContext().paths.configDir;
|
|
358369
|
+
}
|
|
358360
358370
|
|
|
358361
358371
|
// packages/omo-opencode/src/cli/config-manager/add-tui-plugin-to-tui-config.ts
|
|
358362
358372
|
import { existsSync as existsSync36, mkdirSync as mkdirSync8, readFileSync as readFileSync24 } from "fs";
|
|
@@ -358518,6 +358528,51 @@ function ensureTuiPluginEntry(opts = {}) {
|
|
|
358518
358528
|
return { changed: true, reason: "added" };
|
|
358519
358529
|
}
|
|
358520
358530
|
|
|
358531
|
+
// packages/omo-opencode/src/cli/config-manager/load-gateway-env.ts
|
|
358532
|
+
import { existsSync as existsSync37, readFileSync as readFileSync25 } from "fs";
|
|
358533
|
+
import { join as join43 } from "path";
|
|
358534
|
+
|
|
358535
|
+
// packages/omo-opencode/src/cli/config-manager/write-gateway-env.ts
|
|
358536
|
+
var GATEWAY_ENV_FILENAME = ".klc-gateway.env";
|
|
358537
|
+
|
|
358538
|
+
// packages/omo-opencode/src/cli/config-manager/load-gateway-env.ts
|
|
358539
|
+
function loadGatewayEnvFile(configDir) {
|
|
358540
|
+
const dir = configDir ?? getConfigDir();
|
|
358541
|
+
const envPath = join43(dir, GATEWAY_ENV_FILENAME);
|
|
358542
|
+
if (!existsSync37(envPath)) {
|
|
358543
|
+
console.warn(`[gateway-env] env file not found at ${envPath} \u2014 skipping`);
|
|
358544
|
+
return;
|
|
358545
|
+
}
|
|
358546
|
+
let content;
|
|
358547
|
+
try {
|
|
358548
|
+
content = readFileSync25(envPath, "utf-8");
|
|
358549
|
+
} catch (error) {
|
|
358550
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
358551
|
+
console.warn(`[gateway-env] failed to read env file at ${envPath}: ${detail}`);
|
|
358552
|
+
return;
|
|
358553
|
+
}
|
|
358554
|
+
for (const rawLine of content.split(`
|
|
358555
|
+
`)) {
|
|
358556
|
+
const line = rawLine.trim();
|
|
358557
|
+
if (line.length === 0 || line.startsWith("#"))
|
|
358558
|
+
continue;
|
|
358559
|
+
const withoutExport = line.replace(/^(export\s+)/i, "");
|
|
358560
|
+
const eqIndex = withoutExport.indexOf("=");
|
|
358561
|
+
if (eqIndex === -1)
|
|
358562
|
+
continue;
|
|
358563
|
+
const key = withoutExport.slice(0, eqIndex).trim();
|
|
358564
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key))
|
|
358565
|
+
continue;
|
|
358566
|
+
let value = withoutExport.slice(eqIndex + 1).trim();
|
|
358567
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
358568
|
+
value = value.slice(1, -1);
|
|
358569
|
+
}
|
|
358570
|
+
if (process.env[key] === undefined) {
|
|
358571
|
+
process.env[key] = value;
|
|
358572
|
+
}
|
|
358573
|
+
}
|
|
358574
|
+
}
|
|
358575
|
+
|
|
358521
358576
|
// packages/omo-opencode/src/hooks/todo-continuation-enforcer/index.ts
|
|
358522
358577
|
init_logger2();
|
|
358523
358578
|
|
|
@@ -358544,17 +358599,17 @@ var FAILURE_RESET_WINDOW_MS = 5 * 60 * 1000;
|
|
|
358544
358599
|
// packages/omo-opencode/src/features/run-continuation-state/constants.ts
|
|
358545
358600
|
var CONTINUATION_MARKER_DIR = ".omo/run-continuation";
|
|
358546
358601
|
// packages/omo-opencode/src/features/run-continuation-state/storage.ts
|
|
358547
|
-
import { existsSync as
|
|
358548
|
-
import { join as
|
|
358602
|
+
import { existsSync as existsSync38, mkdirSync as mkdirSync9, readFileSync as readFileSync26, rmSync as rmSync2, writeFileSync as writeFileSync6 } from "fs";
|
|
358603
|
+
import { join as join44 } from "path";
|
|
358549
358604
|
function getMarkerPath(directory, sessionID) {
|
|
358550
|
-
return
|
|
358605
|
+
return join44(directory, CONTINUATION_MARKER_DIR, `${sessionID}.json`);
|
|
358551
358606
|
}
|
|
358552
358607
|
function readContinuationMarker(directory, sessionID) {
|
|
358553
358608
|
const markerPath2 = getMarkerPath(directory, sessionID);
|
|
358554
|
-
if (!
|
|
358609
|
+
if (!existsSync38(markerPath2))
|
|
358555
358610
|
return null;
|
|
358556
358611
|
try {
|
|
358557
|
-
const raw =
|
|
358612
|
+
const raw = readFileSync26(markerPath2, "utf-8");
|
|
358558
358613
|
const parsed = JSON.parse(raw);
|
|
358559
358614
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
358560
358615
|
return null;
|
|
@@ -358582,13 +358637,13 @@ function setContinuationMarkerSource(directory, sessionID, source, state2, reaso
|
|
|
358582
358637
|
}
|
|
358583
358638
|
};
|
|
358584
358639
|
const markerPath2 = getMarkerPath(directory, sessionID);
|
|
358585
|
-
mkdirSync9(
|
|
358640
|
+
mkdirSync9(join44(directory, CONTINUATION_MARKER_DIR), { recursive: true });
|
|
358586
358641
|
writeFileSync6(markerPath2, JSON.stringify(next, null, 2), "utf-8");
|
|
358587
358642
|
return next;
|
|
358588
358643
|
}
|
|
358589
358644
|
function clearContinuationMarker(directory, sessionID) {
|
|
358590
358645
|
const markerPath2 = getMarkerPath(directory, sessionID);
|
|
358591
|
-
if (!
|
|
358646
|
+
if (!existsSync38(markerPath2))
|
|
358592
358647
|
return;
|
|
358593
358648
|
try {
|
|
358594
358649
|
rmSync2(markerPath2);
|
|
@@ -360417,13 +360472,13 @@ function createSessionNotification(ctx, config = {}) {
|
|
|
360417
360472
|
};
|
|
360418
360473
|
}
|
|
360419
360474
|
// packages/omo-opencode/src/hooks/comment-checker/cli-runner.ts
|
|
360420
|
-
import { existsSync as
|
|
360475
|
+
import { existsSync as existsSync41 } from "fs";
|
|
360421
360476
|
|
|
360422
360477
|
// packages/omo-opencode/src/hooks/comment-checker/cli.ts
|
|
360423
360478
|
init_bun_spawn_shim();
|
|
360424
360479
|
init_bun_which_shim();
|
|
360425
|
-
import { join as
|
|
360426
|
-
import { existsSync as
|
|
360480
|
+
import { join as join47 } from "path";
|
|
360481
|
+
import { existsSync as existsSync40 } from "fs";
|
|
360427
360482
|
import * as fs8 from "fs";
|
|
360428
360483
|
import { tmpdir as tmpdir4 } from "os";
|
|
360429
360484
|
// packages/comment-checker-core/src/apply-patch-edits.ts
|
|
@@ -360565,7 +360620,7 @@ function joinPatchLines(lines) {
|
|
|
360565
360620
|
}
|
|
360566
360621
|
// packages/comment-checker-core/src/runner.ts
|
|
360567
360622
|
import { createRequire as createRequire2 } from "module";
|
|
360568
|
-
import { dirname as dirname10, join as
|
|
360623
|
+
import { dirname as dirname10, join as join45 } from "path";
|
|
360569
360624
|
var EMPTY_RESULT = { hasComments: false, message: "" };
|
|
360570
360625
|
function normalizeMessage(message) {
|
|
360571
360626
|
return message.replace(/\r\n/g, `
|
|
@@ -360591,7 +360646,7 @@ function resolveCommentCheckerBinary(input) {
|
|
|
360591
360646
|
try {
|
|
360592
360647
|
const require2 = createRequire2(input.importMetaUrl);
|
|
360593
360648
|
const packageJsonPath = require2.resolve(`${packageName}/package.json`);
|
|
360594
|
-
const binaryPath =
|
|
360649
|
+
const binaryPath = join45(dirname10(packageJsonPath), "bin", input.binaryName);
|
|
360595
360650
|
return input.existsSync(binaryPath) ? binaryPath : null;
|
|
360596
360651
|
} catch (error) {
|
|
360597
360652
|
if (error instanceof Error) {
|
|
@@ -360658,14 +360713,14 @@ async function runCommentChecker(input, options) {
|
|
|
360658
360713
|
}
|
|
360659
360714
|
}
|
|
360660
360715
|
// packages/omo-opencode/src/hooks/comment-checker/downloader.ts
|
|
360661
|
-
import { existsSync as
|
|
360662
|
-
import { join as
|
|
360716
|
+
import { existsSync as existsSync39, appendFileSync as appendFileSync3 } from "fs";
|
|
360717
|
+
import { join as join46 } from "path";
|
|
360663
360718
|
import { homedir as homedir16, tmpdir as tmpdir3 } from "os";
|
|
360664
360719
|
import { createRequire as createRequire3 } from "module";
|
|
360665
360720
|
init_logger2();
|
|
360666
360721
|
init_plugin_identity();
|
|
360667
360722
|
var DEBUG = process.env.COMMENT_CHECKER_DEBUG === "1";
|
|
360668
|
-
var DEBUG_FILE =
|
|
360723
|
+
var DEBUG_FILE = join46(tmpdir3(), "comment-checker-debug.log");
|
|
360669
360724
|
function debugLog(...args) {
|
|
360670
360725
|
if (DEBUG) {
|
|
360671
360726
|
const msg = `[${new Date().toISOString()}] [comment-checker:downloader] ${args.map((a) => typeof a === "object" ? JSON.stringify(a, null, 2) : String(a)).join(" ")}
|
|
@@ -360684,12 +360739,12 @@ var PLATFORM_MAP = {
|
|
|
360684
360739
|
function getCacheDir2() {
|
|
360685
360740
|
if (process.platform === "win32") {
|
|
360686
360741
|
const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA;
|
|
360687
|
-
const base2 = localAppData ||
|
|
360688
|
-
return
|
|
360742
|
+
const base2 = localAppData || join46(homedir16(), "AppData", "Local");
|
|
360743
|
+
return join46(base2, CACHE_DIR_NAME, "bin");
|
|
360689
360744
|
}
|
|
360690
360745
|
const xdgCache = process.env.XDG_CACHE_HOME;
|
|
360691
|
-
const base = xdgCache ||
|
|
360692
|
-
return
|
|
360746
|
+
const base = xdgCache || join46(homedir16(), ".cache");
|
|
360747
|
+
return join46(base, CACHE_DIR_NAME, "bin");
|
|
360693
360748
|
}
|
|
360694
360749
|
function getBinaryName() {
|
|
360695
360750
|
return process.platform === "win32" ? "comment-checker.exe" : "comment-checker";
|
|
@@ -360716,8 +360771,8 @@ async function downloadCommentChecker() {
|
|
|
360716
360771
|
}
|
|
360717
360772
|
const cacheDir = getCacheDir2();
|
|
360718
360773
|
const binaryName = getBinaryName();
|
|
360719
|
-
const binaryPath =
|
|
360720
|
-
if (
|
|
360774
|
+
const binaryPath = join46(cacheDir, binaryName);
|
|
360775
|
+
if (existsSync39(binaryPath)) {
|
|
360721
360776
|
debugLog("Binary already cached at:", binaryPath);
|
|
360722
360777
|
return binaryPath;
|
|
360723
360778
|
}
|
|
@@ -360729,7 +360784,7 @@ async function downloadCommentChecker() {
|
|
|
360729
360784
|
log2(`[${PUBLISHED_PACKAGE_NAME}] Downloading comment-checker binary...`);
|
|
360730
360785
|
try {
|
|
360731
360786
|
ensureCacheDir(cacheDir);
|
|
360732
|
-
const archivePath =
|
|
360787
|
+
const archivePath = join46(cacheDir, assetName);
|
|
360733
360788
|
await downloadArchive(downloadUrl, archivePath);
|
|
360734
360789
|
debugLog(`Downloaded archive to: ${archivePath}`);
|
|
360735
360790
|
if (ext === "tar.gz") {
|
|
@@ -360761,7 +360816,7 @@ async function ensureCommentCheckerBinary() {
|
|
|
360761
360816
|
|
|
360762
360817
|
// packages/omo-opencode/src/hooks/comment-checker/cli.ts
|
|
360763
360818
|
var DEBUG2 = process.env.COMMENT_CHECKER_DEBUG === "1";
|
|
360764
|
-
var DEBUG_FILE2 =
|
|
360819
|
+
var DEBUG_FILE2 = join47(tmpdir4(), "comment-checker-debug.log");
|
|
360765
360820
|
function debugLog2(...args) {
|
|
360766
360821
|
if (DEBUG2) {
|
|
360767
360822
|
const msg = `[${new Date().toISOString()}] [comment-checker:cli] ${args.map((a) => typeof a === "object" ? JSON.stringify(a, null, 2) : String(a)).join(" ")}
|
|
@@ -360785,7 +360840,7 @@ function findCommentCheckerPathSync() {
|
|
|
360785
360840
|
const resolvedPath = resolveCommentCheckerBinary({
|
|
360786
360841
|
binaryName,
|
|
360787
360842
|
cachedBinaryPath: getCachedBinaryPath2(),
|
|
360788
|
-
existsSync:
|
|
360843
|
+
existsSync: existsSync40,
|
|
360789
360844
|
importMetaUrl: import.meta.url
|
|
360790
360845
|
});
|
|
360791
360846
|
if (resolvedPath !== null) {
|
|
@@ -360793,7 +360848,7 @@ function findCommentCheckerPathSync() {
|
|
|
360793
360848
|
return resolvedPath;
|
|
360794
360849
|
}
|
|
360795
360850
|
const pathBinary = resolveCommentCheckerPathFromPath(binaryName);
|
|
360796
|
-
if (pathBinary !== null &&
|
|
360851
|
+
if (pathBinary !== null && existsSync40(pathBinary)) {
|
|
360797
360852
|
debugLog2("resolved PATH binary:", pathBinary);
|
|
360798
360853
|
return pathBinary;
|
|
360799
360854
|
}
|
|
@@ -360811,7 +360866,7 @@ async function getCommentCheckerPath() {
|
|
|
360811
360866
|
}
|
|
360812
360867
|
initPromise2 = (async () => {
|
|
360813
360868
|
const syncPath = findCommentCheckerPathSync();
|
|
360814
|
-
if (syncPath &&
|
|
360869
|
+
if (syncPath && existsSync40(syncPath)) {
|
|
360815
360870
|
resolvedCliPath = syncPath;
|
|
360816
360871
|
debugLog2("using sync-resolved path:", syncPath);
|
|
360817
360872
|
return syncPath;
|
|
@@ -360849,7 +360904,7 @@ async function runCommentChecker2(input, cliPath, customPrompt) {
|
|
|
360849
360904
|
}
|
|
360850
360905
|
try {
|
|
360851
360906
|
const result = await runCommentChecker({ hookInput: input, binaryPath, customPrompt }, {
|
|
360852
|
-
existsSync:
|
|
360907
|
+
existsSync: existsSync40,
|
|
360853
360908
|
spawn: (args) => spawn([...args], {
|
|
360854
360909
|
stdin: "pipe",
|
|
360855
360910
|
stdout: "pipe",
|
|
@@ -360977,7 +361032,7 @@ ${result.message}`;
|
|
|
360977
361032
|
}
|
|
360978
361033
|
}
|
|
360979
361034
|
function isCliPathUsable(cliPath) {
|
|
360980
|
-
return Boolean(cliPath &&
|
|
361035
|
+
return Boolean(cliPath && existsSync41(cliPath));
|
|
360981
361036
|
}
|
|
360982
361037
|
|
|
360983
361038
|
// packages/omo-opencode/src/hooks/comment-checker/pending-calls.ts
|
|
@@ -361033,9 +361088,9 @@ function ensureCommentCheckerInitialization(initializer) {
|
|
|
361033
361088
|
// packages/omo-opencode/src/hooks/comment-checker/hook.ts
|
|
361034
361089
|
import * as fs9 from "fs";
|
|
361035
361090
|
import { tmpdir as tmpdir5 } from "os";
|
|
361036
|
-
import { join as
|
|
361091
|
+
import { join as join48 } from "path";
|
|
361037
361092
|
var DEBUG3 = process.env.COMMENT_CHECKER_DEBUG === "1";
|
|
361038
|
-
var DEBUG_FILE3 =
|
|
361093
|
+
var DEBUG_FILE3 = join48(tmpdir5(), "comment-checker-debug.log");
|
|
361039
361094
|
function debugLog3(...args) {
|
|
361040
361095
|
if (DEBUG3) {
|
|
361041
361096
|
const msg = `[${new Date().toISOString()}] [comment-checker:hook] ${args.map((a) => typeof a === "object" ? JSON.stringify(a, null, 2) : String(a)).join(" ")}
|
|
@@ -361208,8 +361263,8 @@ function createAgentsMdCache() {
|
|
|
361208
361263
|
};
|
|
361209
361264
|
}
|
|
361210
361265
|
// packages/rules-engine/src/agents-md.ts
|
|
361211
|
-
import { existsSync as
|
|
361212
|
-
import { dirname as dirname11, isAbsolute as isAbsolute7, join as
|
|
361266
|
+
import { existsSync as existsSync42, realpathSync as realpathSync8, statSync as statSync5 } from "fs";
|
|
361267
|
+
import { dirname as dirname11, isAbsolute as isAbsolute7, join as join49, relative as relative6, resolve as resolve14 } from "path";
|
|
361213
361268
|
|
|
361214
361269
|
// packages/rules-engine/src/constants.ts
|
|
361215
361270
|
var PROJECT_MARKERS = [".git", "pyproject.toml", "package.json", "Cargo.toml", "go.mod", ".venv"];
|
|
@@ -361258,7 +361313,7 @@ async function findAgentsMdUp(input) {
|
|
|
361258
361313
|
while (true) {
|
|
361259
361314
|
const isRootDir = current === rootDir;
|
|
361260
361315
|
if (!(skipRoot && isRootDir)) {
|
|
361261
|
-
const agentsPath = resolveAgentsFilePath(
|
|
361316
|
+
const agentsPath = resolveAgentsFilePath(join49(current, AGENTS_FILENAME), rootDir);
|
|
361262
361317
|
if (agentsPath)
|
|
361263
361318
|
found.push(agentsPath);
|
|
361264
361319
|
}
|
|
@@ -361283,7 +361338,7 @@ function canonicalizePath(path8) {
|
|
|
361283
361338
|
}
|
|
361284
361339
|
}
|
|
361285
361340
|
function resolveAgentsFilePath(path8, rootDir) {
|
|
361286
|
-
if (!
|
|
361341
|
+
if (!existsSync42(path8))
|
|
361287
361342
|
return null;
|
|
361288
361343
|
try {
|
|
361289
361344
|
const canonicalPath = realpathSync8(path8);
|
|
@@ -361299,9 +361354,9 @@ function isSameOrChildPath(childPath, parentPath) {
|
|
|
361299
361354
|
return relativePath === "" || !relativePath.startsWith("..") && !isAbsolute7(relativePath);
|
|
361300
361355
|
}
|
|
361301
361356
|
// packages/rules-engine/src/finder.ts
|
|
361302
|
-
import { existsSync as
|
|
361357
|
+
import { existsSync as existsSync44, statSync as statSync6 } from "fs";
|
|
361303
361358
|
import { homedir as homedir17 } from "os";
|
|
361304
|
-
import { dirname as dirname13, isAbsolute as isAbsolute9, join as
|
|
361359
|
+
import { dirname as dirname13, isAbsolute as isAbsolute9, join as join51, relative as relative8, resolve as resolve15 } from "path";
|
|
361305
361360
|
|
|
361306
361361
|
// packages/rules-engine/src/ordering.ts
|
|
361307
361362
|
function sortCandidates(candidates) {
|
|
@@ -361319,8 +361374,8 @@ function compareString(left, right) {
|
|
|
361319
361374
|
}
|
|
361320
361375
|
|
|
361321
361376
|
// packages/rules-engine/src/scanner.ts
|
|
361322
|
-
import { existsSync as
|
|
361323
|
-
import { basename as basename10, dirname as dirname12, isAbsolute as isAbsolute8, join as
|
|
361377
|
+
import { existsSync as existsSync43, readdirSync as readdirSync10, realpathSync as realpathSync9 } from "fs";
|
|
361378
|
+
import { basename as basename10, dirname as dirname12, isAbsolute as isAbsolute8, join as join50, relative as relative7 } from "path";
|
|
361324
361379
|
function isGitHubInstructionsDir(dir) {
|
|
361325
361380
|
const normalizedDir = dir.replaceAll("\\", "/");
|
|
361326
361381
|
return normalizedDir.includes(".github/instructions") || normalizedDir.endsWith(".github/instructions");
|
|
@@ -361339,7 +361394,7 @@ function safeRealpathSync(filePath) {
|
|
|
361339
361394
|
const parentPath = dirname12(filePath);
|
|
361340
361395
|
if (parentPath === filePath)
|
|
361341
361396
|
return filePath;
|
|
361342
|
-
return
|
|
361397
|
+
return join50(safeRealpathSync(parentPath), basename10(filePath));
|
|
361343
361398
|
}
|
|
361344
361399
|
}
|
|
361345
361400
|
function isPathWithinRoot(candidate, root) {
|
|
@@ -361347,7 +361402,7 @@ function isPathWithinRoot(candidate, root) {
|
|
|
361347
361402
|
return rel === "" || !rel.startsWith("..") && !isAbsolute8(rel);
|
|
361348
361403
|
}
|
|
361349
361404
|
function findRuleFilesRecursive(dir, results, visited = new Set, boundaryRoot) {
|
|
361350
|
-
if (!
|
|
361405
|
+
if (!existsSync43(dir))
|
|
361351
361406
|
return;
|
|
361352
361407
|
const realDir = safeRealpathSync(dir);
|
|
361353
361408
|
const effectiveBoundary = boundaryRoot === undefined ? realDir : safeRealpathSync(boundaryRoot);
|
|
@@ -361363,7 +361418,7 @@ function findRuleFilesRecursive(dir, results, visited = new Set, boundaryRoot) {
|
|
|
361363
361418
|
return;
|
|
361364
361419
|
}
|
|
361365
361420
|
for (const entry of entries) {
|
|
361366
|
-
const fullPath =
|
|
361421
|
+
const fullPath = join50(dir, entry.name);
|
|
361367
361422
|
if (entry.isDirectory()) {
|
|
361368
361423
|
if (!EXCLUDED_DIRS2.has(entry.name))
|
|
361369
361424
|
findRuleFilesRecursive(fullPath, results, visited, effectiveBoundary);
|
|
@@ -361419,7 +361474,7 @@ function addProjectRuleCandidates(projectRoot, startDir, candidates, seenRealPat
|
|
|
361419
361474
|
while (true) {
|
|
361420
361475
|
for (const [parent, subdir] of PROJECT_RULE_SUBDIRS) {
|
|
361421
361476
|
const source = `${parent}/${subdir}`;
|
|
361422
|
-
const ruleDir =
|
|
361477
|
+
const ruleDir = join51(currentDir, parent, subdir);
|
|
361423
361478
|
for (const entry of scanDirectoryWithCache(ruleDir, cache, projectRootRealPath)) {
|
|
361424
361479
|
if (seenRealPaths.has(entry.realPath))
|
|
361425
361480
|
continue;
|
|
@@ -361447,7 +361502,7 @@ function addProjectRuleCandidates(projectRoot, startDir, candidates, seenRealPat
|
|
|
361447
361502
|
function addProjectSingleFileCandidates(projectRoot, candidates, seenRealPaths) {
|
|
361448
361503
|
const projectRootRealPath = safeRealpathSync(projectRoot);
|
|
361449
361504
|
for (const ruleFile of PROJECT_RULE_FILES) {
|
|
361450
|
-
const filePath =
|
|
361505
|
+
const filePath = join51(projectRoot, ruleFile);
|
|
361451
361506
|
const realPath = validFileRealPath(filePath, projectRootRealPath);
|
|
361452
361507
|
if (realPath === null || seenRealPaths.has(realPath))
|
|
361453
361508
|
continue;
|
|
@@ -361464,9 +361519,9 @@ function addProjectSingleFileCandidates(projectRoot, candidates, seenRealPaths)
|
|
|
361464
361519
|
}
|
|
361465
361520
|
}
|
|
361466
361521
|
function addUserRuleCandidates(homeDir, skipClaudeUserRules, candidates, seenRealPaths, cache) {
|
|
361467
|
-
const userRuleDirs = OPENCODE_USER_RULE_DIRS.map((dir) => [
|
|
361522
|
+
const userRuleDirs = OPENCODE_USER_RULE_DIRS.map((dir) => [join51(homeDir, dir), `~/${dir}`]);
|
|
361468
361523
|
if (!skipClaudeUserRules)
|
|
361469
|
-
userRuleDirs.push([
|
|
361524
|
+
userRuleDirs.push([join51(homeDir, USER_RULE_DIR), "~/.claude/rules"]);
|
|
361470
361525
|
for (const [userRuleDir, source] of userRuleDirs) {
|
|
361471
361526
|
for (const entry of scanDirectoryWithCache(userRuleDir, cache)) {
|
|
361472
361527
|
if (seenRealPaths.has(entry.realPath))
|
|
@@ -361506,7 +361561,7 @@ function warnSisyphusRuleDeprecation(source, path8) {
|
|
|
361506
361561
|
});
|
|
361507
361562
|
}
|
|
361508
361563
|
function validFileRealPath(filePath, boundaryRealPath) {
|
|
361509
|
-
if (!
|
|
361564
|
+
if (!existsSync44(filePath))
|
|
361510
361565
|
return null;
|
|
361511
361566
|
try {
|
|
361512
361567
|
if (!statSync6(filePath).isFile())
|
|
@@ -361600,8 +361655,8 @@ function toPosix(path8) {
|
|
|
361600
361655
|
return path8.replaceAll("\\", "/");
|
|
361601
361656
|
}
|
|
361602
361657
|
// packages/rules-engine/src/project-root.ts
|
|
361603
|
-
import { existsSync as
|
|
361604
|
-
import { dirname as dirname14, join as
|
|
361658
|
+
import { existsSync as existsSync45, statSync as statSync7 } from "fs";
|
|
361659
|
+
import { dirname as dirname14, join as join52 } from "path";
|
|
361605
361660
|
var projectRootCache = new Map;
|
|
361606
361661
|
function clearProjectRootCache() {
|
|
361607
361662
|
projectRootCache.clear();
|
|
@@ -361648,7 +361703,7 @@ function resolveStartDir(startPath) {
|
|
|
361648
361703
|
}
|
|
361649
361704
|
}
|
|
361650
361705
|
function hasProjectMarker(directory) {
|
|
361651
|
-
return PROJECT_MARKERS.some((marker) =>
|
|
361706
|
+
return PROJECT_MARKERS.some((marker) => existsSync45(join52(directory, marker)));
|
|
361652
361707
|
}
|
|
361653
361708
|
// packages/agents-md-core/src/constants.ts
|
|
361654
361709
|
var TRUNCATION_NOTICE_PREFIX = `
|
|
@@ -361740,26 +361795,26 @@ async function processFilePathForAgentsInjection(input) {
|
|
|
361740
361795
|
}
|
|
361741
361796
|
}
|
|
361742
361797
|
// packages/omo-opencode/src/hooks/directory-agents-injector/constants.ts
|
|
361743
|
-
import { join as
|
|
361744
|
-
var AGENTS_INJECTOR_STORAGE =
|
|
361798
|
+
import { join as join53 } from "path";
|
|
361799
|
+
var AGENTS_INJECTOR_STORAGE = join53(OPENCODE_STORAGE, "directory-agents");
|
|
361745
361800
|
|
|
361746
361801
|
// packages/omo-opencode/src/shared/session-injected-paths.ts
|
|
361747
361802
|
import {
|
|
361748
|
-
existsSync as
|
|
361803
|
+
existsSync as existsSync46,
|
|
361749
361804
|
mkdirSync as mkdirSync10,
|
|
361750
|
-
readFileSync as
|
|
361805
|
+
readFileSync as readFileSync27,
|
|
361751
361806
|
unlinkSync as unlinkSync5,
|
|
361752
361807
|
writeFileSync as writeFileSync7
|
|
361753
361808
|
} from "fs";
|
|
361754
|
-
import { join as
|
|
361809
|
+
import { join as join54 } from "path";
|
|
361755
361810
|
function createInjectedPathsStorage(storageDir) {
|
|
361756
|
-
const getStoragePath = (sessionID) =>
|
|
361811
|
+
const getStoragePath = (sessionID) => join54(storageDir, `${sessionID}.json`);
|
|
361757
361812
|
const loadInjectedPaths = (sessionID) => {
|
|
361758
361813
|
const filePath = getStoragePath(sessionID);
|
|
361759
|
-
if (!
|
|
361814
|
+
if (!existsSync46(filePath))
|
|
361760
361815
|
return new Set;
|
|
361761
361816
|
try {
|
|
361762
|
-
const content =
|
|
361817
|
+
const content = readFileSync27(filePath, "utf-8");
|
|
361763
361818
|
const data = JSON.parse(content);
|
|
361764
361819
|
return new Set(data.injectedPaths);
|
|
361765
361820
|
} catch (error) {
|
|
@@ -361770,7 +361825,7 @@ function createInjectedPathsStorage(storageDir) {
|
|
|
361770
361825
|
}
|
|
361771
361826
|
};
|
|
361772
361827
|
const saveInjectedPaths = (sessionID, paths) => {
|
|
361773
|
-
if (!
|
|
361828
|
+
if (!existsSync46(storageDir)) {
|
|
361774
361829
|
mkdirSync10(storageDir, { recursive: true });
|
|
361775
361830
|
}
|
|
361776
361831
|
const data = {
|
|
@@ -361782,7 +361837,7 @@ function createInjectedPathsStorage(storageDir) {
|
|
|
361782
361837
|
};
|
|
361783
361838
|
const clearInjectedPaths = (sessionID) => {
|
|
361784
361839
|
const filePath = getStoragePath(sessionID);
|
|
361785
|
-
if (
|
|
361840
|
+
if (existsSync46(filePath)) {
|
|
361786
361841
|
unlinkSync5(filePath);
|
|
361787
361842
|
}
|
|
361788
361843
|
};
|
|
@@ -361851,11 +361906,11 @@ import { dirname as dirname17 } from "path";
|
|
|
361851
361906
|
|
|
361852
361907
|
// packages/omo-opencode/src/hooks/directory-readme-injector/finder.ts
|
|
361853
361908
|
import { access as access2 } from "fs/promises";
|
|
361854
|
-
import { dirname as dirname16, isAbsolute as isAbsolute11, join as
|
|
361909
|
+
import { dirname as dirname16, isAbsolute as isAbsolute11, join as join56, resolve as resolve17 } from "path";
|
|
361855
361910
|
|
|
361856
361911
|
// packages/omo-opencode/src/hooks/directory-readme-injector/constants.ts
|
|
361857
|
-
import { join as
|
|
361858
|
-
var README_INJECTOR_STORAGE =
|
|
361912
|
+
import { join as join55 } from "path";
|
|
361913
|
+
var README_INJECTOR_STORAGE = join55(OPENCODE_STORAGE, "directory-readme");
|
|
361859
361914
|
var README_FILENAME = "README.md";
|
|
361860
361915
|
|
|
361861
361916
|
// packages/omo-opencode/src/hooks/directory-readme-injector/finder.ts
|
|
@@ -361870,7 +361925,7 @@ async function findReadmeMdUp(input) {
|
|
|
361870
361925
|
const found = [];
|
|
361871
361926
|
let current = input.startDir;
|
|
361872
361927
|
while (true) {
|
|
361873
|
-
const readmePath =
|
|
361928
|
+
const readmePath = join56(current, README_FILENAME);
|
|
361874
361929
|
try {
|
|
361875
361930
|
await access2(readmePath);
|
|
361876
361931
|
found.push(readmePath);
|
|
@@ -362312,14 +362367,14 @@ function incrementEmptyContentAttempt(autoCompactState, sessionID) {
|
|
|
362312
362367
|
}
|
|
362313
362368
|
|
|
362314
362369
|
// packages/omo-opencode/src/hooks/anthropic-context-window-limit-recovery/tool-result-storage.ts
|
|
362315
|
-
import { existsSync as
|
|
362316
|
-
import { join as
|
|
362370
|
+
import { existsSync as existsSync48, readdirSync as readdirSync12, readFileSync as readFileSync28, writeFileSync as writeFileSync8 } from "fs";
|
|
362371
|
+
import { join as join57 } from "path";
|
|
362317
362372
|
|
|
362318
362373
|
// packages/omo-opencode/src/hooks/anthropic-context-window-limit-recovery/message-storage-directory.ts
|
|
362319
|
-
import { existsSync as
|
|
362374
|
+
import { existsSync as existsSync47, readdirSync as readdirSync11 } from "fs";
|
|
362320
362375
|
function getMessageIds(sessionID) {
|
|
362321
362376
|
const messageDir = getMessageDir(sessionID);
|
|
362322
|
-
if (!messageDir || !
|
|
362377
|
+
if (!messageDir || !existsSync47(messageDir))
|
|
362323
362378
|
return [];
|
|
362324
362379
|
const messageIds = [];
|
|
362325
362380
|
for (const file2 of readdirSync11(messageDir)) {
|
|
@@ -362341,15 +362396,15 @@ function findToolResultsBySize(sessionID) {
|
|
|
362341
362396
|
const messageIds = getMessageIds(sessionID);
|
|
362342
362397
|
const results = [];
|
|
362343
362398
|
for (const messageID of messageIds) {
|
|
362344
|
-
const partDir =
|
|
362345
|
-
if (!
|
|
362399
|
+
const partDir = join57(PART_STORAGE, messageID);
|
|
362400
|
+
if (!existsSync48(partDir))
|
|
362346
362401
|
continue;
|
|
362347
362402
|
for (const file2 of readdirSync12(partDir)) {
|
|
362348
362403
|
if (!file2.endsWith(".json"))
|
|
362349
362404
|
continue;
|
|
362350
362405
|
try {
|
|
362351
|
-
const partPath =
|
|
362352
|
-
const content =
|
|
362406
|
+
const partPath = join57(partDir, file2);
|
|
362407
|
+
const content = readFileSync28(partPath, "utf-8");
|
|
362353
362408
|
const part = JSON.parse(content);
|
|
362354
362409
|
if (part.type === "tool" && part.state?.output && !part.truncated) {
|
|
362355
362410
|
results.push({
|
|
@@ -362379,7 +362434,7 @@ function truncateToolResult(partPath) {
|
|
|
362379
362434
|
return { success: false };
|
|
362380
362435
|
}
|
|
362381
362436
|
try {
|
|
362382
|
-
const content =
|
|
362437
|
+
const content = readFileSync28(partPath, "utf-8");
|
|
362383
362438
|
const part = JSON.parse(content);
|
|
362384
362439
|
if (!part.state?.output) {
|
|
362385
362440
|
return { success: false };
|
|
@@ -362575,20 +362630,20 @@ var THINKING_TYPES = new Set(["thinking", "redacted_thinking", "reasoning"]);
|
|
|
362575
362630
|
var META_TYPES = new Set(["step-start", "step-finish"]);
|
|
362576
362631
|
|
|
362577
362632
|
// packages/omo-opencode/src/hooks/anthropic-context-window-limit-recovery/storage/parts-reader.ts
|
|
362578
|
-
import { existsSync as
|
|
362579
|
-
import { join as
|
|
362633
|
+
import { existsSync as existsSync49, readdirSync as readdirSync13, readFileSync as readFileSync29 } from "fs";
|
|
362634
|
+
import { join as join58 } from "path";
|
|
362580
362635
|
function readParts(messageID) {
|
|
362581
362636
|
if (isSqliteBackend())
|
|
362582
362637
|
return [];
|
|
362583
|
-
const partDir =
|
|
362584
|
-
if (!
|
|
362638
|
+
const partDir = join58(PART_STORAGE, messageID);
|
|
362639
|
+
if (!existsSync49(partDir))
|
|
362585
362640
|
return [];
|
|
362586
362641
|
const parts = [];
|
|
362587
362642
|
for (const file2 of readdirSync13(partDir)) {
|
|
362588
362643
|
if (!file2.endsWith(".json"))
|
|
362589
362644
|
continue;
|
|
362590
362645
|
try {
|
|
362591
|
-
const content =
|
|
362646
|
+
const content = readFileSync29(join58(partDir, file2), "utf-8");
|
|
362592
362647
|
parts.push(JSON.parse(content));
|
|
362593
362648
|
} catch (error) {
|
|
362594
362649
|
if (!(error instanceof Error)) {
|
|
@@ -362624,20 +362679,20 @@ function messageHasContent(messageID) {
|
|
|
362624
362679
|
}
|
|
362625
362680
|
|
|
362626
362681
|
// packages/omo-opencode/src/hooks/anthropic-context-window-limit-recovery/storage/messages-reader.ts
|
|
362627
|
-
import { existsSync as
|
|
362628
|
-
import { join as
|
|
362682
|
+
import { existsSync as existsSync50, readdirSync as readdirSync14, readFileSync as readFileSync30 } from "fs";
|
|
362683
|
+
import { join as join59 } from "path";
|
|
362629
362684
|
function readMessages(sessionID) {
|
|
362630
362685
|
if (isSqliteBackend())
|
|
362631
362686
|
return [];
|
|
362632
362687
|
const messageDir = getMessageDir(sessionID);
|
|
362633
|
-
if (!messageDir || !
|
|
362688
|
+
if (!messageDir || !existsSync50(messageDir))
|
|
362634
362689
|
return [];
|
|
362635
362690
|
const messages = [];
|
|
362636
362691
|
for (const file2 of readdirSync14(messageDir)) {
|
|
362637
362692
|
if (!file2.endsWith(".json"))
|
|
362638
362693
|
continue;
|
|
362639
362694
|
try {
|
|
362640
|
-
const content =
|
|
362695
|
+
const content = readFileSync30(join59(messageDir, file2), "utf-8");
|
|
362641
362696
|
messages.push(JSON.parse(content));
|
|
362642
362697
|
} catch (error) {
|
|
362643
362698
|
if (!(error instanceof Error)) {
|
|
@@ -362690,23 +362745,23 @@ function findEmptyMessageByIndex(sessionID, targetIndex) {
|
|
|
362690
362745
|
}
|
|
362691
362746
|
|
|
362692
362747
|
// packages/omo-opencode/src/hooks/anthropic-context-window-limit-recovery/storage/empty-text.ts
|
|
362693
|
-
import { existsSync as
|
|
362694
|
-
import { join as
|
|
362748
|
+
import { existsSync as existsSync51, readdirSync as readdirSync15, readFileSync as readFileSync31, writeFileSync as writeFileSync9 } from "fs";
|
|
362749
|
+
import { join as join60 } from "path";
|
|
362695
362750
|
function replaceEmptyTextParts(messageID, replacementText) {
|
|
362696
362751
|
if (isSqliteBackend()) {
|
|
362697
362752
|
log2("[auto-compact] Disabled on SQLite backend: replaceEmptyTextParts (use async variant)");
|
|
362698
362753
|
return false;
|
|
362699
362754
|
}
|
|
362700
|
-
const partDir =
|
|
362701
|
-
if (!
|
|
362755
|
+
const partDir = join60(PART_STORAGE, messageID);
|
|
362756
|
+
if (!existsSync51(partDir))
|
|
362702
362757
|
return false;
|
|
362703
362758
|
let anyReplaced = false;
|
|
362704
362759
|
for (const file2 of readdirSync15(partDir)) {
|
|
362705
362760
|
if (!file2.endsWith(".json"))
|
|
362706
362761
|
continue;
|
|
362707
362762
|
try {
|
|
362708
|
-
const filePath =
|
|
362709
|
-
const content =
|
|
362763
|
+
const filePath = join60(partDir, file2);
|
|
362764
|
+
const content = readFileSync31(filePath, "utf-8");
|
|
362710
362765
|
const part = JSON.parse(content);
|
|
362711
362766
|
if (part.type === "text") {
|
|
362712
362767
|
const textPart = part;
|
|
@@ -362793,8 +362848,8 @@ async function findMessagesWithEmptyTextPartsFromSDK(client3, sessionID) {
|
|
|
362793
362848
|
}
|
|
362794
362849
|
|
|
362795
362850
|
// packages/omo-opencode/src/hooks/anthropic-context-window-limit-recovery/storage/text-part-injector.ts
|
|
362796
|
-
import { existsSync as
|
|
362797
|
-
import { join as
|
|
362851
|
+
import { existsSync as existsSync52, mkdirSync as mkdirSync11, writeFileSync as writeFileSync10 } from "fs";
|
|
362852
|
+
import { join as join61 } from "path";
|
|
362798
362853
|
|
|
362799
362854
|
// packages/omo-opencode/src/hooks/anthropic-context-window-limit-recovery/storage/part-id.ts
|
|
362800
362855
|
function generatePartId2() {
|
|
@@ -362809,8 +362864,8 @@ function injectTextPart(sessionID, messageID, text) {
|
|
|
362809
362864
|
log2("[auto-compact] Disabled on SQLite backend: injectTextPart (use async variant)");
|
|
362810
362865
|
return false;
|
|
362811
362866
|
}
|
|
362812
|
-
const partDir =
|
|
362813
|
-
if (!
|
|
362867
|
+
const partDir = join61(PART_STORAGE, messageID);
|
|
362868
|
+
if (!existsSync52(partDir)) {
|
|
362814
362869
|
mkdirSync11(partDir, { recursive: true });
|
|
362815
362870
|
}
|
|
362816
362871
|
const partId = generatePartId2();
|
|
@@ -362823,7 +362878,7 @@ function injectTextPart(sessionID, messageID, text) {
|
|
|
362823
362878
|
synthetic: true
|
|
362824
362879
|
};
|
|
362825
362880
|
try {
|
|
362826
|
-
writeFileSync10(
|
|
362881
|
+
writeFileSync10(join61(partDir, `${partId}.json`), JSON.stringify(part, null, 2));
|
|
362827
362882
|
return true;
|
|
362828
362883
|
} catch (error) {
|
|
362829
362884
|
if (!(error instanceof Error)) {
|
|
@@ -363532,8 +363587,8 @@ async function executeCompact(sessionID, msg, autoCompactState, client3, directo
|
|
|
363532
363587
|
}
|
|
363533
363588
|
|
|
363534
363589
|
// packages/omo-opencode/src/hooks/anthropic-context-window-limit-recovery/pruning-deduplication.ts
|
|
363535
|
-
import { readdirSync as readdirSync16, readFileSync as
|
|
363536
|
-
import { join as
|
|
363590
|
+
import { readdirSync as readdirSync16, readFileSync as readFileSync32 } from "fs";
|
|
363591
|
+
import { join as join62 } from "path";
|
|
363537
363592
|
|
|
363538
363593
|
// packages/omo-opencode/src/hooks/anthropic-context-window-limit-recovery/pruning-types.ts
|
|
363539
363594
|
var CHARS_PER_TOKEN = 4;
|
|
@@ -363569,7 +363624,7 @@ function readMessages2(sessionID) {
|
|
|
363569
363624
|
try {
|
|
363570
363625
|
const files = readdirSync16(messageDir).filter((f) => f.endsWith(".json"));
|
|
363571
363626
|
for (const file2 of files) {
|
|
363572
|
-
const content =
|
|
363627
|
+
const content = readFileSync32(join62(messageDir, file2), "utf-8");
|
|
363573
363628
|
const data = JSON.parse(content);
|
|
363574
363629
|
if (data.parts) {
|
|
363575
363630
|
messages.push(data);
|
|
@@ -363684,11 +363739,11 @@ function findToolOutput(messages, callID) {
|
|
|
363684
363739
|
}
|
|
363685
363740
|
|
|
363686
363741
|
// packages/omo-opencode/src/hooks/anthropic-context-window-limit-recovery/pruning-tool-output-truncation.ts
|
|
363687
|
-
import { existsSync as
|
|
363688
|
-
import { join as
|
|
363742
|
+
import { existsSync as existsSync53, readdirSync as readdirSync17, readFileSync as readFileSync33 } from "fs";
|
|
363743
|
+
import { join as join63 } from "path";
|
|
363689
363744
|
init_logger2();
|
|
363690
363745
|
function getPartStorage() {
|
|
363691
|
-
return
|
|
363746
|
+
return join63(getOpenCodeStorageDir(), "part");
|
|
363692
363747
|
}
|
|
363693
363748
|
function getMessageIds2(sessionID) {
|
|
363694
363749
|
const messageDir = getMessageDir(sessionID);
|
|
@@ -363713,15 +363768,15 @@ async function truncateToolOutputsByCallId(sessionID, callIds, client3) {
|
|
|
363713
363768
|
return { truncatedCount: 0 };
|
|
363714
363769
|
let truncatedCount = 0;
|
|
363715
363770
|
for (const messageID of messageIds) {
|
|
363716
|
-
const partDir =
|
|
363717
|
-
if (!
|
|
363771
|
+
const partDir = join63(getPartStorage(), messageID);
|
|
363772
|
+
if (!existsSync53(partDir))
|
|
363718
363773
|
continue;
|
|
363719
363774
|
for (const file2 of readdirSync17(partDir)) {
|
|
363720
363775
|
if (!file2.endsWith(".json"))
|
|
363721
363776
|
continue;
|
|
363722
|
-
const partPath =
|
|
363777
|
+
const partPath = join63(partDir, file2);
|
|
363723
363778
|
try {
|
|
363724
|
-
const content =
|
|
363779
|
+
const content = readFileSync33(partPath, "utf-8");
|
|
363725
363780
|
const part = JSON.parse(content);
|
|
363726
363781
|
if (part.type !== "tool" || !part.callID)
|
|
363727
363782
|
continue;
|
|
@@ -364682,8 +364737,8 @@ function createModelFallbackHook(args) {
|
|
|
364682
364737
|
};
|
|
364683
364738
|
}
|
|
364684
364739
|
// packages/omo-opencode/src/hooks/claude-code-hooks/config.ts
|
|
364685
|
-
import { join as
|
|
364686
|
-
import { existsSync as
|
|
364740
|
+
import { join as join64 } from "path";
|
|
364741
|
+
import { existsSync as existsSync54 } from "fs";
|
|
364687
364742
|
init_logger2();
|
|
364688
364743
|
var CONFIG_CACHE_TTL_MS = 30000;
|
|
364689
364744
|
var configCache = new Map;
|
|
@@ -364719,11 +364774,11 @@ function normalizeHooksConfig(raw) {
|
|
|
364719
364774
|
function getClaudeSettingsPaths(customPath) {
|
|
364720
364775
|
const claudeConfigDir = getClaudeConfigDir();
|
|
364721
364776
|
const paths = [
|
|
364722
|
-
|
|
364723
|
-
|
|
364724
|
-
|
|
364777
|
+
join64(claudeConfigDir, "settings.json"),
|
|
364778
|
+
join64(process.cwd(), ".claude", "settings.json"),
|
|
364779
|
+
join64(process.cwd(), ".claude", "settings.local.json")
|
|
364725
364780
|
];
|
|
364726
|
-
if (customPath &&
|
|
364781
|
+
if (customPath && existsSync54(customPath)) {
|
|
364727
364782
|
paths.unshift(customPath);
|
|
364728
364783
|
}
|
|
364729
364784
|
return [...new Set(paths)];
|
|
@@ -364830,7 +364885,7 @@ async function loadClaudeHooksConfig(customSettingsPath) {
|
|
|
364830
364885
|
const paths = getClaudeSettingsPaths(customSettingsPath);
|
|
364831
364886
|
let mergedConfig = {};
|
|
364832
364887
|
for (const settingsPath of paths) {
|
|
364833
|
-
if (
|
|
364888
|
+
if (existsSync54(settingsPath)) {
|
|
364834
364889
|
try {
|
|
364835
364890
|
const content = await bunFile(settingsPath).text();
|
|
364836
364891
|
const settings = JSON.parse(content);
|
|
@@ -364859,15 +364914,15 @@ async function loadClaudeHooksConfig(customSettingsPath) {
|
|
|
364859
364914
|
|
|
364860
364915
|
// packages/omo-opencode/src/hooks/claude-code-hooks/config-loader.ts
|
|
364861
364916
|
init_logger2();
|
|
364862
|
-
import { existsSync as
|
|
364863
|
-
import { join as
|
|
364917
|
+
import { existsSync as existsSync55 } from "fs";
|
|
364918
|
+
import { join as join65 } from "path";
|
|
364864
364919
|
var CONFIG_CACHE_TTL_MS2 = 30000;
|
|
364865
364920
|
var configCache2 = new Map;
|
|
364866
364921
|
function getUserConfigPath() {
|
|
364867
|
-
return
|
|
364922
|
+
return join65(getOpenCodeConfigDir({ binary: "opencode" }), "opencode-cc-plugin.json");
|
|
364868
364923
|
}
|
|
364869
364924
|
function getProjectConfigPath() {
|
|
364870
|
-
return
|
|
364925
|
+
return join65(process.cwd(), ".opencode", "opencode-cc-plugin.json");
|
|
364871
364926
|
}
|
|
364872
364927
|
function getCacheKey2() {
|
|
364873
364928
|
return `${process.cwd()}::${getUserConfigPath()}`;
|
|
@@ -364887,7 +364942,7 @@ function clearPluginExtendedConfigCache() {
|
|
|
364887
364942
|
configCache2.clear();
|
|
364888
364943
|
}
|
|
364889
364944
|
async function loadConfigFromPath(path8) {
|
|
364890
|
-
if (!
|
|
364945
|
+
if (!existsSync55(path8)) {
|
|
364891
364946
|
return null;
|
|
364892
364947
|
}
|
|
364893
364948
|
try {
|
|
@@ -365208,16 +365263,16 @@ ${USER_PROMPT_SUBMIT_TAG_CLOSE}`);
|
|
|
365208
365263
|
}
|
|
365209
365264
|
|
|
365210
365265
|
// packages/omo-opencode/src/hooks/claude-code-hooks/transcript.ts
|
|
365211
|
-
import { join as
|
|
365212
|
-
import { mkdirSync as mkdirSync12, appendFileSync as appendFileSync6, existsSync as
|
|
365266
|
+
import { join as join66 } from "path";
|
|
365267
|
+
import { mkdirSync as mkdirSync12, appendFileSync as appendFileSync6, existsSync as existsSync56, writeFileSync as writeFileSync11, unlinkSync as unlinkSync6 } from "fs";
|
|
365213
365268
|
import { tmpdir as tmpdir6 } from "os";
|
|
365214
365269
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
365215
|
-
var TRANSCRIPT_DIR =
|
|
365270
|
+
var TRANSCRIPT_DIR = join66(getClaudeConfigDir(), "transcripts");
|
|
365216
365271
|
function getTranscriptPath(sessionId) {
|
|
365217
|
-
return
|
|
365272
|
+
return join66(TRANSCRIPT_DIR, `${sessionId}.jsonl`);
|
|
365218
365273
|
}
|
|
365219
365274
|
function ensureTranscriptDir() {
|
|
365220
|
-
if (!
|
|
365275
|
+
if (!existsSync56(TRANSCRIPT_DIR)) {
|
|
365221
365276
|
mkdirSync12(TRANSCRIPT_DIR, { recursive: true });
|
|
365222
365277
|
}
|
|
365223
365278
|
}
|
|
@@ -365354,7 +365409,7 @@ async function buildTranscriptFromSession(client3, sessionId, directory, current
|
|
|
365354
365409
|
}
|
|
365355
365410
|
}
|
|
365356
365411
|
}
|
|
365357
|
-
const tempPath =
|
|
365412
|
+
const tempPath = join66(tmpdir6(), `opencode-transcript-${sessionId}-${randomUUID3()}.jsonl`);
|
|
365358
365413
|
writeFileSync11(tempPath, allEntries.join(`
|
|
365359
365414
|
`) + `
|
|
365360
365415
|
`);
|
|
@@ -365370,7 +365425,7 @@ async function buildTranscriptFromSession(client3, sessionId, directory, current
|
|
|
365370
365425
|
logTranscriptError("[transcript] failed to build transcript from session", { thrown: error });
|
|
365371
365426
|
}
|
|
365372
365427
|
try {
|
|
365373
|
-
const tempPath =
|
|
365428
|
+
const tempPath = join66(tmpdir6(), `opencode-transcript-${sessionId}-${randomUUID3()}.jsonl`);
|
|
365374
365429
|
writeFileSync11(tempPath, buildCurrentEntry(currentToolName, currentToolInput) + `
|
|
365375
365430
|
`);
|
|
365376
365431
|
return tempPath;
|
|
@@ -365621,10 +365676,10 @@ function createPreCompactHandler(ctx, config) {
|
|
|
365621
365676
|
}
|
|
365622
365677
|
|
|
365623
365678
|
// packages/omo-opencode/src/hooks/claude-code-hooks/todo.ts
|
|
365624
|
-
import { join as
|
|
365625
|
-
var TODO_DIR =
|
|
365679
|
+
import { join as join67 } from "path";
|
|
365680
|
+
var TODO_DIR = join67(getClaudeConfigDir(), "todos");
|
|
365626
365681
|
function getTodoPath(sessionId) {
|
|
365627
|
-
return
|
|
365682
|
+
return join67(TODO_DIR, `${sessionId}-agent-${sessionId}.json`);
|
|
365628
365683
|
}
|
|
365629
365684
|
|
|
365630
365685
|
// packages/omo-opencode/src/hooks/claude-code-hooks/stop.ts
|
|
@@ -366320,7 +366375,7 @@ var NOTEPAD_DIR = "notepads";
|
|
|
366320
366375
|
var NOTEPAD_BASE_PATH = `${BOULDER_DIR}/${NOTEPAD_DIR}`;
|
|
366321
366376
|
var PROMETHEUS_PLANS_DIR = ".omo/plans";
|
|
366322
366377
|
// packages/boulder-state/src/top-level-task.ts
|
|
366323
|
-
import { existsSync as
|
|
366378
|
+
import { existsSync as existsSync57, readFileSync as readFileSync34 } from "fs";
|
|
366324
366379
|
var TODO_HEADING_PATTERN = /^##\s+TODOs\b/i;
|
|
366325
366380
|
var FINAL_VERIFICATION_HEADING_PATTERN = /^##\s+Final Verification Wave\b/i;
|
|
366326
366381
|
var SECOND_LEVEL_HEADING_PATTERN = /^##\s+/;
|
|
@@ -366343,11 +366398,11 @@ function buildTaskRef(section, taskLabel) {
|
|
|
366343
366398
|
};
|
|
366344
366399
|
}
|
|
366345
366400
|
function readCurrentTopLevelTask(planPath) {
|
|
366346
|
-
if (!
|
|
366401
|
+
if (!existsSync57(planPath)) {
|
|
366347
366402
|
return null;
|
|
366348
366403
|
}
|
|
366349
366404
|
try {
|
|
366350
|
-
const content =
|
|
366405
|
+
const content = readFileSync34(planPath, "utf-8");
|
|
366351
366406
|
const lines = content.split(/\r?\n/);
|
|
366352
366407
|
let section = "other";
|
|
366353
366408
|
for (const line of lines) {
|
|
@@ -366372,10 +366427,10 @@ function readCurrentTopLevelTask(planPath) {
|
|
|
366372
366427
|
}
|
|
366373
366428
|
}
|
|
366374
366429
|
// packages/boulder-state/src/storage/path.ts
|
|
366375
|
-
import { existsSync as
|
|
366376
|
-
import { isAbsolute as isAbsolute12, join as
|
|
366430
|
+
import { existsSync as existsSync58 } from "fs";
|
|
366431
|
+
import { isAbsolute as isAbsolute12, join as join68, relative as relative11, resolve as resolve18 } from "path";
|
|
366377
366432
|
function getBoulderFilePath(directory) {
|
|
366378
|
-
return
|
|
366433
|
+
return join68(directory, BOULDER_DIR, BOULDER_FILE);
|
|
366379
366434
|
}
|
|
366380
366435
|
function resolveTrackedPath(baseDirectory, trackedPath) {
|
|
366381
366436
|
return isAbsolute12(trackedPath) ? resolve18(trackedPath) : resolve18(baseDirectory, trackedPath);
|
|
@@ -366393,14 +366448,14 @@ function resolveBoulderPlanPath(directory, state3) {
|
|
|
366393
366448
|
}
|
|
366394
366449
|
const absoluteWorktreePath = resolveTrackedPath(directory, worktreePath);
|
|
366395
366450
|
const worktreePlanPath = resolve18(absoluteWorktreePath, relativePlanPath);
|
|
366396
|
-
return
|
|
366451
|
+
return existsSync58(worktreePlanPath) ? worktreePlanPath : absolutePlanPath;
|
|
366397
366452
|
}
|
|
366398
366453
|
function resolveBoulderPlanPathForWork(directory, work) {
|
|
366399
366454
|
return resolveBoulderPlanPath(directory, work);
|
|
366400
366455
|
}
|
|
366401
366456
|
// packages/boulder-state/src/storage/plan-progress.ts
|
|
366402
|
-
import { existsSync as
|
|
366403
|
-
import { basename as basename12, join as
|
|
366457
|
+
import { existsSync as existsSync59, readFileSync as readFileSync35, readdirSync as readdirSync18, statSync as statSync8 } from "fs";
|
|
366458
|
+
import { basename as basename12, join as join69 } from "path";
|
|
366404
366459
|
var TODO_HEADING_PATTERN2 = /^##\s+TODOs\b/i;
|
|
366405
366460
|
var FINAL_VERIFICATION_HEADING_PATTERN2 = /^##\s+Final Verification Wave\b/i;
|
|
366406
366461
|
var SECOND_LEVEL_HEADING_PATTERN2 = /^##\s+/;
|
|
@@ -366413,11 +366468,11 @@ var PROMETHEUS_PLAN_DIRS = [PROMETHEUS_PLANS_DIR, LEGACY_PROMETHEUS_PLANS_DIR];
|
|
|
366413
366468
|
function findPrometheusPlans(directory) {
|
|
366414
366469
|
try {
|
|
366415
366470
|
return PROMETHEUS_PLAN_DIRS.flatMap((planDir) => {
|
|
366416
|
-
const plansDir =
|
|
366417
|
-
if (!
|
|
366471
|
+
const plansDir = join69(directory, planDir);
|
|
366472
|
+
if (!existsSync59(plansDir)) {
|
|
366418
366473
|
return [];
|
|
366419
366474
|
}
|
|
366420
|
-
return readdirSync18(plansDir).filter((file2) => file2.endsWith(".md")).map((file2) =>
|
|
366475
|
+
return readdirSync18(plansDir).filter((file2) => file2.endsWith(".md")).map((file2) => join69(plansDir, file2));
|
|
366421
366476
|
}).sort((left, right) => statSync8(right).mtimeMs - statSync8(left).mtimeMs);
|
|
366422
366477
|
} catch {
|
|
366423
366478
|
return [];
|
|
@@ -366427,11 +366482,11 @@ function getPlanName(planPath) {
|
|
|
366427
366482
|
return basename12(planPath, ".md");
|
|
366428
366483
|
}
|
|
366429
366484
|
function getPlanProgress(planPath) {
|
|
366430
|
-
if (!
|
|
366485
|
+
if (!existsSync59(planPath)) {
|
|
366431
366486
|
return { total: 0, completed: 0, isComplete: false };
|
|
366432
366487
|
}
|
|
366433
366488
|
try {
|
|
366434
|
-
const content =
|
|
366489
|
+
const content = readFileSync35(planPath, "utf-8");
|
|
366435
366490
|
const lines = content.split(/\r?\n/);
|
|
366436
366491
|
const hasStructuredSections = lines.some((line) => TODO_HEADING_PATTERN2.test(line) || FINAL_VERIFICATION_HEADING_PATTERN2.test(line));
|
|
366437
366492
|
if (hasStructuredSections) {
|
|
@@ -366561,14 +366616,14 @@ function selectMirrorWork(state3) {
|
|
|
366561
366616
|
return sorted[0] ?? null;
|
|
366562
366617
|
}
|
|
366563
366618
|
// packages/boulder-state/src/storage/read-state.ts
|
|
366564
|
-
import { existsSync as
|
|
366619
|
+
import { existsSync as existsSync60, readFileSync as readFileSync36 } from "fs";
|
|
366565
366620
|
function readBoulderState(directory) {
|
|
366566
366621
|
const filePath = getBoulderFilePath(directory);
|
|
366567
|
-
if (!
|
|
366622
|
+
if (!existsSync60(filePath)) {
|
|
366568
366623
|
return null;
|
|
366569
366624
|
}
|
|
366570
366625
|
try {
|
|
366571
|
-
const content =
|
|
366626
|
+
const content = readFileSync36(filePath, "utf-8");
|
|
366572
366627
|
const parsed = JSON.parse(content);
|
|
366573
366628
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
366574
366629
|
return null;
|
|
@@ -366717,15 +366772,15 @@ function getTaskSessionState(directory, taskKey) {
|
|
|
366717
366772
|
return state3.task_sessions[taskKey] ?? null;
|
|
366718
366773
|
}
|
|
366719
366774
|
// packages/boulder-state/src/storage/write-state.ts
|
|
366720
|
-
import { existsSync as
|
|
366721
|
-
import { dirname as dirname18, join as
|
|
366775
|
+
import { existsSync as existsSync61, mkdirSync as mkdirSync13, unlinkSync as unlinkSync7, writeFileSync as writeFileSync12 } from "fs";
|
|
366776
|
+
import { dirname as dirname18, join as join70 } from "path";
|
|
366722
366777
|
function writeBoulderState(directory, state3) {
|
|
366723
366778
|
const filePath = getBoulderFilePath(directory);
|
|
366724
366779
|
try {
|
|
366725
366780
|
const dir = dirname18(filePath);
|
|
366726
|
-
if (!
|
|
366781
|
+
if (!existsSync61(dir)) {
|
|
366727
366782
|
mkdirSync13(dir, { recursive: true });
|
|
366728
|
-
writeFileSync12(
|
|
366783
|
+
writeFileSync12(join70(dir, ".gitignore"), ["*", "!/rules/", "!/rules/**", ""].join(`
|
|
366729
366784
|
`), "utf-8");
|
|
366730
366785
|
}
|
|
366731
366786
|
const stateToWrite = { ...state3 };
|
|
@@ -366761,7 +366816,7 @@ function writeBoulderState(directory, state3) {
|
|
|
366761
366816
|
function clearBoulderState(directory) {
|
|
366762
366817
|
const filePath = getBoulderFilePath(directory);
|
|
366763
366818
|
try {
|
|
366764
|
-
if (
|
|
366819
|
+
if (existsSync61(filePath)) {
|
|
366765
366820
|
unlinkSync7(filePath);
|
|
366766
366821
|
}
|
|
366767
366822
|
return true;
|
|
@@ -367164,28 +367219,28 @@ function createClaudeCodeHooksHook(ctx, config = {}, contextCollector) {
|
|
|
367164
367219
|
}
|
|
367165
367220
|
// packages/omo-opencode/src/hooks/rules-injector/storage.ts
|
|
367166
367221
|
import {
|
|
367167
|
-
existsSync as
|
|
367222
|
+
existsSync as existsSync62,
|
|
367168
367223
|
mkdirSync as mkdirSync14,
|
|
367169
|
-
readFileSync as
|
|
367224
|
+
readFileSync as readFileSync37,
|
|
367170
367225
|
writeFileSync as writeFileSync13,
|
|
367171
367226
|
unlinkSync as unlinkSync8
|
|
367172
367227
|
} from "fs";
|
|
367173
|
-
import { join as
|
|
367228
|
+
import { join as join72 } from "path";
|
|
367174
367229
|
|
|
367175
367230
|
// packages/omo-opencode/src/hooks/rules-injector/constants.ts
|
|
367176
|
-
import { join as
|
|
367177
|
-
var RULES_INJECTOR_STORAGE =
|
|
367231
|
+
import { join as join71 } from "path";
|
|
367232
|
+
var RULES_INJECTOR_STORAGE = join71(OPENCODE_STORAGE, "rules-injector");
|
|
367178
367233
|
|
|
367179
367234
|
// packages/omo-opencode/src/hooks/rules-injector/storage.ts
|
|
367180
367235
|
function getStoragePath(sessionID) {
|
|
367181
|
-
return
|
|
367236
|
+
return join72(RULES_INJECTOR_STORAGE, `${sessionID}.json`);
|
|
367182
367237
|
}
|
|
367183
367238
|
function loadInjectedRules(sessionID) {
|
|
367184
367239
|
const filePath = getStoragePath(sessionID);
|
|
367185
|
-
if (!
|
|
367240
|
+
if (!existsSync62(filePath))
|
|
367186
367241
|
return { contentHashes: new Set, realPaths: new Set };
|
|
367187
367242
|
try {
|
|
367188
|
-
const content =
|
|
367243
|
+
const content = readFileSync37(filePath, "utf-8");
|
|
367189
367244
|
const data = JSON.parse(content);
|
|
367190
367245
|
return {
|
|
367191
367246
|
contentHashes: new Set(data.injectedHashes),
|
|
@@ -367218,7 +367273,7 @@ function saveInjectedRules(sessionID, data) {
|
|
|
367218
367273
|
}
|
|
367219
367274
|
function clearInjectedRules(sessionID) {
|
|
367220
367275
|
const filePath = getStoragePath(sessionID);
|
|
367221
|
-
if (
|
|
367276
|
+
if (existsSync62(filePath)) {
|
|
367222
367277
|
unlinkSync8(filePath);
|
|
367223
367278
|
}
|
|
367224
367279
|
}
|
|
@@ -367312,7 +367367,7 @@ function matchDecisionCacheKey(projectRoot, resolvedFilePath, realPath, statFing
|
|
|
367312
367367
|
}
|
|
367313
367368
|
|
|
367314
367369
|
// packages/omo-opencode/src/hooks/rules-injector/parsed-rule-cache.ts
|
|
367315
|
-
import { readFileSync as
|
|
367370
|
+
import { readFileSync as readFileSync38, statSync as statSync9 } from "fs";
|
|
367316
367371
|
var MAX_PARSED_RULE_CACHE_ENTRIES = 256;
|
|
367317
367372
|
var MAX_PARSED_RULE_CACHE_BODY_BYTES = 64 * 1024;
|
|
367318
367373
|
var parsedRuleCache = new Map;
|
|
@@ -367320,7 +367375,7 @@ function clearParsedRuleCache() {
|
|
|
367320
367375
|
parsedRuleCache.clear();
|
|
367321
367376
|
}
|
|
367322
367377
|
function createParsedRuleReader(options) {
|
|
367323
|
-
const readRuleFileSync = options?.readFileSync ??
|
|
367378
|
+
const readRuleFileSync = options?.readFileSync ?? readFileSync38;
|
|
367324
367379
|
const statRuleSync = options?.statSync ?? statSync9;
|
|
367325
367380
|
return (filePath, realPath) => {
|
|
367326
367381
|
try {
|
|
@@ -367932,7 +367987,7 @@ function getCachedVersion(options = {}) {
|
|
|
367932
367987
|
// package.json
|
|
367933
367988
|
var package_default = {
|
|
367934
367989
|
name: "@kl-c/matrixos",
|
|
367935
|
-
version: "0.1.
|
|
367990
|
+
version: "0.1.23",
|
|
367936
367991
|
description: "MaTrixOS \u2014 Agentic OS for OpenCode. Personalizable, communicating, self-improving, resilient.",
|
|
367937
367992
|
main: "./dist/index.js",
|
|
367938
367993
|
types: "dist/index.d.ts",
|
|
@@ -368291,13 +368346,13 @@ function syncCachePackageJsonToIntent(pluginInfo) {
|
|
|
368291
368346
|
};
|
|
368292
368347
|
}
|
|
368293
368348
|
// packages/omo-opencode/src/hooks/auto-update-checker/hook/background-update-check.ts
|
|
368294
|
-
import { existsSync as
|
|
368295
|
-
import { dirname as dirname23, join as
|
|
368349
|
+
import { existsSync as existsSync71 } from "fs";
|
|
368350
|
+
import { dirname as dirname23, join as join80 } from "path";
|
|
368296
368351
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
368297
368352
|
// packages/omo-opencode/src/shared/migrate-legacy-config-file.ts
|
|
368298
368353
|
init_logger2();
|
|
368299
|
-
import { existsSync as
|
|
368300
|
-
import { join as
|
|
368354
|
+
import { existsSync as existsSync68, readFileSync as readFileSync45, renameSync as renameSync6, rmSync as rmSync3 } from "fs";
|
|
368355
|
+
import { join as join77, dirname as dirname22, basename as basename13 } from "path";
|
|
368301
368356
|
|
|
368302
368357
|
// packages/omo-opencode/src/shared/migration/migrations-sidecar.ts
|
|
368303
368358
|
init_migrations_sidecar();
|
|
@@ -368307,7 +368362,7 @@ init_plugin_identity();
|
|
|
368307
368362
|
function buildCanonicalPath(legacyPath) {
|
|
368308
368363
|
const dir = dirname22(legacyPath);
|
|
368309
368364
|
const ext = basename13(legacyPath).includes(".jsonc") ? ".jsonc" : ".json";
|
|
368310
|
-
return
|
|
368365
|
+
return join77(dir, `${CONFIG_BASENAME}${ext}`);
|
|
368311
368366
|
}
|
|
368312
368367
|
function archiveLegacyConfigFile(legacyPath) {
|
|
368313
368368
|
const backupPath = `${legacyPath}.bak`;
|
|
@@ -368340,13 +368395,13 @@ function archiveLegacyConfigFile(legacyPath) {
|
|
|
368340
368395
|
}
|
|
368341
368396
|
function migrateLegacySidecarFile(legacyPath, canonicalPath) {
|
|
368342
368397
|
const legacySidecarPath = getSidecarPath(legacyPath);
|
|
368343
|
-
if (!
|
|
368398
|
+
if (!existsSync68(legacySidecarPath))
|
|
368344
368399
|
return true;
|
|
368345
368400
|
const canonicalSidecarPath = getSidecarPath(canonicalPath);
|
|
368346
|
-
if (
|
|
368401
|
+
if (existsSync68(canonicalSidecarPath))
|
|
368347
368402
|
return true;
|
|
368348
368403
|
try {
|
|
368349
|
-
const content =
|
|
368404
|
+
const content = readFileSync45(legacySidecarPath, "utf-8");
|
|
368350
368405
|
writeFileAtomically2(canonicalSidecarPath, content);
|
|
368351
368406
|
log2("[migrateLegacyConfigFile] Migrated legacy migration sidecar to canonical path", {
|
|
368352
368407
|
from: legacySidecarPath,
|
|
@@ -368363,15 +368418,15 @@ function migrateLegacySidecarFile(legacyPath, canonicalPath) {
|
|
|
368363
368418
|
}
|
|
368364
368419
|
}
|
|
368365
368420
|
function migrateLegacyConfigFile(legacyPath) {
|
|
368366
|
-
if (!
|
|
368421
|
+
if (!existsSync68(legacyPath))
|
|
368367
368422
|
return false;
|
|
368368
368423
|
if (!basename13(legacyPath).startsWith(LEGACY_CONFIG_BASENAME))
|
|
368369
368424
|
return false;
|
|
368370
368425
|
const canonicalPath = buildCanonicalPath(legacyPath);
|
|
368371
|
-
if (
|
|
368426
|
+
if (existsSync68(canonicalPath))
|
|
368372
368427
|
return false;
|
|
368373
368428
|
try {
|
|
368374
|
-
const content =
|
|
368429
|
+
const content = readFileSync45(legacyPath, "utf-8");
|
|
368375
368430
|
writeFileAtomically2(canonicalPath, content);
|
|
368376
368431
|
const migratedSidecar = migrateLegacySidecarFile(legacyPath, canonicalPath);
|
|
368377
368432
|
const archivedLegacyConfig = archiveLegacyConfigFile(legacyPath);
|
|
@@ -368460,13 +368515,13 @@ function spawnWithWindowsHide(command, options) {
|
|
|
368460
368515
|
return wrapNodeProcess2(proc);
|
|
368461
368516
|
}
|
|
368462
368517
|
// packages/omo-opencode/src/cli/config-manager/bun-install.ts
|
|
368463
|
-
import { existsSync as
|
|
368464
|
-
import { join as
|
|
368518
|
+
import { existsSync as existsSync69 } from "fs";
|
|
368519
|
+
import { join as join78 } from "path";
|
|
368465
368520
|
init_logger2();
|
|
368466
368521
|
var BUN_INSTALL_TIMEOUT_SECONDS = 60;
|
|
368467
368522
|
var BUN_INSTALL_TIMEOUT_MS = BUN_INSTALL_TIMEOUT_SECONDS * 1000;
|
|
368468
368523
|
function getDefaultWorkspaceDir() {
|
|
368469
|
-
return
|
|
368524
|
+
return join78(getOpenCodeCacheDir(), "packages");
|
|
368470
368525
|
}
|
|
368471
368526
|
function readProcessOutput(stream2) {
|
|
368472
368527
|
if (!stream2) {
|
|
@@ -368492,7 +368547,7 @@ async function runBunInstallWithDetails(options) {
|
|
|
368492
368547
|
const outputMode = options?.outputMode ?? "pipe";
|
|
368493
368548
|
const cacheDir = options?.workspaceDir ?? getDefaultWorkspaceDir();
|
|
368494
368549
|
const packageJsonPath = `${cacheDir}/package.json`;
|
|
368495
|
-
if (!
|
|
368550
|
+
if (!existsSync69(packageJsonPath)) {
|
|
368496
368551
|
return {
|
|
368497
368552
|
success: false,
|
|
368498
368553
|
error: `Workspace not initialized: ${packageJsonPath} not found. OpenCode should create this on first run.`
|
|
@@ -368729,8 +368784,8 @@ function getCacheWorkspaceDir(deps) {
|
|
|
368729
368784
|
return deps.join(deps.getOpenCodeCacheDir(), "packages");
|
|
368730
368785
|
}
|
|
368731
368786
|
var defaultDeps2 = {
|
|
368732
|
-
existsSync:
|
|
368733
|
-
join:
|
|
368787
|
+
existsSync: existsSync71,
|
|
368788
|
+
join: join80,
|
|
368734
368789
|
runBunInstallWithDetails,
|
|
368735
368790
|
log: log2,
|
|
368736
368791
|
getOpenCodeCacheDir,
|
|
@@ -369105,9 +369160,9 @@ v${latestVersion} available. Restart OpenCode to apply.` : "OpenCode is now on S
|
|
|
369105
369160
|
}
|
|
369106
369161
|
// packages/omo-opencode/src/hooks/codegraph-bootstrap/hook.ts
|
|
369107
369162
|
init_src();
|
|
369108
|
-
import { existsSync as
|
|
369163
|
+
import { existsSync as existsSync72 } from "fs";
|
|
369109
369164
|
import { homedir as homedir21 } from "os";
|
|
369110
|
-
import { join as
|
|
369165
|
+
import { join as join81 } from "path";
|
|
369111
369166
|
|
|
369112
369167
|
// packages/omo-opencode/src/hooks/codegraph-bootstrap/command-runner.ts
|
|
369113
369168
|
init_src();
|
|
@@ -369260,14 +369315,14 @@ function defaultSchedule(task) {
|
|
|
369260
369315
|
timer.unref?.();
|
|
369261
369316
|
}
|
|
369262
369317
|
function defaultInstallDir2() {
|
|
369263
|
-
return
|
|
369318
|
+
return join81(homedir21(), ".omo", "codegraph");
|
|
369264
369319
|
}
|
|
369265
369320
|
function provisionedBinFromInstallDir(installDir) {
|
|
369266
369321
|
if (installDir === undefined)
|
|
369267
369322
|
return null;
|
|
369268
369323
|
const binaryName = process.platform === "win32" ? "codegraph.cmd" : "codegraph";
|
|
369269
|
-
const candidate =
|
|
369270
|
-
return
|
|
369324
|
+
const candidate = join81(installDir, "bin", binaryName);
|
|
369325
|
+
return existsSync72(candidate) ? candidate : null;
|
|
369271
369326
|
}
|
|
369272
369327
|
function codegraphEnv(deps, config) {
|
|
369273
369328
|
const env2 = deps.buildEnv();
|
|
@@ -369296,7 +369351,7 @@ async function resolveOrProvisionCommand(deps, config) {
|
|
|
369296
369351
|
const installDir = config.install_dir ?? defaultInstallDir2();
|
|
369297
369352
|
const provisioned = await deps.ensureProvisioned({
|
|
369298
369353
|
installDir,
|
|
369299
|
-
lockDir:
|
|
369354
|
+
lockDir: join81(installDir, "locks"),
|
|
369300
369355
|
version: CODEGRAPH_VERSION
|
|
369301
369356
|
});
|
|
369302
369357
|
if (!provisioned.provisioned || provisioned.binPath === undefined) {
|
|
@@ -369311,8 +369366,8 @@ async function resolveOrProvisionCommand(deps, config) {
|
|
|
369311
369366
|
async function runBootstrap(projectRoot, config, deps) {
|
|
369312
369367
|
try {
|
|
369313
369368
|
const autoInit = config.auto_init !== false;
|
|
369314
|
-
const codegraphPath =
|
|
369315
|
-
if (!autoInit && !
|
|
369369
|
+
const codegraphPath = join81(projectRoot, ".codegraph");
|
|
369370
|
+
if (!autoInit && !existsSync72(codegraphPath)) {
|
|
369316
369371
|
deps.log("[codegraph-bootstrap] CodeGraph auto_init disabled and .codegraph not present; skipping bootstrap", {
|
|
369317
369372
|
projectRoot
|
|
369318
369373
|
});
|
|
@@ -369400,7 +369455,7 @@ function createCodegraphBootstrapHook(ctx, config, depsOverride = {}) {
|
|
|
369400
369455
|
// packages/omo-opencode/src/hooks/ast-grep-sg-provision/hook.ts
|
|
369401
369456
|
init_src();
|
|
369402
369457
|
import { homedir as homedir22 } from "os";
|
|
369403
|
-
import { join as
|
|
369458
|
+
import { join as join82 } from "path";
|
|
369404
369459
|
var provisionedTargets = new Set;
|
|
369405
369460
|
function defaultSchedule2(task) {
|
|
369406
369461
|
const timer = setTimeout(() => {
|
|
@@ -369427,7 +369482,7 @@ var defaultDeps5 = {
|
|
|
369427
369482
|
function createAstGrepSgProvisionHook(depsOverride = {}) {
|
|
369428
369483
|
const deps = { ...defaultDeps5, ...depsOverride };
|
|
369429
369484
|
const platform2 = deps.platform ?? process.platform;
|
|
369430
|
-
const targetDir = astGrepRuntimeDir(
|
|
369485
|
+
const targetDir = astGrepRuntimeDir(join82(deps.homeDir(), ".omo"), platform2, deps.arch ?? process.arch);
|
|
369431
369486
|
return {
|
|
369432
369487
|
event(input) {
|
|
369433
369488
|
try {
|
|
@@ -369448,17 +369503,17 @@ function createAstGrepSgProvisionHook(depsOverride = {}) {
|
|
|
369448
369503
|
}
|
|
369449
369504
|
// packages/omo-opencode/src/hooks/agent-usage-reminder/storage.ts
|
|
369450
369505
|
import {
|
|
369451
|
-
existsSync as
|
|
369506
|
+
existsSync as existsSync73,
|
|
369452
369507
|
mkdirSync as mkdirSync16,
|
|
369453
|
-
readFileSync as
|
|
369508
|
+
readFileSync as readFileSync47,
|
|
369454
369509
|
writeFileSync as writeFileSync16,
|
|
369455
369510
|
unlinkSync as unlinkSync11
|
|
369456
369511
|
} from "fs";
|
|
369457
|
-
import { join as
|
|
369512
|
+
import { join as join84 } from "path";
|
|
369458
369513
|
|
|
369459
369514
|
// packages/omo-opencode/src/hooks/agent-usage-reminder/constants.ts
|
|
369460
|
-
import { join as
|
|
369461
|
-
var AGENT_USAGE_REMINDER_STORAGE =
|
|
369515
|
+
import { join as join83 } from "path";
|
|
369516
|
+
var AGENT_USAGE_REMINDER_STORAGE = join83(OPENCODE_STORAGE, "agent-usage-reminder");
|
|
369462
369517
|
var TARGET_TOOLS = new Set([
|
|
369463
369518
|
"grep",
|
|
369464
369519
|
"safe_grep",
|
|
@@ -369504,14 +369559,14 @@ ALWAYS prefer: Multiple parallel task calls > Direct tool calls
|
|
|
369504
369559
|
|
|
369505
369560
|
// packages/omo-opencode/src/hooks/agent-usage-reminder/storage.ts
|
|
369506
369561
|
function getStoragePath2(sessionID) {
|
|
369507
|
-
return
|
|
369562
|
+
return join84(AGENT_USAGE_REMINDER_STORAGE, `${sessionID}.json`);
|
|
369508
369563
|
}
|
|
369509
369564
|
function loadAgentUsageState(sessionID) {
|
|
369510
369565
|
const filePath = getStoragePath2(sessionID);
|
|
369511
|
-
if (!
|
|
369566
|
+
if (!existsSync73(filePath))
|
|
369512
369567
|
return null;
|
|
369513
369568
|
try {
|
|
369514
|
-
const content =
|
|
369569
|
+
const content = readFileSync47(filePath, "utf-8");
|
|
369515
369570
|
return JSON.parse(content);
|
|
369516
369571
|
} catch (error) {
|
|
369517
369572
|
error instanceof Error;
|
|
@@ -369519,7 +369574,7 @@ function loadAgentUsageState(sessionID) {
|
|
|
369519
369574
|
}
|
|
369520
369575
|
}
|
|
369521
369576
|
function saveAgentUsageState(state3) {
|
|
369522
|
-
if (!
|
|
369577
|
+
if (!existsSync73(AGENT_USAGE_REMINDER_STORAGE)) {
|
|
369523
369578
|
mkdirSync16(AGENT_USAGE_REMINDER_STORAGE, { recursive: true });
|
|
369524
369579
|
}
|
|
369525
369580
|
const filePath = getStoragePath2(state3.sessionID);
|
|
@@ -369527,7 +369582,7 @@ function saveAgentUsageState(state3) {
|
|
|
369527
369582
|
}
|
|
369528
369583
|
function clearAgentUsageState(sessionID) {
|
|
369529
369584
|
const filePath = getStoragePath2(sessionID);
|
|
369530
|
-
if (
|
|
369585
|
+
if (existsSync73(filePath)) {
|
|
369531
369586
|
unlinkSync11(filePath);
|
|
369532
369587
|
}
|
|
369533
369588
|
}
|
|
@@ -374477,17 +374532,17 @@ function createNonInteractiveEnvHook(_ctx) {
|
|
|
374477
374532
|
}
|
|
374478
374533
|
// packages/omo-opencode/src/hooks/interactive-bash-session/storage.ts
|
|
374479
374534
|
import {
|
|
374480
|
-
existsSync as
|
|
374535
|
+
existsSync as existsSync74,
|
|
374481
374536
|
mkdirSync as mkdirSync17,
|
|
374482
|
-
readFileSync as
|
|
374537
|
+
readFileSync as readFileSync48,
|
|
374483
374538
|
writeFileSync as writeFileSync17,
|
|
374484
374539
|
unlinkSync as unlinkSync12
|
|
374485
374540
|
} from "fs";
|
|
374486
|
-
import { join as
|
|
374541
|
+
import { join as join86 } from "path";
|
|
374487
374542
|
|
|
374488
374543
|
// packages/omo-opencode/src/hooks/interactive-bash-session/constants.ts
|
|
374489
|
-
import { join as
|
|
374490
|
-
var INTERACTIVE_BASH_SESSION_STORAGE =
|
|
374544
|
+
import { join as join85 } from "path";
|
|
374545
|
+
var INTERACTIVE_BASH_SESSION_STORAGE = join85(OPENCODE_STORAGE, "interactive-bash-session");
|
|
374491
374546
|
var OMO_SESSION_PREFIX = "omo-";
|
|
374492
374547
|
function buildSessionReminderMessage(sessions) {
|
|
374493
374548
|
if (sessions.length === 0)
|
|
@@ -374499,14 +374554,14 @@ function buildSessionReminderMessage(sessions) {
|
|
|
374499
374554
|
|
|
374500
374555
|
// packages/omo-opencode/src/hooks/interactive-bash-session/storage.ts
|
|
374501
374556
|
function getStoragePath3(sessionID) {
|
|
374502
|
-
return
|
|
374557
|
+
return join86(INTERACTIVE_BASH_SESSION_STORAGE, `${sessionID}.json`);
|
|
374503
374558
|
}
|
|
374504
374559
|
function loadInteractiveBashSessionState(sessionID) {
|
|
374505
374560
|
const filePath = getStoragePath3(sessionID);
|
|
374506
|
-
if (!
|
|
374561
|
+
if (!existsSync74(filePath))
|
|
374507
374562
|
return null;
|
|
374508
374563
|
try {
|
|
374509
|
-
const content =
|
|
374564
|
+
const content = readFileSync48(filePath, "utf-8");
|
|
374510
374565
|
const serialized = JSON.parse(content);
|
|
374511
374566
|
return {
|
|
374512
374567
|
sessionID: serialized.sessionID,
|
|
@@ -374521,7 +374576,7 @@ function loadInteractiveBashSessionState(sessionID) {
|
|
|
374521
374576
|
}
|
|
374522
374577
|
}
|
|
374523
374578
|
function saveInteractiveBashSessionState(state3) {
|
|
374524
|
-
if (!
|
|
374579
|
+
if (!existsSync74(INTERACTIVE_BASH_SESSION_STORAGE)) {
|
|
374525
374580
|
mkdirSync17(INTERACTIVE_BASH_SESSION_STORAGE, { recursive: true });
|
|
374526
374581
|
}
|
|
374527
374582
|
const filePath = getStoragePath3(state3.sessionID);
|
|
@@ -374534,7 +374589,7 @@ function saveInteractiveBashSessionState(state3) {
|
|
|
374534
374589
|
}
|
|
374535
374590
|
function clearInteractiveBashSessionState(sessionID) {
|
|
374536
374591
|
const filePath = getStoragePath3(sessionID);
|
|
374537
|
-
if (
|
|
374592
|
+
if (existsSync74(filePath)) {
|
|
374538
374593
|
unlinkSync12(filePath);
|
|
374539
374594
|
}
|
|
374540
374595
|
}
|
|
@@ -376477,7 +376532,7 @@ async function handleDetectedCompletion(ctx, input) {
|
|
|
376477
376532
|
init_logger2();
|
|
376478
376533
|
init_constants3();
|
|
376479
376534
|
init_constants3();
|
|
376480
|
-
import { existsSync as
|
|
376535
|
+
import { existsSync as existsSync76, readFileSync as readFileSync50 } from "fs";
|
|
376481
376536
|
function extractTranscriptEntryText(entry) {
|
|
376482
376537
|
if (typeof entry.content === "string")
|
|
376483
376538
|
return entry.content;
|
|
@@ -376515,9 +376570,9 @@ function detectCompletionInTranscript(transcriptPath, promise, startedAt) {
|
|
|
376515
376570
|
if (!transcriptPath)
|
|
376516
376571
|
return false;
|
|
376517
376572
|
try {
|
|
376518
|
-
if (!
|
|
376573
|
+
if (!existsSync76(transcriptPath))
|
|
376519
376574
|
return false;
|
|
376520
|
-
const content =
|
|
376575
|
+
const content = readFileSync50(transcriptPath, "utf-8");
|
|
376521
376576
|
const pattern = buildPromisePattern(promise);
|
|
376522
376577
|
const lines = content.split(`
|
|
376523
376578
|
`).filter((line) => line.trim());
|
|
@@ -377610,7 +377665,7 @@ import { dirname as dirname31 } from "path";
|
|
|
377610
377665
|
init_resolve_commands_in_text();
|
|
377611
377666
|
// packages/skills-loader-core/src/features/opencode-skill-loader/loader.ts
|
|
377612
377667
|
init_src();
|
|
377613
|
-
import { join as
|
|
377668
|
+
import { join as join94 } from "path";
|
|
377614
377669
|
|
|
377615
377670
|
// packages/shared-skills/index.mjs
|
|
377616
377671
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
@@ -377620,21 +377675,21 @@ function sharedSkillsRootPath() {
|
|
|
377620
377675
|
|
|
377621
377676
|
// packages/skills-loader-core/src/shared/claude-config-dir.ts
|
|
377622
377677
|
init_src();
|
|
377623
|
-
import { join as
|
|
377678
|
+
import { join as join88 } from "path";
|
|
377624
377679
|
function getClaudeConfigDir2() {
|
|
377625
377680
|
const envConfigDir = process.env.CLAUDE_CONFIG_DIR;
|
|
377626
377681
|
if (envConfigDir) {
|
|
377627
377682
|
return envConfigDir;
|
|
377628
377683
|
}
|
|
377629
|
-
return
|
|
377684
|
+
return join88(getHomeDirectory(), ".claude");
|
|
377630
377685
|
}
|
|
377631
377686
|
// packages/skills-loader-core/src/shared/opencode-command-dirs.ts
|
|
377632
|
-
import { basename as basename14, dirname as dirname26, join as
|
|
377687
|
+
import { basename as basename14, dirname as dirname26, join as join90 } from "path";
|
|
377633
377688
|
|
|
377634
377689
|
// packages/skills-loader-core/src/shared/opencode-config-dir.ts
|
|
377635
|
-
import { existsSync as
|
|
377690
|
+
import { existsSync as existsSync77, realpathSync as realpathSync12 } from "fs";
|
|
377636
377691
|
import { homedir as homedir24 } from "os";
|
|
377637
|
-
import { join as
|
|
377692
|
+
import { join as join89, posix as posix4, resolve as resolve21, win32 as win325 } from "path";
|
|
377638
377693
|
|
|
377639
377694
|
// packages/skills-loader-core/src/shared/plugin-identity.ts
|
|
377640
377695
|
init_src();
|
|
@@ -377667,15 +377722,15 @@ function getTauriConfigDir2(identifier) {
|
|
|
377667
377722
|
const platform2 = process.platform;
|
|
377668
377723
|
switch (platform2) {
|
|
377669
377724
|
case "darwin":
|
|
377670
|
-
return
|
|
377725
|
+
return join89(homedir24(), "Library", "Application Support", identifier);
|
|
377671
377726
|
case "win32": {
|
|
377672
|
-
const appData = process.env.APPDATA ||
|
|
377727
|
+
const appData = process.env.APPDATA || join89(homedir24(), "AppData", "Roaming");
|
|
377673
377728
|
return win325.join(appData, identifier);
|
|
377674
377729
|
}
|
|
377675
377730
|
case "linux":
|
|
377676
377731
|
default: {
|
|
377677
|
-
const xdgConfig = process.env.XDG_CONFIG_HOME ||
|
|
377678
|
-
return
|
|
377732
|
+
const xdgConfig = process.env.XDG_CONFIG_HOME || join89(homedir24(), ".config");
|
|
377733
|
+
return join89(xdgConfig, identifier);
|
|
377679
377734
|
}
|
|
377680
377735
|
}
|
|
377681
377736
|
}
|
|
@@ -377684,7 +377739,7 @@ function resolveConfigPath2(pathValue) {
|
|
|
377684
377739
|
return posix4.normalize(pathValue);
|
|
377685
377740
|
}
|
|
377686
377741
|
const resolvedPath = resolve21(pathValue);
|
|
377687
|
-
if (!
|
|
377742
|
+
if (!existsSync77(resolvedPath))
|
|
377688
377743
|
return resolvedPath;
|
|
377689
377744
|
try {
|
|
377690
377745
|
return realpathSync12(resolvedPath);
|
|
@@ -377718,8 +377773,8 @@ function getWslLinuxHomeDir2(windowsConfigRoot) {
|
|
|
377718
377773
|
function getCliDefaultConfigDir2() {
|
|
377719
377774
|
const envXdgConfig = process.env.XDG_CONFIG_HOME?.trim();
|
|
377720
377775
|
const shouldIgnoreWindowsXdg = envXdgConfig !== undefined && envXdgConfig.length > 0 && isWslEnvironment2() && isWindowsUserConfigRoot2(envXdgConfig);
|
|
377721
|
-
const xdgConfig = shouldIgnoreWindowsXdg ? posix4.join(getWslLinuxHomeDir2(envXdgConfig) ?? "/home", ".config") : envXdgConfig ||
|
|
377722
|
-
const configDir = isWslEnvironment2() ? posix4.join(xdgConfig, "opencode") :
|
|
377776
|
+
const xdgConfig = shouldIgnoreWindowsXdg ? posix4.join(getWslLinuxHomeDir2(envXdgConfig) ?? "/home", ".config") : envXdgConfig || join89(homedir24(), ".config");
|
|
377777
|
+
const configDir = isWslEnvironment2() ? posix4.join(xdgConfig, "opencode") : join89(xdgConfig, "opencode");
|
|
377723
377778
|
return resolveConfigPath2(configDir);
|
|
377724
377779
|
}
|
|
377725
377780
|
function getCliCustomConfigDir2() {
|
|
@@ -377752,9 +377807,9 @@ function getOpenCodeConfigDir2(options) {
|
|
|
377752
377807
|
const tauriDir = process.platform === "win32" ? win325.isAbsolute(tauriDirBase) ? win325.normalize(tauriDirBase) : win325.resolve(tauriDirBase) : resolveConfigPath2(tauriDirBase);
|
|
377753
377808
|
if (checkExisting) {
|
|
377754
377809
|
const legacyDir = getCliConfigDir2();
|
|
377755
|
-
const legacyConfig =
|
|
377756
|
-
const legacyConfigC =
|
|
377757
|
-
if (
|
|
377810
|
+
const legacyConfig = join89(legacyDir, "opencode.json");
|
|
377811
|
+
const legacyConfigC = join89(legacyDir, "opencode.jsonc");
|
|
377812
|
+
if (existsSync77(legacyConfig) || existsSync77(legacyConfigC)) {
|
|
377758
377813
|
return legacyDir;
|
|
377759
377814
|
}
|
|
377760
377815
|
}
|
|
@@ -377775,21 +377830,21 @@ function getOpenCodeSkillDirs(options) {
|
|
|
377775
377830
|
...configDirs.flatMap((configDir) => {
|
|
377776
377831
|
const parentConfigDir = getParentOpencodeConfigDir2(configDir);
|
|
377777
377832
|
return [
|
|
377778
|
-
|
|
377779
|
-
|
|
377780
|
-
...parentConfigDir ? [
|
|
377833
|
+
join90(configDir, "skills"),
|
|
377834
|
+
join90(configDir, "skill"),
|
|
377835
|
+
...parentConfigDir ? [join90(parentConfigDir, "skills"), join90(parentConfigDir, "skill")] : []
|
|
377781
377836
|
];
|
|
377782
377837
|
})
|
|
377783
377838
|
]));
|
|
377784
377839
|
}
|
|
377785
377840
|
// packages/skills-loader-core/src/shared/project-discovery-dirs.ts
|
|
377786
377841
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
377787
|
-
import { existsSync as
|
|
377788
|
-
import { dirname as dirname27, join as
|
|
377842
|
+
import { existsSync as existsSync78, realpathSync as realpathSync13 } from "fs";
|
|
377843
|
+
import { dirname as dirname27, join as join91, resolve as resolve22, win32 as win326 } from "path";
|
|
377789
377844
|
var worktreePathCache2 = new Map;
|
|
377790
377845
|
function normalizePath4(path17) {
|
|
377791
377846
|
const resolvedPath = process.platform !== "win32" && win326.isAbsolute(path17) ? path17 : resolve22(path17);
|
|
377792
|
-
if (!
|
|
377847
|
+
if (!existsSync78(resolvedPath)) {
|
|
377793
377848
|
return resolvedPath;
|
|
377794
377849
|
}
|
|
377795
377850
|
try {
|
|
@@ -377820,8 +377875,8 @@ function findAncestorDirectories2(startDirectory, targetPaths, stopDirectory) {
|
|
|
377820
377875
|
const stopDirectoryKey = resolvedStopDirectory ? pathKey2(resolvedStopDirectory) : undefined;
|
|
377821
377876
|
while (true) {
|
|
377822
377877
|
for (const targetPath of targetPaths) {
|
|
377823
|
-
const candidateDirectory =
|
|
377824
|
-
if (!
|
|
377878
|
+
const candidateDirectory = join91(currentDirectory, ...targetPath);
|
|
377879
|
+
if (!existsSync78(candidateDirectory)) {
|
|
377825
377880
|
continue;
|
|
377826
377881
|
}
|
|
377827
377882
|
const normalizedCandidateDirectory = normalizePath4(candidateDirectory);
|
|
@@ -377993,7 +378048,7 @@ function deduplicateSkillsByName(skills) {
|
|
|
377993
378048
|
// packages/skills-loader-core/src/features/opencode-skill-loader/skill-directory-loader.ts
|
|
377994
378049
|
init_src();
|
|
377995
378050
|
import * as fs19 from "fs/promises";
|
|
377996
|
-
import { join as
|
|
378051
|
+
import { join as join93 } from "path";
|
|
377997
378052
|
|
|
377998
378053
|
// packages/skills-loader-core/src/features/opencode-skill-loader/loaded-skill-from-path.ts
|
|
377999
378054
|
init_src();
|
|
@@ -378013,7 +378068,7 @@ function parseAllowedTools(allowedTools) {
|
|
|
378013
378068
|
// packages/skills-loader-core/src/features/opencode-skill-loader/skill-mcp-config.ts
|
|
378014
378069
|
init_js_yaml();
|
|
378015
378070
|
import * as fs17 from "fs/promises";
|
|
378016
|
-
import { join as
|
|
378071
|
+
import { join as join92 } from "path";
|
|
378017
378072
|
function parseSkillMcpConfigFromFrontmatter(content) {
|
|
378018
378073
|
const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
378019
378074
|
if (!frontmatterMatch)
|
|
@@ -378032,7 +378087,7 @@ function parseSkillMcpConfigFromFrontmatter(content) {
|
|
|
378032
378087
|
return;
|
|
378033
378088
|
}
|
|
378034
378089
|
async function loadMcpJsonFromDir(skillDir) {
|
|
378035
|
-
const mcpJsonPath =
|
|
378090
|
+
const mcpJsonPath = join92(skillDir, "mcp.json");
|
|
378036
378091
|
try {
|
|
378037
378092
|
const content = await fs17.readFile(mcpJsonPath, "utf-8");
|
|
378038
378093
|
const parsed = JSON.parse(content);
|
|
@@ -378148,10 +378203,10 @@ async function loadSkillsFromDir(options) {
|
|
|
378148
378203
|
const directories = entries.filter((entry) => !entry.name.startsWith(".") && (entry.isDirectory() || entry.isSymbolicLink()));
|
|
378149
378204
|
const files = entries.filter((entry) => !entry.name.startsWith(".") && !entry.isDirectory() && !entry.isSymbolicLink() && isMarkdownFile(entry));
|
|
378150
378205
|
for (const entry of directories) {
|
|
378151
|
-
const entryPath =
|
|
378206
|
+
const entryPath = join93(options.skillsDir, entry.name);
|
|
378152
378207
|
const resolvedPath = await resolveSymlinkAsync(entryPath);
|
|
378153
378208
|
const dirName = entry.name;
|
|
378154
|
-
const skillMdPath =
|
|
378209
|
+
const skillMdPath = join93(resolvedPath, "SKILL.md");
|
|
378155
378210
|
if (await canAccessFile(skillMdPath)) {
|
|
378156
378211
|
const skill = await loadSkillFromPath({
|
|
378157
378212
|
skillPath: skillMdPath,
|
|
@@ -378165,7 +378220,7 @@ async function loadSkillsFromDir(options) {
|
|
|
378165
378220
|
}
|
|
378166
378221
|
continue;
|
|
378167
378222
|
}
|
|
378168
|
-
const namedSkillMdPath =
|
|
378223
|
+
const namedSkillMdPath = join93(resolvedPath, `${dirName}.md`);
|
|
378169
378224
|
if (await canAccessFile(namedSkillMdPath)) {
|
|
378170
378225
|
const skill = await loadSkillFromPath({
|
|
378171
378226
|
skillPath: namedSkillMdPath,
|
|
@@ -378196,7 +378251,7 @@ async function loadSkillsFromDir(options) {
|
|
|
378196
378251
|
}
|
|
378197
378252
|
}
|
|
378198
378253
|
for (const entry of files) {
|
|
378199
|
-
const entryPath =
|
|
378254
|
+
const entryPath = join93(options.skillsDir, entry.name);
|
|
378200
378255
|
const baseName = inferSkillNameFromFileName(entryPath);
|
|
378201
378256
|
const skill = await loadSkillFromPath({
|
|
378202
378257
|
skillPath: entryPath,
|
|
@@ -378214,7 +378269,7 @@ async function loadSkillsFromDir(options) {
|
|
|
378214
378269
|
|
|
378215
378270
|
// packages/skills-loader-core/src/features/opencode-skill-loader/loader.ts
|
|
378216
378271
|
async function loadUserSkills() {
|
|
378217
|
-
const userSkillsDir =
|
|
378272
|
+
const userSkillsDir = join94(getClaudeConfigDir2(), "skills");
|
|
378218
378273
|
const skills = await loadSkillsFromDir({ skillsDir: userSkillsDir, scope: "user" });
|
|
378219
378274
|
return skillsToCommandDefinitionRecord(skills);
|
|
378220
378275
|
}
|
|
@@ -378239,7 +378294,7 @@ async function loadProjectAgentsSkills(directory) {
|
|
|
378239
378294
|
return skillsToCommandDefinitionRecord(deduplicateSkillsByName(allSkills.flat()));
|
|
378240
378295
|
}
|
|
378241
378296
|
async function loadGlobalAgentsSkills(homeDirectory = getHomeDirectory()) {
|
|
378242
|
-
const agentsGlobalDir =
|
|
378297
|
+
const agentsGlobalDir = join94(homeDirectory, ".agents", "skills");
|
|
378243
378298
|
const skills = await loadSkillsFromDir({ skillsDir: agentsGlobalDir, scope: "user" });
|
|
378244
378299
|
return skillsToCommandDefinitionRecord(skills);
|
|
378245
378300
|
}
|
|
@@ -378310,7 +378365,7 @@ async function discoverSkills(options = {}) {
|
|
|
378310
378365
|
]);
|
|
378311
378366
|
}
|
|
378312
378367
|
async function discoverUserClaudeSkills() {
|
|
378313
|
-
const userSkillsDir =
|
|
378368
|
+
const userSkillsDir = join94(getClaudeConfigDir2(), "skills");
|
|
378314
378369
|
return loadSkillsFromDir({ skillsDir: userSkillsDir, scope: "user" });
|
|
378315
378370
|
}
|
|
378316
378371
|
async function discoverProjectClaudeSkills(directory) {
|
|
@@ -378337,17 +378392,17 @@ async function discoverProjectAgentsSkills(directory) {
|
|
|
378337
378392
|
return deduplicateSkillsByName(allSkills.flat());
|
|
378338
378393
|
}
|
|
378339
378394
|
async function discoverGlobalAgentsSkills(homeDirectory = getHomeDirectory()) {
|
|
378340
|
-
const agentsGlobalDir =
|
|
378395
|
+
const agentsGlobalDir = join94(homeDirectory, ".agents", "skills");
|
|
378341
378396
|
return loadSkillsFromDir({ skillsDir: agentsGlobalDir, scope: "user" });
|
|
378342
378397
|
}
|
|
378343
378398
|
// packages/skills-loader-core/src/features/opencode-skill-loader/merger/builtin-skill-converter.ts
|
|
378344
|
-
import { existsSync as
|
|
378345
|
-
import { join as
|
|
378399
|
+
import { existsSync as existsSync79 } from "fs";
|
|
378400
|
+
import { join as join95 } from "path";
|
|
378346
378401
|
function resolveBuiltinSkillPath(builtin) {
|
|
378347
378402
|
if (builtin.resolvedPath !== undefined)
|
|
378348
378403
|
return builtin.resolvedPath;
|
|
378349
|
-
const sharedSkillPath =
|
|
378350
|
-
return
|
|
378404
|
+
const sharedSkillPath = join95(sharedSkillsRootPath(), builtin.name);
|
|
378405
|
+
return existsSync79(sharedSkillPath) ? sharedSkillPath : undefined;
|
|
378351
378406
|
}
|
|
378352
378407
|
function builtinToLoadedSkill(builtin) {
|
|
378353
378408
|
const definition = {
|
|
@@ -378374,7 +378429,7 @@ function builtinToLoadedSkill(builtin) {
|
|
|
378374
378429
|
|
|
378375
378430
|
// packages/skills-loader-core/src/features/opencode-skill-loader/merger/config-skill-entry-loader.ts
|
|
378376
378431
|
init_src();
|
|
378377
|
-
import { existsSync as
|
|
378432
|
+
import { existsSync as existsSync80, readFileSync as readFileSync51 } from "fs";
|
|
378378
378433
|
import { dirname as dirname28, isAbsolute as isAbsolute13, resolve as resolve23 } from "path";
|
|
378379
378434
|
import { homedir as homedir25 } from "os";
|
|
378380
378435
|
function resolveFilePath5(from, configDir) {
|
|
@@ -378393,9 +378448,9 @@ function resolveFilePath5(from, configDir) {
|
|
|
378393
378448
|
}
|
|
378394
378449
|
function loadSkillFromFile(filePath) {
|
|
378395
378450
|
try {
|
|
378396
|
-
if (!
|
|
378451
|
+
if (!existsSync80(filePath))
|
|
378397
378452
|
return null;
|
|
378398
|
-
const content =
|
|
378453
|
+
const content = readFileSync51(filePath, "utf-8");
|
|
378399
378454
|
const { data, body } = parseFrontmatter(content);
|
|
378400
378455
|
return { template: body, metadata: data };
|
|
378401
378456
|
} catch (error) {
|
|
@@ -379261,17 +379316,17 @@ playwright-cli close
|
|
|
379261
379316
|
allowedTools: ["Bash(playwright-cli:*)"]
|
|
379262
379317
|
};
|
|
379263
379318
|
// packages/skills-loader-core/src/features/builtin-skills/skill-file-loader.ts
|
|
379264
|
-
import { readFileSync as
|
|
379265
|
-
import { join as
|
|
379319
|
+
import { readFileSync as readFileSync52 } from "fs";
|
|
379320
|
+
import { join as join96 } from "path";
|
|
379266
379321
|
init_src();
|
|
379267
|
-
function createSharedSkillTemplateLoader(readFile9 =
|
|
379322
|
+
function createSharedSkillTemplateLoader(readFile9 = readFileSync52, skillsRootPath = sharedSkillsRootPath()) {
|
|
379268
379323
|
const cache2 = new Map;
|
|
379269
379324
|
return (skillName) => {
|
|
379270
379325
|
const cached = cache2.get(skillName);
|
|
379271
379326
|
if (cached !== undefined)
|
|
379272
379327
|
return cached;
|
|
379273
379328
|
try {
|
|
379274
|
-
const { body } = parseFrontmatter(readFile9(
|
|
379329
|
+
const { body } = parseFrontmatter(readFile9(join96(skillsRootPath, skillName, "SKILL.md"), "utf8"));
|
|
379275
379330
|
cache2.set(skillName, body);
|
|
379276
379331
|
return body;
|
|
379277
379332
|
} catch (error) {
|
|
@@ -380408,7 +380463,7 @@ var gitMasterSkill = {
|
|
|
380408
380463
|
template: GIT_MASTER_TEMPLATE
|
|
380409
380464
|
};
|
|
380410
380465
|
// packages/skills-loader-core/src/features/builtin-skills/skills/dev-browser.ts
|
|
380411
|
-
import { dirname as dirname29, join as
|
|
380466
|
+
import { dirname as dirname29, join as join97 } from "path";
|
|
380412
380467
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
380413
380468
|
var CURRENT_DIR = dirname29(fileURLToPath6(import.meta.url));
|
|
380414
380469
|
var devBrowserSkill = {
|
|
@@ -380628,7 +380683,7 @@ console.log({
|
|
|
380628
380683
|
await client.disconnect();
|
|
380629
380684
|
EOF
|
|
380630
380685
|
\`\`\``,
|
|
380631
|
-
resolvedPath:
|
|
380686
|
+
resolvedPath: join97(CURRENT_DIR, "..", "dev-browser")
|
|
380632
380687
|
};
|
|
380633
380688
|
// packages/skills-loader-core/src/features/builtin-skills/skills/review-work.ts
|
|
380634
380689
|
var reviewWorkSkill = {
|
|
@@ -381305,13 +381360,13 @@ function mergeSkills(builtinSkills, config, configSourceSkills, userClaudeSkills
|
|
|
381305
381360
|
}
|
|
381306
381361
|
// packages/skills-loader-core/src/features/opencode-skill-loader/loaded-skill-template-extractor.ts
|
|
381307
381362
|
init_src();
|
|
381308
|
-
import { readFileSync as
|
|
381363
|
+
import { readFileSync as readFileSync53 } from "fs";
|
|
381309
381364
|
function extractSkillTemplate(skill) {
|
|
381310
381365
|
if (skill.scope === "config" && skill.definition.template) {
|
|
381311
381366
|
return skill.definition.template;
|
|
381312
381367
|
}
|
|
381313
381368
|
if (skill.path) {
|
|
381314
|
-
const content =
|
|
381369
|
+
const content = readFileSync53(skill.path, "utf-8");
|
|
381315
381370
|
const { body } = parseFrontmatter(content);
|
|
381316
381371
|
return body.trim();
|
|
381317
381372
|
}
|
|
@@ -381628,7 +381683,7 @@ init_src();
|
|
|
381628
381683
|
var import_picomatch2 = __toESM(require_picomatch2(), 1);
|
|
381629
381684
|
import * as fs20 from "fs/promises";
|
|
381630
381685
|
import { homedir as homedir26 } from "os";
|
|
381631
|
-
import { dirname as dirname30, extname as extname2, isAbsolute as isAbsolute14, join as
|
|
381686
|
+
import { dirname as dirname30, extname as extname2, isAbsolute as isAbsolute14, join as join98, relative as relative12 } from "path";
|
|
381632
381687
|
var MAX_RECURSIVE_DEPTH = 10;
|
|
381633
381688
|
function isHttpUrl(path17) {
|
|
381634
381689
|
return path17.startsWith("http://") || path17.startsWith("https://");
|
|
@@ -381638,12 +381693,12 @@ function toAbsolutePath(path17, configDir) {
|
|
|
381638
381693
|
return homedir26();
|
|
381639
381694
|
}
|
|
381640
381695
|
if (path17.startsWith("~/")) {
|
|
381641
|
-
return
|
|
381696
|
+
return join98(homedir26(), path17.slice(2));
|
|
381642
381697
|
}
|
|
381643
381698
|
if (isAbsolute14(path17)) {
|
|
381644
381699
|
return path17;
|
|
381645
381700
|
}
|
|
381646
|
-
return
|
|
381701
|
+
return join98(configDir, path17);
|
|
381647
381702
|
}
|
|
381648
381703
|
function isMarkdownPath(path17) {
|
|
381649
381704
|
return extname2(path17).toLowerCase() === ".md";
|
|
@@ -381770,8 +381825,8 @@ function readOpencodeConfigSkills(directory) {
|
|
|
381770
381825
|
return { paths, urls };
|
|
381771
381826
|
}
|
|
381772
381827
|
// packages/omo-opencode/src/tools/slashcommand/command-discovery.ts
|
|
381773
|
-
import { existsSync as
|
|
381774
|
-
import { basename as basename16, join as
|
|
381828
|
+
import { existsSync as existsSync82, readdirSync as readdirSync20, readFileSync as readFileSync55, statSync as statSync11 } from "fs";
|
|
381829
|
+
import { basename as basename16, join as join100 } from "path";
|
|
381775
381830
|
|
|
381776
381831
|
// packages/omo-opencode/src/tools/slashcommand/command-discovery-deps.ts
|
|
381777
381832
|
init_frontmatter2();
|
|
@@ -383335,7 +383390,7 @@ function loadBuiltinCommands(disabledCommands, options) {
|
|
|
383335
383390
|
// packages/omo-opencode/src/tools/slashcommand/command-discovery.ts
|
|
383336
383391
|
var NESTED_COMMAND_SEPARATOR = "/";
|
|
383337
383392
|
function discoverCommandsFromDir(commandsDir, scope, prefix = "") {
|
|
383338
|
-
if (!
|
|
383393
|
+
if (!existsSync82(commandsDir))
|
|
383339
383394
|
return [];
|
|
383340
383395
|
if (!statSync11(commandsDir).isDirectory()) {
|
|
383341
383396
|
log2(`[command-discovery] Skipping non-directory path: ${commandsDir}`);
|
|
@@ -383350,16 +383405,16 @@ function discoverCommandsFromDir(commandsDir, scope, prefix = "") {
|
|
|
383350
383405
|
if (entry.name.startsWith("."))
|
|
383351
383406
|
continue;
|
|
383352
383407
|
const nestedPrefix = prefix ? `${prefix}${NESTED_COMMAND_SEPARATOR}${entry.name}` : entry.name;
|
|
383353
|
-
commands.push(...discoverCommandsFromDir(
|
|
383408
|
+
commands.push(...discoverCommandsFromDir(join100(commandsDir, entry.name), scope, nestedPrefix));
|
|
383354
383409
|
continue;
|
|
383355
383410
|
}
|
|
383356
383411
|
if (!isMarkdownFile(entry))
|
|
383357
383412
|
continue;
|
|
383358
|
-
const commandPath =
|
|
383413
|
+
const commandPath = join100(commandsDir, entry.name);
|
|
383359
383414
|
const baseCommandName = basename16(entry.name, ".md");
|
|
383360
383415
|
const commandName = prefix ? `${prefix}${NESTED_COMMAND_SEPARATOR}${baseCommandName}` : baseCommandName;
|
|
383361
383416
|
try {
|
|
383362
|
-
const content =
|
|
383417
|
+
const content = readFileSync55(commandPath, "utf-8");
|
|
383363
383418
|
const { data, body } = parseFrontmatter(content);
|
|
383364
383419
|
const isOpencodeSource = scope === "opencode" || scope === "opencode-project";
|
|
383365
383420
|
const metadata = {
|
|
@@ -383414,8 +383469,8 @@ function deduplicateCommandInfosByName(commands) {
|
|
|
383414
383469
|
return deduplicatedCommands;
|
|
383415
383470
|
}
|
|
383416
383471
|
function discoverCommandsSync(directory, options) {
|
|
383417
|
-
const userCommandsDir =
|
|
383418
|
-
const projectCommandsDir =
|
|
383472
|
+
const userCommandsDir = join100(getClaudeConfigDir(), "commands");
|
|
383473
|
+
const projectCommandsDir = join100(directory ?? process.cwd(), ".claude", "commands");
|
|
383419
383474
|
const opencodeGlobalDirs = getOpenCodeCommandDirs({ binary: "opencode" });
|
|
383420
383475
|
const opencodeProjectDirs = findProjectOpencodeCommandDirs(directory ?? process.cwd());
|
|
383421
383476
|
const userCommands = discoverCommandsFromDir(userCommandsDir, "user");
|
|
@@ -384090,11 +384145,11 @@ init_logger2();
|
|
|
384090
384145
|
|
|
384091
384146
|
// packages/omo-opencode/src/hooks/start-work/worktree-detector.ts
|
|
384092
384147
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
384093
|
-
import { existsSync as
|
|
384148
|
+
import { existsSync as existsSync83, realpathSync as realpathSync14 } from "fs";
|
|
384094
384149
|
import { resolve as resolve25, win32 as win327 } from "path";
|
|
384095
384150
|
function normalizePath5(path18) {
|
|
384096
384151
|
const resolvedPath = process.platform !== "win32" && win327.isAbsolute(path18) ? path18 : resolve25(path18);
|
|
384097
|
-
if (!
|
|
384152
|
+
if (!existsSync83(resolvedPath)) {
|
|
384098
384153
|
return resolvedPath;
|
|
384099
384154
|
}
|
|
384100
384155
|
try {
|
|
@@ -385389,8 +385444,8 @@ async function isSessionInBoulderLineage(input) {
|
|
|
385389
385444
|
}
|
|
385390
385445
|
|
|
385391
385446
|
// packages/omo-opencode/src/hooks/the-operator/session-last-agent.ts
|
|
385392
|
-
import { readFileSync as
|
|
385393
|
-
import { join as
|
|
385447
|
+
import { readFileSync as readFileSync56, readdirSync as readdirSync21 } from "fs";
|
|
385448
|
+
import { join as join101 } from "path";
|
|
385394
385449
|
var defaultSessionLastAgentDeps = {
|
|
385395
385450
|
getMessageDir,
|
|
385396
385451
|
isSqliteBackend,
|
|
@@ -385450,7 +385505,7 @@ async function getLastAgentFromSession(sessionID, client3, deps = {}) {
|
|
|
385450
385505
|
try {
|
|
385451
385506
|
const messages = readdirSync21(messageDir).filter((fileName) => fileName.endsWith(".json")).map((fileName) => {
|
|
385452
385507
|
try {
|
|
385453
|
-
const content =
|
|
385508
|
+
const content = readFileSync56(join101(messageDir, fileName), "utf-8");
|
|
385454
385509
|
const parsed = JSON.parse(content);
|
|
385455
385510
|
return {
|
|
385456
385511
|
fileName,
|
|
@@ -385993,7 +386048,7 @@ function isOmoPath(filePath) {
|
|
|
385993
386048
|
}
|
|
385994
386049
|
|
|
385995
386050
|
// packages/omo-opencode/src/hooks/the-operator/tool-execute-after-plan-tasks.ts
|
|
385996
|
-
import { existsSync as
|
|
386051
|
+
import { existsSync as existsSync84, readFileSync as readFileSync57 } from "fs";
|
|
385997
386052
|
var TODO_HEADING_PATTERN3 = /^##\s+TODOs\b/i;
|
|
385998
386053
|
var FINAL_VERIFICATION_HEADING_PATTERN3 = /^##\s+Final Verification Wave\b/i;
|
|
385999
386054
|
var SECOND_LEVEL_HEADING_PATTERN3 = /^##\s+/;
|
|
@@ -386001,7 +386056,7 @@ var CHECKED_CHECKBOX_PATTERN2 = /^(\s*)[-*]\s*\[[xX]\]\s*(.+)$/;
|
|
|
386001
386056
|
var TODO_TASK_PATTERN3 = /^(\d+)\.\s+(.+)$/;
|
|
386002
386057
|
var FINAL_WAVE_TASK_PATTERN3 = /^(F\d+)\.\s+(.+)$/i;
|
|
386003
386058
|
function isTrackedTaskChecked(planPath, taskKey) {
|
|
386004
|
-
if (!
|
|
386059
|
+
if (!existsSync84(planPath)) {
|
|
386005
386060
|
return false;
|
|
386006
386061
|
}
|
|
386007
386062
|
const [section, label] = taskKey.split(":");
|
|
@@ -386014,7 +386069,7 @@ function isTrackedTaskChecked(planPath, taskKey) {
|
|
|
386014
386069
|
return false;
|
|
386015
386070
|
}
|
|
386016
386071
|
try {
|
|
386017
|
-
const content =
|
|
386072
|
+
const content = readFileSync57(planPath, "utf-8");
|
|
386018
386073
|
return matcher.test(content);
|
|
386019
386074
|
} catch (error) {
|
|
386020
386075
|
if (!(error instanceof Error)) {
|
|
@@ -386055,11 +386110,11 @@ function parseCheckedTopLevelTaskKeys(planContent) {
|
|
|
386055
386110
|
return checkedKeys;
|
|
386056
386111
|
}
|
|
386057
386112
|
function readCheckedTaskKeysFromPlan(planPath) {
|
|
386058
|
-
if (!
|
|
386113
|
+
if (!existsSync84(planPath)) {
|
|
386059
386114
|
return new Set;
|
|
386060
386115
|
}
|
|
386061
386116
|
try {
|
|
386062
|
-
return parseCheckedTopLevelTaskKeys(
|
|
386117
|
+
return parseCheckedTopLevelTaskKeys(readFileSync57(planPath, "utf-8"));
|
|
386063
386118
|
} catch (error) {
|
|
386064
386119
|
if (!(error instanceof Error)) {
|
|
386065
386120
|
throw error;
|
|
@@ -386234,7 +386289,7 @@ async function resolveFallbackTrackedSessionId(input) {
|
|
|
386234
386289
|
}
|
|
386235
386290
|
|
|
386236
386291
|
// packages/omo-opencode/src/hooks/the-operator/final-wave-plan-state.ts
|
|
386237
|
-
import { existsSync as
|
|
386292
|
+
import { existsSync as existsSync85, readFileSync as readFileSync58 } from "fs";
|
|
386238
386293
|
var TODO_HEADING_PATTERN4 = /^##\s+TODOs\b/i;
|
|
386239
386294
|
var FINAL_VERIFICATION_HEADING_PATTERN4 = /^##\s+Final Verification Wave\b/i;
|
|
386240
386295
|
var SECOND_LEVEL_HEADING_PATTERN4 = /^##\s+/;
|
|
@@ -386242,11 +386297,11 @@ var UNCHECKED_CHECKBOX_PATTERN3 = /^\s*[-*]\s*\[\s*\]\s*(.+)$/;
|
|
|
386242
386297
|
var TODO_TASK_PATTERN4 = /^\d+\./;
|
|
386243
386298
|
var FINAL_WAVE_TASK_PATTERN4 = /^F\d+\./i;
|
|
386244
386299
|
function readFinalWavePlanState(planPath) {
|
|
386245
|
-
if (!
|
|
386300
|
+
if (!existsSync85(planPath)) {
|
|
386246
386301
|
return null;
|
|
386247
386302
|
}
|
|
386248
386303
|
try {
|
|
386249
|
-
const content =
|
|
386304
|
+
const content = readFileSync58(planPath, "utf-8");
|
|
386250
386305
|
const lines = content.split(/\r?\n/);
|
|
386251
386306
|
let section = "other";
|
|
386252
386307
|
let pendingImplementationTaskCount = 0;
|
|
@@ -386842,7 +386897,7 @@ function createToolExecuteAfterHandler2(input) {
|
|
|
386842
386897
|
|
|
386843
386898
|
// packages/omo-opencode/src/hooks/the-operator/tool-execute-before.ts
|
|
386844
386899
|
init_logger2();
|
|
386845
|
-
import { existsSync as
|
|
386900
|
+
import { existsSync as existsSync86, readFileSync as readFileSync59 } from "fs";
|
|
386846
386901
|
import { resolve as resolve27 } from "path";
|
|
386847
386902
|
var TASK_SECTION_HEADER_PATTERN = /^##\s*1\.\s*TASK\s*$/i;
|
|
386848
386903
|
var TODO_TASK_LINE_PATTERN = /^(?:[-*]\s*\[\s*\]\s*)?(\d+)\.\s+(.+)$/;
|
|
@@ -386903,8 +386958,8 @@ function createToolExecuteBeforeHandler2(input) {
|
|
|
386903
386958
|
const planPath = sessionWork ? resolveBoulderPlanPathForWork(ctx.directory, sessionWork) : state3 ? resolveBoulderPlanPath(ctx.directory, state3) : null;
|
|
386904
386959
|
if (planPath && resolve27(filePath) === resolve27(planPath) && pendingPlanSnapshots) {
|
|
386905
386960
|
try {
|
|
386906
|
-
if (
|
|
386907
|
-
pendingPlanSnapshots.set(toolInput.callID,
|
|
386961
|
+
if (existsSync86(planPath)) {
|
|
386962
|
+
pendingPlanSnapshots.set(toolInput.callID, readFileSync59(planPath, "utf-8"));
|
|
386908
386963
|
}
|
|
386909
386964
|
} catch (error) {
|
|
386910
386965
|
if (!(error instanceof Error)) {
|
|
@@ -390801,11 +390856,11 @@ function createRuntimeFallbackHook(ctx, options, factoryOverrides = {}) {
|
|
|
390801
390856
|
};
|
|
390802
390857
|
}
|
|
390803
390858
|
// packages/omo-opencode/src/hooks/write-existing-file-guard/hook.ts
|
|
390804
|
-
import { existsSync as
|
|
390805
|
-
import { basename as basename17, dirname as dirname32, isAbsolute as isAbsolute16, join as
|
|
390859
|
+
import { existsSync as existsSync88, realpathSync as realpathSync15 } from "fs";
|
|
390860
|
+
import { basename as basename17, dirname as dirname32, isAbsolute as isAbsolute16, join as join102, normalize as normalize2, relative as relative14, resolve as resolve28 } from "path";
|
|
390806
390861
|
|
|
390807
390862
|
// packages/omo-opencode/src/hooks/write-existing-file-guard/tool-execute-before-handler.ts
|
|
390808
|
-
import { existsSync as
|
|
390863
|
+
import { existsSync as existsSync87 } from "fs";
|
|
390809
390864
|
|
|
390810
390865
|
// packages/omo-opencode/src/hooks/write-existing-file-guard/session-read-permissions.ts
|
|
390811
390866
|
function touchSession(sessionLastAccess, sessionID) {
|
|
@@ -390906,7 +390961,7 @@ async function handleWriteExistingFileGuardToolExecuteBefore(params) {
|
|
|
390906
390961
|
return;
|
|
390907
390962
|
}
|
|
390908
390963
|
if (toolName === "read") {
|
|
390909
|
-
if (!
|
|
390964
|
+
if (!existsSync87(resolvedPath) || !input.sessionID) {
|
|
390910
390965
|
return;
|
|
390911
390966
|
}
|
|
390912
390967
|
registerReadPermission({
|
|
@@ -390924,7 +390979,7 @@ async function handleWriteExistingFileGuardToolExecuteBefore(params) {
|
|
|
390924
390979
|
const { overwrite: _, ...rest } = argsRecord;
|
|
390925
390980
|
output.args = rest;
|
|
390926
390981
|
}
|
|
390927
|
-
if (!
|
|
390982
|
+
if (!existsSync87(resolvedPath)) {
|
|
390928
390983
|
return;
|
|
390929
390984
|
}
|
|
390930
390985
|
if (isOmoWorkspacePath(canonicalPath)) {
|
|
@@ -390982,7 +391037,7 @@ function isPathInsideDirectory(pathToCheck, directory) {
|
|
|
390982
391037
|
}
|
|
390983
391038
|
function toCanonicalPath2(absolutePath) {
|
|
390984
391039
|
let canonicalPath = absolutePath;
|
|
390985
|
-
if (
|
|
391040
|
+
if (existsSync88(absolutePath)) {
|
|
390986
391041
|
try {
|
|
390987
391042
|
canonicalPath = realpathSync15.native(absolutePath);
|
|
390988
391043
|
} catch (canonicalPathError) {
|
|
@@ -390991,8 +391046,8 @@ function toCanonicalPath2(absolutePath) {
|
|
|
390991
391046
|
}
|
|
390992
391047
|
} else {
|
|
390993
391048
|
const absoluteDir = dirname32(absolutePath);
|
|
390994
|
-
const resolvedDir =
|
|
390995
|
-
canonicalPath =
|
|
391049
|
+
const resolvedDir = existsSync88(absoluteDir) ? realpathSync15.native(absoluteDir) : absoluteDir;
|
|
391050
|
+
canonicalPath = join102(resolvedDir, basename17(absolutePath));
|
|
390996
391051
|
}
|
|
390997
391052
|
return normalize2(canonicalPath);
|
|
390998
391053
|
}
|
|
@@ -393753,23 +393808,23 @@ init_logger2();
|
|
|
393753
393808
|
init_plugin_identity();
|
|
393754
393809
|
|
|
393755
393810
|
// packages/omo-opencode/src/hooks/legacy-plugin-toast/auto-migrate.ts
|
|
393756
|
-
import { existsSync as
|
|
393757
|
-
import { join as
|
|
393811
|
+
import { existsSync as existsSync89, readFileSync as readFileSync60 } from "fs";
|
|
393812
|
+
import { join as join103 } from "path";
|
|
393758
393813
|
init_plugin_identity();
|
|
393759
393814
|
function detectOpenCodeConfigPath(overrideConfigDir) {
|
|
393760
393815
|
if (overrideConfigDir) {
|
|
393761
|
-
const jsoncPath =
|
|
393762
|
-
const jsonPath =
|
|
393763
|
-
if (
|
|
393816
|
+
const jsoncPath = join103(overrideConfigDir, "opencode.jsonc");
|
|
393817
|
+
const jsonPath = join103(overrideConfigDir, "opencode.json");
|
|
393818
|
+
if (existsSync89(jsoncPath))
|
|
393764
393819
|
return jsoncPath;
|
|
393765
|
-
if (
|
|
393820
|
+
if (existsSync89(jsonPath))
|
|
393766
393821
|
return jsonPath;
|
|
393767
393822
|
return null;
|
|
393768
393823
|
}
|
|
393769
393824
|
const paths = getOpenCodeConfigPaths({ binary: "opencode", version: null });
|
|
393770
|
-
if (
|
|
393825
|
+
if (existsSync89(paths.configJsonc))
|
|
393771
393826
|
return paths.configJsonc;
|
|
393772
|
-
if (
|
|
393827
|
+
if (existsSync89(paths.configJson))
|
|
393773
393828
|
return paths.configJson;
|
|
393774
393829
|
return null;
|
|
393775
393830
|
}
|
|
@@ -393778,7 +393833,7 @@ function autoMigrateLegacyPluginEntry(overrideConfigDir) {
|
|
|
393778
393833
|
if (!configPath)
|
|
393779
393834
|
return { migrated: false, from: null, to: null, configPath: null };
|
|
393780
393835
|
try {
|
|
393781
|
-
const content =
|
|
393836
|
+
const content = readFileSync60(configPath, "utf-8");
|
|
393782
393837
|
const parseResult = parseJsoncSafe(content);
|
|
393783
393838
|
if (!parseResult.data?.plugin)
|
|
393784
393839
|
return { migrated: false, from: null, to: null, configPath };
|
|
@@ -393961,7 +394016,7 @@ function createNotepadWriteGuardHook() {
|
|
|
393961
394016
|
};
|
|
393962
394017
|
}
|
|
393963
394018
|
// packages/omo-opencode/src/hooks/plan-format-validator/hook.ts
|
|
393964
|
-
import { existsSync as
|
|
394019
|
+
import { existsSync as existsSync90, readFileSync as readFileSync61 } from "fs";
|
|
393965
394020
|
import { resolve as resolve29 } from "path";
|
|
393966
394021
|
init_logger2();
|
|
393967
394022
|
var WRITE_TOOLS = new Set(["Write", "Edit", "write", "edit"]);
|
|
@@ -394045,9 +394100,9 @@ function createPlanFormatValidatorHook(_ctx) {
|
|
|
394045
394100
|
if (!isPlanFilePath(filePath))
|
|
394046
394101
|
return;
|
|
394047
394102
|
const resolvedPath = resolve29(_ctx.directory, filePath);
|
|
394048
|
-
if (!
|
|
394103
|
+
if (!existsSync90(resolvedPath))
|
|
394049
394104
|
return;
|
|
394050
|
-
const content =
|
|
394105
|
+
const content = readFileSync61(resolvedPath, "utf-8");
|
|
394051
394106
|
if (!CHECKBOX_PATTERN.test(content))
|
|
394052
394107
|
return;
|
|
394053
394108
|
const rawCount = countRawTopLevelCheckboxes(content);
|
|
@@ -394157,19 +394212,19 @@ tool.schema = z3;
|
|
|
394157
394212
|
|
|
394158
394213
|
// packages/omo-opencode/src/shared/ripgrep-cli.ts
|
|
394159
394214
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
394160
|
-
import { existsSync as
|
|
394161
|
-
import { dirname as dirname33, join as
|
|
394215
|
+
import { existsSync as existsSync92 } from "fs";
|
|
394216
|
+
import { dirname as dirname33, join as join105 } from "path";
|
|
394162
394217
|
|
|
394163
394218
|
// packages/omo-opencode/src/tools/grep/downloader.ts
|
|
394164
|
-
import { existsSync as
|
|
394165
|
-
import { join as
|
|
394219
|
+
import { existsSync as existsSync91, readdirSync as readdirSync22 } from "fs";
|
|
394220
|
+
import { join as join104 } from "path";
|
|
394166
394221
|
init_plugin_identity();
|
|
394167
394222
|
function findFileRecursive(dir, filename) {
|
|
394168
394223
|
try {
|
|
394169
394224
|
const entries = readdirSync22(dir, { withFileTypes: true, recursive: true });
|
|
394170
394225
|
for (const entry of entries) {
|
|
394171
394226
|
if (entry.isFile() && entry.name === filename) {
|
|
394172
|
-
return
|
|
394227
|
+
return join104(entry.parentPath ?? dir, entry.name);
|
|
394173
394228
|
}
|
|
394174
394229
|
}
|
|
394175
394230
|
} catch (error) {
|
|
@@ -394193,11 +394248,11 @@ function getPlatformKey() {
|
|
|
394193
394248
|
}
|
|
394194
394249
|
function getInstallDir() {
|
|
394195
394250
|
const homeDir = process.env.HOME || process.env.USERPROFILE || ".";
|
|
394196
|
-
return
|
|
394251
|
+
return join104(homeDir, ".cache", CACHE_DIR_NAME, "bin");
|
|
394197
394252
|
}
|
|
394198
394253
|
function getRgPath() {
|
|
394199
394254
|
const isWindows2 = process.platform === "win32";
|
|
394200
|
-
return
|
|
394255
|
+
return join104(getInstallDir(), isWindows2 ? "rg.exe" : "rg");
|
|
394201
394256
|
}
|
|
394202
394257
|
async function extractTarGz3(archivePath, destDir) {
|
|
394203
394258
|
const platformKey2 = getPlatformKey();
|
|
@@ -394214,7 +394269,7 @@ async function extractZip2(archivePath, destDir) {
|
|
|
394214
394269
|
const binaryName = process.platform === "win32" ? "rg.exe" : "rg";
|
|
394215
394270
|
const foundPath = findFileRecursive(destDir, binaryName);
|
|
394216
394271
|
if (foundPath) {
|
|
394217
|
-
const destPath =
|
|
394272
|
+
const destPath = join104(destDir, binaryName);
|
|
394218
394273
|
if (foundPath !== destPath) {
|
|
394219
394274
|
const { renameSync: renameSync7 } = await import("fs");
|
|
394220
394275
|
renameSync7(foundPath, destPath);
|
|
@@ -394229,13 +394284,13 @@ async function downloadAndInstallRipgrep() {
|
|
|
394229
394284
|
}
|
|
394230
394285
|
const installDir = getInstallDir();
|
|
394231
394286
|
const rgPath = getRgPath();
|
|
394232
|
-
if (
|
|
394287
|
+
if (existsSync91(rgPath)) {
|
|
394233
394288
|
return rgPath;
|
|
394234
394289
|
}
|
|
394235
394290
|
ensureCacheDir(installDir);
|
|
394236
394291
|
const filename = `ripgrep-${RG_VERSION}-${config.platform}.${config.extension}`;
|
|
394237
394292
|
const url = `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/${filename}`;
|
|
394238
|
-
const archivePath =
|
|
394293
|
+
const archivePath = join104(installDir, filename);
|
|
394239
394294
|
try {
|
|
394240
394295
|
await downloadArchive(url, archivePath);
|
|
394241
394296
|
if (config.extension === "tar.gz") {
|
|
@@ -394244,7 +394299,7 @@ async function downloadAndInstallRipgrep() {
|
|
|
394244
394299
|
await extractZip2(archivePath, installDir);
|
|
394245
394300
|
}
|
|
394246
394301
|
ensureExecutable(rgPath);
|
|
394247
|
-
if (!
|
|
394302
|
+
if (!existsSync91(rgPath)) {
|
|
394248
394303
|
throw new Error("ripgrep binary not found after extraction");
|
|
394249
394304
|
}
|
|
394250
394305
|
return rgPath;
|
|
@@ -394260,7 +394315,7 @@ async function downloadAndInstallRipgrep() {
|
|
|
394260
394315
|
}
|
|
394261
394316
|
function getInstalledRipgrepPath() {
|
|
394262
394317
|
const rgPath = getRgPath();
|
|
394263
|
-
return
|
|
394318
|
+
return existsSync91(rgPath) ? rgPath : null;
|
|
394264
394319
|
}
|
|
394265
394320
|
|
|
394266
394321
|
// packages/omo-opencode/src/shared/ripgrep-cli.ts
|
|
@@ -394300,15 +394355,15 @@ function getOpenCodeBundledRg() {
|
|
|
394300
394355
|
const isWindows2 = process.platform === "win32";
|
|
394301
394356
|
const rgName = isWindows2 ? "rg.exe" : "rg";
|
|
394302
394357
|
const candidates = [
|
|
394303
|
-
|
|
394304
|
-
|
|
394305
|
-
|
|
394306
|
-
|
|
394307
|
-
|
|
394308
|
-
|
|
394358
|
+
join105(getOpenCodeCacheDir(), "bin", rgName),
|
|
394359
|
+
join105(getDataDir(), "opencode", "bin", rgName),
|
|
394360
|
+
join105(execDir, rgName),
|
|
394361
|
+
join105(execDir, "bin", rgName),
|
|
394362
|
+
join105(execDir, "..", "bin", rgName),
|
|
394363
|
+
join105(execDir, "..", "libexec", rgName)
|
|
394309
394364
|
];
|
|
394310
394365
|
for (const candidate of candidates) {
|
|
394311
|
-
if (
|
|
394366
|
+
if (existsSync92(candidate)) {
|
|
394312
394367
|
return candidate;
|
|
394313
394368
|
}
|
|
394314
394369
|
}
|
|
@@ -395558,9 +395613,9 @@ function createSkillTool(options) {
|
|
|
395558
395613
|
}
|
|
395559
395614
|
var skill = createSkillTool({ directory: process.cwd() });
|
|
395560
395615
|
// packages/omo-opencode/src/tools/session-manager/constants.ts
|
|
395561
|
-
import { join as
|
|
395562
|
-
var TODO_DIR2 =
|
|
395563
|
-
var TRANSCRIPT_DIR2 =
|
|
395616
|
+
import { join as join106 } from "path";
|
|
395617
|
+
var TODO_DIR2 = join106(getClaudeConfigDir(), "todos");
|
|
395618
|
+
var TRANSCRIPT_DIR2 = join106(getClaudeConfigDir(), "transcripts");
|
|
395564
395619
|
var SESSION_LIST_DESCRIPTION = `List all OpenCode sessions with optional filtering.
|
|
395565
395620
|
|
|
395566
395621
|
Returns a list of available session IDs with metadata including message count, date range, and agents used.
|
|
@@ -395633,16 +395688,16 @@ Has Todos: Yes (12 items, 8 completed)
|
|
|
395633
395688
|
Has Transcript: Yes (234 entries)`;
|
|
395634
395689
|
|
|
395635
395690
|
// packages/omo-opencode/src/tools/session-manager/file-storage.ts
|
|
395636
|
-
import { existsSync as
|
|
395691
|
+
import { existsSync as existsSync93 } from "fs";
|
|
395637
395692
|
import { readdir as readdir6, readFile as readFile9 } from "fs/promises";
|
|
395638
|
-
import { join as
|
|
395693
|
+
import { join as join107 } from "path";
|
|
395639
395694
|
function ignoreFileStorageError(error) {
|
|
395640
395695
|
if (error instanceof Error)
|
|
395641
395696
|
return;
|
|
395642
395697
|
throw error;
|
|
395643
395698
|
}
|
|
395644
395699
|
async function getFileMainSessions(directory) {
|
|
395645
|
-
if (!
|
|
395700
|
+
if (!existsSync93(SESSION_STORAGE))
|
|
395646
395701
|
return [];
|
|
395647
395702
|
const sessions = [];
|
|
395648
395703
|
try {
|
|
@@ -395650,13 +395705,13 @@ async function getFileMainSessions(directory) {
|
|
|
395650
395705
|
for (const projectDir of projectDirs) {
|
|
395651
395706
|
if (!projectDir.isDirectory())
|
|
395652
395707
|
continue;
|
|
395653
|
-
const projectPath =
|
|
395708
|
+
const projectPath = join107(SESSION_STORAGE, projectDir.name);
|
|
395654
395709
|
const sessionFiles = await readdir6(projectPath);
|
|
395655
395710
|
for (const file2 of sessionFiles) {
|
|
395656
395711
|
if (!file2.endsWith(".json"))
|
|
395657
395712
|
continue;
|
|
395658
395713
|
try {
|
|
395659
|
-
const content = await readFile9(
|
|
395714
|
+
const content = await readFile9(join107(projectPath, file2), "utf-8");
|
|
395660
395715
|
const meta = JSON.parse(content);
|
|
395661
395716
|
if (meta.parentID)
|
|
395662
395717
|
continue;
|
|
@@ -395676,7 +395731,7 @@ async function getFileMainSessions(directory) {
|
|
|
395676
395731
|
return sessions.sort((a, b) => b.time.updated - a.time.updated);
|
|
395677
395732
|
}
|
|
395678
395733
|
async function getFileAllSessions() {
|
|
395679
|
-
if (!
|
|
395734
|
+
if (!existsSync93(MESSAGE_STORAGE))
|
|
395680
395735
|
return [];
|
|
395681
395736
|
const sessions = [];
|
|
395682
395737
|
async function scanDirectory(dir) {
|
|
@@ -395685,7 +395740,7 @@ async function getFileAllSessions() {
|
|
|
395685
395740
|
for (const entry of entries) {
|
|
395686
395741
|
if (!entry.isDirectory())
|
|
395687
395742
|
continue;
|
|
395688
|
-
const sessionPath =
|
|
395743
|
+
const sessionPath = join107(dir, entry.name);
|
|
395689
395744
|
const files = await readdir6(sessionPath);
|
|
395690
395745
|
if (files.some((file2) => file2.endsWith(".json"))) {
|
|
395691
395746
|
sessions.push(entry.name);
|
|
@@ -395706,7 +395761,7 @@ async function fileSessionExists(sessionID) {
|
|
|
395706
395761
|
}
|
|
395707
395762
|
async function getFileSessionMessages(sessionID) {
|
|
395708
395763
|
const messageDir = getMessageDir(sessionID);
|
|
395709
|
-
if (!messageDir || !
|
|
395764
|
+
if (!messageDir || !existsSync93(messageDir))
|
|
395710
395765
|
return [];
|
|
395711
395766
|
const messages = [];
|
|
395712
395767
|
try {
|
|
@@ -395715,7 +395770,7 @@ async function getFileSessionMessages(sessionID) {
|
|
|
395715
395770
|
if (!file2.endsWith(".json"))
|
|
395716
395771
|
continue;
|
|
395717
395772
|
try {
|
|
395718
|
-
const content = await readFile9(
|
|
395773
|
+
const content = await readFile9(join107(messageDir, file2), "utf-8");
|
|
395719
395774
|
const meta = JSON.parse(content);
|
|
395720
395775
|
const parts = await readParts2(meta.id);
|
|
395721
395776
|
messages.push({
|
|
@@ -395743,8 +395798,8 @@ async function getFileSessionMessages(sessionID) {
|
|
|
395743
395798
|
});
|
|
395744
395799
|
}
|
|
395745
395800
|
async function readParts2(messageID) {
|
|
395746
|
-
const partDir =
|
|
395747
|
-
if (!
|
|
395801
|
+
const partDir = join107(PART_STORAGE, messageID);
|
|
395802
|
+
if (!existsSync93(partDir))
|
|
395748
395803
|
return [];
|
|
395749
395804
|
const parts = [];
|
|
395750
395805
|
try {
|
|
@@ -395753,7 +395808,7 @@ async function readParts2(messageID) {
|
|
|
395753
395808
|
if (!file2.endsWith(".json"))
|
|
395754
395809
|
continue;
|
|
395755
395810
|
try {
|
|
395756
|
-
const content = await readFile9(
|
|
395811
|
+
const content = await readFile9(join107(partDir, file2), "utf-8");
|
|
395757
395812
|
parts.push(JSON.parse(content));
|
|
395758
395813
|
} catch (error) {
|
|
395759
395814
|
ignoreFileStorageError(error);
|
|
@@ -395767,14 +395822,14 @@ async function readParts2(messageID) {
|
|
|
395767
395822
|
return parts.sort((a, b) => a.id.localeCompare(b.id));
|
|
395768
395823
|
}
|
|
395769
395824
|
async function getFileSessionTodos(sessionID) {
|
|
395770
|
-
if (!
|
|
395825
|
+
if (!existsSync93(TODO_DIR2))
|
|
395771
395826
|
return [];
|
|
395772
395827
|
try {
|
|
395773
395828
|
const allFiles = await readdir6(TODO_DIR2);
|
|
395774
395829
|
const todoFiles = allFiles.filter((file2) => file2 === `${sessionID}.json`);
|
|
395775
395830
|
for (const file2 of todoFiles) {
|
|
395776
395831
|
try {
|
|
395777
|
-
const content = await readFile9(
|
|
395832
|
+
const content = await readFile9(join107(TODO_DIR2, file2), "utf-8");
|
|
395778
395833
|
const data = JSON.parse(content);
|
|
395779
395834
|
if (!Array.isArray(data))
|
|
395780
395835
|
continue;
|
|
@@ -395796,10 +395851,10 @@ async function getFileSessionTodos(sessionID) {
|
|
|
395796
395851
|
return [];
|
|
395797
395852
|
}
|
|
395798
395853
|
async function getFileSessionTranscript(sessionID) {
|
|
395799
|
-
if (!
|
|
395854
|
+
if (!existsSync93(TRANSCRIPT_DIR2))
|
|
395800
395855
|
return 0;
|
|
395801
|
-
const transcriptFile =
|
|
395802
|
-
if (!
|
|
395856
|
+
const transcriptFile = join107(TRANSCRIPT_DIR2, `${sessionID}.jsonl`);
|
|
395857
|
+
if (!existsSync93(transcriptFile))
|
|
395803
395858
|
return 0;
|
|
395804
395859
|
try {
|
|
395805
395860
|
const content = await readFile9(transcriptFile, "utf-8");
|
|
@@ -397842,23 +397897,23 @@ Pass \`session_id=<id>\` to continue previous agent with full context. Nested su
|
|
|
397842
397897
|
// packages/omo-opencode/src/tools/call-omo-agent/tools.ts
|
|
397843
397898
|
init_plugin_identity();
|
|
397844
397899
|
// packages/claude-code-compat-core/src/features/claude-code-agent-loader/loader.ts
|
|
397845
|
-
import { existsSync as
|
|
397846
|
-
import { join as
|
|
397900
|
+
import { existsSync as existsSync98, readdirSync as readdirSync23 } from "fs";
|
|
397901
|
+
import { join as join113 } from "path";
|
|
397847
397902
|
|
|
397848
397903
|
// packages/claude-code-compat-core/src/shared/claude-config-dir.ts
|
|
397849
397904
|
import { homedir as homedir27 } from "os";
|
|
397850
|
-
import { join as
|
|
397905
|
+
import { join as join108 } from "path";
|
|
397851
397906
|
function getClaudeConfigDir3() {
|
|
397852
397907
|
const envConfigDir = process.env.CLAUDE_CONFIG_DIR;
|
|
397853
397908
|
if (envConfigDir) {
|
|
397854
397909
|
return envConfigDir;
|
|
397855
397910
|
}
|
|
397856
|
-
return
|
|
397911
|
+
return join108(process.env.HOME || process.env.USERPROFILE || homedir27(), ".claude");
|
|
397857
397912
|
}
|
|
397858
397913
|
// packages/claude-code-compat-core/src/shared/opencode-config-dir.ts
|
|
397859
|
-
import { existsSync as
|
|
397914
|
+
import { existsSync as existsSync94, realpathSync as realpathSync16 } from "fs";
|
|
397860
397915
|
import { homedir as homedir28 } from "os";
|
|
397861
|
-
import { join as
|
|
397916
|
+
import { join as join109, posix as posix6, resolve as resolve33, win32 as win329 } from "path";
|
|
397862
397917
|
var TAURI_APP_IDENTIFIER3 = "ai.opencode.desktop";
|
|
397863
397918
|
var TAURI_APP_IDENTIFIER_DEV3 = "ai.opencode.desktop.dev";
|
|
397864
397919
|
function isDevBuild3(version) {
|
|
@@ -397870,15 +397925,15 @@ function getTauriConfigDir3(identifier) {
|
|
|
397870
397925
|
const platform3 = process.platform;
|
|
397871
397926
|
switch (platform3) {
|
|
397872
397927
|
case "darwin":
|
|
397873
|
-
return
|
|
397928
|
+
return join109(homedir28(), "Library", "Application Support", identifier);
|
|
397874
397929
|
case "win32": {
|
|
397875
|
-
const appData = process.env.APPDATA ||
|
|
397930
|
+
const appData = process.env.APPDATA || join109(homedir28(), "AppData", "Roaming");
|
|
397876
397931
|
return win329.join(appData, identifier);
|
|
397877
397932
|
}
|
|
397878
397933
|
case "linux":
|
|
397879
397934
|
default: {
|
|
397880
|
-
const xdgConfig = process.env.XDG_CONFIG_HOME ||
|
|
397881
|
-
return
|
|
397935
|
+
const xdgConfig = process.env.XDG_CONFIG_HOME || join109(homedir28(), ".config");
|
|
397936
|
+
return join109(xdgConfig, identifier);
|
|
397882
397937
|
}
|
|
397883
397938
|
}
|
|
397884
397939
|
}
|
|
@@ -397887,7 +397942,7 @@ function resolveConfigPath3(pathValue) {
|
|
|
397887
397942
|
return posix6.normalize(pathValue);
|
|
397888
397943
|
}
|
|
397889
397944
|
const resolvedPath = resolve33(pathValue);
|
|
397890
|
-
if (!
|
|
397945
|
+
if (!existsSync94(resolvedPath))
|
|
397891
397946
|
return resolvedPath;
|
|
397892
397947
|
try {
|
|
397893
397948
|
return realpathSync16(resolvedPath);
|
|
@@ -397921,8 +397976,8 @@ function getWslLinuxHomeDir3(windowsConfigRoot) {
|
|
|
397921
397976
|
function getCliDefaultConfigDir3() {
|
|
397922
397977
|
const envXdgConfig = process.env.XDG_CONFIG_HOME?.trim();
|
|
397923
397978
|
const shouldIgnoreWindowsXdg = envXdgConfig !== undefined && envXdgConfig.length > 0 && isWslEnvironment3() && isWindowsUserConfigRoot3(envXdgConfig);
|
|
397924
|
-
const xdgConfig = shouldIgnoreWindowsXdg ? posix6.join(getWslLinuxHomeDir3(envXdgConfig) ?? "/home", ".config") : envXdgConfig ||
|
|
397925
|
-
const configDir = isWslEnvironment3() ? posix6.join(xdgConfig, "opencode") :
|
|
397979
|
+
const xdgConfig = shouldIgnoreWindowsXdg ? posix6.join(getWslLinuxHomeDir3(envXdgConfig) ?? "/home", ".config") : envXdgConfig || join109(homedir28(), ".config");
|
|
397980
|
+
const configDir = isWslEnvironment3() ? posix6.join(xdgConfig, "opencode") : join109(xdgConfig, "opencode");
|
|
397926
397981
|
return resolveConfigPath3(configDir);
|
|
397927
397982
|
}
|
|
397928
397983
|
function getCliCustomConfigDir3() {
|
|
@@ -397955,9 +398010,9 @@ function getOpenCodeConfigDir3(options) {
|
|
|
397955
398010
|
const tauriDir = process.platform === "win32" ? win329.isAbsolute(tauriDirBase) ? win329.normalize(tauriDirBase) : win329.resolve(tauriDirBase) : resolveConfigPath3(tauriDirBase);
|
|
397956
398011
|
if (checkExisting) {
|
|
397957
398012
|
const legacyDir = getCliConfigDir3();
|
|
397958
|
-
const legacyConfig =
|
|
397959
|
-
const legacyConfigC =
|
|
397960
|
-
if (
|
|
398013
|
+
const legacyConfig = join109(legacyDir, "opencode.json");
|
|
398014
|
+
const legacyConfigC = join109(legacyDir, "opencode.jsonc");
|
|
398015
|
+
if (existsSync94(legacyConfig) || existsSync94(legacyConfigC)) {
|
|
397961
398016
|
return legacyDir;
|
|
397962
398017
|
}
|
|
397963
398018
|
}
|
|
@@ -397967,10 +398022,10 @@ function getOpenCodeConfigDir3(options) {
|
|
|
397967
398022
|
init_src();
|
|
397968
398023
|
// packages/claude-code-compat-core/src/shared/resolve-agent-definition-paths.ts
|
|
397969
398024
|
import { homedir as homedir29 } from "os";
|
|
397970
|
-
import { isAbsolute as isAbsolute17, join as
|
|
398025
|
+
import { isAbsolute as isAbsolute17, join as join110, resolve as resolve34 } from "path";
|
|
397971
398026
|
function resolveAgentDefinitionPaths2(paths, baseDir, containmentDir) {
|
|
397972
398027
|
return paths.flatMap((p) => {
|
|
397973
|
-
const expanded = p.startsWith("~/") ?
|
|
398028
|
+
const expanded = p.startsWith("~/") ? join110(homedir29(), p.slice(2)) : p;
|
|
397974
398029
|
const resolved = isAbsolute17(expanded) ? expanded : resolve34(baseDir, expanded);
|
|
397975
398030
|
if (containmentDir !== null && !isWithinProject(resolved, containmentDir)) {
|
|
397976
398031
|
log4(`agent_definitions path rejected (outside project boundary): ${p} -> ${resolved}`);
|
|
@@ -397998,7 +398053,7 @@ var EXCLUDED_DIR_NAMES2 = [
|
|
|
397998
398053
|
];
|
|
397999
398054
|
var EXCLUDED_DIRS3 = Object.freeze(new Set(EXCLUDED_DIR_NAMES2));
|
|
398000
398055
|
// packages/claude-code-compat-core/src/shared/opencode-command-dirs.ts
|
|
398001
|
-
import { basename as basename18, dirname as dirname36, join as
|
|
398056
|
+
import { basename as basename18, dirname as dirname36, join as join111 } from "path";
|
|
398002
398057
|
function getParentOpencodeConfigDir3(configDir) {
|
|
398003
398058
|
const parentDir = dirname36(configDir);
|
|
398004
398059
|
if (basename18(parentDir) !== "profiles") {
|
|
@@ -398012,21 +398067,21 @@ function getOpenCodeCommandDirs2(options) {
|
|
|
398012
398067
|
...configDirs.flatMap((configDir) => {
|
|
398013
398068
|
const parentConfigDir = getParentOpencodeConfigDir3(configDir);
|
|
398014
398069
|
return [
|
|
398015
|
-
|
|
398016
|
-
|
|
398017
|
-
...parentConfigDir ? [
|
|
398070
|
+
join111(configDir, "commands"),
|
|
398071
|
+
join111(configDir, "command"),
|
|
398072
|
+
...parentConfigDir ? [join111(parentConfigDir, "commands"), join111(parentConfigDir, "command")] : []
|
|
398018
398073
|
];
|
|
398019
398074
|
})
|
|
398020
398075
|
]));
|
|
398021
398076
|
}
|
|
398022
398077
|
// packages/claude-code-compat-core/src/shared/project-discovery-dirs.ts
|
|
398023
398078
|
import { execFileSync as execFileSync6 } from "child_process";
|
|
398024
|
-
import { existsSync as
|
|
398025
|
-
import { dirname as dirname37, join as
|
|
398079
|
+
import { existsSync as existsSync95, realpathSync as realpathSync17 } from "fs";
|
|
398080
|
+
import { dirname as dirname37, join as join112, resolve as resolve35, win32 as win3210 } from "path";
|
|
398026
398081
|
var worktreePathCache3 = new Map;
|
|
398027
398082
|
function normalizePath6(path18) {
|
|
398028
398083
|
const resolvedPath = process.platform !== "win32" && win3210.isAbsolute(path18) ? path18 : resolve35(path18);
|
|
398029
|
-
if (!
|
|
398084
|
+
if (!existsSync95(resolvedPath)) {
|
|
398030
398085
|
return resolvedPath;
|
|
398031
398086
|
}
|
|
398032
398087
|
try {
|
|
@@ -398081,7 +398136,7 @@ function detectWorktreePath4(directory) {
|
|
|
398081
398136
|
function findGitMarkerAncestor(directory) {
|
|
398082
398137
|
let currentDirectory = normalizePath6(directory);
|
|
398083
398138
|
while (true) {
|
|
398084
|
-
if (
|
|
398139
|
+
if (existsSync95(join112(currentDirectory, ".git"))) {
|
|
398085
398140
|
return currentDirectory;
|
|
398086
398141
|
}
|
|
398087
398142
|
const parentDirectory = dirname37(currentDirectory);
|
|
@@ -398099,8 +398154,8 @@ function findAncestorDirectories3(startDirectory, targetPaths, stopDirectory) {
|
|
|
398099
398154
|
const stopDirectoryKey = resolvedStopDirectory ? pathKey3(resolvedStopDirectory) : undefined;
|
|
398100
398155
|
while (true) {
|
|
398101
398156
|
for (const targetPath of targetPaths) {
|
|
398102
|
-
const candidateDirectory =
|
|
398103
|
-
if (!
|
|
398157
|
+
const candidateDirectory = join112(currentDirectory, ...targetPath);
|
|
398158
|
+
if (!existsSync95(candidateDirectory)) {
|
|
398104
398159
|
continue;
|
|
398105
398160
|
}
|
|
398106
398161
|
const normalizedCandidateDirectory = normalizePath6(candidateDirectory);
|
|
@@ -398129,17 +398184,17 @@ function findProjectOpencodeCommandDirs2(startDirectory, stopDirectory) {
|
|
|
398129
398184
|
], detectedStopDirectory);
|
|
398130
398185
|
}
|
|
398131
398186
|
// packages/claude-code-compat-core/src/features/claude-code-agent-loader/agent-definitions-loader.ts
|
|
398132
|
-
import { existsSync as
|
|
398187
|
+
import { existsSync as existsSync97, readFileSync as readFileSync63 } from "fs";
|
|
398133
398188
|
import { basename as basename19, extname as extname4 } from "path";
|
|
398134
398189
|
|
|
398135
398190
|
// packages/claude-code-compat-core/src/features/claude-code-agent-loader/json-agent-loader.ts
|
|
398136
|
-
import { existsSync as
|
|
398191
|
+
import { existsSync as existsSync96, readFileSync as readFileSync62 } from "fs";
|
|
398137
398192
|
function parseJsonAgentFile(filePath, scope) {
|
|
398138
398193
|
try {
|
|
398139
|
-
if (!
|
|
398194
|
+
if (!existsSync96(filePath)) {
|
|
398140
398195
|
return null;
|
|
398141
398196
|
}
|
|
398142
|
-
const content =
|
|
398197
|
+
const content = readFileSync62(filePath, "utf-8");
|
|
398143
398198
|
const { data } = parseJsoncSafe(content);
|
|
398144
398199
|
if (!data) {
|
|
398145
398200
|
return null;
|
|
@@ -398177,10 +398232,10 @@ function parseJsonAgentFile(filePath, scope) {
|
|
|
398177
398232
|
// packages/claude-code-compat-core/src/features/claude-code-agent-loader/agent-definitions-loader.ts
|
|
398178
398233
|
function parseMarkdownAgentFile(filePath, scope, anthropicProvider) {
|
|
398179
398234
|
try {
|
|
398180
|
-
if (!
|
|
398235
|
+
if (!existsSync97(filePath)) {
|
|
398181
398236
|
return null;
|
|
398182
398237
|
}
|
|
398183
|
-
const content =
|
|
398238
|
+
const content = readFileSync63(filePath, "utf-8");
|
|
398184
398239
|
const { data, body } = parseFrontmatter(content);
|
|
398185
398240
|
const fileName = basename19(filePath);
|
|
398186
398241
|
const agentName = fileName.replace(/\.md$/i, "");
|
|
@@ -398214,7 +398269,7 @@ function parseMarkdownAgentFile(filePath, scope, anthropicProvider) {
|
|
|
398214
398269
|
function loadAgentDefinitions(paths, scope, anthropicProvider) {
|
|
398215
398270
|
const result = Object.create(null);
|
|
398216
398271
|
for (const filePath of paths) {
|
|
398217
|
-
if (!
|
|
398272
|
+
if (!existsSync97(filePath)) {
|
|
398218
398273
|
log4(`[agent-definitions-loader] File not found, skipping: ${filePath}`);
|
|
398219
398274
|
continue;
|
|
398220
398275
|
}
|
|
@@ -398239,7 +398294,7 @@ function loadAgentDefinitions(paths, scope, anthropicProvider) {
|
|
|
398239
398294
|
|
|
398240
398295
|
// packages/claude-code-compat-core/src/features/claude-code-agent-loader/loader.ts
|
|
398241
398296
|
function loadAgentsFromDir(agentsDir, scope, anthropicProvider) {
|
|
398242
|
-
if (!
|
|
398297
|
+
if (!existsSync98(agentsDir)) {
|
|
398243
398298
|
return [];
|
|
398244
398299
|
}
|
|
398245
398300
|
const entries = readdirSync23(agentsDir, { withFileTypes: true });
|
|
@@ -398247,7 +398302,7 @@ function loadAgentsFromDir(agentsDir, scope, anthropicProvider) {
|
|
|
398247
398302
|
for (const entry of entries) {
|
|
398248
398303
|
if (!isMarkdownFile(entry))
|
|
398249
398304
|
continue;
|
|
398250
|
-
const agentPath =
|
|
398305
|
+
const agentPath = join113(agentsDir, entry.name);
|
|
398251
398306
|
const agent = parseMarkdownAgentFile(agentPath, scope, anthropicProvider);
|
|
398252
398307
|
if (agent) {
|
|
398253
398308
|
agents.push(agent);
|
|
@@ -398256,7 +398311,7 @@ function loadAgentsFromDir(agentsDir, scope, anthropicProvider) {
|
|
|
398256
398311
|
return agents;
|
|
398257
398312
|
}
|
|
398258
398313
|
function loadUserAgents(anthropicProvider) {
|
|
398259
|
-
const userAgentsDir =
|
|
398314
|
+
const userAgentsDir = join113(getClaudeConfigDir3(), "agents");
|
|
398260
398315
|
const agents = loadAgentsFromDir(userAgentsDir, "user", anthropicProvider);
|
|
398261
398316
|
const result = Object.create(null);
|
|
398262
398317
|
for (const agent of agents) {
|
|
@@ -398265,7 +398320,7 @@ function loadUserAgents(anthropicProvider) {
|
|
|
398265
398320
|
return result;
|
|
398266
398321
|
}
|
|
398267
398322
|
function loadProjectAgents(directory, anthropicProvider) {
|
|
398268
|
-
const projectAgentsDir =
|
|
398323
|
+
const projectAgentsDir = join113(directory ?? process.cwd(), ".claude", "agents");
|
|
398269
398324
|
const agents = loadAgentsFromDir(projectAgentsDir, "project", anthropicProvider);
|
|
398270
398325
|
const result = Object.create(null);
|
|
398271
398326
|
for (const agent of agents) {
|
|
@@ -398277,7 +398332,7 @@ function loadOpencodeGlobalAgents() {
|
|
|
398277
398332
|
const result = Object.create(null);
|
|
398278
398333
|
const configDirs = getOpenCodeConfigDirs3({ binary: "opencode" });
|
|
398279
398334
|
for (const configDir of configDirs) {
|
|
398280
|
-
const opencodeAgentsDir =
|
|
398335
|
+
const opencodeAgentsDir = join113(configDir, "agents");
|
|
398281
398336
|
const agents = loadAgentsFromDir(opencodeAgentsDir, "opencode");
|
|
398282
398337
|
for (const agent of agents) {
|
|
398283
398338
|
if (!(agent.name in result)) {
|
|
@@ -398288,7 +398343,7 @@ function loadOpencodeGlobalAgents() {
|
|
|
398288
398343
|
return result;
|
|
398289
398344
|
}
|
|
398290
398345
|
function loadOpencodeProjectAgents(directory) {
|
|
398291
|
-
const opencodeProjectDir =
|
|
398346
|
+
const opencodeProjectDir = join113(directory ?? process.cwd(), ".opencode", "agents");
|
|
398292
398347
|
const agents = loadAgentsFromDir(opencodeProjectDir, "opencode-project");
|
|
398293
398348
|
const result = Object.create(null);
|
|
398294
398349
|
for (const agent of agents) {
|
|
@@ -399102,15 +399157,15 @@ function validateArgs(args) {
|
|
|
399102
399157
|
}
|
|
399103
399158
|
|
|
399104
399159
|
// packages/omo-opencode/src/tools/look-at/look-at-input-preparer.ts
|
|
399105
|
-
import { readFileSync as
|
|
399160
|
+
import { readFileSync as readFileSync66 } from "fs";
|
|
399106
399161
|
import { basename as basename20 } from "path";
|
|
399107
399162
|
import { pathToFileURL } from "url";
|
|
399108
399163
|
|
|
399109
399164
|
// packages/omo-opencode/src/tools/look-at/image-converter.ts
|
|
399110
399165
|
import * as childProcess2 from "child_process";
|
|
399111
|
-
import { existsSync as
|
|
399166
|
+
import { existsSync as existsSync100, mkdtempSync, readFileSync as readFileSync65, rmSync as rmSync5, unlinkSync as unlinkSync14, writeFileSync as writeFileSync19 } from "fs";
|
|
399112
399167
|
import { tmpdir as tmpdir7 } from "os";
|
|
399113
|
-
import { dirname as dirname39, join as
|
|
399168
|
+
import { dirname as dirname39, join as join115 } from "path";
|
|
399114
399169
|
var SUPPORTED_FORMATS = new Set([
|
|
399115
399170
|
"image/jpeg",
|
|
399116
399171
|
"image/png",
|
|
@@ -399140,7 +399195,7 @@ var UNSUPPORTED_FORMATS = new Set([
|
|
|
399140
399195
|
var CONVERSION_TIMEOUT_MS = 30000;
|
|
399141
399196
|
function cleanupTemporaryFileAfterFailure(filePath) {
|
|
399142
399197
|
try {
|
|
399143
|
-
if (
|
|
399198
|
+
if (existsSync100(filePath)) {
|
|
399144
399199
|
unlinkSync14(filePath);
|
|
399145
399200
|
}
|
|
399146
399201
|
} catch (cleanupError) {
|
|
@@ -399158,11 +399213,11 @@ function needsConversion(mimeType2) {
|
|
|
399158
399213
|
return mimeType2.startsWith("image/");
|
|
399159
399214
|
}
|
|
399160
399215
|
function convertImageToJpeg(inputPath, mimeType2) {
|
|
399161
|
-
if (!
|
|
399216
|
+
if (!existsSync100(inputPath)) {
|
|
399162
399217
|
throw new Error(`File not found: ${inputPath}`);
|
|
399163
399218
|
}
|
|
399164
|
-
const tempDir = mkdtempSync(
|
|
399165
|
-
const outputPath =
|
|
399219
|
+
const tempDir = mkdtempSync(join115(tmpdir7(), "opencode-img-"));
|
|
399220
|
+
const outputPath = join115(tempDir, "converted.jpg");
|
|
399166
399221
|
log2(`[image-converter] Converting ${mimeType2} to JPEG: ${inputPath}`);
|
|
399167
399222
|
try {
|
|
399168
399223
|
if (process.platform === "darwin") {
|
|
@@ -399172,7 +399227,7 @@ function convertImageToJpeg(inputPath, mimeType2) {
|
|
|
399172
399227
|
encoding: "utf-8",
|
|
399173
399228
|
timeout: CONVERSION_TIMEOUT_MS
|
|
399174
399229
|
});
|
|
399175
|
-
if (
|
|
399230
|
+
if (existsSync100(outputPath)) {
|
|
399176
399231
|
log2(`[image-converter] Converted using sips: ${outputPath}`);
|
|
399177
399232
|
return outputPath;
|
|
399178
399233
|
}
|
|
@@ -399188,7 +399243,7 @@ function convertImageToJpeg(inputPath, mimeType2) {
|
|
|
399188
399243
|
encoding: "utf-8",
|
|
399189
399244
|
timeout: CONVERSION_TIMEOUT_MS
|
|
399190
399245
|
});
|
|
399191
|
-
if (
|
|
399246
|
+
if (existsSync100(outputPath)) {
|
|
399192
399247
|
log2(`[image-converter] Converted using ImageMagick: ${outputPath}`);
|
|
399193
399248
|
return outputPath;
|
|
399194
399249
|
}
|
|
@@ -399212,11 +399267,11 @@ function convertImageToJpeg(inputPath, mimeType2) {
|
|
|
399212
399267
|
function cleanupConvertedImage(filePath) {
|
|
399213
399268
|
try {
|
|
399214
399269
|
const tempDirectory = dirname39(filePath);
|
|
399215
|
-
if (
|
|
399270
|
+
if (existsSync100(filePath)) {
|
|
399216
399271
|
unlinkSync14(filePath);
|
|
399217
399272
|
log2(`[image-converter] Cleaned up temporary file: ${filePath}`);
|
|
399218
399273
|
}
|
|
399219
|
-
if (
|
|
399274
|
+
if (existsSync100(tempDirectory)) {
|
|
399220
399275
|
rmSync5(tempDirectory, { recursive: true, force: true });
|
|
399221
399276
|
log2(`[image-converter] Cleaned up temporary directory: ${tempDirectory}`);
|
|
399222
399277
|
}
|
|
@@ -399226,9 +399281,9 @@ function cleanupConvertedImage(filePath) {
|
|
|
399226
399281
|
}
|
|
399227
399282
|
}
|
|
399228
399283
|
function convertBase64ImageToJpeg(base64Data, mimeType2) {
|
|
399229
|
-
const tempDir = mkdtempSync(
|
|
399284
|
+
const tempDir = mkdtempSync(join115(tmpdir7(), "opencode-b64-"));
|
|
399230
399285
|
const inputExt = mimeType2.split("/")[1] || "bin";
|
|
399231
|
-
const inputPath =
|
|
399286
|
+
const inputPath = join115(tempDir, `input.${inputExt}`);
|
|
399232
399287
|
const tempFiles = [inputPath];
|
|
399233
399288
|
try {
|
|
399234
399289
|
const cleanBase64 = base64Data.replace(/^data:[^;]+;base64,/, "");
|
|
@@ -399237,7 +399292,7 @@ function convertBase64ImageToJpeg(base64Data, mimeType2) {
|
|
|
399237
399292
|
log2(`[image-converter] Converting Base64 ${mimeType2} to JPEG`);
|
|
399238
399293
|
const outputPath = convertImageToJpeg(inputPath, mimeType2);
|
|
399239
399294
|
tempFiles.push(outputPath);
|
|
399240
|
-
const convertedBuffer =
|
|
399295
|
+
const convertedBuffer = readFileSync65(outputPath);
|
|
399241
399296
|
const convertedBase64 = convertedBuffer.toString("base64");
|
|
399242
399297
|
log2(`[image-converter] Base64 conversion successful`);
|
|
399243
399298
|
return { base64: convertedBase64, tempFiles };
|
|
@@ -399267,7 +399322,7 @@ function getTemporaryConversionPath(error) {
|
|
|
399267
399322
|
function readJsonTextPart(filePath) {
|
|
399268
399323
|
let fileContent;
|
|
399269
399324
|
try {
|
|
399270
|
-
fileContent =
|
|
399325
|
+
fileContent = readFileSync66(filePath, "utf-8");
|
|
399271
399326
|
} catch (error) {
|
|
399272
399327
|
const code = error instanceof Error ? Reflect.get(error, "code") : undefined;
|
|
399273
399328
|
if (code === "ENOENT") {
|
|
@@ -403373,7 +403428,7 @@ function isExplicitSyncRun(runInBackground) {
|
|
|
403373
403428
|
return runInBackground === false || runInBackground === "false";
|
|
403374
403429
|
}
|
|
403375
403430
|
// packages/omo-opencode/src/tools/task/task-create.ts
|
|
403376
|
-
import { join as
|
|
403431
|
+
import { join as join117 } from "path";
|
|
403377
403432
|
|
|
403378
403433
|
// packages/omo-opencode/src/tools/task/types.ts
|
|
403379
403434
|
import { z as z4 } from "zod";
|
|
@@ -403428,8 +403483,8 @@ var TaskDeleteInputSchema = z4.object({
|
|
|
403428
403483
|
});
|
|
403429
403484
|
|
|
403430
403485
|
// packages/omo-opencode/src/features/claude-tasks/storage.ts
|
|
403431
|
-
import { join as
|
|
403432
|
-
import { existsSync as
|
|
403486
|
+
import { join as join116, dirname as dirname40, basename as basename21, isAbsolute as isAbsolute18 } from "path";
|
|
403487
|
+
import { existsSync as existsSync101, mkdirSync as mkdirSync19, readFileSync as readFileSync67, writeFileSync as writeFileSync20, renameSync as renameSync7, unlinkSync as unlinkSync15, readdirSync as readdirSync24 } from "fs";
|
|
403433
403488
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
403434
403489
|
function ignoreClaudeTaskStorageError(error) {
|
|
403435
403490
|
if (error instanceof Error)
|
|
@@ -403440,11 +403495,11 @@ function getTaskDir(config = {}) {
|
|
|
403440
403495
|
const tasksConfig = config.morpheus?.tasks;
|
|
403441
403496
|
const storagePath = tasksConfig?.storage_path;
|
|
403442
403497
|
if (storagePath) {
|
|
403443
|
-
return isAbsolute18(storagePath) ? storagePath :
|
|
403498
|
+
return isAbsolute18(storagePath) ? storagePath : join116(process.cwd(), storagePath);
|
|
403444
403499
|
}
|
|
403445
403500
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
403446
403501
|
const listId = resolveTaskListId(config);
|
|
403447
|
-
return
|
|
403502
|
+
return join116(configDir, "tasks", listId);
|
|
403448
403503
|
}
|
|
403449
403504
|
function sanitizePathSegment(value) {
|
|
403450
403505
|
return value.replace(/[^a-zA-Z0-9_-]/g, "-") || "default";
|
|
@@ -403462,16 +403517,16 @@ function resolveTaskListId(config = {}) {
|
|
|
403462
403517
|
return sanitizePathSegment(basename21(process.cwd()));
|
|
403463
403518
|
}
|
|
403464
403519
|
function ensureDir(dirPath) {
|
|
403465
|
-
if (!
|
|
403520
|
+
if (!existsSync101(dirPath)) {
|
|
403466
403521
|
mkdirSync19(dirPath, { recursive: true });
|
|
403467
403522
|
}
|
|
403468
403523
|
}
|
|
403469
403524
|
function readJsonSafe(filePath, schema2) {
|
|
403470
403525
|
try {
|
|
403471
|
-
if (!
|
|
403526
|
+
if (!existsSync101(filePath)) {
|
|
403472
403527
|
return null;
|
|
403473
403528
|
}
|
|
403474
|
-
const content =
|
|
403529
|
+
const content = readFileSync67(filePath, "utf-8");
|
|
403475
403530
|
const parsed = JSON.parse(content);
|
|
403476
403531
|
const result = schema2.safeParse(parsed);
|
|
403477
403532
|
if (!result.success) {
|
|
@@ -403492,7 +403547,7 @@ function writeJsonAtomic(filePath, data) {
|
|
|
403492
403547
|
renameSync7(tempPath, filePath);
|
|
403493
403548
|
} catch (error) {
|
|
403494
403549
|
try {
|
|
403495
|
-
if (
|
|
403550
|
+
if (existsSync101(tempPath)) {
|
|
403496
403551
|
unlinkSync15(tempPath);
|
|
403497
403552
|
}
|
|
403498
403553
|
} catch (cleanupError) {
|
|
@@ -403506,7 +403561,7 @@ function generateTaskId() {
|
|
|
403506
403561
|
return `T-${randomUUID7()}`;
|
|
403507
403562
|
}
|
|
403508
403563
|
function acquireLock3(dirPath) {
|
|
403509
|
-
const lockPath =
|
|
403564
|
+
const lockPath = join116(dirPath, ".lock");
|
|
403510
403565
|
const lockId = randomUUID7();
|
|
403511
403566
|
const createLock = (timestamp2) => {
|
|
403512
403567
|
writeFileSync20(lockPath, JSON.stringify({ id: lockId, timestamp: timestamp2 }), {
|
|
@@ -403516,7 +403571,7 @@ function acquireLock3(dirPath) {
|
|
|
403516
403571
|
};
|
|
403517
403572
|
const isStale = () => {
|
|
403518
403573
|
try {
|
|
403519
|
-
const lockContent =
|
|
403574
|
+
const lockContent = readFileSync67(lockPath, "utf-8");
|
|
403520
403575
|
const lockData = JSON.parse(lockContent);
|
|
403521
403576
|
const lockAge = Date.now() - lockData.timestamp;
|
|
403522
403577
|
return lockAge > STALE_LOCK_THRESHOLD_MS;
|
|
@@ -403557,9 +403612,9 @@ function acquireLock3(dirPath) {
|
|
|
403557
403612
|
acquired: true,
|
|
403558
403613
|
release: () => {
|
|
403559
403614
|
try {
|
|
403560
|
-
if (!
|
|
403615
|
+
if (!existsSync101(lockPath))
|
|
403561
403616
|
return;
|
|
403562
|
-
const lockContent =
|
|
403617
|
+
const lockContent = readFileSync67(lockPath, "utf-8");
|
|
403563
403618
|
const lockData = JSON.parse(lockContent);
|
|
403564
403619
|
if (lockData.id !== lockId)
|
|
403565
403620
|
return;
|
|
@@ -403724,7 +403779,7 @@ async function handleCreate(args, config, ctx, context) {
|
|
|
403724
403779
|
threadID: context.sessionID
|
|
403725
403780
|
};
|
|
403726
403781
|
const validatedTask = TaskObjectSchema.parse(task);
|
|
403727
|
-
writeJsonAtomic(
|
|
403782
|
+
writeJsonAtomic(join117(taskDir, `${taskId}.json`), validatedTask);
|
|
403728
403783
|
await syncTaskTodoUpdate(ctx, validatedTask, context.sessionID);
|
|
403729
403784
|
return JSON.stringify({
|
|
403730
403785
|
task: {
|
|
@@ -403746,7 +403801,7 @@ async function handleCreate(args, config, ctx, context) {
|
|
|
403746
403801
|
}
|
|
403747
403802
|
}
|
|
403748
403803
|
// packages/omo-opencode/src/tools/task/task-get.ts
|
|
403749
|
-
import { join as
|
|
403804
|
+
import { join as join118 } from "path";
|
|
403750
403805
|
var TASK_ID_PATTERN = /^T-[A-Za-z0-9-]+$/;
|
|
403751
403806
|
function parseTaskId(id) {
|
|
403752
403807
|
if (!TASK_ID_PATTERN.test(id))
|
|
@@ -403771,7 +403826,7 @@ Returns null if the task does not exist or the file is invalid.`,
|
|
|
403771
403826
|
return JSON.stringify({ error: "invalid_task_id" });
|
|
403772
403827
|
}
|
|
403773
403828
|
const taskDir = getTaskDir(config);
|
|
403774
|
-
const taskPath =
|
|
403829
|
+
const taskPath = join118(taskDir, `${taskId}.json`);
|
|
403775
403830
|
const task = readJsonSafe(taskPath, TaskObjectSchema);
|
|
403776
403831
|
return JSON.stringify({ task: task ?? null });
|
|
403777
403832
|
} catch (error) {
|
|
@@ -403784,8 +403839,8 @@ Returns null if the task does not exist or the file is invalid.`,
|
|
|
403784
403839
|
});
|
|
403785
403840
|
}
|
|
403786
403841
|
// packages/omo-opencode/src/tools/task/task-list.ts
|
|
403787
|
-
import { join as
|
|
403788
|
-
import { existsSync as
|
|
403842
|
+
import { join as join119 } from "path";
|
|
403843
|
+
import { existsSync as existsSync102, readdirSync as readdirSync25 } from "fs";
|
|
403789
403844
|
function createTaskList(config) {
|
|
403790
403845
|
return tool({
|
|
403791
403846
|
description: `List all active tasks with summary information.
|
|
@@ -403796,7 +403851,7 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
|
|
|
403796
403851
|
args: {},
|
|
403797
403852
|
execute: async () => {
|
|
403798
403853
|
const taskDir = getTaskDir(config);
|
|
403799
|
-
if (!
|
|
403854
|
+
if (!existsSync102(taskDir)) {
|
|
403800
403855
|
return JSON.stringify({ tasks: [] });
|
|
403801
403856
|
}
|
|
403802
403857
|
const files = readdirSync25(taskDir).filter((f) => f.endsWith(".json") && f.startsWith("T-")).map((f) => f.replace(".json", ""));
|
|
@@ -403805,7 +403860,7 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
|
|
|
403805
403860
|
}
|
|
403806
403861
|
const allTasks = [];
|
|
403807
403862
|
for (const fileId of files) {
|
|
403808
|
-
const task = readJsonSafe(
|
|
403863
|
+
const task = readJsonSafe(join119(taskDir, `${fileId}.json`), TaskObjectSchema);
|
|
403809
403864
|
if (task) {
|
|
403810
403865
|
allTasks.push(task);
|
|
403811
403866
|
}
|
|
@@ -403833,7 +403888,7 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
|
|
|
403833
403888
|
});
|
|
403834
403889
|
}
|
|
403835
403890
|
// packages/omo-opencode/src/tools/task/task-update.ts
|
|
403836
|
-
import { join as
|
|
403891
|
+
import { join as join120 } from "path";
|
|
403837
403892
|
var TASK_ID_PATTERN2 = /^T-[A-Za-z0-9-]+$/;
|
|
403838
403893
|
function parseTaskId2(id) {
|
|
403839
403894
|
if (!TASK_ID_PATTERN2.test(id))
|
|
@@ -403881,7 +403936,7 @@ async function handleUpdate(args, config, ctx, context) {
|
|
|
403881
403936
|
return JSON.stringify({ error: "task_lock_unavailable" });
|
|
403882
403937
|
}
|
|
403883
403938
|
try {
|
|
403884
|
-
const taskPath =
|
|
403939
|
+
const taskPath = join120(taskDir, `${taskId}.json`);
|
|
403885
403940
|
const task = readJsonSafe(taskPath, TaskObjectSchema);
|
|
403886
403941
|
if (!task) {
|
|
403887
403942
|
return JSON.stringify({ error: "task_not_found" });
|
|
@@ -406122,7 +406177,7 @@ function createScannerDaemon(options) {
|
|
|
406122
406177
|
};
|
|
406123
406178
|
}
|
|
406124
406179
|
// packages/omo-opencode/src/features/background-agent/manager.ts
|
|
406125
|
-
import { join as
|
|
406180
|
+
import { join as join123 } from "path";
|
|
406126
406181
|
init_tmux();
|
|
406127
406182
|
|
|
406128
406183
|
// packages/omo-opencode/src/features/background-agent/abort-with-timeout.ts
|
|
@@ -406410,8 +406465,8 @@ function writeBackgroundTaskMarker(input) {
|
|
|
406410
406465
|
}
|
|
406411
406466
|
|
|
406412
406467
|
// packages/omo-opencode/src/features/background-agent/compaction-aware-message-resolver.ts
|
|
406413
|
-
import { readdirSync as readdirSync26, readFileSync as
|
|
406414
|
-
import { join as
|
|
406468
|
+
import { readdirSync as readdirSync26, readFileSync as readFileSync69 } from "fs";
|
|
406469
|
+
import { join as join122 } from "path";
|
|
406415
406470
|
function hasFullAgentAndModel(message) {
|
|
406416
406471
|
return !!message.agent && !isCompactionAgent(message.agent) && !!message.model?.providerID && !!message.model?.modelID;
|
|
406417
406472
|
}
|
|
@@ -406490,7 +406545,7 @@ function findNearestMessageExcludingCompaction(messageDir, sessionID) {
|
|
|
406490
406545
|
const messages = [];
|
|
406491
406546
|
for (const file2 of files) {
|
|
406492
406547
|
try {
|
|
406493
|
-
const content =
|
|
406548
|
+
const content = readFileSync69(join122(messageDir, file2), "utf-8");
|
|
406494
406549
|
const parsed = JSON.parse(content);
|
|
406495
406550
|
if (hasCompactionPartInStorage(parsed.id) || isCompactionAgent(parsed.agent)) {
|
|
406496
406551
|
continue;
|
|
@@ -411247,7 +411302,7 @@ The task was re-queued on a fallback model after a retryable failure.
|
|
|
411247
411302
|
parentSessionID: task.parentSessionId
|
|
411248
411303
|
});
|
|
411249
411304
|
}
|
|
411250
|
-
const messageDir =
|
|
411305
|
+
const messageDir = join123(MESSAGE_STORAGE, task.parentSessionId);
|
|
411251
411306
|
const currentMessage = messageDir ? findNearestMessageExcludingCompaction(messageDir, task.parentSessionId) : null;
|
|
411252
411307
|
agent = currentMessage?.agent ?? task.parentAgent;
|
|
411253
411308
|
model = currentMessage?.model?.providerID && currentMessage?.model?.modelID ? { providerID: currentMessage.model.providerID, modelID: currentMessage.model.modelID } : undefined;
|
|
@@ -412869,23 +412924,23 @@ function createMonitorManager(options) {
|
|
|
412869
412924
|
import { createHash as createHash6 } from "crypto";
|
|
412870
412925
|
import {
|
|
412871
412926
|
chmodSync as chmodSync5,
|
|
412872
|
-
existsSync as
|
|
412927
|
+
existsSync as existsSync107,
|
|
412873
412928
|
mkdirSync as mkdirSync22,
|
|
412874
412929
|
readdirSync as readdirSync27,
|
|
412875
|
-
readFileSync as
|
|
412930
|
+
readFileSync as readFileSync71,
|
|
412876
412931
|
renameSync as renameSync9,
|
|
412877
412932
|
unlinkSync as unlinkSync16,
|
|
412878
412933
|
writeFileSync as writeFileSync23
|
|
412879
412934
|
} from "fs";
|
|
412880
|
-
import { basename as basename22, dirname as dirname42, join as
|
|
412935
|
+
import { basename as basename22, dirname as dirname42, join as join126 } from "path";
|
|
412881
412936
|
|
|
412882
412937
|
// packages/mcp-client-core/src/config-dir.ts
|
|
412883
|
-
import { existsSync as
|
|
412938
|
+
import { existsSync as existsSync105, realpathSync as realpathSync18 } from "fs";
|
|
412884
412939
|
import { homedir as homedir31 } from "os";
|
|
412885
|
-
import { join as
|
|
412940
|
+
import { join as join124, resolve as resolve36 } from "path";
|
|
412886
412941
|
function resolveConfigPath4(pathValue) {
|
|
412887
412942
|
const resolvedPath = resolve36(pathValue);
|
|
412888
|
-
if (!
|
|
412943
|
+
if (!existsSync105(resolvedPath))
|
|
412889
412944
|
return resolvedPath;
|
|
412890
412945
|
try {
|
|
412891
412946
|
return realpathSync18(resolvedPath);
|
|
@@ -412900,13 +412955,13 @@ function getOpenCodeCliConfigDir(env2 = process.env) {
|
|
|
412900
412955
|
if (customConfigDir) {
|
|
412901
412956
|
return resolveConfigPath4(customConfigDir);
|
|
412902
412957
|
}
|
|
412903
|
-
const xdgConfigDir = env2["XDG_CONFIG_HOME"]?.trim() ||
|
|
412904
|
-
return resolveConfigPath4(
|
|
412958
|
+
const xdgConfigDir = env2["XDG_CONFIG_HOME"]?.trim() || join124(homedir31(), ".config");
|
|
412959
|
+
return resolveConfigPath4(join124(xdgConfigDir, "opencode"));
|
|
412905
412960
|
}
|
|
412906
412961
|
|
|
412907
412962
|
// packages/mcp-client-core/src/mcp-oauth/storage-index.ts
|
|
412908
|
-
import { chmodSync as chmodSync4, existsSync as
|
|
412909
|
-
import { join as
|
|
412963
|
+
import { chmodSync as chmodSync4, existsSync as existsSync106, readFileSync as readFileSync70, renameSync as renameSync8, writeFileSync as writeFileSync22 } from "fs";
|
|
412964
|
+
import { join as join125 } from "path";
|
|
412910
412965
|
var INDEX_FILE_NAME = "index.json";
|
|
412911
412966
|
function isTokenIndex(value) {
|
|
412912
412967
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
@@ -412914,14 +412969,14 @@ function isTokenIndex(value) {
|
|
|
412914
412969
|
return Object.values(value).every((entry) => typeof entry === "string");
|
|
412915
412970
|
}
|
|
412916
412971
|
function getIndexPath(storageDir) {
|
|
412917
|
-
return
|
|
412972
|
+
return join125(storageDir, INDEX_FILE_NAME);
|
|
412918
412973
|
}
|
|
412919
412974
|
function readTokenIndex(storageDir) {
|
|
412920
412975
|
const indexPath = getIndexPath(storageDir);
|
|
412921
|
-
if (!
|
|
412976
|
+
if (!existsSync106(indexPath))
|
|
412922
412977
|
return {};
|
|
412923
412978
|
try {
|
|
412924
|
-
const parsed = JSON.parse(
|
|
412979
|
+
const parsed = JSON.parse(readFileSync70(indexPath, "utf-8"));
|
|
412925
412980
|
return isTokenIndex(parsed) ? parsed : {};
|
|
412926
412981
|
} catch (readError) {
|
|
412927
412982
|
if (!(readError instanceof Error))
|
|
@@ -412951,16 +413006,16 @@ function saveTokenIndexEntry(storageDir, hash, key) {
|
|
|
412951
413006
|
var STORAGE_DIR_NAME = "mcp-oauth";
|
|
412952
413007
|
var LEGACY_STORAGE_FILE_NAME = "mcp-oauth.json";
|
|
412953
413008
|
function getMcpOauthStorageDir() {
|
|
412954
|
-
return
|
|
413009
|
+
return join126(getOpenCodeCliConfigDir(), STORAGE_DIR_NAME);
|
|
412955
413010
|
}
|
|
412956
413011
|
function getMcpOauthServerHash(serverHost, resource) {
|
|
412957
413012
|
return createHash6("sha256").update(buildKey(serverHost, resource)).digest("hex").slice(0, 32);
|
|
412958
413013
|
}
|
|
412959
413014
|
function getMcpOauthStoragePath(serverHost, resource) {
|
|
412960
|
-
return
|
|
413015
|
+
return join126(getMcpOauthStorageDir(), `${getMcpOauthServerHash(serverHost, resource)}.json`);
|
|
412961
413016
|
}
|
|
412962
413017
|
function getLegacyStoragePath() {
|
|
412963
|
-
return
|
|
413018
|
+
return join126(getOpenCodeCliConfigDir(), LEGACY_STORAGE_FILE_NAME);
|
|
412964
413019
|
}
|
|
412965
413020
|
function normalizeHost(serverHost) {
|
|
412966
413021
|
let host = serverHost.trim();
|
|
@@ -413021,10 +413076,10 @@ function isOAuthTokenData(value) {
|
|
|
413021
413076
|
return clientSecret === undefined || typeof clientSecret === "string";
|
|
413022
413077
|
}
|
|
413023
413078
|
function readTokenFile(filePath) {
|
|
413024
|
-
if (!
|
|
413079
|
+
if (!existsSync107(filePath))
|
|
413025
413080
|
return null;
|
|
413026
413081
|
try {
|
|
413027
|
-
const parsed = JSON.parse(
|
|
413082
|
+
const parsed = JSON.parse(readFileSync71(filePath, "utf-8"));
|
|
413028
413083
|
return isOAuthTokenData(parsed) ? parsed : null;
|
|
413029
413084
|
} catch (readError) {
|
|
413030
413085
|
if (!(readError instanceof Error))
|
|
@@ -413034,10 +413089,10 @@ function readTokenFile(filePath) {
|
|
|
413034
413089
|
}
|
|
413035
413090
|
function readLegacyStore() {
|
|
413036
413091
|
const filePath = getLegacyStoragePath();
|
|
413037
|
-
if (!
|
|
413092
|
+
if (!existsSync107(filePath))
|
|
413038
413093
|
return null;
|
|
413039
413094
|
try {
|
|
413040
|
-
const parsed = JSON.parse(
|
|
413095
|
+
const parsed = JSON.parse(readFileSync71(filePath, "utf-8"));
|
|
413041
413096
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
413042
413097
|
return null;
|
|
413043
413098
|
const result = {};
|
|
@@ -413055,7 +413110,7 @@ function readLegacyStore() {
|
|
|
413055
413110
|
function writeTokenFile(filePath, token) {
|
|
413056
413111
|
try {
|
|
413057
413112
|
const dir = dirname42(filePath);
|
|
413058
|
-
if (!
|
|
413113
|
+
if (!existsSync107(dir)) {
|
|
413059
413114
|
mkdirSync22(dir, { recursive: true });
|
|
413060
413115
|
}
|
|
413061
413116
|
const tempPath = `${filePath}.tmp.${Date.now()}`;
|
|
@@ -418447,16 +418502,16 @@ var WRITE_DEBOUNCE_MS = 250;
|
|
|
418447
418502
|
init_logger2();
|
|
418448
418503
|
|
|
418449
418504
|
// packages/omo-opencode/src/features/tui-sidebar/mirror-io.ts
|
|
418450
|
-
import { mkdirSync as mkdirSync23, readFileSync as
|
|
418505
|
+
import { mkdirSync as mkdirSync23, readFileSync as readFileSync72 } from "fs";
|
|
418451
418506
|
import { dirname as dirname43 } from "path";
|
|
418452
418507
|
|
|
418453
418508
|
// packages/omo-opencode/src/features/tui-sidebar/mirror-path.ts
|
|
418454
418509
|
import { createHash as createHash8 } from "crypto";
|
|
418455
418510
|
import { realpathSync as realpathSync19 } from "fs";
|
|
418456
418511
|
import { homedir as homedir32 } from "os";
|
|
418457
|
-
import { join as
|
|
418512
|
+
import { join as join127, resolve as resolve37 } from "path";
|
|
418458
418513
|
function mirrorStorageDir() {
|
|
418459
|
-
return
|
|
418514
|
+
return join127(process.env.XDG_DATA_HOME ?? join127(homedir32(), ".local", "share"), "opencode", "storage", "matrixos", MIRROR_DIR_NAME);
|
|
418460
418515
|
}
|
|
418461
418516
|
function canonicalProjectDir(projectDir) {
|
|
418462
418517
|
try {
|
|
@@ -418470,7 +418525,7 @@ function canonicalProjectDir(projectDir) {
|
|
|
418470
418525
|
}
|
|
418471
418526
|
function mirrorFilePath(projectDir) {
|
|
418472
418527
|
const projectHash = createHash8("sha1").update(canonicalProjectDir(projectDir)).digest("hex").slice(0, 16);
|
|
418473
|
-
return
|
|
418528
|
+
return join127(mirrorStorageDir(), `${projectHash}.json`);
|
|
418474
418529
|
}
|
|
418475
418530
|
|
|
418476
418531
|
// packages/omo-opencode/src/features/tui-sidebar/snapshot-schema.ts
|
|
@@ -418528,8 +418583,8 @@ function writeMirror(projectDir, snapshot) {
|
|
|
418528
418583
|
}
|
|
418529
418584
|
|
|
418530
418585
|
// packages/omo-opencode/src/features/tui-sidebar/loop-reader.ts
|
|
418531
|
-
import { readdirSync as readdirSync28, readFileSync as
|
|
418532
|
-
import { join as
|
|
418586
|
+
import { readdirSync as readdirSync28, readFileSync as readFileSync73, statSync as statSync13 } from "fs";
|
|
418587
|
+
import { join as join128 } from "path";
|
|
418533
418588
|
import { z as z12 } from "zod";
|
|
418534
418589
|
var CriterionSchema = z12.object({
|
|
418535
418590
|
status: z12.string()
|
|
@@ -418559,7 +418614,7 @@ function enumerateCandidates(projectDir) {
|
|
|
418559
418614
|
return [...currentLoopCandidates(projectDir), legacyLoopCandidate(projectDir)].filter((candidate) => candidate !== null);
|
|
418560
418615
|
}
|
|
418561
418616
|
function currentLoopCandidates(projectDir) {
|
|
418562
|
-
const loopRoot =
|
|
418617
|
+
const loopRoot = join128(projectDir, ".omo", "ulw-loop");
|
|
418563
418618
|
let entries;
|
|
418564
418619
|
try {
|
|
418565
418620
|
entries = readdirSync28(loopRoot, { withFileTypes: true });
|
|
@@ -418569,10 +418624,10 @@ function currentLoopCandidates(projectDir) {
|
|
|
418569
418624
|
}
|
|
418570
418625
|
throw error;
|
|
418571
418626
|
}
|
|
418572
|
-
return entries.filter((entry) => entry.isDirectory()).map((entry) => statCandidate(
|
|
418627
|
+
return entries.filter((entry) => entry.isDirectory()).map((entry) => statCandidate(join128(loopRoot, entry.name, "goals.json"))).filter((candidate) => candidate !== null);
|
|
418573
418628
|
}
|
|
418574
418629
|
function legacyLoopCandidate(projectDir) {
|
|
418575
|
-
return statCandidate(
|
|
418630
|
+
return statCandidate(join128(projectDir, ".omo", "loop", "goals.json"));
|
|
418576
418631
|
}
|
|
418577
418632
|
function statCandidate(path22) {
|
|
418578
418633
|
try {
|
|
@@ -418597,7 +418652,7 @@ function readLiveCandidate(candidate) {
|
|
|
418597
418652
|
function readParsedLoop(path22) {
|
|
418598
418653
|
let raw;
|
|
418599
418654
|
try {
|
|
418600
|
-
raw = JSON.parse(
|
|
418655
|
+
raw = JSON.parse(readFileSync73(path22, "utf8"));
|
|
418601
418656
|
} catch (error) {
|
|
418602
418657
|
if (error instanceof Error) {
|
|
418603
418658
|
return null;
|
|
@@ -421058,25 +421113,25 @@ async function createRuntimeSkillSourceServer(options, runtimeEnv = runtime6) {
|
|
|
421058
421113
|
};
|
|
421059
421114
|
}
|
|
421060
421115
|
// packages/claude-code-compat-core/src/features/claude-code-mcp-loader/loader.ts
|
|
421061
|
-
import { existsSync as
|
|
421062
|
-
import { join as
|
|
421116
|
+
import { existsSync as existsSync108, readFileSync as readFileSync74 } from "fs";
|
|
421117
|
+
import { join as join129 } from "path";
|
|
421063
421118
|
import { homedir as homedir33 } from "os";
|
|
421064
421119
|
function getMcpConfigPaths() {
|
|
421065
421120
|
const claudeConfigDir = getClaudeConfigDir3();
|
|
421066
421121
|
const homeDir = getHomeDir();
|
|
421067
421122
|
const cwd = process.cwd();
|
|
421068
421123
|
return [
|
|
421069
|
-
{ path:
|
|
421070
|
-
{ path:
|
|
421071
|
-
{ path:
|
|
421072
|
-
{ path:
|
|
421124
|
+
{ path: join129(homeDir, ".claude.json"), scope: "user" },
|
|
421125
|
+
{ path: join129(claudeConfigDir, ".mcp.json"), scope: "user" },
|
|
421126
|
+
{ path: join129(cwd, ".mcp.json"), scope: "project" },
|
|
421127
|
+
{ path: join129(cwd, ".claude", ".mcp.json"), scope: "local" }
|
|
421073
421128
|
];
|
|
421074
421129
|
}
|
|
421075
421130
|
function getHomeDir() {
|
|
421076
421131
|
return process.env.HOME || process.env.USERPROFILE || homedir33();
|
|
421077
421132
|
}
|
|
421078
421133
|
async function loadMcpConfigFile(filePath) {
|
|
421079
|
-
if (!
|
|
421134
|
+
if (!existsSync108(filePath)) {
|
|
421080
421135
|
return null;
|
|
421081
421136
|
}
|
|
421082
421137
|
try {
|
|
@@ -421096,10 +421151,10 @@ function getSystemMcpServerNames() {
|
|
|
421096
421151
|
const paths2 = getMcpConfigPaths();
|
|
421097
421152
|
const cwd = process.cwd();
|
|
421098
421153
|
for (const { path: path22 } of paths2) {
|
|
421099
|
-
if (!
|
|
421154
|
+
if (!existsSync108(path22))
|
|
421100
421155
|
continue;
|
|
421101
421156
|
try {
|
|
421102
|
-
const content =
|
|
421157
|
+
const content = readFileSync74(path22, "utf-8");
|
|
421103
421158
|
const config = JSON.parse(content);
|
|
421104
421159
|
if (!config?.mcpServers)
|
|
421105
421160
|
continue;
|
|
@@ -428297,15 +428352,15 @@ function createTankAgent(model, availableAgents, availableToolNames, availableSk
|
|
|
428297
428352
|
}
|
|
428298
428353
|
createTankAgent.mode = MODE9;
|
|
428299
428354
|
// packages/omo-opencode/src/agents/builtin-agents/resolve-file-uri.ts
|
|
428300
|
-
import { existsSync as
|
|
428355
|
+
import { existsSync as existsSync109, readFileSync as readFileSync75 } from "fs";
|
|
428301
428356
|
import { homedir as homedir34 } from "os";
|
|
428302
|
-
import { isAbsolute as isAbsolute19, join as
|
|
428357
|
+
import { isAbsolute as isAbsolute19, join as join130, resolve as resolve38 } from "path";
|
|
428303
428358
|
init_logger2();
|
|
428304
428359
|
var ALLOWED_HOME_SUBDIRS = [
|
|
428305
|
-
|
|
428306
|
-
|
|
428307
|
-
|
|
428308
|
-
|
|
428360
|
+
join130(homedir34(), ".config", "opencode"),
|
|
428361
|
+
join130(homedir34(), ".config", "MaTrixOS"),
|
|
428362
|
+
join130(homedir34(), ".omo"),
|
|
428363
|
+
join130(homedir34(), ".opencode")
|
|
428309
428364
|
];
|
|
428310
428365
|
function isWithinAllowedPaths(filePath, projectRoot) {
|
|
428311
428366
|
if (isWithinProject(filePath, projectRoot))
|
|
@@ -428341,11 +428396,11 @@ function resolvePromptAppend(promptAppend, configDir) {
|
|
|
428341
428396
|
});
|
|
428342
428397
|
return `[WARNING: Path rejected: ${promptAppend} (resolved outside project root ${projectRoot} and allowed home directories; file:// prompts must reside within the project directory, ~/.config/opencode/, ~/.config/MaTrixOS/, ~/.omo/, or ~/.opencode/)]`;
|
|
428343
428398
|
}
|
|
428344
|
-
if (!
|
|
428399
|
+
if (!existsSync109(filePath)) {
|
|
428345
428400
|
return `[WARNING: Could not resolve file URI: ${promptAppend}]`;
|
|
428346
428401
|
}
|
|
428347
428402
|
try {
|
|
428348
|
-
return
|
|
428403
|
+
return readFileSync75(filePath, "utf8");
|
|
428349
428404
|
} catch (error) {
|
|
428350
428405
|
if (!(error instanceof Error)) {
|
|
428351
428406
|
throw error;
|
|
@@ -431517,7 +431572,7 @@ async function applyAgentConfig(params) {
|
|
|
431517
431572
|
}
|
|
431518
431573
|
// packages/claude-code-compat-core/src/features/claude-code-command-loader/loader.ts
|
|
431519
431574
|
import { promises as fs23 } from "fs";
|
|
431520
|
-
import { join as
|
|
431575
|
+
import { join as join131, basename as basename23 } from "path";
|
|
431521
431576
|
|
|
431522
431577
|
// packages/claude-code-compat-core/src/features/claude-code-command-loader/loader-cache.ts
|
|
431523
431578
|
var commandLoaderCache = new Map;
|
|
@@ -431565,7 +431620,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
431565
431620
|
continue;
|
|
431566
431621
|
if (entry.name.startsWith("."))
|
|
431567
431622
|
continue;
|
|
431568
|
-
const subDirPath =
|
|
431623
|
+
const subDirPath = join131(commandsDir, entry.name);
|
|
431569
431624
|
const subPrefix = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
431570
431625
|
const subCommands = await loadCommandsFromDir(subDirPath, scope, visited, subPrefix);
|
|
431571
431626
|
commands.push(...subCommands);
|
|
@@ -431573,7 +431628,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
431573
431628
|
}
|
|
431574
431629
|
if (!isMarkdownFile(entry))
|
|
431575
431630
|
continue;
|
|
431576
|
-
const commandPath =
|
|
431631
|
+
const commandPath = join131(commandsDir, entry.name);
|
|
431577
431632
|
const baseCommandName = basename23(entry.name, ".md");
|
|
431578
431633
|
const commandName = prefix ? `${prefix}/${baseCommandName}` : baseCommandName;
|
|
431579
431634
|
try {
|
|
@@ -431636,12 +431691,12 @@ function commandsToRecord(commands) {
|
|
|
431636
431691
|
return result;
|
|
431637
431692
|
}
|
|
431638
431693
|
async function loadUserCommands() {
|
|
431639
|
-
const userCommandsDir =
|
|
431694
|
+
const userCommandsDir = join131(getClaudeConfigDir3(), "commands");
|
|
431640
431695
|
const commands = await loadCommandsFromDir(userCommandsDir, "user");
|
|
431641
431696
|
return commandsToRecord(commands);
|
|
431642
431697
|
}
|
|
431643
431698
|
async function loadProjectCommands(directory) {
|
|
431644
|
-
const projectCommandsDir =
|
|
431699
|
+
const projectCommandsDir = join131(directory ?? process.cwd(), ".claude", "commands");
|
|
431645
431700
|
const commands = await loadCommandsFromDir(projectCommandsDir, "project");
|
|
431646
431701
|
return commandsToRecord(commands);
|
|
431647
431702
|
}
|
|
@@ -431831,8 +431886,8 @@ var grep_app = {
|
|
|
431831
431886
|
|
|
431832
431887
|
// packages/omo-opencode/src/mcp/codegraph.ts
|
|
431833
431888
|
init_src();
|
|
431834
|
-
import { existsSync as
|
|
431835
|
-
import { join as
|
|
431889
|
+
import { existsSync as existsSync110 } from "fs";
|
|
431890
|
+
import { join as join132 } from "path";
|
|
431836
431891
|
|
|
431837
431892
|
// packages/omo-opencode/src/mcp/runtime-executable.ts
|
|
431838
431893
|
init_bun_which_shim();
|
|
@@ -431879,7 +431934,7 @@ function createWhichResolver(resolveExecutable) {
|
|
|
431879
431934
|
function provisionedBinFromInstallDir2(installDir, fileExists2) {
|
|
431880
431935
|
if (installDir === undefined)
|
|
431881
431936
|
return null;
|
|
431882
|
-
const candidate =
|
|
431937
|
+
const candidate = join132(installDir, "bin", process.platform === "win32" ? "codegraph.cmd" : "codegraph");
|
|
431883
431938
|
return fileExists2(candidate) ? candidate : null;
|
|
431884
431939
|
}
|
|
431885
431940
|
function codegraphEnvForConfig(config, homeDir) {
|
|
@@ -431890,7 +431945,7 @@ function createCodegraphMcpConfig(options = {}) {
|
|
|
431890
431945
|
const env2 = options.env ?? process.env;
|
|
431891
431946
|
const resolveExecutable = options.resolveExecutable ?? resolveRuntimeExecutable;
|
|
431892
431947
|
const which2 = createWhichResolver(resolveExecutable);
|
|
431893
|
-
const fileExists2 = options.fileExists ??
|
|
431948
|
+
const fileExists2 = options.fileExists ?? existsSync110;
|
|
431894
431949
|
const resolvedCommand = resolveCodegraphCommand({
|
|
431895
431950
|
env: env2,
|
|
431896
431951
|
fileExists: fileExists2,
|
|
@@ -431916,7 +431971,7 @@ function createCodegraphMcpConfig(options = {}) {
|
|
|
431916
431971
|
}
|
|
431917
431972
|
|
|
431918
431973
|
// packages/omo-opencode/src/mcp/lsp.ts
|
|
431919
|
-
import { existsSync as
|
|
431974
|
+
import { existsSync as existsSync111, readFileSync as readFileSync76 } from "fs";
|
|
431920
431975
|
import { delimiter as delimiter2, dirname as dirname44, resolve as resolve40 } from "path";
|
|
431921
431976
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
431922
431977
|
import { z as z13 } from "zod";
|
|
@@ -432026,7 +432081,7 @@ function findBootstrapRoot(candidates, pathExists) {
|
|
|
432026
432081
|
}
|
|
432027
432082
|
function readDaemonPackageVersion(root) {
|
|
432028
432083
|
try {
|
|
432029
|
-
const packageJson = JSON.parse(
|
|
432084
|
+
const packageJson = JSON.parse(readFileSync76(resolve40(root, PACKAGE_REL, "package.json"), "utf-8"));
|
|
432030
432085
|
return DaemonPackageSchema.parse(packageJson).version;
|
|
432031
432086
|
} catch (error) {
|
|
432032
432087
|
if (!(error instanceof Error))
|
|
@@ -432048,7 +432103,7 @@ function createBootstrapCandidate(root, pathExists, resolveExecutable) {
|
|
|
432048
432103
|
};
|
|
432049
432104
|
}
|
|
432050
432105
|
function resolveLspCommand(options = {}) {
|
|
432051
|
-
const pathExists = options.exists ??
|
|
432106
|
+
const pathExists = options.exists ?? existsSync111;
|
|
432052
432107
|
const resolveExecutable = options.resolveExecutable ?? resolveRuntimeExecutable;
|
|
432053
432108
|
const moduleDirectory = getModuleDirectory(options.moduleUrl ?? import.meta.url);
|
|
432054
432109
|
const candidates = moduleDirectory ? createAncestorCliCandidates({
|
|
@@ -432498,7 +432553,7 @@ function createConfigHandler(deps) {
|
|
|
432498
432553
|
}
|
|
432499
432554
|
// packages/omo-opencode/src/create-managers.ts
|
|
432500
432555
|
init_server_health2();
|
|
432501
|
-
import { join as
|
|
432556
|
+
import { join as join133 } from "path";
|
|
432502
432557
|
var defaultCreateManagersDeps = {
|
|
432503
432558
|
BackgroundManagerClass: BackgroundManager,
|
|
432504
432559
|
SkillMcpManagerClass: SkillMcpManager,
|
|
@@ -432555,9 +432610,9 @@ function createManagers(args) {
|
|
|
432555
432610
|
}
|
|
432556
432611
|
});
|
|
432557
432612
|
const scannerDaemon = createScannerDaemon({
|
|
432558
|
-
auditLogPath:
|
|
432613
|
+
auditLogPath: join133(getDataDir(), "opencode", "matrix-gateway-audit.jsonl"),
|
|
432559
432614
|
projectDir: ctx.directory,
|
|
432560
|
-
learningsPath:
|
|
432615
|
+
learningsPath: join133(ctx.directory, ".matrix", "learnings.jsonl"),
|
|
432561
432616
|
intervalMs: 14400000,
|
|
432562
432617
|
onScanComplete(result) {
|
|
432563
432618
|
log2("[scanner-daemon] scan complete", result);
|
|
@@ -438561,20 +438616,20 @@ function createChatHeadersHandler(args) {
|
|
|
438561
438616
|
}
|
|
438562
438617
|
|
|
438563
438618
|
// packages/omo-opencode/src/plugin/auto-adoption.ts
|
|
438564
|
-
import { existsSync as
|
|
438565
|
-
import { join as
|
|
438619
|
+
import { existsSync as existsSync112, readFileSync as readFileSync77 } from "fs";
|
|
438620
|
+
import { join as join134 } from "path";
|
|
438566
438621
|
import { homedir as homedir35 } from "os";
|
|
438567
|
-
var ADOPTION_CONTEXT_RELATIVE =
|
|
438622
|
+
var ADOPTION_CONTEXT_RELATIVE = join134("MOS_Vault", "04-Areas", "user-context.md");
|
|
438568
438623
|
function resolveUserContextPath() {
|
|
438569
|
-
const base = process.env.MOS_VAULT_DIR ??
|
|
438570
|
-
return
|
|
438624
|
+
const base = process.env.MOS_VAULT_DIR ?? join134(homedir35(), "MOS_Vault");
|
|
438625
|
+
return join134(base, "04-Areas", "user-context.md");
|
|
438571
438626
|
}
|
|
438572
438627
|
function isAdoptionNeeded() {
|
|
438573
438628
|
const path26 = resolveUserContextPath();
|
|
438574
|
-
if (!
|
|
438629
|
+
if (!existsSync112(path26))
|
|
438575
438630
|
return true;
|
|
438576
438631
|
try {
|
|
438577
|
-
const content =
|
|
438632
|
+
const content = readFileSync77(path26, "utf8");
|
|
438578
438633
|
return !/features/i.test(content);
|
|
438579
438634
|
} catch {
|
|
438580
438635
|
return true;
|
|
@@ -438583,8 +438638,8 @@ function isAdoptionNeeded() {
|
|
|
438583
438638
|
var ADOPTION_TRIGGER_INSTRUCTION = `SYST\xC8ME \u2014 Rituel d'adoption automatique : lance imm\xE9diatement le rituel d'adoption comme si l'utilisateur avait tap\xE9 /adopt. M\xEAme si un contexte utilisateur (user-context.md) existe d\xE9j\xE0, tu DOIS proposer les fonctionnalit\xE9s opt-in (especially Dashboard Mission Control sur 127.0.0.1:9123) \u2014 ne saute jamais cette \xE9tape. Pose les 5 questions (identit\xE9, projet, contraintes, style de collaboration, reporting), puis pr\xE9sente la checklist des fonctionnalit\xE9s opt-in depuis l'inventaire (OPT_IN_FEATURES). Utilise l'outil question pour les questions. Ne r\xE9ponds pas encore \xE0 la demande de l'utilisateur \u2014 l'adoption prime.`;
|
|
438584
438639
|
|
|
438585
438640
|
// packages/omo-opencode/src/plugin/ultrawork-db-model-override.ts
|
|
438586
|
-
import { join as
|
|
438587
|
-
import { existsSync as
|
|
438641
|
+
import { join as join135 } from "path";
|
|
438642
|
+
import { existsSync as existsSync113 } from "fs";
|
|
438588
438643
|
async function importBunSqlite() {
|
|
438589
438644
|
if (typeof globalThis.Bun === "undefined") {
|
|
438590
438645
|
return null;
|
|
@@ -438600,7 +438655,7 @@ async function importBunSqlite() {
|
|
|
438600
438655
|
}
|
|
438601
438656
|
}
|
|
438602
438657
|
function getDbPath() {
|
|
438603
|
-
return
|
|
438658
|
+
return join135(getDataDir(), "opencode", "opencode.db");
|
|
438604
438659
|
}
|
|
438605
438660
|
var MAX_MICROTASK_RETRIES = 10;
|
|
438606
438661
|
function logCaughtDbError(message, metadata, error) {
|
|
@@ -438703,7 +438758,7 @@ async function scheduleDeferredModelOverride(messageId, targetModel, variant) {
|
|
|
438703
438758
|
return;
|
|
438704
438759
|
}
|
|
438705
438760
|
const dbPath = getDbPath();
|
|
438706
|
-
if (!
|
|
438761
|
+
if (!existsSync113(dbPath)) {
|
|
438707
438762
|
log2("[ultrawork-db-override] DB not found, skipping deferred override");
|
|
438708
438763
|
return;
|
|
438709
438764
|
}
|
|
@@ -439183,7 +439238,20 @@ function createChatMessageHandler3(args) {
|
|
|
439183
439238
|
if (isFirstMessage) {
|
|
439184
439239
|
firstMessageVariantGate.markApplied(input.sessionID);
|
|
439185
439240
|
if (isAdoptionNeeded()) {
|
|
439186
|
-
output.parts.
|
|
439241
|
+
const textPartIndex = output.parts.findIndex((p) => p.type === "text" && typeof p.text === "string");
|
|
439242
|
+
if (textPartIndex >= 0) {
|
|
439243
|
+
const original = output.parts[textPartIndex];
|
|
439244
|
+
const originalText = original.text ?? "";
|
|
439245
|
+
output.parts[textPartIndex] = {
|
|
439246
|
+
...original,
|
|
439247
|
+
type: "text",
|
|
439248
|
+
text: `${ADOPTION_TRIGGER_INSTRUCTION}
|
|
439249
|
+
|
|
439250
|
+
${originalText}`
|
|
439251
|
+
};
|
|
439252
|
+
} else {
|
|
439253
|
+
output.parts.push({ type: "text", text: ADOPTION_TRIGGER_INSTRUCTION });
|
|
439254
|
+
}
|
|
439187
439255
|
log2("[chat-message] Auto-adoption triggered \u2014 no user-context.md found", {
|
|
439188
439256
|
sessionID: input.sessionID
|
|
439189
439257
|
});
|
|
@@ -441482,12 +441550,12 @@ function createAgentAntiLoopHooks(config) {
|
|
|
441482
441550
|
}
|
|
441483
441551
|
|
|
441484
441552
|
// packages/omo-opencode/src/features/anti-loop/logger.ts
|
|
441485
|
-
import { existsSync as
|
|
441486
|
-
import { join as
|
|
441553
|
+
import { existsSync as existsSync114, mkdirSync as mkdirSync24, appendFileSync as appendFileSync8 } from "fs";
|
|
441554
|
+
import { join as join136 } from "path";
|
|
441487
441555
|
function createAntiLoopLogger(logsDir) {
|
|
441488
|
-
const logFile =
|
|
441489
|
-
const parentDir =
|
|
441490
|
-
if (!
|
|
441556
|
+
const logFile = join136(logsDir, "anti-loop.jsonl");
|
|
441557
|
+
const parentDir = join136(logsDir, "..");
|
|
441558
|
+
if (!existsSync114(logsDir)) {
|
|
441491
441559
|
mkdirSync24(logsDir, { recursive: true });
|
|
441492
441560
|
}
|
|
441493
441561
|
return {
|
|
@@ -441511,10 +441579,10 @@ function getRunningTasks() {
|
|
|
441511
441579
|
}
|
|
441512
441580
|
|
|
441513
441581
|
// packages/omo-opencode/src/plugin/agent-anti-loop.ts
|
|
441514
|
-
import { join as
|
|
441582
|
+
import { join as join137 } from "path";
|
|
441515
441583
|
function createAgentAntiLoopWiring(config, deps) {
|
|
441516
441584
|
const hooks = createAgentAntiLoopHooks(config);
|
|
441517
|
-
const logDir = deps.projectDir ?
|
|
441585
|
+
const logDir = deps.projectDir ? join137(deps.projectDir, ".matrixos", "logs") : process.cwd();
|
|
441518
441586
|
const antiLoopLog = createAntiLoopLogger(logDir);
|
|
441519
441587
|
return {
|
|
441520
441588
|
toolExecuteAfter(input) {
|
|
@@ -444392,22 +444460,22 @@ init_plugin_identity();
|
|
|
444392
444460
|
// packages/telemetry-core/src/activity-state.ts
|
|
444393
444461
|
init_atomic_write();
|
|
444394
444462
|
init_xdg_data_dir();
|
|
444395
|
-
import { existsSync as
|
|
444396
|
-
import { basename as basename26, join as
|
|
444463
|
+
import { existsSync as existsSync121, mkdirSync as mkdirSync27, readFileSync as readFileSync82 } from "fs";
|
|
444464
|
+
import { basename as basename26, join as join145 } from "path";
|
|
444397
444465
|
var POSTHOG_ACTIVITY_STATE_FILE = "posthog-activity.json";
|
|
444398
444466
|
function resolveTelemetryStateDir(product, options = {}) {
|
|
444399
444467
|
const dataDir = resolveXdgDataDir(product.cacheDirName, {
|
|
444400
444468
|
env: options.env,
|
|
444401
444469
|
osProvider: options.osProvider
|
|
444402
444470
|
});
|
|
444403
|
-
const xdgStateDir = options.env?.XDG_DATA_HOME === undefined ? undefined :
|
|
444471
|
+
const xdgStateDir = options.env?.XDG_DATA_HOME === undefined ? undefined : join145(options.env.XDG_DATA_HOME, product.cacheDirName);
|
|
444404
444472
|
if (dataDir === xdgStateDir || xdgStateDir === undefined && basename26(dataDir) === product.cacheDirName) {
|
|
444405
444473
|
return dataDir;
|
|
444406
444474
|
}
|
|
444407
|
-
return
|
|
444475
|
+
return join145(dataDir, product.cacheDirName);
|
|
444408
444476
|
}
|
|
444409
444477
|
function getTelemetryActivityStateFilePath(stateDir) {
|
|
444410
|
-
return
|
|
444478
|
+
return join145(stateDir, POSTHOG_ACTIVITY_STATE_FILE);
|
|
444411
444479
|
}
|
|
444412
444480
|
function getDailyActiveCaptureState(input2) {
|
|
444413
444481
|
const state3 = readPostHogActivityState(input2.stateDir, input2.diagnostics);
|
|
@@ -444432,11 +444500,11 @@ function isPostHogActivityState(value) {
|
|
|
444432
444500
|
}
|
|
444433
444501
|
function readPostHogActivityState(stateDir, diagnostics) {
|
|
444434
444502
|
const stateFilePath = getTelemetryActivityStateFilePath(stateDir);
|
|
444435
|
-
if (!
|
|
444503
|
+
if (!existsSync121(stateFilePath)) {
|
|
444436
444504
|
return {};
|
|
444437
444505
|
}
|
|
444438
444506
|
try {
|
|
444439
|
-
const stateContent =
|
|
444507
|
+
const stateContent = readFileSync82(stateFilePath, "utf-8");
|
|
444440
444508
|
const stateJson = JSON.parse(stateContent);
|
|
444441
444509
|
if (!isPostHogActivityState(stateJson)) {
|
|
444442
444510
|
return {};
|
|
@@ -451814,6 +451882,7 @@ function createPluginModule(overrides2 = {}) {
|
|
|
451814
451882
|
}
|
|
451815
451883
|
deps.injectServerAuthIntoClient(input2.client);
|
|
451816
451884
|
const pluginConfig = deps.loadPluginConfig(input2.directory, input2);
|
|
451885
|
+
loadGatewayEnvFile();
|
|
451817
451886
|
if (pluginConfig.profiles && pluginConfig.profiles.length > 0) {
|
|
451818
451887
|
try {
|
|
451819
451888
|
const { resolveProfiles: resolveProfiles2, MatrixosConfigSchema: MatrixosConfigSchema2 } = await Promise.resolve().then(() => (init_src3(), exports_src2));
|