oh-my-opencode 3.15.0 → 3.15.1
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/index.js +144 -98
- package/dist/hooks/auto-update-checker/checker/sync-package-json.d.ts +1 -1
- package/dist/hooks/auto-update-checker/constants.d.ts +3 -2
- package/dist/hooks/todo-continuation-enforcer/session-state.d.ts +4 -3
- package/dist/hooks/todo-continuation-enforcer/types.d.ts +3 -0
- package/dist/index.js +299 -200
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -60911,8 +60911,6 @@ function getMessageDir(sessionID) {
|
|
|
60911
60911
|
return null;
|
|
60912
60912
|
if (/[/\\]|\.\./.test(sessionID))
|
|
60913
60913
|
return null;
|
|
60914
|
-
if (isSqliteBackend())
|
|
60915
|
-
return null;
|
|
60916
60914
|
if (!existsSync12(MESSAGE_STORAGE))
|
|
60917
60915
|
return null;
|
|
60918
60916
|
const directPath = join14(MESSAGE_STORAGE, sessionID);
|
|
@@ -63600,6 +63598,12 @@ function startCountdown(args) {
|
|
|
63600
63598
|
}
|
|
63601
63599
|
|
|
63602
63600
|
// src/hooks/todo-continuation-enforcer/idle-event.ts
|
|
63601
|
+
function shouldAllowActivityProgress(modelID) {
|
|
63602
|
+
if (!modelID) {
|
|
63603
|
+
return false;
|
|
63604
|
+
}
|
|
63605
|
+
return !modelID.toLowerCase().includes("codex");
|
|
63606
|
+
}
|
|
63603
63607
|
async function handleSessionIdle(args) {
|
|
63604
63608
|
const {
|
|
63605
63609
|
ctx,
|
|
@@ -63731,7 +63735,7 @@ async function handleSessionIdle(args) {
|
|
|
63731
63735
|
log(`[${HOOK_NAME}] Skipped: continuation stopped for session`, { sessionID });
|
|
63732
63736
|
return;
|
|
63733
63737
|
}
|
|
63734
|
-
const progressUpdate = sessionStateStore.trackContinuationProgress(sessionID, incompleteCount, todos);
|
|
63738
|
+
const progressUpdate = sessionStateStore.trackContinuationProgress(sessionID, incompleteCount, todos, { allowActivityProgress: shouldAllowActivityProgress(resolvedInfo?.model?.modelID) });
|
|
63735
63739
|
if (shouldStopForStagnation({ sessionID, incompleteCount, progressUpdate })) {
|
|
63736
63740
|
return;
|
|
63737
63741
|
}
|
|
@@ -63770,6 +63774,7 @@ function handleNonIdleEvent(args) {
|
|
|
63770
63774
|
if (state2) {
|
|
63771
63775
|
state2.abortDetectedAt = undefined;
|
|
63772
63776
|
state2.wasCancelled = false;
|
|
63777
|
+
sessionStateStore.recordActivity(sessionID);
|
|
63773
63778
|
}
|
|
63774
63779
|
sessionStateStore.cancelCountdown(sessionID);
|
|
63775
63780
|
return;
|
|
@@ -63779,6 +63784,7 @@ function handleNonIdleEvent(args) {
|
|
|
63779
63784
|
if (state2) {
|
|
63780
63785
|
state2.abortDetectedAt = undefined;
|
|
63781
63786
|
state2.wasCancelled = false;
|
|
63787
|
+
sessionStateStore.recordActivity(sessionID);
|
|
63782
63788
|
}
|
|
63783
63789
|
sessionStateStore.cancelCountdown(sessionID);
|
|
63784
63790
|
return;
|
|
@@ -63792,8 +63798,10 @@ function handleNonIdleEvent(args) {
|
|
|
63792
63798
|
const targetSessionID = sessionID ?? legacySessionID;
|
|
63793
63799
|
if (targetSessionID) {
|
|
63794
63800
|
const state2 = sessionStateStore.getExistingState(targetSessionID);
|
|
63795
|
-
if (state2)
|
|
63801
|
+
if (state2) {
|
|
63796
63802
|
state2.abortDetectedAt = undefined;
|
|
63803
|
+
sessionStateStore.recordActivity(targetSessionID);
|
|
63804
|
+
}
|
|
63797
63805
|
sessionStateStore.cancelCountdown(targetSessionID);
|
|
63798
63806
|
}
|
|
63799
63807
|
return;
|
|
@@ -63805,6 +63813,7 @@ function handleNonIdleEvent(args) {
|
|
|
63805
63813
|
if (state2) {
|
|
63806
63814
|
state2.abortDetectedAt = undefined;
|
|
63807
63815
|
state2.wasCancelled = false;
|
|
63816
|
+
sessionStateStore.recordActivity(sessionID);
|
|
63808
63817
|
}
|
|
63809
63818
|
sessionStateStore.cancelCountdown(sessionID);
|
|
63810
63819
|
}
|
|
@@ -63817,6 +63826,7 @@ function handleNonIdleEvent(args) {
|
|
|
63817
63826
|
if (state2) {
|
|
63818
63827
|
state2.abortDetectedAt = undefined;
|
|
63819
63828
|
state2.wasCancelled = false;
|
|
63829
|
+
sessionStateStore.recordActivity(sessionID);
|
|
63820
63830
|
}
|
|
63821
63831
|
sessionStateStore.cancelCountdown(sessionID);
|
|
63822
63832
|
}
|
|
@@ -63953,7 +63963,8 @@ function createSessionStateStore() {
|
|
|
63953
63963
|
};
|
|
63954
63964
|
const trackedSession = {
|
|
63955
63965
|
state: rawState,
|
|
63956
|
-
lastAccessedAt: Date.now()
|
|
63966
|
+
lastAccessedAt: Date.now(),
|
|
63967
|
+
activitySignalCount: 0
|
|
63957
63968
|
};
|
|
63958
63969
|
sessions.set(sessionID, trackedSession);
|
|
63959
63970
|
return trackedSession;
|
|
@@ -63969,15 +63980,21 @@ function createSessionStateStore() {
|
|
|
63969
63980
|
}
|
|
63970
63981
|
return;
|
|
63971
63982
|
}
|
|
63972
|
-
function
|
|
63983
|
+
function recordActivity(sessionID) {
|
|
63984
|
+
const trackedSession = getTrackedSession(sessionID);
|
|
63985
|
+
trackedSession.activitySignalCount += 1;
|
|
63986
|
+
}
|
|
63987
|
+
function trackContinuationProgress(sessionID, incompleteCount, todos, options = {}) {
|
|
63973
63988
|
const trackedSession = getTrackedSession(sessionID);
|
|
63974
63989
|
const state2 = trackedSession.state;
|
|
63975
63990
|
const previousIncompleteCount = state2.lastIncompleteCount;
|
|
63976
63991
|
const previousStagnationCount = state2.stagnationCount;
|
|
63977
63992
|
const currentCompletedCount = todos?.filter((todo) => todo.status === "completed").length;
|
|
63978
63993
|
const currentTodoSnapshot = todos ? getTodoSnapshot(todos) : undefined;
|
|
63994
|
+
const currentActivitySignalCount = trackedSession.activitySignalCount;
|
|
63979
63995
|
const hasCompletedMoreTodos = currentCompletedCount !== undefined && trackedSession.lastCompletedCount !== undefined && currentCompletedCount > trackedSession.lastCompletedCount;
|
|
63980
63996
|
const hasTodoSnapshotChanged = currentTodoSnapshot !== undefined && trackedSession.lastTodoSnapshot !== undefined && currentTodoSnapshot !== trackedSession.lastTodoSnapshot;
|
|
63997
|
+
const hasObservedExternalActivity = options.allowActivityProgress === true && trackedSession.lastObservedActivitySignalCount !== undefined && currentActivitySignalCount > trackedSession.lastObservedActivitySignalCount;
|
|
63981
63998
|
const hadSuccessfulInjectionAwaitingProgressCheck = state2.awaitingPostInjectionProgressCheck === true;
|
|
63982
63999
|
state2.lastIncompleteCount = incompleteCount;
|
|
63983
64000
|
if (currentCompletedCount !== undefined) {
|
|
@@ -63986,6 +64003,7 @@ function createSessionStateStore() {
|
|
|
63986
64003
|
if (currentTodoSnapshot !== undefined) {
|
|
63987
64004
|
trackedSession.lastTodoSnapshot = currentTodoSnapshot;
|
|
63988
64005
|
}
|
|
64006
|
+
trackedSession.lastObservedActivitySignalCount = currentActivitySignalCount;
|
|
63989
64007
|
if (previousIncompleteCount === undefined) {
|
|
63990
64008
|
state2.stagnationCount = 0;
|
|
63991
64009
|
return {
|
|
@@ -63996,7 +64014,7 @@ function createSessionStateStore() {
|
|
|
63996
64014
|
progressSource: "none"
|
|
63997
64015
|
};
|
|
63998
64016
|
}
|
|
63999
|
-
const progressSource = incompleteCount < previousIncompleteCount || hasCompletedMoreTodos || hasTodoSnapshotChanged ? "todo" : "none";
|
|
64017
|
+
const progressSource = incompleteCount < previousIncompleteCount || hasCompletedMoreTodos || hasTodoSnapshotChanged ? "todo" : hasObservedExternalActivity ? "activity" : "none";
|
|
64000
64018
|
if (progressSource !== "none") {
|
|
64001
64019
|
state2.stagnationCount = 0;
|
|
64002
64020
|
state2.awaitingPostInjectionProgressCheck = false;
|
|
@@ -64038,6 +64056,8 @@ function createSessionStateStore() {
|
|
|
64038
64056
|
state2.awaitingPostInjectionProgressCheck = false;
|
|
64039
64057
|
trackedSession.lastCompletedCount = undefined;
|
|
64040
64058
|
trackedSession.lastTodoSnapshot = undefined;
|
|
64059
|
+
trackedSession.activitySignalCount = 0;
|
|
64060
|
+
trackedSession.lastObservedActivitySignalCount = undefined;
|
|
64041
64061
|
}
|
|
64042
64062
|
function cancelCountdown(sessionID) {
|
|
64043
64063
|
const tracked = sessions.get(sessionID);
|
|
@@ -64074,6 +64094,7 @@ function createSessionStateStore() {
|
|
|
64074
64094
|
return {
|
|
64075
64095
|
getState,
|
|
64076
64096
|
getExistingState,
|
|
64097
|
+
recordActivity,
|
|
64077
64098
|
trackContinuationProgress,
|
|
64078
64099
|
resetContinuationProgress,
|
|
64079
64100
|
cancelCountdown,
|
|
@@ -82148,11 +82169,13 @@ async function applyFallbackToChatMessage(params) {
|
|
|
82148
82169
|
var RETRYABLE_ERROR_NAMES = new Set([
|
|
82149
82170
|
"providermodelnotfounderror",
|
|
82150
82171
|
"ratelimiterror",
|
|
82151
|
-
"quotaexceedederror",
|
|
82152
|
-
"insufficientcreditserror",
|
|
82153
82172
|
"modelunavailableerror",
|
|
82154
82173
|
"providerconnectionerror",
|
|
82155
|
-
"authenticationerror"
|
|
82174
|
+
"authenticationerror"
|
|
82175
|
+
]);
|
|
82176
|
+
var STOP_ERROR_NAMES = new Set([
|
|
82177
|
+
"quotaexceedederror",
|
|
82178
|
+
"insufficientcreditserror",
|
|
82156
82179
|
"freeusagelimiterror"
|
|
82157
82180
|
]);
|
|
82158
82181
|
var NON_RETRYABLE_ERROR_NAMES = new Set([
|
|
@@ -82223,6 +82246,9 @@ function isRetryableModelError(error48) {
|
|
|
82223
82246
|
if (NON_RETRYABLE_ERROR_NAMES.has(errorNameLower)) {
|
|
82224
82247
|
return false;
|
|
82225
82248
|
}
|
|
82249
|
+
if (STOP_ERROR_NAMES.has(errorNameLower)) {
|
|
82250
|
+
return false;
|
|
82251
|
+
}
|
|
82226
82252
|
if (RETRYABLE_ERROR_NAMES.has(errorNameLower)) {
|
|
82227
82253
|
return true;
|
|
82228
82254
|
}
|
|
@@ -84390,11 +84416,12 @@ import { fileURLToPath as fileURLToPath2 } from "url";
|
|
|
84390
84416
|
// src/hooks/auto-update-checker/constants.ts
|
|
84391
84417
|
import * as path5 from "path";
|
|
84392
84418
|
import * as os4 from "os";
|
|
84393
|
-
var PACKAGE_NAME = "oh-my-
|
|
84419
|
+
var PACKAGE_NAME = "oh-my-openagent";
|
|
84394
84420
|
var NPM_REGISTRY_URL = `https://registry.npmjs.org/-/package/${PACKAGE_NAME}/dist-tags`;
|
|
84395
84421
|
var NPM_FETCH_TIMEOUT = 5000;
|
|
84396
|
-
var
|
|
84397
|
-
var
|
|
84422
|
+
var CACHE_ROOT_DIR = getOpenCodeCacheDir();
|
|
84423
|
+
var CACHE_DIR = path5.join(CACHE_ROOT_DIR, "packages");
|
|
84424
|
+
var VERSION_FILE = path5.join(CACHE_ROOT_DIR, "version");
|
|
84398
84425
|
function getWindowsAppdataDir2() {
|
|
84399
84426
|
if (process.platform !== "win32")
|
|
84400
84427
|
return null;
|
|
@@ -84642,11 +84669,28 @@ function getIntentVersion(pluginInfo) {
|
|
|
84642
84669
|
}
|
|
84643
84670
|
return pluginInfo.pinnedVersion;
|
|
84644
84671
|
}
|
|
84672
|
+
function writeCachePackageJson(cachePackageJsonPath, pkgJson) {
|
|
84673
|
+
const tmpPath = `${cachePackageJsonPath}.${crypto2.randomUUID()}`;
|
|
84674
|
+
try {
|
|
84675
|
+
fs12.mkdirSync(path9.dirname(cachePackageJsonPath), { recursive: true });
|
|
84676
|
+
fs12.writeFileSync(tmpPath, JSON.stringify(pkgJson, null, 2));
|
|
84677
|
+
fs12.renameSync(tmpPath, cachePackageJsonPath);
|
|
84678
|
+
return { synced: true, error: null };
|
|
84679
|
+
} catch (err) {
|
|
84680
|
+
log("[auto-update-checker] Failed to write cache package.json:", err);
|
|
84681
|
+
safeUnlink(tmpPath);
|
|
84682
|
+
return { synced: false, error: "write_error", message: "Failed to write cache package.json" };
|
|
84683
|
+
}
|
|
84684
|
+
}
|
|
84645
84685
|
function syncCachePackageJsonToIntent(pluginInfo) {
|
|
84646
84686
|
const cachePackageJsonPath = path9.join(CACHE_DIR, "package.json");
|
|
84687
|
+
const intentVersion = getIntentVersion(pluginInfo);
|
|
84647
84688
|
if (!fs12.existsSync(cachePackageJsonPath)) {
|
|
84648
|
-
log("[auto-update-checker] Cache package.json
|
|
84649
|
-
return {
|
|
84689
|
+
log("[auto-update-checker] Cache package.json missing, creating workspace package.json", { intentVersion });
|
|
84690
|
+
return {
|
|
84691
|
+
...writeCachePackageJson(cachePackageJsonPath, { dependencies: { [PACKAGE_NAME]: intentVersion } }),
|
|
84692
|
+
message: `Created cache package.json with: ${intentVersion}`
|
|
84693
|
+
};
|
|
84650
84694
|
}
|
|
84651
84695
|
let content;
|
|
84652
84696
|
let pkgJson;
|
|
@@ -84663,11 +84707,20 @@ function syncCachePackageJsonToIntent(pluginInfo) {
|
|
|
84663
84707
|
return { synced: false, error: "parse_error", message: "Failed to parse cache package.json (malformed JSON)" };
|
|
84664
84708
|
}
|
|
84665
84709
|
if (!pkgJson || !pkgJson.dependencies?.[PACKAGE_NAME]) {
|
|
84666
|
-
log("[auto-update-checker] Plugin
|
|
84667
|
-
|
|
84710
|
+
log("[auto-update-checker] Plugin missing from cache package.json dependencies, adding dependency", { intentVersion });
|
|
84711
|
+
const nextPkgJson = {
|
|
84712
|
+
...pkgJson ?? {},
|
|
84713
|
+
dependencies: {
|
|
84714
|
+
...pkgJson?.dependencies ?? {},
|
|
84715
|
+
[PACKAGE_NAME]: intentVersion
|
|
84716
|
+
}
|
|
84717
|
+
};
|
|
84718
|
+
return {
|
|
84719
|
+
...writeCachePackageJson(cachePackageJsonPath, nextPkgJson),
|
|
84720
|
+
message: `Added ${PACKAGE_NAME}: ${intentVersion}`
|
|
84721
|
+
};
|
|
84668
84722
|
}
|
|
84669
84723
|
const currentVersion = pkgJson.dependencies[PACKAGE_NAME];
|
|
84670
|
-
const intentVersion = getIntentVersion(pluginInfo);
|
|
84671
84724
|
if (currentVersion === intentVersion) {
|
|
84672
84725
|
log("[auto-update-checker] Cache package.json already matches intent:", intentVersion);
|
|
84673
84726
|
return { synced: false, error: null, message: `Already matches intent: ${intentVersion}` };
|
|
@@ -84680,20 +84733,14 @@ function syncCachePackageJsonToIntent(pluginInfo) {
|
|
|
84680
84733
|
log(`[auto-update-checker] Updating cache package.json: "${currentVersion}" \u2192 "${intentVersion}"`);
|
|
84681
84734
|
}
|
|
84682
84735
|
pkgJson.dependencies[PACKAGE_NAME] = intentVersion;
|
|
84683
|
-
|
|
84684
|
-
|
|
84685
|
-
|
|
84686
|
-
|
|
84687
|
-
return { synced: true, error: null, message: `Updated: "${currentVersion}" \u2192 "${intentVersion}"` };
|
|
84688
|
-
} catch (err) {
|
|
84689
|
-
log("[auto-update-checker] Failed to write cache package.json:", err);
|
|
84690
|
-
safeUnlink(tmpPath);
|
|
84691
|
-
return { synced: false, error: "write_error", message: "Failed to write cache package.json" };
|
|
84692
|
-
}
|
|
84736
|
+
return {
|
|
84737
|
+
...writeCachePackageJson(cachePackageJsonPath, pkgJson),
|
|
84738
|
+
message: `Updated: "${currentVersion}" \u2192 "${intentVersion}"`
|
|
84739
|
+
};
|
|
84693
84740
|
}
|
|
84694
84741
|
// src/hooks/auto-update-checker/hook/background-update-check.ts
|
|
84695
84742
|
import { existsSync as existsSync52 } from "fs";
|
|
84696
|
-
import { join as
|
|
84743
|
+
import { join as join56 } from "path";
|
|
84697
84744
|
// src/shared/spawn-with-windows-hide.ts
|
|
84698
84745
|
var {spawn: bunSpawn } = globalThis.Bun;
|
|
84699
84746
|
import { spawn as nodeSpawn } from "child_process";
|
|
@@ -84754,9 +84801,13 @@ function spawnWithWindowsHide(command, options) {
|
|
|
84754
84801
|
}
|
|
84755
84802
|
// src/cli/config-manager/bun-install.ts
|
|
84756
84803
|
import { existsSync as existsSync50 } from "fs";
|
|
84804
|
+
import { join as join54 } from "path";
|
|
84757
84805
|
init_logger();
|
|
84758
84806
|
var BUN_INSTALL_TIMEOUT_SECONDS = 60;
|
|
84759
84807
|
var BUN_INSTALL_TIMEOUT_MS = BUN_INSTALL_TIMEOUT_SECONDS * 1000;
|
|
84808
|
+
function getDefaultWorkspaceDir() {
|
|
84809
|
+
return join54(getOpenCodeCacheDir(), "packages");
|
|
84810
|
+
}
|
|
84760
84811
|
function readProcessOutput(stream) {
|
|
84761
84812
|
if (!stream) {
|
|
84762
84813
|
return Promise.resolve("");
|
|
@@ -84779,7 +84830,7 @@ function logCapturedOutputOnFailure(outputMode, output) {
|
|
|
84779
84830
|
}
|
|
84780
84831
|
async function runBunInstallWithDetails(options) {
|
|
84781
84832
|
const outputMode = options?.outputMode ?? "pipe";
|
|
84782
|
-
const cacheDir = options?.workspaceDir ??
|
|
84833
|
+
const cacheDir = options?.workspaceDir ?? getDefaultWorkspaceDir();
|
|
84783
84834
|
const packageJsonPath = `${cacheDir}/package.json`;
|
|
84784
84835
|
if (!existsSync50(packageJsonPath)) {
|
|
84785
84836
|
return {
|
|
@@ -84938,9 +84989,12 @@ Restart OpenCode to apply.`,
|
|
|
84938
84989
|
}
|
|
84939
84990
|
|
|
84940
84991
|
// src/hooks/auto-update-checker/hook/background-update-check.ts
|
|
84992
|
+
function getCacheWorkspaceDir(deps) {
|
|
84993
|
+
return deps.join(deps.getOpenCodeCacheDir(), "packages");
|
|
84994
|
+
}
|
|
84941
84995
|
var defaultDeps = {
|
|
84942
84996
|
existsSync: existsSync52,
|
|
84943
|
-
join:
|
|
84997
|
+
join: join56,
|
|
84944
84998
|
runBunInstallWithDetails,
|
|
84945
84999
|
log,
|
|
84946
85000
|
getOpenCodeCacheDir,
|
|
@@ -84959,7 +85013,7 @@ function getPinnedVersionToastMessage(latestVersion) {
|
|
|
84959
85013
|
}
|
|
84960
85014
|
function resolveActiveInstallWorkspace(deps) {
|
|
84961
85015
|
const configPaths = deps.getOpenCodeConfigPaths({ binary: "opencode" });
|
|
84962
|
-
const cacheDir = deps
|
|
85016
|
+
const cacheDir = getCacheWorkspaceDir(deps);
|
|
84963
85017
|
const configInstallPath = deps.join(configPaths.configDir, "node_modules", PACKAGE_NAME, "package.json");
|
|
84964
85018
|
const cacheInstallPath = deps.join(cacheDir, "node_modules", PACKAGE_NAME, "package.json");
|
|
84965
85019
|
if (deps.existsSync(configInstallPath)) {
|
|
@@ -84970,6 +85024,11 @@ function resolveActiveInstallWorkspace(deps) {
|
|
|
84970
85024
|
deps.log(`[auto-update-checker] Active workspace: cache-dir (${cacheDir})`);
|
|
84971
85025
|
return cacheDir;
|
|
84972
85026
|
}
|
|
85027
|
+
const cachePackageJsonPath = deps.join(cacheDir, "package.json");
|
|
85028
|
+
if (deps.existsSync(cachePackageJsonPath)) {
|
|
85029
|
+
deps.log(`[auto-update-checker] Active workspace: cache-dir (${cacheDir}, package.json present)`);
|
|
85030
|
+
return cacheDir;
|
|
85031
|
+
}
|
|
84973
85032
|
deps.log(`[auto-update-checker] Active workspace: config-dir (default, no install detected)`);
|
|
84974
85033
|
return configPaths.configDir;
|
|
84975
85034
|
}
|
|
@@ -84986,6 +85045,14 @@ async function runBunInstallSafe(workspaceDir, deps) {
|
|
|
84986
85045
|
return false;
|
|
84987
85046
|
}
|
|
84988
85047
|
}
|
|
85048
|
+
async function primeCacheWorkspace(activeWorkspace, deps) {
|
|
85049
|
+
const cacheWorkspace = getCacheWorkspaceDir(deps);
|
|
85050
|
+
if (activeWorkspace === cacheWorkspace) {
|
|
85051
|
+
return true;
|
|
85052
|
+
}
|
|
85053
|
+
deps.log(`[auto-update-checker] Priming cache workspace after install: ${cacheWorkspace}`);
|
|
85054
|
+
return runBunInstallSafe(cacheWorkspace, deps);
|
|
85055
|
+
}
|
|
84989
85056
|
function createBackgroundUpdateCheckRunner(overrides = {}) {
|
|
84990
85057
|
const deps = { ...defaultDeps, ...overrides };
|
|
84991
85058
|
return async function runBackgroundUpdateCheck(ctx, autoUpdate, getToastMessage) {
|
|
@@ -85031,6 +85098,12 @@ function createBackgroundUpdateCheckRunner(overrides = {}) {
|
|
|
85031
85098
|
const activeWorkspace = resolveActiveInstallWorkspace(deps);
|
|
85032
85099
|
const installSuccess = await runBunInstallSafe(activeWorkspace, deps);
|
|
85033
85100
|
if (installSuccess) {
|
|
85101
|
+
const cachePrimed = await primeCacheWorkspace(activeWorkspace, deps);
|
|
85102
|
+
if (!cachePrimed) {
|
|
85103
|
+
await deps.showUpdateAvailableToast(ctx, latestVersion, getToastMessage);
|
|
85104
|
+
deps.log("[auto-update-checker] cache workspace priming failed after install");
|
|
85105
|
+
return;
|
|
85106
|
+
}
|
|
85034
85107
|
await deps.showAutoUpdatedToast(ctx, currentVersion, latestVersion);
|
|
85035
85108
|
deps.log(`[auto-update-checker] Update installed: ${currentVersion} \u2192 ${latestVersion}`);
|
|
85036
85109
|
return;
|
|
@@ -85243,16 +85316,16 @@ v${latestVersion} available. Restart OpenCode to apply.` : "OpenCode is now on S
|
|
|
85243
85316
|
// src/hooks/agent-usage-reminder/storage.ts
|
|
85244
85317
|
import {
|
|
85245
85318
|
existsSync as existsSync53,
|
|
85246
|
-
mkdirSync as
|
|
85319
|
+
mkdirSync as mkdirSync12,
|
|
85247
85320
|
readFileSync as readFileSync35,
|
|
85248
85321
|
writeFileSync as writeFileSync15,
|
|
85249
85322
|
unlinkSync as unlinkSync8
|
|
85250
85323
|
} from "fs";
|
|
85251
|
-
import { join as
|
|
85324
|
+
import { join as join58 } from "path";
|
|
85252
85325
|
|
|
85253
85326
|
// src/hooks/agent-usage-reminder/constants.ts
|
|
85254
|
-
import { join as
|
|
85255
|
-
var AGENT_USAGE_REMINDER_STORAGE =
|
|
85327
|
+
import { join as join57 } from "path";
|
|
85328
|
+
var AGENT_USAGE_REMINDER_STORAGE = join57(OPENCODE_STORAGE, "agent-usage-reminder");
|
|
85256
85329
|
var TARGET_TOOLS = new Set([
|
|
85257
85330
|
"grep",
|
|
85258
85331
|
"safe_grep",
|
|
@@ -85298,7 +85371,7 @@ ALWAYS prefer: Multiple parallel task calls > Direct tool calls
|
|
|
85298
85371
|
|
|
85299
85372
|
// src/hooks/agent-usage-reminder/storage.ts
|
|
85300
85373
|
function getStoragePath2(sessionID) {
|
|
85301
|
-
return
|
|
85374
|
+
return join58(AGENT_USAGE_REMINDER_STORAGE, `${sessionID}.json`);
|
|
85302
85375
|
}
|
|
85303
85376
|
function loadAgentUsageState(sessionID) {
|
|
85304
85377
|
const filePath = getStoragePath2(sessionID);
|
|
@@ -85313,7 +85386,7 @@ function loadAgentUsageState(sessionID) {
|
|
|
85313
85386
|
}
|
|
85314
85387
|
function saveAgentUsageState(state3) {
|
|
85315
85388
|
if (!existsSync53(AGENT_USAGE_REMINDER_STORAGE)) {
|
|
85316
|
-
|
|
85389
|
+
mkdirSync12(AGENT_USAGE_REMINDER_STORAGE, { recursive: true });
|
|
85317
85390
|
}
|
|
85318
85391
|
const filePath = getStoragePath2(state3.sessionID);
|
|
85319
85392
|
writeFileSync15(filePath, JSON.stringify(state3, null, 2));
|
|
@@ -86596,16 +86669,16 @@ function createNonInteractiveEnvHook(_ctx) {
|
|
|
86596
86669
|
// src/hooks/interactive-bash-session/storage.ts
|
|
86597
86670
|
import {
|
|
86598
86671
|
existsSync as existsSync54,
|
|
86599
|
-
mkdirSync as
|
|
86672
|
+
mkdirSync as mkdirSync13,
|
|
86600
86673
|
readFileSync as readFileSync36,
|
|
86601
86674
|
writeFileSync as writeFileSync16,
|
|
86602
86675
|
unlinkSync as unlinkSync9
|
|
86603
86676
|
} from "fs";
|
|
86604
|
-
import { join as
|
|
86677
|
+
import { join as join60 } from "path";
|
|
86605
86678
|
|
|
86606
86679
|
// src/hooks/interactive-bash-session/constants.ts
|
|
86607
|
-
import { join as
|
|
86608
|
-
var INTERACTIVE_BASH_SESSION_STORAGE =
|
|
86680
|
+
import { join as join59 } from "path";
|
|
86681
|
+
var INTERACTIVE_BASH_SESSION_STORAGE = join59(OPENCODE_STORAGE, "interactive-bash-session");
|
|
86609
86682
|
var OMO_SESSION_PREFIX = "omo-";
|
|
86610
86683
|
function buildSessionReminderMessage(sessions) {
|
|
86611
86684
|
if (sessions.length === 0)
|
|
@@ -86617,7 +86690,7 @@ function buildSessionReminderMessage(sessions) {
|
|
|
86617
86690
|
|
|
86618
86691
|
// src/hooks/interactive-bash-session/storage.ts
|
|
86619
86692
|
function getStoragePath3(sessionID) {
|
|
86620
|
-
return
|
|
86693
|
+
return join60(INTERACTIVE_BASH_SESSION_STORAGE, `${sessionID}.json`);
|
|
86621
86694
|
}
|
|
86622
86695
|
function loadInteractiveBashSessionState(sessionID) {
|
|
86623
86696
|
const filePath = getStoragePath3(sessionID);
|
|
@@ -86637,7 +86710,7 @@ function loadInteractiveBashSessionState(sessionID) {
|
|
|
86637
86710
|
}
|
|
86638
86711
|
function saveInteractiveBashSessionState(state3) {
|
|
86639
86712
|
if (!existsSync54(INTERACTIVE_BASH_SESSION_STORAGE)) {
|
|
86640
|
-
|
|
86713
|
+
mkdirSync13(INTERACTIVE_BASH_SESSION_STORAGE, { recursive: true });
|
|
86641
86714
|
}
|
|
86642
86715
|
const filePath = getStoragePath3(state3.sessionID);
|
|
86643
86716
|
const serialized = {
|
|
@@ -87155,10 +87228,10 @@ var DEFAULT_MAX_ITERATIONS = 100;
|
|
|
87155
87228
|
var DEFAULT_COMPLETION_PROMISE = "DONE";
|
|
87156
87229
|
var ULTRAWORK_VERIFICATION_PROMISE = "VERIFIED";
|
|
87157
87230
|
// src/hooks/ralph-loop/storage.ts
|
|
87158
|
-
import { existsSync as existsSync55, readFileSync as readFileSync37, writeFileSync as writeFileSync17, unlinkSync as unlinkSync10, mkdirSync as
|
|
87159
|
-
import { dirname as
|
|
87231
|
+
import { existsSync as existsSync55, readFileSync as readFileSync37, writeFileSync as writeFileSync17, unlinkSync as unlinkSync10, mkdirSync as mkdirSync14 } from "fs";
|
|
87232
|
+
import { dirname as dirname15, join as join61 } from "path";
|
|
87160
87233
|
function getStateFilePath(directory, customPath) {
|
|
87161
|
-
return customPath ?
|
|
87234
|
+
return customPath ? join61(directory, customPath) : join61(directory, DEFAULT_STATE_FILE);
|
|
87162
87235
|
}
|
|
87163
87236
|
function readState(directory, customPath) {
|
|
87164
87237
|
const filePath = getStateFilePath(directory, customPath);
|
|
@@ -87207,9 +87280,9 @@ function readState(directory, customPath) {
|
|
|
87207
87280
|
function writeState(directory, state3, customPath) {
|
|
87208
87281
|
const filePath = getStateFilePath(directory, customPath);
|
|
87209
87282
|
try {
|
|
87210
|
-
const dir =
|
|
87283
|
+
const dir = dirname15(filePath);
|
|
87211
87284
|
if (!existsSync55(dir)) {
|
|
87212
|
-
|
|
87285
|
+
mkdirSync14(dir, { recursive: true });
|
|
87213
87286
|
}
|
|
87214
87287
|
const sessionIdLine = state3.session_id ? `session_id: "${state3.session_id}"
|
|
87215
87288
|
` : "";
|
|
@@ -88336,9 +88409,9 @@ function findSlashCommandPartIndex(parts) {
|
|
|
88336
88409
|
return -1;
|
|
88337
88410
|
}
|
|
88338
88411
|
// src/hooks/auto-slash-command/executor.ts
|
|
88339
|
-
import { dirname as
|
|
88412
|
+
import { dirname as dirname18 } from "path";
|
|
88340
88413
|
// src/features/opencode-skill-loader/loader.ts
|
|
88341
|
-
import { join as
|
|
88414
|
+
import { join as join64 } from "path";
|
|
88342
88415
|
import { homedir as homedir11 } from "os";
|
|
88343
88416
|
|
|
88344
88417
|
// src/features/opencode-skill-loader/skill-definition-record.ts
|
|
@@ -88366,7 +88439,7 @@ function deduplicateSkillsByName(skills) {
|
|
|
88366
88439
|
|
|
88367
88440
|
// src/features/opencode-skill-loader/skill-directory-loader.ts
|
|
88368
88441
|
import { promises as fs16 } from "fs";
|
|
88369
|
-
import { join as
|
|
88442
|
+
import { join as join63 } from "path";
|
|
88370
88443
|
|
|
88371
88444
|
// src/features/opencode-skill-loader/loaded-skill-from-path.ts
|
|
88372
88445
|
import { promises as fs15 } from "fs";
|
|
@@ -88384,7 +88457,7 @@ function parseAllowedTools(allowedTools) {
|
|
|
88384
88457
|
|
|
88385
88458
|
// src/features/opencode-skill-loader/skill-mcp-config.ts
|
|
88386
88459
|
import { promises as fs14 } from "fs";
|
|
88387
|
-
import { join as
|
|
88460
|
+
import { join as join62 } from "path";
|
|
88388
88461
|
function parseSkillMcpConfigFromFrontmatter(content) {
|
|
88389
88462
|
const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
88390
88463
|
if (!frontmatterMatch)
|
|
@@ -88400,7 +88473,7 @@ function parseSkillMcpConfigFromFrontmatter(content) {
|
|
|
88400
88473
|
return;
|
|
88401
88474
|
}
|
|
88402
88475
|
async function loadMcpJsonFromDir(skillDir) {
|
|
88403
|
-
const mcpJsonPath =
|
|
88476
|
+
const mcpJsonPath = join62(skillDir, "mcp.json");
|
|
88404
88477
|
try {
|
|
88405
88478
|
const content = await fs14.readFile(mcpJsonPath, "utf-8");
|
|
88406
88479
|
const parsed = JSON.parse(content);
|
|
@@ -88489,10 +88562,10 @@ async function loadSkillsFromDir(options) {
|
|
|
88489
88562
|
const directories = entries.filter((entry) => !entry.name.startsWith(".") && (entry.isDirectory() || entry.isSymbolicLink()));
|
|
88490
88563
|
const files = entries.filter((entry) => !entry.name.startsWith(".") && !entry.isDirectory() && !entry.isSymbolicLink() && isMarkdownFile(entry));
|
|
88491
88564
|
for (const entry of directories) {
|
|
88492
|
-
const entryPath =
|
|
88565
|
+
const entryPath = join63(options.skillsDir, entry.name);
|
|
88493
88566
|
const resolvedPath = await resolveSymlinkAsync(entryPath);
|
|
88494
88567
|
const dirName = entry.name;
|
|
88495
|
-
const skillMdPath =
|
|
88568
|
+
const skillMdPath = join63(resolvedPath, "SKILL.md");
|
|
88496
88569
|
try {
|
|
88497
88570
|
await fs16.access(skillMdPath);
|
|
88498
88571
|
const skill = await loadSkillFromPath({
|
|
@@ -88507,7 +88580,7 @@ async function loadSkillsFromDir(options) {
|
|
|
88507
88580
|
}
|
|
88508
88581
|
continue;
|
|
88509
88582
|
} catch {}
|
|
88510
|
-
const namedSkillMdPath =
|
|
88583
|
+
const namedSkillMdPath = join63(resolvedPath, `${dirName}.md`);
|
|
88511
88584
|
try {
|
|
88512
88585
|
await fs16.access(namedSkillMdPath);
|
|
88513
88586
|
const skill = await loadSkillFromPath({
|
|
@@ -88539,7 +88612,7 @@ async function loadSkillsFromDir(options) {
|
|
|
88539
88612
|
}
|
|
88540
88613
|
}
|
|
88541
88614
|
for (const entry of files) {
|
|
88542
|
-
const entryPath =
|
|
88615
|
+
const entryPath = join63(options.skillsDir, entry.name);
|
|
88543
88616
|
const baseName = inferSkillNameFromFileName(entryPath);
|
|
88544
88617
|
const skill = await loadSkillFromPath({
|
|
88545
88618
|
skillPath: entryPath,
|
|
@@ -88557,7 +88630,7 @@ async function loadSkillsFromDir(options) {
|
|
|
88557
88630
|
|
|
88558
88631
|
// src/features/opencode-skill-loader/loader.ts
|
|
88559
88632
|
async function loadUserSkills() {
|
|
88560
|
-
const userSkillsDir =
|
|
88633
|
+
const userSkillsDir = join64(getClaudeConfigDir(), "skills");
|
|
88561
88634
|
const skills = await loadSkillsFromDir({ skillsDir: userSkillsDir, scope: "user" });
|
|
88562
88635
|
return skillsToCommandDefinitionRecord(skills);
|
|
88563
88636
|
}
|
|
@@ -88582,7 +88655,7 @@ async function loadProjectAgentsSkills(directory) {
|
|
|
88582
88655
|
return skillsToCommandDefinitionRecord(deduplicateSkillsByName(allSkills.flat()));
|
|
88583
88656
|
}
|
|
88584
88657
|
async function loadGlobalAgentsSkills() {
|
|
88585
|
-
const agentsGlobalDir =
|
|
88658
|
+
const agentsGlobalDir = join64(homedir11(), ".agents", "skills");
|
|
88586
88659
|
const skills = await loadSkillsFromDir({ skillsDir: agentsGlobalDir, scope: "user" });
|
|
88587
88660
|
return skillsToCommandDefinitionRecord(skills);
|
|
88588
88661
|
}
|
|
@@ -88629,7 +88702,7 @@ async function discoverSkills(options = {}) {
|
|
|
88629
88702
|
]);
|
|
88630
88703
|
}
|
|
88631
88704
|
async function discoverUserClaudeSkills() {
|
|
88632
|
-
const userSkillsDir =
|
|
88705
|
+
const userSkillsDir = join64(getClaudeConfigDir(), "skills");
|
|
88633
88706
|
return loadSkillsFromDir({ skillsDir: userSkillsDir, scope: "user" });
|
|
88634
88707
|
}
|
|
88635
88708
|
async function discoverProjectClaudeSkills(directory) {
|
|
@@ -88653,7 +88726,7 @@ async function discoverProjectAgentsSkills(directory) {
|
|
|
88653
88726
|
return deduplicateSkillsByName(allSkills.flat());
|
|
88654
88727
|
}
|
|
88655
88728
|
async function discoverGlobalAgentsSkills() {
|
|
88656
|
-
const agentsGlobalDir =
|
|
88729
|
+
const agentsGlobalDir = join64(homedir11(), ".agents", "skills");
|
|
88657
88730
|
return loadSkillsFromDir({ skillsDir: agentsGlobalDir, scope: "user" });
|
|
88658
88731
|
}
|
|
88659
88732
|
// src/features/opencode-skill-loader/merger/builtin-skill-converter.ts
|
|
@@ -88681,7 +88754,7 @@ function builtinToLoadedSkill(builtin) {
|
|
|
88681
88754
|
|
|
88682
88755
|
// src/features/opencode-skill-loader/merger/config-skill-entry-loader.ts
|
|
88683
88756
|
import { existsSync as existsSync57, readFileSync as readFileSync39 } from "fs";
|
|
88684
|
-
import { dirname as
|
|
88757
|
+
import { dirname as dirname16, isAbsolute as isAbsolute7, resolve as resolve10 } from "path";
|
|
88685
88758
|
import { homedir as homedir12 } from "os";
|
|
88686
88759
|
init_logger();
|
|
88687
88760
|
function resolveFilePath5(from, configDir) {
|
|
@@ -88736,7 +88809,7 @@ function configEntryToLoadedSkill(name, entry, configDir) {
|
|
|
88736
88809
|
return null;
|
|
88737
88810
|
}
|
|
88738
88811
|
const description = entry.description || fileMetadata.description || "";
|
|
88739
|
-
const resolvedPath = sourcePath ?
|
|
88812
|
+
const resolvedPath = sourcePath ? dirname16(sourcePath) : configDir || process.cwd();
|
|
88740
88813
|
const resolvedTemplate = resolveSkillPathReferences(template.trim(), resolvedPath);
|
|
88741
88814
|
const wrappedTemplate = `<skill-instruction>
|
|
88742
88815
|
Base directory for this skill: ${resolvedPath}/
|
|
@@ -92467,7 +92540,7 @@ async function resolveMultipleSkillsAsync(skillNames, options) {
|
|
|
92467
92540
|
var import_picomatch2 = __toESM(require_picomatch2(), 1);
|
|
92468
92541
|
import { promises as fs17 } from "fs";
|
|
92469
92542
|
import { homedir as homedir13 } from "os";
|
|
92470
|
-
import { dirname as
|
|
92543
|
+
import { dirname as dirname17, extname, isAbsolute as isAbsolute8, join as join65, relative as relative6 } from "path";
|
|
92471
92544
|
var MAX_RECURSIVE_DEPTH = 10;
|
|
92472
92545
|
function isHttpUrl(path11) {
|
|
92473
92546
|
return path11.startsWith("http://") || path11.startsWith("https://");
|
|
@@ -92477,12 +92550,12 @@ function toAbsolutePath(path11, configDir) {
|
|
|
92477
92550
|
return homedir13();
|
|
92478
92551
|
}
|
|
92479
92552
|
if (path11.startsWith("~/")) {
|
|
92480
|
-
return
|
|
92553
|
+
return join65(homedir13(), path11.slice(2));
|
|
92481
92554
|
}
|
|
92482
92555
|
if (isAbsolute8(path11)) {
|
|
92483
92556
|
return path11;
|
|
92484
92557
|
}
|
|
92485
|
-
return
|
|
92558
|
+
return join65(configDir, path11);
|
|
92486
92559
|
}
|
|
92487
92560
|
function isMarkdownPath(path11) {
|
|
92488
92561
|
return extname(path11).toLowerCase() === ".md";
|
|
@@ -92513,13 +92586,13 @@ async function loadSourcePath(options) {
|
|
|
92513
92586
|
return [];
|
|
92514
92587
|
const loaded = await loadSkillFromPath({
|
|
92515
92588
|
skillPath: absolutePath,
|
|
92516
|
-
resolvedPath:
|
|
92589
|
+
resolvedPath: dirname17(absolutePath),
|
|
92517
92590
|
defaultName: inferSkillNameFromFileName(absolutePath),
|
|
92518
92591
|
scope: "config"
|
|
92519
92592
|
});
|
|
92520
92593
|
if (!loaded)
|
|
92521
92594
|
return [];
|
|
92522
|
-
return filterByGlob([loaded],
|
|
92595
|
+
return filterByGlob([loaded], dirname17(absolutePath), options.globPattern);
|
|
92523
92596
|
}
|
|
92524
92597
|
if (!stat.isDirectory())
|
|
92525
92598
|
return [];
|
|
@@ -92553,7 +92626,7 @@ async function discoverConfigSourceSkills(options) {
|
|
|
92553
92626
|
}
|
|
92554
92627
|
// src/tools/slashcommand/command-discovery.ts
|
|
92555
92628
|
import { existsSync as existsSync58, readdirSync as readdirSync15, readFileSync as readFileSync41, statSync as statSync6 } from "fs";
|
|
92556
|
-
import { basename as basename7, join as
|
|
92629
|
+
import { basename as basename7, join as join66 } from "path";
|
|
92557
92630
|
// src/features/builtin-commands/templates/init-deep.ts
|
|
92558
92631
|
var INIT_DEEP_TEMPLATE = `# /init-deep
|
|
92559
92632
|
|
|
@@ -94104,12 +94177,12 @@ function discoverCommandsFromDir(commandsDir, scope, prefix = "") {
|
|
|
94104
94177
|
if (entry.name.startsWith("."))
|
|
94105
94178
|
continue;
|
|
94106
94179
|
const nestedPrefix = prefix ? `${prefix}${NESTED_COMMAND_SEPARATOR}${entry.name}` : entry.name;
|
|
94107
|
-
commands3.push(...discoverCommandsFromDir(
|
|
94180
|
+
commands3.push(...discoverCommandsFromDir(join66(commandsDir, entry.name), scope, nestedPrefix));
|
|
94108
94181
|
continue;
|
|
94109
94182
|
}
|
|
94110
94183
|
if (!isMarkdownFile(entry))
|
|
94111
94184
|
continue;
|
|
94112
|
-
const commandPath =
|
|
94185
|
+
const commandPath = join66(commandsDir, entry.name);
|
|
94113
94186
|
const baseCommandName = basename7(entry.name, ".md");
|
|
94114
94187
|
const commandName = prefix ? `${prefix}${NESTED_COMMAND_SEPARATOR}${baseCommandName}` : baseCommandName;
|
|
94115
94188
|
try {
|
|
@@ -94165,8 +94238,8 @@ function deduplicateCommandInfosByName(commands3) {
|
|
|
94165
94238
|
return deduplicatedCommands;
|
|
94166
94239
|
}
|
|
94167
94240
|
function discoverCommandsSync(directory, options) {
|
|
94168
|
-
const userCommandsDir =
|
|
94169
|
-
const projectCommandsDir =
|
|
94241
|
+
const userCommandsDir = join66(getClaudeConfigDir(), "commands");
|
|
94242
|
+
const projectCommandsDir = join66(directory ?? process.cwd(), ".claude", "commands");
|
|
94170
94243
|
const opencodeGlobalDirs = getOpenCodeCommandDirs({ binary: "opencode" });
|
|
94171
94244
|
const opencodeProjectDirs = findProjectOpencodeCommandDirs(directory ?? process.cwd());
|
|
94172
94245
|
const userCommands = discoverCommandsFromDir(userCommandsDir, "user");
|
|
@@ -94269,7 +94342,7 @@ async function formatCommandTemplate(cmd, args) {
|
|
|
94269
94342
|
if (!content && cmd.lazyContentLoader) {
|
|
94270
94343
|
content = await cmd.lazyContentLoader.load();
|
|
94271
94344
|
}
|
|
94272
|
-
const commandDir = cmd.path ?
|
|
94345
|
+
const commandDir = cmd.path ? dirname18(cmd.path) : process.cwd();
|
|
94273
94346
|
const withFileRefs = await resolveFileReferencesInText(content, commandDir);
|
|
94274
94347
|
const resolvedContent = await resolveCommandsInText(withFileRefs);
|
|
94275
94348
|
const resolvedArguments = args;
|
|
@@ -94651,11 +94724,11 @@ var NOTEPAD_DIR = "notepads";
|
|
|
94651
94724
|
var NOTEPAD_BASE_PATH = `${BOULDER_DIR}/${NOTEPAD_DIR}`;
|
|
94652
94725
|
var PROMETHEUS_PLANS_DIR = ".sisyphus/plans";
|
|
94653
94726
|
// src/features/boulder-state/storage.ts
|
|
94654
|
-
import { existsSync as existsSync59, readFileSync as readFileSync42, writeFileSync as writeFileSync18, mkdirSync as
|
|
94655
|
-
import { dirname as
|
|
94727
|
+
import { existsSync as existsSync59, readFileSync as readFileSync42, writeFileSync as writeFileSync18, mkdirSync as mkdirSync15, readdirSync as readdirSync16 } from "fs";
|
|
94728
|
+
import { dirname as dirname19, join as join67, basename as basename8 } from "path";
|
|
94656
94729
|
var RESERVED_KEYS = new Set(["__proto__", "prototype", "constructor"]);
|
|
94657
94730
|
function getBoulderFilePath(directory) {
|
|
94658
|
-
return
|
|
94731
|
+
return join67(directory, BOULDER_DIR, BOULDER_FILE);
|
|
94659
94732
|
}
|
|
94660
94733
|
function readBoulderState(directory) {
|
|
94661
94734
|
const filePath = getBoulderFilePath(directory);
|
|
@@ -94682,9 +94755,9 @@ function readBoulderState(directory) {
|
|
|
94682
94755
|
function writeBoulderState(directory, state3) {
|
|
94683
94756
|
const filePath = getBoulderFilePath(directory);
|
|
94684
94757
|
try {
|
|
94685
|
-
const dir =
|
|
94758
|
+
const dir = dirname19(filePath);
|
|
94686
94759
|
if (!existsSync59(dir)) {
|
|
94687
|
-
|
|
94760
|
+
mkdirSync15(dir, { recursive: true });
|
|
94688
94761
|
}
|
|
94689
94762
|
writeFileSync18(filePath, JSON.stringify(state3, null, 2), "utf-8");
|
|
94690
94763
|
return true;
|
|
@@ -94754,13 +94827,13 @@ function upsertTaskSessionState(directory, input) {
|
|
|
94754
94827
|
return null;
|
|
94755
94828
|
}
|
|
94756
94829
|
function findPrometheusPlans(directory) {
|
|
94757
|
-
const plansDir =
|
|
94830
|
+
const plansDir = join67(directory, PROMETHEUS_PLANS_DIR);
|
|
94758
94831
|
if (!existsSync59(plansDir)) {
|
|
94759
94832
|
return [];
|
|
94760
94833
|
}
|
|
94761
94834
|
try {
|
|
94762
94835
|
const files = readdirSync16(plansDir);
|
|
94763
|
-
return files.filter((f) => f.endsWith(".md")).map((f) =>
|
|
94836
|
+
return files.filter((f) => f.endsWith(".md")).map((f) => join67(plansDir, f)).sort((a, b) => {
|
|
94764
94837
|
const aStat = __require("fs").statSync(a);
|
|
94765
94838
|
const bStat = __require("fs").statSync(b);
|
|
94766
94839
|
return bStat.mtimeMs - aStat.mtimeMs;
|
|
@@ -98049,11 +98122,11 @@ import * as path11 from "path";
|
|
|
98049
98122
|
// src/shared/migrate-legacy-config-file.ts
|
|
98050
98123
|
init_logger();
|
|
98051
98124
|
import { existsSync as existsSync62, readFileSync as readFileSync45, renameSync as renameSync4, rmSync as rmSync3 } from "fs";
|
|
98052
|
-
import { join as
|
|
98125
|
+
import { join as join68, dirname as dirname20, basename as basename9 } from "path";
|
|
98053
98126
|
function buildCanonicalPath(legacyPath) {
|
|
98054
|
-
const dir =
|
|
98127
|
+
const dir = dirname20(legacyPath);
|
|
98055
98128
|
const ext = basename9(legacyPath).includes(".jsonc") ? ".jsonc" : ".json";
|
|
98056
|
-
return
|
|
98129
|
+
return join68(dir, `${CONFIG_BASENAME}${ext}`);
|
|
98057
98130
|
}
|
|
98058
98131
|
function archiveLegacyConfigFile(legacyPath) {
|
|
98059
98132
|
const backupPath = `${legacyPath}.bak`;
|
|
@@ -99570,7 +99643,7 @@ function createRuntimeFallbackHook(ctx, options) {
|
|
|
99570
99643
|
}
|
|
99571
99644
|
// src/hooks/write-existing-file-guard/hook.ts
|
|
99572
99645
|
import { existsSync as existsSync65, realpathSync as realpathSync7 } from "fs";
|
|
99573
|
-
import { basename as basename11, dirname as
|
|
99646
|
+
import { basename as basename11, dirname as dirname22, isAbsolute as isAbsolute10, join as join70, normalize as normalize2, relative as relative8, resolve as resolve12 } from "path";
|
|
99574
99647
|
|
|
99575
99648
|
// src/hooks/write-existing-file-guard/tool-execute-before-handler.ts
|
|
99576
99649
|
import { existsSync as existsSync64 } from "fs";
|
|
@@ -99743,9 +99816,9 @@ function toCanonicalPath2(absolutePath) {
|
|
|
99743
99816
|
canonicalPath = absolutePath;
|
|
99744
99817
|
}
|
|
99745
99818
|
} else {
|
|
99746
|
-
const absoluteDir =
|
|
99819
|
+
const absoluteDir = dirname22(absolutePath);
|
|
99747
99820
|
const resolvedDir = existsSync65(absoluteDir) ? realpathSync7.native(absoluteDir) : absoluteDir;
|
|
99748
|
-
canonicalPath =
|
|
99821
|
+
canonicalPath = join70(resolvedDir, basename11(absolutePath));
|
|
99749
99822
|
}
|
|
99750
99823
|
return normalize2(canonicalPath);
|
|
99751
99824
|
}
|
|
@@ -100761,11 +100834,11 @@ init_logger();
|
|
|
100761
100834
|
|
|
100762
100835
|
// src/hooks/legacy-plugin-toast/auto-migrate.ts
|
|
100763
100836
|
import { existsSync as existsSync66, readFileSync as readFileSync47 } from "fs";
|
|
100764
|
-
import { join as
|
|
100837
|
+
import { join as join71 } from "path";
|
|
100765
100838
|
function detectOpenCodeConfigPath(overrideConfigDir) {
|
|
100766
100839
|
if (overrideConfigDir) {
|
|
100767
|
-
const jsoncPath =
|
|
100768
|
-
const jsonPath =
|
|
100840
|
+
const jsoncPath = join71(overrideConfigDir, "opencode.jsonc");
|
|
100841
|
+
const jsonPath = join71(overrideConfigDir, "opencode.json");
|
|
100769
100842
|
if (existsSync66(jsoncPath))
|
|
100770
100843
|
return jsoncPath;
|
|
100771
100844
|
if (existsSync66(jsonPath))
|
|
@@ -101179,7 +101252,7 @@ var DEFAULT_MAX_DIAGNOSTICS = 200;
|
|
|
101179
101252
|
var DEFAULT_MAX_DIRECTORY_FILES = 50;
|
|
101180
101253
|
// src/tools/lsp/server-config-loader.ts
|
|
101181
101254
|
import { existsSync as existsSync67, readFileSync as readFileSync48 } from "fs";
|
|
101182
|
-
import { join as
|
|
101255
|
+
import { join as join72 } from "path";
|
|
101183
101256
|
function loadJsonFile(path12) {
|
|
101184
101257
|
if (!existsSync67(path12))
|
|
101185
101258
|
return null;
|
|
@@ -101193,9 +101266,9 @@ function getConfigPaths3() {
|
|
|
101193
101266
|
const cwd = process.cwd();
|
|
101194
101267
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
101195
101268
|
return {
|
|
101196
|
-
project: detectPluginConfigFile(
|
|
101269
|
+
project: detectPluginConfigFile(join72(cwd, ".opencode")).path,
|
|
101197
101270
|
user: detectPluginConfigFile(configDir).path,
|
|
101198
|
-
opencode: detectConfigFile(
|
|
101271
|
+
opencode: detectConfigFile(join72(configDir, "opencode")).path
|
|
101199
101272
|
};
|
|
101200
101273
|
}
|
|
101201
101274
|
function loadAllConfigs() {
|
|
@@ -101265,19 +101338,19 @@ function getMergedServers() {
|
|
|
101265
101338
|
|
|
101266
101339
|
// src/tools/lsp/server-installation.ts
|
|
101267
101340
|
import { existsSync as existsSync68 } from "fs";
|
|
101268
|
-
import { delimiter, join as
|
|
101341
|
+
import { delimiter, join as join74 } from "path";
|
|
101269
101342
|
|
|
101270
101343
|
// src/tools/lsp/server-path-bases.ts
|
|
101271
|
-
import { join as
|
|
101344
|
+
import { join as join73 } from "path";
|
|
101272
101345
|
function getLspServerAdditionalPathBases(workingDirectory) {
|
|
101273
101346
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
101274
|
-
const dataDir =
|
|
101347
|
+
const dataDir = join73(getDataDir(), "opencode");
|
|
101275
101348
|
return [
|
|
101276
|
-
|
|
101277
|
-
|
|
101278
|
-
|
|
101279
|
-
|
|
101280
|
-
|
|
101349
|
+
join73(workingDirectory, "node_modules", ".bin"),
|
|
101350
|
+
join73(configDir, "bin"),
|
|
101351
|
+
join73(configDir, "node_modules", ".bin"),
|
|
101352
|
+
join73(dataDir, "bin"),
|
|
101353
|
+
join73(dataDir, "bin", "node_modules", ".bin")
|
|
101281
101354
|
];
|
|
101282
101355
|
}
|
|
101283
101356
|
|
|
@@ -101308,14 +101381,14 @@ function isServerInstalled(command) {
|
|
|
101308
101381
|
const paths = pathEnv.split(delimiter);
|
|
101309
101382
|
for (const p of paths) {
|
|
101310
101383
|
for (const suffix of exts) {
|
|
101311
|
-
if (existsSync68(
|
|
101384
|
+
if (existsSync68(join74(p, cmd + suffix))) {
|
|
101312
101385
|
return true;
|
|
101313
101386
|
}
|
|
101314
101387
|
}
|
|
101315
101388
|
}
|
|
101316
101389
|
for (const base of getLspServerAdditionalPathBases(process.cwd())) {
|
|
101317
101390
|
for (const suffix of exts) {
|
|
101318
|
-
if (existsSync68(
|
|
101391
|
+
if (existsSync68(join74(base, cmd + suffix))) {
|
|
101319
101392
|
return true;
|
|
101320
101393
|
}
|
|
101321
101394
|
}
|
|
@@ -114888,7 +114961,7 @@ import { resolve as resolve16 } from "path";
|
|
|
114888
114961
|
|
|
114889
114962
|
// src/tools/lsp/directory-diagnostics.ts
|
|
114890
114963
|
import { existsSync as existsSync71, lstatSync as lstatSync2, readdirSync as readdirSync17 } from "fs";
|
|
114891
|
-
import { extname as extname6, join as
|
|
114964
|
+
import { extname as extname6, join as join75, resolve as resolve15 } from "path";
|
|
114892
114965
|
var SKIP_DIRECTORIES = new Set(["node_modules", ".git", "dist", "build", ".next", "out"]);
|
|
114893
114966
|
function collectFilesWithExtension(dir, extension, maxFiles) {
|
|
114894
114967
|
const files = [];
|
|
@@ -114904,7 +114977,7 @@ function collectFilesWithExtension(dir, extension, maxFiles) {
|
|
|
114904
114977
|
for (const entry of entries) {
|
|
114905
114978
|
if (files.length >= maxFiles)
|
|
114906
114979
|
return;
|
|
114907
|
-
const fullPath =
|
|
114980
|
+
const fullPath = join75(currentDir, entry);
|
|
114908
114981
|
let stat;
|
|
114909
114982
|
try {
|
|
114910
114983
|
stat = lstatSync2(fullPath);
|
|
@@ -115007,7 +115080,7 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
|
|
|
115007
115080
|
|
|
115008
115081
|
// src/tools/lsp/infer-extension.ts
|
|
115009
115082
|
import { readdirSync as readdirSync18, lstatSync as lstatSync3 } from "fs";
|
|
115010
|
-
import { extname as extname7, join as
|
|
115083
|
+
import { extname as extname7, join as join76 } from "path";
|
|
115011
115084
|
var SKIP_DIRECTORIES2 = new Set(["node_modules", ".git", "dist", "build", ".next", "out"]);
|
|
115012
115085
|
var MAX_SCAN_ENTRIES = 500;
|
|
115013
115086
|
function inferExtensionFromDirectory(directory) {
|
|
@@ -115025,7 +115098,7 @@ function inferExtensionFromDirectory(directory) {
|
|
|
115025
115098
|
for (const entry of entries) {
|
|
115026
115099
|
if (scanned >= MAX_SCAN_ENTRIES)
|
|
115027
115100
|
return;
|
|
115028
|
-
const fullPath =
|
|
115101
|
+
const fullPath = join76(dir, entry);
|
|
115029
115102
|
let stat;
|
|
115030
115103
|
try {
|
|
115031
115104
|
stat = lstatSync3(fullPath);
|
|
@@ -115190,12 +115263,12 @@ var DEFAULT_MAX_MATCHES = 500;
|
|
|
115190
115263
|
|
|
115191
115264
|
// src/tools/ast-grep/sg-cli-path.ts
|
|
115192
115265
|
import { createRequire as createRequire4 } from "module";
|
|
115193
|
-
import { dirname as
|
|
115266
|
+
import { dirname as dirname23, join as join78 } from "path";
|
|
115194
115267
|
import { existsSync as existsSync73, statSync as statSync10 } from "fs";
|
|
115195
115268
|
|
|
115196
115269
|
// src/tools/ast-grep/downloader.ts
|
|
115197
115270
|
import { existsSync as existsSync72 } from "fs";
|
|
115198
|
-
import { join as
|
|
115271
|
+
import { join as join77 } from "path";
|
|
115199
115272
|
import { homedir as homedir14 } from "os";
|
|
115200
115273
|
import { createRequire as createRequire3 } from "module";
|
|
115201
115274
|
init_logger();
|
|
@@ -115222,12 +115295,12 @@ var PLATFORM_MAP2 = {
|
|
|
115222
115295
|
function getCacheDir3() {
|
|
115223
115296
|
if (process.platform === "win32") {
|
|
115224
115297
|
const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA;
|
|
115225
|
-
const base2 = localAppData ||
|
|
115226
|
-
return
|
|
115298
|
+
const base2 = localAppData || join77(homedir14(), "AppData", "Local");
|
|
115299
|
+
return join77(base2, "oh-my-opencode", "bin");
|
|
115227
115300
|
}
|
|
115228
115301
|
const xdgCache = process.env.XDG_CACHE_HOME;
|
|
115229
|
-
const base = xdgCache ||
|
|
115230
|
-
return
|
|
115302
|
+
const base = xdgCache || join77(homedir14(), ".cache");
|
|
115303
|
+
return join77(base, "oh-my-opencode", "bin");
|
|
115231
115304
|
}
|
|
115232
115305
|
function getBinaryName3() {
|
|
115233
115306
|
return process.platform === "win32" ? "sg.exe" : "sg";
|
|
@@ -115244,7 +115317,7 @@ async function downloadAstGrep(version3 = DEFAULT_VERSION) {
|
|
|
115244
115317
|
}
|
|
115245
115318
|
const cacheDir = getCacheDir3();
|
|
115246
115319
|
const binaryName = getBinaryName3();
|
|
115247
|
-
const binaryPath =
|
|
115320
|
+
const binaryPath = join77(cacheDir, binaryName);
|
|
115248
115321
|
if (existsSync72(binaryPath)) {
|
|
115249
115322
|
return binaryPath;
|
|
115250
115323
|
}
|
|
@@ -115253,7 +115326,7 @@ async function downloadAstGrep(version3 = DEFAULT_VERSION) {
|
|
|
115253
115326
|
const downloadUrl = `https://github.com/${REPO2}/releases/download/${version3}/${assetName}`;
|
|
115254
115327
|
log(`[oh-my-opencode] Downloading ast-grep binary...`);
|
|
115255
115328
|
try {
|
|
115256
|
-
const archivePath =
|
|
115329
|
+
const archivePath = join77(cacheDir, assetName);
|
|
115257
115330
|
ensureCacheDir(cacheDir);
|
|
115258
115331
|
await downloadArchive(downloadUrl, archivePath);
|
|
115259
115332
|
await extractZipArchive(archivePath, cacheDir);
|
|
@@ -115306,8 +115379,8 @@ function findSgCliPathSync() {
|
|
|
115306
115379
|
try {
|
|
115307
115380
|
const require2 = createRequire4(import.meta.url);
|
|
115308
115381
|
const cliPackageJsonPath = require2.resolve("@ast-grep/cli/package.json");
|
|
115309
|
-
const cliDirectory =
|
|
115310
|
-
const sgPath =
|
|
115382
|
+
const cliDirectory = dirname23(cliPackageJsonPath);
|
|
115383
|
+
const sgPath = join78(cliDirectory, binaryName);
|
|
115311
115384
|
if (existsSync73(sgPath) && isValidBinary(sgPath)) {
|
|
115312
115385
|
return sgPath;
|
|
115313
115386
|
}
|
|
@@ -115317,9 +115390,9 @@ function findSgCliPathSync() {
|
|
|
115317
115390
|
try {
|
|
115318
115391
|
const require2 = createRequire4(import.meta.url);
|
|
115319
115392
|
const packageJsonPath = require2.resolve(`${platformPackage}/package.json`);
|
|
115320
|
-
const packageDirectory =
|
|
115393
|
+
const packageDirectory = dirname23(packageJsonPath);
|
|
115321
115394
|
const astGrepBinaryName = process.platform === "win32" ? "ast-grep.exe" : "ast-grep";
|
|
115322
|
-
const binaryPath =
|
|
115395
|
+
const binaryPath = join78(packageDirectory, astGrepBinaryName);
|
|
115323
115396
|
if (existsSync73(binaryPath) && isValidBinary(binaryPath)) {
|
|
115324
115397
|
return binaryPath;
|
|
115325
115398
|
}
|
|
@@ -115721,18 +115794,18 @@ var {spawn: spawn18 } = globalThis.Bun;
|
|
|
115721
115794
|
|
|
115722
115795
|
// src/tools/grep/constants.ts
|
|
115723
115796
|
import { existsSync as existsSync77 } from "fs";
|
|
115724
|
-
import { join as
|
|
115797
|
+
import { join as join80, dirname as dirname24 } from "path";
|
|
115725
115798
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
115726
115799
|
|
|
115727
115800
|
// src/tools/grep/downloader.ts
|
|
115728
115801
|
import { existsSync as existsSync76, readdirSync as readdirSync19 } from "fs";
|
|
115729
|
-
import { join as
|
|
115802
|
+
import { join as join79 } from "path";
|
|
115730
115803
|
function findFileRecursive(dir, filename) {
|
|
115731
115804
|
try {
|
|
115732
115805
|
const entries = readdirSync19(dir, { withFileTypes: true, recursive: true });
|
|
115733
115806
|
for (const entry of entries) {
|
|
115734
115807
|
if (entry.isFile() && entry.name === filename) {
|
|
115735
|
-
return
|
|
115808
|
+
return join79(entry.parentPath ?? dir, entry.name);
|
|
115736
115809
|
}
|
|
115737
115810
|
}
|
|
115738
115811
|
} catch {
|
|
@@ -115753,11 +115826,11 @@ function getPlatformKey() {
|
|
|
115753
115826
|
}
|
|
115754
115827
|
function getInstallDir() {
|
|
115755
115828
|
const homeDir = process.env.HOME || process.env.USERPROFILE || ".";
|
|
115756
|
-
return
|
|
115829
|
+
return join79(homeDir, ".cache", "oh-my-opencode", "bin");
|
|
115757
115830
|
}
|
|
115758
115831
|
function getRgPath() {
|
|
115759
115832
|
const isWindows2 = process.platform === "win32";
|
|
115760
|
-
return
|
|
115833
|
+
return join79(getInstallDir(), isWindows2 ? "rg.exe" : "rg");
|
|
115761
115834
|
}
|
|
115762
115835
|
async function extractTarGz2(archivePath, destDir) {
|
|
115763
115836
|
const platformKey = getPlatformKey();
|
|
@@ -115774,7 +115847,7 @@ async function extractZip2(archivePath, destDir) {
|
|
|
115774
115847
|
const binaryName = process.platform === "win32" ? "rg.exe" : "rg";
|
|
115775
115848
|
const foundPath = findFileRecursive(destDir, binaryName);
|
|
115776
115849
|
if (foundPath) {
|
|
115777
|
-
const destPath =
|
|
115850
|
+
const destPath = join79(destDir, binaryName);
|
|
115778
115851
|
if (foundPath !== destPath) {
|
|
115779
115852
|
const { renameSync: renameSync5 } = await import("fs");
|
|
115780
115853
|
renameSync5(foundPath, destPath);
|
|
@@ -115795,7 +115868,7 @@ async function downloadAndInstallRipgrep() {
|
|
|
115795
115868
|
ensureCacheDir(installDir);
|
|
115796
115869
|
const filename = `ripgrep-${RG_VERSION}-${config4.platform}.${config4.extension}`;
|
|
115797
115870
|
const url3 = `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/${filename}`;
|
|
115798
|
-
const archivePath =
|
|
115871
|
+
const archivePath = join79(installDir, filename);
|
|
115799
115872
|
try {
|
|
115800
115873
|
await downloadArchive(url3, archivePath);
|
|
115801
115874
|
if (config4.extension === "tar.gz") {
|
|
@@ -115837,15 +115910,15 @@ function findExecutable(name) {
|
|
|
115837
115910
|
}
|
|
115838
115911
|
function getOpenCodeBundledRg() {
|
|
115839
115912
|
const execPath = process.execPath;
|
|
115840
|
-
const execDir =
|
|
115913
|
+
const execDir = dirname24(execPath);
|
|
115841
115914
|
const isWindows2 = process.platform === "win32";
|
|
115842
115915
|
const rgName = isWindows2 ? "rg.exe" : "rg";
|
|
115843
115916
|
const candidates = [
|
|
115844
|
-
|
|
115845
|
-
|
|
115846
|
-
|
|
115847
|
-
|
|
115848
|
-
|
|
115917
|
+
join80(getDataDir(), "opencode", "bin", rgName),
|
|
115918
|
+
join80(execDir, rgName),
|
|
115919
|
+
join80(execDir, "bin", rgName),
|
|
115920
|
+
join80(execDir, "..", "bin", rgName),
|
|
115921
|
+
join80(execDir, "..", "libexec", rgName)
|
|
115849
115922
|
];
|
|
115850
115923
|
for (const candidate of candidates) {
|
|
115851
115924
|
if (existsSync77(candidate)) {
|
|
@@ -116496,9 +116569,9 @@ Use this when a task matches an available skill's or command's description.
|
|
|
116496
116569
|
- The tool will return detailed instructions with your context applied.
|
|
116497
116570
|
`;
|
|
116498
116571
|
// src/tools/skill/tools.ts
|
|
116499
|
-
import { dirname as
|
|
116572
|
+
import { dirname as dirname26 } from "path";
|
|
116500
116573
|
// src/tools/slashcommand/command-output-formatter.ts
|
|
116501
|
-
import { dirname as
|
|
116574
|
+
import { dirname as dirname25 } from "path";
|
|
116502
116575
|
async function formatLoadedCommand(command, userMessage) {
|
|
116503
116576
|
const sections = [];
|
|
116504
116577
|
sections.push(`# /${command.name} Command
|
|
@@ -116537,7 +116610,7 @@ async function formatLoadedCommand(command, userMessage) {
|
|
|
116537
116610
|
if (!content && command.lazyContentLoader) {
|
|
116538
116611
|
content = await command.lazyContentLoader.load();
|
|
116539
116612
|
}
|
|
116540
|
-
const commandDir = command.path ?
|
|
116613
|
+
const commandDir = command.path ? dirname25(command.path) : process.cwd();
|
|
116541
116614
|
const withFileReferences = await resolveFileReferencesInText(content, commandDir);
|
|
116542
116615
|
const resolvedContent = await resolveCommandsInText(withFileReferences);
|
|
116543
116616
|
let finalContent = resolvedContent.trim();
|
|
@@ -116917,7 +116990,7 @@ function createSkillTool(options = {}) {
|
|
|
116917
116990
|
if (matchedSkill.name === "git-master") {
|
|
116918
116991
|
body = injectGitMasterConfig(body, options.gitMasterConfig);
|
|
116919
116992
|
}
|
|
116920
|
-
const dir = matchedSkill.path ?
|
|
116993
|
+
const dir = matchedSkill.path ? dirname26(matchedSkill.path) : matchedSkill.resolvedPath || process.cwd();
|
|
116921
116994
|
const output = [
|
|
116922
116995
|
`## Skill: ${matchedSkill.name}`,
|
|
116923
116996
|
"",
|
|
@@ -116957,9 +117030,9 @@ function createSkillTool(options = {}) {
|
|
|
116957
117030
|
}
|
|
116958
117031
|
var skill = createSkillTool();
|
|
116959
117032
|
// src/tools/session-manager/constants.ts
|
|
116960
|
-
import { join as
|
|
116961
|
-
var TODO_DIR2 =
|
|
116962
|
-
var TRANSCRIPT_DIR2 =
|
|
117033
|
+
import { join as join81 } from "path";
|
|
117034
|
+
var TODO_DIR2 = join81(getClaudeConfigDir(), "todos");
|
|
117035
|
+
var TRANSCRIPT_DIR2 = join81(getClaudeConfigDir(), "transcripts");
|
|
116963
117036
|
var SESSION_LIST_DESCRIPTION = `List all OpenCode sessions with optional filtering.
|
|
116964
117037
|
|
|
116965
117038
|
Returns a list of available session IDs with metadata including message count, date range, and agents used.
|
|
@@ -117034,7 +117107,7 @@ Has Transcript: Yes (234 entries)`;
|
|
|
117034
117107
|
// src/tools/session-manager/file-storage.ts
|
|
117035
117108
|
import { existsSync as existsSync78 } from "fs";
|
|
117036
117109
|
import { readdir, readFile } from "fs/promises";
|
|
117037
|
-
import { join as
|
|
117110
|
+
import { join as join82 } from "path";
|
|
117038
117111
|
async function getFileMainSessions(directory) {
|
|
117039
117112
|
if (!existsSync78(SESSION_STORAGE))
|
|
117040
117113
|
return [];
|
|
@@ -117044,13 +117117,13 @@ async function getFileMainSessions(directory) {
|
|
|
117044
117117
|
for (const projectDir of projectDirs) {
|
|
117045
117118
|
if (!projectDir.isDirectory())
|
|
117046
117119
|
continue;
|
|
117047
|
-
const projectPath =
|
|
117120
|
+
const projectPath = join82(SESSION_STORAGE, projectDir.name);
|
|
117048
117121
|
const sessionFiles = await readdir(projectPath);
|
|
117049
117122
|
for (const file3 of sessionFiles) {
|
|
117050
117123
|
if (!file3.endsWith(".json"))
|
|
117051
117124
|
continue;
|
|
117052
117125
|
try {
|
|
117053
|
-
const content = await readFile(
|
|
117126
|
+
const content = await readFile(join82(projectPath, file3), "utf-8");
|
|
117054
117127
|
const meta3 = JSON.parse(content);
|
|
117055
117128
|
if (meta3.parentID)
|
|
117056
117129
|
continue;
|
|
@@ -117077,7 +117150,7 @@ async function getFileAllSessions() {
|
|
|
117077
117150
|
for (const entry of entries) {
|
|
117078
117151
|
if (!entry.isDirectory())
|
|
117079
117152
|
continue;
|
|
117080
|
-
const sessionPath =
|
|
117153
|
+
const sessionPath = join82(dir, entry.name);
|
|
117081
117154
|
const files = await readdir(sessionPath);
|
|
117082
117155
|
if (files.some((file3) => file3.endsWith(".json"))) {
|
|
117083
117156
|
sessions.push(entry.name);
|
|
@@ -117106,7 +117179,7 @@ async function getFileSessionMessages(sessionID) {
|
|
|
117106
117179
|
if (!file3.endsWith(".json"))
|
|
117107
117180
|
continue;
|
|
117108
117181
|
try {
|
|
117109
|
-
const content = await readFile(
|
|
117182
|
+
const content = await readFile(join82(messageDir, file3), "utf-8");
|
|
117110
117183
|
const meta3 = JSON.parse(content);
|
|
117111
117184
|
const parts = await readParts2(meta3.id);
|
|
117112
117185
|
messages.push({
|
|
@@ -117132,7 +117205,7 @@ async function getFileSessionMessages(sessionID) {
|
|
|
117132
117205
|
});
|
|
117133
117206
|
}
|
|
117134
117207
|
async function readParts2(messageID) {
|
|
117135
|
-
const partDir =
|
|
117208
|
+
const partDir = join82(PART_STORAGE, messageID);
|
|
117136
117209
|
if (!existsSync78(partDir))
|
|
117137
117210
|
return [];
|
|
117138
117211
|
const parts = [];
|
|
@@ -117142,7 +117215,7 @@ async function readParts2(messageID) {
|
|
|
117142
117215
|
if (!file3.endsWith(".json"))
|
|
117143
117216
|
continue;
|
|
117144
117217
|
try {
|
|
117145
|
-
const content = await readFile(
|
|
117218
|
+
const content = await readFile(join82(partDir, file3), "utf-8");
|
|
117146
117219
|
parts.push(JSON.parse(content));
|
|
117147
117220
|
} catch {
|
|
117148
117221
|
continue;
|
|
@@ -117161,7 +117234,7 @@ async function getFileSessionTodos(sessionID) {
|
|
|
117161
117234
|
const todoFiles = allFiles.filter((file3) => file3 === `${sessionID}.json`);
|
|
117162
117235
|
for (const file3 of todoFiles) {
|
|
117163
117236
|
try {
|
|
117164
|
-
const content = await readFile(
|
|
117237
|
+
const content = await readFile(join82(TODO_DIR2, file3), "utf-8");
|
|
117165
117238
|
const data = JSON.parse(content);
|
|
117166
117239
|
if (!Array.isArray(data))
|
|
117167
117240
|
continue;
|
|
@@ -117183,7 +117256,7 @@ async function getFileSessionTodos(sessionID) {
|
|
|
117183
117256
|
async function getFileSessionTranscript(sessionID) {
|
|
117184
117257
|
if (!existsSync78(TRANSCRIPT_DIR2))
|
|
117185
117258
|
return 0;
|
|
117186
|
-
const transcriptFile =
|
|
117259
|
+
const transcriptFile = join82(TRANSCRIPT_DIR2, `${sessionID}.jsonl`);
|
|
117187
117260
|
if (!existsSync78(transcriptFile))
|
|
117188
117261
|
return 0;
|
|
117189
117262
|
try {
|
|
@@ -117349,6 +117422,19 @@ function shouldFallbackFromSdkError(error92) {
|
|
|
117349
117422
|
}
|
|
117350
117423
|
|
|
117351
117424
|
// src/tools/session-manager/storage.ts
|
|
117425
|
+
function mergeSessionMetadataLists(sdkSessions, fileSessions) {
|
|
117426
|
+
const merged = new Map;
|
|
117427
|
+
for (const session of fileSessions) {
|
|
117428
|
+
merged.set(session.id, session);
|
|
117429
|
+
}
|
|
117430
|
+
for (const session of sdkSessions) {
|
|
117431
|
+
merged.set(session.id, session);
|
|
117432
|
+
}
|
|
117433
|
+
return [...merged.values()].sort((a, b) => b.time.updated - a.time.updated);
|
|
117434
|
+
}
|
|
117435
|
+
function mergeSessionIds(sdkSessionIds, fileSessionIds) {
|
|
117436
|
+
return [...new Set([...sdkSessionIds, ...fileSessionIds])];
|
|
117437
|
+
}
|
|
117352
117438
|
var sdkClient = null;
|
|
117353
117439
|
function setStorageClient(client2) {
|
|
117354
117440
|
sdkClient = client2;
|
|
@@ -117356,7 +117442,9 @@ function setStorageClient(client2) {
|
|
|
117356
117442
|
async function getMainSessions(options) {
|
|
117357
117443
|
if (isSqliteBackend() && sdkClient) {
|
|
117358
117444
|
try {
|
|
117359
|
-
|
|
117445
|
+
const sdkSessions = await getSdkMainSessions(sdkClient, options.directory);
|
|
117446
|
+
const fileSessions = await getFileMainSessions(options.directory);
|
|
117447
|
+
return mergeSessionMetadataLists(sdkSessions, fileSessions);
|
|
117360
117448
|
} catch (error92) {
|
|
117361
117449
|
if (!shouldFallbackFromSdkError(error92))
|
|
117362
117450
|
throw error92;
|
|
@@ -117368,7 +117456,9 @@ async function getMainSessions(options) {
|
|
|
117368
117456
|
async function getAllSessions() {
|
|
117369
117457
|
if (isSqliteBackend() && sdkClient) {
|
|
117370
117458
|
try {
|
|
117371
|
-
|
|
117459
|
+
const sdkSessionIds = await getSdkAllSessions(sdkClient);
|
|
117460
|
+
const fileSessionIds = await getFileAllSessions();
|
|
117461
|
+
return mergeSessionIds(sdkSessionIds, fileSessionIds);
|
|
117372
117462
|
} catch (error92) {
|
|
117373
117463
|
if (!shouldFallbackFromSdkError(error92))
|
|
117374
117464
|
throw error92;
|
|
@@ -117380,7 +117470,9 @@ async function getAllSessions() {
|
|
|
117380
117470
|
async function sessionExists2(sessionID) {
|
|
117381
117471
|
if (isSqliteBackend() && sdkClient) {
|
|
117382
117472
|
try {
|
|
117383
|
-
|
|
117473
|
+
const existsInSdk = await sdkSessionExists(sdkClient, sessionID);
|
|
117474
|
+
if (existsInSdk)
|
|
117475
|
+
return true;
|
|
117384
117476
|
} catch (error92) {
|
|
117385
117477
|
if (!shouldFallbackFromSdkError(error92))
|
|
117386
117478
|
throw error92;
|
|
@@ -117392,7 +117484,9 @@ async function sessionExists2(sessionID) {
|
|
|
117392
117484
|
async function readSessionMessages2(sessionID) {
|
|
117393
117485
|
if (isSqliteBackend() && sdkClient) {
|
|
117394
117486
|
try {
|
|
117395
|
-
|
|
117487
|
+
const sdkMessages = await getSdkSessionMessages(sdkClient, sessionID);
|
|
117488
|
+
if (sdkMessages.length > 0)
|
|
117489
|
+
return sdkMessages;
|
|
117396
117490
|
} catch (error92) {
|
|
117397
117491
|
if (!shouldFallbackFromSdkError(error92))
|
|
117398
117492
|
throw error92;
|
|
@@ -117404,7 +117498,9 @@ async function readSessionMessages2(sessionID) {
|
|
|
117404
117498
|
async function readSessionTodos(sessionID) {
|
|
117405
117499
|
if (isSqliteBackend() && sdkClient) {
|
|
117406
117500
|
try {
|
|
117407
|
-
|
|
117501
|
+
const sdkTodos = await getSdkSessionTodos(sdkClient, sessionID);
|
|
117502
|
+
if (sdkTodos.length > 0)
|
|
117503
|
+
return sdkTodos;
|
|
117408
117504
|
} catch (error92) {
|
|
117409
117505
|
if (!shouldFallbackFromSdkError(error92))
|
|
117410
117506
|
throw error92;
|
|
@@ -119396,7 +119492,7 @@ async function resolveMultimodalLookerAgentMetadata(ctx) {
|
|
|
119396
119492
|
import * as childProcess from "child_process";
|
|
119397
119493
|
import { existsSync as existsSync79, mkdtempSync, readFileSync as readFileSync51, rmSync as rmSync4, unlinkSync as unlinkSync11, writeFileSync as writeFileSync20 } from "fs";
|
|
119398
119494
|
import { tmpdir as tmpdir7 } from "os";
|
|
119399
|
-
import { dirname as
|
|
119495
|
+
import { dirname as dirname27, join as join83 } from "path";
|
|
119400
119496
|
var SUPPORTED_FORMATS = new Set([
|
|
119401
119497
|
"image/jpeg",
|
|
119402
119498
|
"image/png",
|
|
@@ -119437,8 +119533,8 @@ function convertImageToJpeg(inputPath, mimeType) {
|
|
|
119437
119533
|
if (!existsSync79(inputPath)) {
|
|
119438
119534
|
throw new Error(`File not found: ${inputPath}`);
|
|
119439
119535
|
}
|
|
119440
|
-
const tempDir = mkdtempSync(
|
|
119441
|
-
const outputPath =
|
|
119536
|
+
const tempDir = mkdtempSync(join83(tmpdir7(), "opencode-img-"));
|
|
119537
|
+
const outputPath = join83(tempDir, "converted.jpg");
|
|
119442
119538
|
log(`[image-converter] Converting ${mimeType} to JPEG: ${inputPath}`);
|
|
119443
119539
|
try {
|
|
119444
119540
|
if (process.platform === "darwin") {
|
|
@@ -119489,7 +119585,7 @@ function convertImageToJpeg(inputPath, mimeType) {
|
|
|
119489
119585
|
}
|
|
119490
119586
|
function cleanupConvertedImage(filePath) {
|
|
119491
119587
|
try {
|
|
119492
|
-
const tempDirectory =
|
|
119588
|
+
const tempDirectory = dirname27(filePath);
|
|
119493
119589
|
if (existsSync79(filePath)) {
|
|
119494
119590
|
unlinkSync11(filePath);
|
|
119495
119591
|
log(`[image-converter] Cleaned up temporary file: ${filePath}`);
|
|
@@ -119503,9 +119599,9 @@ function cleanupConvertedImage(filePath) {
|
|
|
119503
119599
|
}
|
|
119504
119600
|
}
|
|
119505
119601
|
function convertBase64ImageToJpeg(base64Data, mimeType) {
|
|
119506
|
-
const tempDir = mkdtempSync(
|
|
119602
|
+
const tempDir = mkdtempSync(join83(tmpdir7(), "opencode-b64-"));
|
|
119507
119603
|
const inputExt = mimeType.split("/")[1] || "bin";
|
|
119508
|
-
const inputPath =
|
|
119604
|
+
const inputPath = join83(tempDir, `input.${inputExt}`);
|
|
119509
119605
|
const tempFiles = [inputPath];
|
|
119510
119606
|
try {
|
|
119511
119607
|
const cleanBase64 = base64Data.replace(/^data:[^;]+;base64,/, "");
|
|
@@ -120062,6 +120158,7 @@ function getTimingConfig() {
|
|
|
120062
120158
|
// src/tools/delegate-task/sync-session-poller.ts
|
|
120063
120159
|
init_logger();
|
|
120064
120160
|
var NON_TERMINAL_FINISH_REASONS = new Set(["tool-calls", "unknown"]);
|
|
120161
|
+
var PENDING_TOOL_PART_TYPES = new Set(["tool", "tool_use", "tool-call"]);
|
|
120065
120162
|
function wait(milliseconds) {
|
|
120066
120163
|
const sharedBuffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT);
|
|
120067
120164
|
const typedArray = new Int32Array(sharedBuffer);
|
|
@@ -120094,6 +120191,8 @@ function isSessionComplete(messages) {
|
|
|
120094
120191
|
return false;
|
|
120095
120192
|
if (NON_TERMINAL_FINISH_REASONS.has(lastAssistant.info.finish))
|
|
120096
120193
|
return false;
|
|
120194
|
+
if (lastAssistant.parts?.some((part) => part.type && PENDING_TOOL_PART_TYPES.has(part.type)))
|
|
120195
|
+
return false;
|
|
120097
120196
|
if (!lastUser?.info?.id || !lastAssistant?.info?.id)
|
|
120098
120197
|
return false;
|
|
120099
120198
|
return lastUser.info.id < lastAssistant.info.id;
|
|
@@ -121789,7 +121888,7 @@ function createDelegateTask(options) {
|
|
|
121789
121888
|
// src/tools/delegate-task/index.ts
|
|
121790
121889
|
init_constants();
|
|
121791
121890
|
// src/tools/task/task-create.ts
|
|
121792
|
-
import { join as
|
|
121891
|
+
import { join as join85 } from "path";
|
|
121793
121892
|
|
|
121794
121893
|
// src/tools/task/types.ts
|
|
121795
121894
|
var TaskStatusSchema = exports_external.enum(["pending", "in_progress", "completed", "deleted"]);
|
|
@@ -121843,18 +121942,18 @@ var TaskDeleteInputSchema = exports_external.object({
|
|
|
121843
121942
|
});
|
|
121844
121943
|
|
|
121845
121944
|
// src/features/claude-tasks/storage.ts
|
|
121846
|
-
import { join as
|
|
121847
|
-
import { existsSync as existsSync80, mkdirSync as
|
|
121945
|
+
import { join as join84, dirname as dirname28, basename as basename13, isAbsolute as isAbsolute11 } from "path";
|
|
121946
|
+
import { existsSync as existsSync80, mkdirSync as mkdirSync16, readFileSync as readFileSync52, writeFileSync as writeFileSync21, renameSync as renameSync5, unlinkSync as unlinkSync12, readdirSync as readdirSync20 } from "fs";
|
|
121848
121947
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
121849
121948
|
function getTaskDir(config4 = {}) {
|
|
121850
121949
|
const tasksConfig = config4.sisyphus?.tasks;
|
|
121851
121950
|
const storagePath = tasksConfig?.storage_path;
|
|
121852
121951
|
if (storagePath) {
|
|
121853
|
-
return isAbsolute11(storagePath) ? storagePath :
|
|
121952
|
+
return isAbsolute11(storagePath) ? storagePath : join84(process.cwd(), storagePath);
|
|
121854
121953
|
}
|
|
121855
121954
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
121856
121955
|
const listId = resolveTaskListId(config4);
|
|
121857
|
-
return
|
|
121956
|
+
return join84(configDir, "tasks", listId);
|
|
121858
121957
|
}
|
|
121859
121958
|
function sanitizePathSegment(value) {
|
|
121860
121959
|
return value.replace(/[^a-zA-Z0-9_-]/g, "-") || "default";
|
|
@@ -121873,7 +121972,7 @@ function resolveTaskListId(config4 = {}) {
|
|
|
121873
121972
|
}
|
|
121874
121973
|
function ensureDir(dirPath) {
|
|
121875
121974
|
if (!existsSync80(dirPath)) {
|
|
121876
|
-
|
|
121975
|
+
mkdirSync16(dirPath, { recursive: true });
|
|
121877
121976
|
}
|
|
121878
121977
|
}
|
|
121879
121978
|
function readJsonSafe(filePath, schema2) {
|
|
@@ -121893,7 +121992,7 @@ function readJsonSafe(filePath, schema2) {
|
|
|
121893
121992
|
}
|
|
121894
121993
|
}
|
|
121895
121994
|
function writeJsonAtomic(filePath, data) {
|
|
121896
|
-
const dir =
|
|
121995
|
+
const dir = dirname28(filePath);
|
|
121897
121996
|
ensureDir(dir);
|
|
121898
121997
|
const tempPath = `${filePath}.tmp.${Date.now()}`;
|
|
121899
121998
|
try {
|
|
@@ -121913,7 +122012,7 @@ function generateTaskId() {
|
|
|
121913
122012
|
return `T-${randomUUID3()}`;
|
|
121914
122013
|
}
|
|
121915
122014
|
function acquireLock(dirPath) {
|
|
121916
|
-
const lockPath =
|
|
122015
|
+
const lockPath = join84(dirPath, ".lock");
|
|
121917
122016
|
const lockId = randomUUID3();
|
|
121918
122017
|
const createLock = (timestamp2) => {
|
|
121919
122018
|
writeFileSync21(lockPath, JSON.stringify({ id: lockId, timestamp: timestamp2 }), {
|
|
@@ -122126,7 +122225,7 @@ async function handleCreate(args, config4, ctx, context) {
|
|
|
122126
122225
|
threadID: context.sessionID
|
|
122127
122226
|
};
|
|
122128
122227
|
const validatedTask = TaskObjectSchema.parse(task);
|
|
122129
|
-
writeJsonAtomic(
|
|
122228
|
+
writeJsonAtomic(join85(taskDir, `${taskId}.json`), validatedTask);
|
|
122130
122229
|
await syncTaskTodoUpdate(ctx, validatedTask, context.sessionID);
|
|
122131
122230
|
return JSON.stringify({
|
|
122132
122231
|
task: {
|
|
@@ -122148,7 +122247,7 @@ async function handleCreate(args, config4, ctx, context) {
|
|
|
122148
122247
|
}
|
|
122149
122248
|
}
|
|
122150
122249
|
// src/tools/task/task-get.ts
|
|
122151
|
-
import { join as
|
|
122250
|
+
import { join as join86 } from "path";
|
|
122152
122251
|
var TASK_ID_PATTERN = /^T-[A-Za-z0-9-]+$/;
|
|
122153
122252
|
function parseTaskId(id) {
|
|
122154
122253
|
if (!TASK_ID_PATTERN.test(id))
|
|
@@ -122173,7 +122272,7 @@ Returns null if the task does not exist or the file is invalid.`,
|
|
|
122173
122272
|
return JSON.stringify({ error: "invalid_task_id" });
|
|
122174
122273
|
}
|
|
122175
122274
|
const taskDir = getTaskDir(config4);
|
|
122176
|
-
const taskPath =
|
|
122275
|
+
const taskPath = join86(taskDir, `${taskId}.json`);
|
|
122177
122276
|
const task = readJsonSafe(taskPath, TaskObjectSchema);
|
|
122178
122277
|
return JSON.stringify({ task: task ?? null });
|
|
122179
122278
|
} catch (error92) {
|
|
@@ -122186,7 +122285,7 @@ Returns null if the task does not exist or the file is invalid.`,
|
|
|
122186
122285
|
});
|
|
122187
122286
|
}
|
|
122188
122287
|
// src/tools/task/task-list.ts
|
|
122189
|
-
import { join as
|
|
122288
|
+
import { join as join87 } from "path";
|
|
122190
122289
|
import { existsSync as existsSync81, readdirSync as readdirSync21 } from "fs";
|
|
122191
122290
|
function createTaskList(config4) {
|
|
122192
122291
|
return tool({
|
|
@@ -122207,7 +122306,7 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
|
|
|
122207
122306
|
}
|
|
122208
122307
|
const allTasks = [];
|
|
122209
122308
|
for (const fileId of files) {
|
|
122210
|
-
const task = readJsonSafe(
|
|
122309
|
+
const task = readJsonSafe(join87(taskDir, `${fileId}.json`), TaskObjectSchema);
|
|
122211
122310
|
if (task) {
|
|
122212
122311
|
allTasks.push(task);
|
|
122213
122312
|
}
|
|
@@ -122235,7 +122334,7 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
|
|
|
122235
122334
|
});
|
|
122236
122335
|
}
|
|
122237
122336
|
// src/tools/task/task-update.ts
|
|
122238
|
-
import { join as
|
|
122337
|
+
import { join as join88 } from "path";
|
|
122239
122338
|
var TASK_ID_PATTERN2 = /^T-[A-Za-z0-9-]+$/;
|
|
122240
122339
|
function parseTaskId2(id) {
|
|
122241
122340
|
if (!TASK_ID_PATTERN2.test(id))
|
|
@@ -122283,7 +122382,7 @@ async function handleUpdate(args, config4, ctx, context) {
|
|
|
122283
122382
|
return JSON.stringify({ error: "task_lock_unavailable" });
|
|
122284
122383
|
}
|
|
122285
122384
|
try {
|
|
122286
|
-
const taskPath =
|
|
122385
|
+
const taskPath = join88(taskDir, `${taskId}.json`);
|
|
122287
122386
|
const task = readJsonSafe(taskPath, TaskObjectSchema);
|
|
122288
122387
|
if (!task) {
|
|
122289
122388
|
return JSON.stringify({ error: "task_not_found" });
|
|
@@ -125005,7 +125104,7 @@ function unregisterManagerForCleanup(manager) {
|
|
|
125005
125104
|
|
|
125006
125105
|
// src/features/background-agent/compaction-aware-message-resolver.ts
|
|
125007
125106
|
import { readdirSync as readdirSync22, readFileSync as readFileSync53 } from "fs";
|
|
125008
|
-
import { join as
|
|
125107
|
+
import { join as join89 } from "path";
|
|
125009
125108
|
function isCompactionAgent4(agent) {
|
|
125010
125109
|
return agent?.trim().toLowerCase() === "compaction";
|
|
125011
125110
|
}
|
|
@@ -125084,7 +125183,7 @@ function findNearestMessageExcludingCompaction(messageDir, sessionID) {
|
|
|
125084
125183
|
const messages = [];
|
|
125085
125184
|
for (const file3 of files) {
|
|
125086
125185
|
try {
|
|
125087
|
-
const content = readFileSync53(
|
|
125186
|
+
const content = readFileSync53(join89(messageDir, file3), "utf-8");
|
|
125088
125187
|
messages.push(JSON.parse(content));
|
|
125089
125188
|
} catch {
|
|
125090
125189
|
continue;
|
|
@@ -125170,7 +125269,7 @@ function handleSessionIdleBackgroundEvent(args) {
|
|
|
125170
125269
|
}
|
|
125171
125270
|
|
|
125172
125271
|
// src/features/background-agent/manager.ts
|
|
125173
|
-
import { join as
|
|
125272
|
+
import { join as join90 } from "path";
|
|
125174
125273
|
|
|
125175
125274
|
// src/features/background-agent/remove-task-toast-tracking.ts
|
|
125176
125275
|
function removeTaskToastTracking(taskId) {
|
|
@@ -126797,7 +126896,7 @@ ${originalText}`;
|
|
|
126797
126896
|
parentSessionID: task.parentSessionID
|
|
126798
126897
|
});
|
|
126799
126898
|
}
|
|
126800
|
-
const messageDir =
|
|
126899
|
+
const messageDir = join90(MESSAGE_STORAGE, task.parentSessionID);
|
|
126801
126900
|
const currentMessage = messageDir ? findNearestMessageExcludingCompaction(messageDir, task.parentSessionID) : null;
|
|
126802
126901
|
agent = currentMessage?.agent ?? task.parentAgent;
|
|
126803
126902
|
model = currentMessage?.model?.providerID && currentMessage?.model?.modelID ? { providerID: currentMessage.model.providerID, modelID: currentMessage.model.modelID } : undefined;
|
|
@@ -127125,11 +127224,11 @@ ${originalText}`;
|
|
|
127125
127224
|
}
|
|
127126
127225
|
}
|
|
127127
127226
|
// src/features/mcp-oauth/storage.ts
|
|
127128
|
-
import { chmodSync as chmodSync2, existsSync as existsSync82, mkdirSync as
|
|
127129
|
-
import { dirname as
|
|
127227
|
+
import { chmodSync as chmodSync2, existsSync as existsSync82, mkdirSync as mkdirSync17, readFileSync as readFileSync54, unlinkSync as unlinkSync13, writeFileSync as writeFileSync22 } from "fs";
|
|
127228
|
+
import { dirname as dirname29, join as join91 } from "path";
|
|
127130
127229
|
var STORAGE_FILE_NAME = "mcp-oauth.json";
|
|
127131
127230
|
function getMcpOauthStoragePath() {
|
|
127132
|
-
return
|
|
127231
|
+
return join91(getOpenCodeConfigDir({ binary: "opencode" }), STORAGE_FILE_NAME);
|
|
127133
127232
|
}
|
|
127134
127233
|
function normalizeHost(serverHost) {
|
|
127135
127234
|
let host = serverHost.trim();
|
|
@@ -127179,9 +127278,9 @@ function readStore() {
|
|
|
127179
127278
|
function writeStore(store2) {
|
|
127180
127279
|
const filePath = getMcpOauthStoragePath();
|
|
127181
127280
|
try {
|
|
127182
|
-
const dir =
|
|
127281
|
+
const dir = dirname29(filePath);
|
|
127183
127282
|
if (!existsSync82(dir)) {
|
|
127184
|
-
|
|
127283
|
+
mkdirSync17(dir, { recursive: true });
|
|
127185
127284
|
}
|
|
127186
127285
|
writeFileSync22(filePath, JSON.stringify(store2, null, 2), { encoding: "utf-8", mode: 384 });
|
|
127187
127286
|
chmodSync2(filePath, 384);
|
|
@@ -133676,17 +133775,17 @@ var SESSION_TIMEOUT_MS3 = 10 * 60 * 1000;
|
|
|
133676
133775
|
var MIN_STABILITY_TIME_MS4 = 10 * 1000;
|
|
133677
133776
|
// src/features/claude-code-mcp-loader/loader.ts
|
|
133678
133777
|
import { existsSync as existsSync83, readFileSync as readFileSync55 } from "fs";
|
|
133679
|
-
import { join as
|
|
133778
|
+
import { join as join92 } from "path";
|
|
133680
133779
|
import { homedir as homedir15 } from "os";
|
|
133681
133780
|
init_logger();
|
|
133682
133781
|
function getMcpConfigPaths() {
|
|
133683
133782
|
const claudeConfigDir = getClaudeConfigDir();
|
|
133684
133783
|
const cwd = process.cwd();
|
|
133685
133784
|
return [
|
|
133686
|
-
{ path:
|
|
133687
|
-
{ path:
|
|
133688
|
-
{ path:
|
|
133689
|
-
{ path:
|
|
133785
|
+
{ path: join92(homedir15(), ".claude.json"), scope: "user" },
|
|
133786
|
+
{ path: join92(claudeConfigDir, ".mcp.json"), scope: "user" },
|
|
133787
|
+
{ path: join92(cwd, ".mcp.json"), scope: "project" },
|
|
133788
|
+
{ path: join92(cwd, ".claude", ".mcp.json"), scope: "local" }
|
|
133690
133789
|
];
|
|
133691
133790
|
}
|
|
133692
133791
|
async function loadMcpConfigFile(filePath) {
|
|
@@ -140388,7 +140487,7 @@ async function createBuiltinAgents(disabledAgents = [], agentOverrides = {}, dir
|
|
|
140388
140487
|
}
|
|
140389
140488
|
// src/features/claude-code-agent-loader/loader.ts
|
|
140390
140489
|
import { existsSync as existsSync85, readdirSync as readdirSync23, readFileSync as readFileSync57 } from "fs";
|
|
140391
|
-
import { join as
|
|
140490
|
+
import { join as join93, basename as basename14 } from "path";
|
|
140392
140491
|
function parseToolsConfig2(toolsStr) {
|
|
140393
140492
|
if (!toolsStr)
|
|
140394
140493
|
return;
|
|
@@ -140410,7 +140509,7 @@ function loadAgentsFromDir(agentsDir, scope) {
|
|
|
140410
140509
|
for (const entry of entries) {
|
|
140411
140510
|
if (!isMarkdownFile(entry))
|
|
140412
140511
|
continue;
|
|
140413
|
-
const agentPath =
|
|
140512
|
+
const agentPath = join93(agentsDir, entry.name);
|
|
140414
140513
|
const agentName = basename14(entry.name, ".md");
|
|
140415
140514
|
try {
|
|
140416
140515
|
const content = readFileSync57(agentPath, "utf-8");
|
|
@@ -140443,7 +140542,7 @@ function loadAgentsFromDir(agentsDir, scope) {
|
|
|
140443
140542
|
return agents;
|
|
140444
140543
|
}
|
|
140445
140544
|
function loadUserAgents() {
|
|
140446
|
-
const userAgentsDir =
|
|
140545
|
+
const userAgentsDir = join93(getClaudeConfigDir(), "agents");
|
|
140447
140546
|
const agents = loadAgentsFromDir(userAgentsDir, "user");
|
|
140448
140547
|
const result = {};
|
|
140449
140548
|
for (const agent of agents) {
|
|
@@ -140452,7 +140551,7 @@ function loadUserAgents() {
|
|
|
140452
140551
|
return result;
|
|
140453
140552
|
}
|
|
140454
140553
|
function loadProjectAgents(directory) {
|
|
140455
|
-
const projectAgentsDir =
|
|
140554
|
+
const projectAgentsDir = join93(directory ?? process.cwd(), ".claude", "agents");
|
|
140456
140555
|
const agents = loadAgentsFromDir(projectAgentsDir, "project");
|
|
140457
140556
|
const result = {};
|
|
140458
140557
|
for (const agent of agents) {
|
|
@@ -142942,7 +143041,7 @@ async function applyAgentConfig(params) {
|
|
|
142942
143041
|
}
|
|
142943
143042
|
// src/features/claude-code-command-loader/loader.ts
|
|
142944
143043
|
import { promises as fs19 } from "fs";
|
|
142945
|
-
import { join as
|
|
143044
|
+
import { join as join94, basename as basename15 } from "path";
|
|
142946
143045
|
init_logger();
|
|
142947
143046
|
async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix = "") {
|
|
142948
143047
|
try {
|
|
@@ -142973,7 +143072,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
142973
143072
|
if (entry.isDirectory()) {
|
|
142974
143073
|
if (entry.name.startsWith("."))
|
|
142975
143074
|
continue;
|
|
142976
|
-
const subDirPath =
|
|
143075
|
+
const subDirPath = join94(commandsDir, entry.name);
|
|
142977
143076
|
const subPrefix = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
142978
143077
|
const subCommands = await loadCommandsFromDir(subDirPath, scope, visited, subPrefix);
|
|
142979
143078
|
commands3.push(...subCommands);
|
|
@@ -142981,7 +143080,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
142981
143080
|
}
|
|
142982
143081
|
if (!isMarkdownFile(entry))
|
|
142983
143082
|
continue;
|
|
142984
|
-
const commandPath =
|
|
143083
|
+
const commandPath = join94(commandsDir, entry.name);
|
|
142985
143084
|
const baseCommandName = basename15(entry.name, ".md");
|
|
142986
143085
|
const commandName = prefix ? `${prefix}/${baseCommandName}` : baseCommandName;
|
|
142987
143086
|
try {
|
|
@@ -143040,12 +143139,12 @@ function commandsToRecord(commands3) {
|
|
|
143040
143139
|
return result;
|
|
143041
143140
|
}
|
|
143042
143141
|
async function loadUserCommands() {
|
|
143043
|
-
const userCommandsDir =
|
|
143142
|
+
const userCommandsDir = join94(getClaudeConfigDir(), "commands");
|
|
143044
143143
|
const commands3 = await loadCommandsFromDir(userCommandsDir, "user");
|
|
143045
143144
|
return commandsToRecord(commands3);
|
|
143046
143145
|
}
|
|
143047
143146
|
async function loadProjectCommands(directory) {
|
|
143048
|
-
const projectCommandsDir =
|
|
143147
|
+
const projectCommandsDir = join94(directory ?? process.cwd(), ".claude", "commands");
|
|
143049
143148
|
const commands3 = await loadCommandsFromDir(projectCommandsDir, "project");
|
|
143050
143149
|
return commandsToRecord(commands3);
|
|
143051
143150
|
}
|
|
@@ -144023,10 +144122,10 @@ function createChatHeadersHandler(args) {
|
|
|
144023
144122
|
|
|
144024
144123
|
// src/plugin/ultrawork-db-model-override.ts
|
|
144025
144124
|
import { Database } from "bun:sqlite";
|
|
144026
|
-
import { join as
|
|
144125
|
+
import { join as join95 } from "path";
|
|
144027
144126
|
import { existsSync as existsSync86 } from "fs";
|
|
144028
144127
|
function getDbPath() {
|
|
144029
|
-
return
|
|
144128
|
+
return join95(getDataDir(), "opencode", "opencode.db");
|
|
144030
144129
|
}
|
|
144031
144130
|
var MAX_MICROTASK_RETRIES = 10;
|
|
144032
144131
|
function tryUpdateMessageModel(db, messageId, targetModel, variant) {
|