@skj1724/oh-my-opencode 3.23.4 → 3.23.5
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/agents/utils.d.ts +1 -2
- package/dist/cli/index.js +3 -4
- package/dist/config/schema.d.ts +2 -4
- package/dist/hooks/index.d.ts +0 -2
- package/dist/hooks/system-language-injector/index.d.ts +19 -0
- package/dist/index.js +344 -704
- package/dist/shared/language-detector.d.ts +2 -2
- package/dist/shared/language-enforcer.d.ts +2 -2
- package/package.json +1 -1
- package/dist/hooks/language-reminder/constants.d.ts +0 -3
- package/dist/hooks/language-reminder/index.d.ts +0 -22
- package/dist/hooks/language-reminder/storage.d.ts +0 -4
- package/dist/hooks/language-reminder/types.d.ts +0 -6
- package/dist/hooks/thinking-language-validator/constants.d.ts +0 -9
- package/dist/hooks/thinking-language-validator/detector.d.ts +0 -2
- package/dist/hooks/thinking-language-validator/detector.test.d.ts +0 -1
- package/dist/hooks/thinking-language-validator/index.d.ts +0 -22
- package/dist/hooks/thinking-language-validator/index.test.d.ts +0 -1
- package/dist/hooks/thinking-language-validator/storage.d.ts +0 -4
- package/dist/hooks/thinking-language-validator/types.d.ts +0 -13
- /package/dist/hooks/{language-reminder → system-language-injector}/index.test.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -6147,14 +6147,6 @@ function isLanguageEnforcementEnabled(config) {
|
|
|
6147
6147
|
function stripCodeAndUrls(text) {
|
|
6148
6148
|
return text.replace(/```[\s\S]*?```/g, "").replace(/`[^`]*`/g, "").replace(/https?:\/\/\S+/g, "").replace(/[A-Za-z]:[\\/]\S+|[./~]\S+\/\S+/g, "");
|
|
6149
6149
|
}
|
|
6150
|
-
function isEnglishText(text, threshold) {
|
|
6151
|
-
const stripped = stripCodeAndUrls(text);
|
|
6152
|
-
const meaningful = stripped.replace(/[\s\d\p{P}]/gu, "");
|
|
6153
|
-
if (meaningful.length < 20)
|
|
6154
|
-
return false;
|
|
6155
|
-
const asciiLetters = (meaningful.match(/[a-zA-Z]/g) || []).length;
|
|
6156
|
-
return asciiLetters / meaningful.length > threshold;
|
|
6157
|
-
}
|
|
6158
6150
|
function detectEnglishViolation(text, threshold = 0.6) {
|
|
6159
6151
|
let stripped = stripCodeAndUrls(text);
|
|
6160
6152
|
stripped = stripped.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1");
|
|
@@ -23149,6 +23141,7 @@ var ZH_LANGUAGE_INSTRUCTION = `
|
|
|
23149
23141
|
---
|
|
23150
23142
|
|
|
23151
23143
|
<Language_Instruction>
|
|
23144
|
+
|
|
23152
23145
|
## \u4E2D\u6587\u8BED\u5883\u786C\u7EA6\u675F\uFF08\u8EAB\u4EFD\u7EA7\u5F3A\u5236\u89C4\u5219\uFF09
|
|
23153
23146
|
|
|
23154
23147
|
### \u4F60\u7684\u8EAB\u4EFD
|
|
@@ -23199,12 +23192,17 @@ var ZH_LANGUAGE_INSTRUCTION = `
|
|
|
23199
23192
|
- \u6B64\u89C4\u5219\u9012\u5F52\u4F20\u9012\u7ED9\u6240\u6709 delegate_task \u5B50\u4EE3\u7406
|
|
23200
23193
|
- \u5B50\u4EE3\u7406\u7684 prompt \u5F00\u5934\u4E5F\u5DF2\u5305\u542B\u8EAB\u4EFD\u58F0\u660E
|
|
23201
23194
|
- \u5B50\u4EE3\u7406\u8F93\u51FA\u4E2D\u6587\u8FDD\u89C4\u65F6\uFF0C\u63D0\u9192\u5E76\u91CD\u65B0\u8C03\u7528
|
|
23202
|
-
</Language_Instruction>`;
|
|
23203
|
-
var ZH_LANGUAGE_INSTRUCTION_DEEPSEEK = `
|
|
23204
23195
|
|
|
23205
|
-
|
|
23206
|
-
|
|
23207
|
-
\
|
|
23196
|
+
### Thinking \u793A\u4F8B\uFF08\u5FC5\u987B\u9075\u5FAA\uFF09
|
|
23197
|
+
|
|
23198
|
+
\u2705 \u6B63\u786E\uFF08\u4E2D\u6587\u601D\u8003\uFF09\uFF1A
|
|
23199
|
+
\u6211\u9700\u8981\u5206\u6790 websockets \u7248\u672C\u517C\u5BB9\u6027\u95EE\u9898\u3002
|
|
23200
|
+
\u5148\u67E5\u770B\u9519\u8BEF\u4FE1\u606F\uFF0C\u53D1\u73B0\u662F handler \u7B7E\u540D\u4E0D\u5339\u914D\u3002
|
|
23201
|
+
\u7136\u540E\u68C0\u67E5\u5DF2\u5B89\u88C5\u7684 websockets \u7248\u672C...
|
|
23202
|
+
|
|
23203
|
+
\u274C \u9519\u8BEF\uFF08\u82F1\u6587\u601D\u8003\u2014\u2014\u7981\u6B62\uFF09\uFF1A
|
|
23204
|
+
But wait, the error message says "missing path"...
|
|
23205
|
+
Actually, let me re-read the error more carefully...
|
|
23208
23206
|
</Language_Instruction>`;
|
|
23209
23207
|
var ZH_SUB_AGENT_INSTRUCTION = ZH_LANGUAGE_INSTRUCTION.replace(`## \u4E2D\u6587\u8BED\u5883\u786C\u7EA6\u675F\uFF08\u8EAB\u4EFD\u7EA7\u5F3A\u5236\u89C4\u5219\uFF09
|
|
23210
23208
|
|
|
@@ -23444,11 +23442,7 @@ async function createBuiltinAgents(disabledAgents = [], agentOverrides = {}, dir
|
|
|
23444
23442
|
for (const name of Object.keys(result)) {
|
|
23445
23443
|
const agent = result[name];
|
|
23446
23444
|
if (agent.prompt) {
|
|
23447
|
-
|
|
23448
|
-
agent.prompt += ZH_LANGUAGE_INSTRUCTION_DEEPSEEK;
|
|
23449
|
-
} else {
|
|
23450
|
-
agent.prompt += MAIN_AGENT_NAMES.has(name) ? ZH_LANGUAGE_INSTRUCTION : ZH_SUB_AGENT_INSTRUCTION;
|
|
23451
|
-
}
|
|
23445
|
+
agent.prompt += MAIN_AGENT_NAMES.has(name) ? ZH_LANGUAGE_INSTRUCTION : ZH_SUB_AGENT_INSTRUCTION;
|
|
23452
23446
|
}
|
|
23453
23447
|
}
|
|
23454
23448
|
}
|
|
@@ -25572,345 +25566,6 @@ function createAgentUsageReminderHook(_ctx) {
|
|
|
25572
25566
|
event: eventHandler
|
|
25573
25567
|
};
|
|
25574
25568
|
}
|
|
25575
|
-
// src/hooks/language-reminder/storage.ts
|
|
25576
|
-
import {
|
|
25577
|
-
existsSync as existsSync31,
|
|
25578
|
-
mkdirSync as mkdirSync13,
|
|
25579
|
-
readFileSync as readFileSync23,
|
|
25580
|
-
writeFileSync as writeFileSync16,
|
|
25581
|
-
unlinkSync as unlinkSync8
|
|
25582
|
-
} from "fs";
|
|
25583
|
-
import { join as join41 } from "path";
|
|
25584
|
-
|
|
25585
|
-
// src/hooks/language-reminder/constants.ts
|
|
25586
|
-
init_data_path();
|
|
25587
|
-
import { join as join40 } from "path";
|
|
25588
|
-
var OPENCODE_STORAGE8 = getOpenCodeStorageDir();
|
|
25589
|
-
var LANGUAGE_REMINDER_STORAGE = join40(OPENCODE_STORAGE8, "language-reminder");
|
|
25590
|
-
var LANGUAGE_REMINDER_MESSAGE = `
|
|
25591
|
-
|
|
25592
|
-
[SYSTEM DIRECTIVE: OH-MY-OPENCODE - LANGUAGE]
|
|
25593
|
-
|
|
25594
|
-
\u8BF7\u7528\u4E2D\u6587\u601D\u8003\u548C\u56DE\u590D\u3002\u8FD9\u662F\u8EAB\u4EFD\u7EA7\u786C\u7EA6\u675F\uFF0C\u4E0D\u53EF\u5728\u957F\u4F1A\u8BDD\u4E2D\u9057\u5FD8\u3002
|
|
25595
|
-
\u7981\u6B62\u5728\u5185\u90E8\u63A8\u7406\uFF08Thought/Thinking\uFF09\u4E2D\u4F7F\u7528\u82F1\u6587\uFF0C\u7981\u6B62\u5728\u56DE\u590D\u6B63\u6587\u4E2D\u4F7F\u7528\u82F1\u6587\u53E5\u5B50\u3002
|
|
25596
|
-
\u6280\u672F\u672F\u8BED\u3001\u4EE3\u7801\u6807\u8BC6\u7B26\u3001\u6587\u4EF6\u8DEF\u5F84\u3001Shell \u547D\u4EE4\u3001\u4EE3\u7801\u5757\u5185\u5BB9\u5141\u8BB8\u4FDD\u7559\u82F1\u6587\u3002
|
|
25597
|
-
\u5982\u679C\u4F60\u53D1\u73B0\u81EA\u5DF1\u5F00\u59CB\u7528\u82F1\u6587\u601D\u8003\uFF0C\u7ACB\u5373\u5207\u6362\u5230\u4E2D\u6587\u3002`;
|
|
25598
|
-
|
|
25599
|
-
// src/hooks/language-reminder/storage.ts
|
|
25600
|
-
function getStoragePath5(sessionID) {
|
|
25601
|
-
return join41(LANGUAGE_REMINDER_STORAGE, `${sessionID}.json`);
|
|
25602
|
-
}
|
|
25603
|
-
function loadLanguageReminderState(sessionID) {
|
|
25604
|
-
const filePath = getStoragePath5(sessionID);
|
|
25605
|
-
if (!existsSync31(filePath))
|
|
25606
|
-
return null;
|
|
25607
|
-
try {
|
|
25608
|
-
const content = readFileSync23(filePath, "utf-8");
|
|
25609
|
-
return JSON.parse(content);
|
|
25610
|
-
} catch {
|
|
25611
|
-
return null;
|
|
25612
|
-
}
|
|
25613
|
-
}
|
|
25614
|
-
function saveLanguageReminderState(state2) {
|
|
25615
|
-
if (!existsSync31(LANGUAGE_REMINDER_STORAGE)) {
|
|
25616
|
-
mkdirSync13(LANGUAGE_REMINDER_STORAGE, { recursive: true });
|
|
25617
|
-
}
|
|
25618
|
-
const filePath = getStoragePath5(state2.sessionID);
|
|
25619
|
-
writeFileSync16(filePath, JSON.stringify(state2, null, 2));
|
|
25620
|
-
}
|
|
25621
|
-
function clearLanguageReminderState(sessionID) {
|
|
25622
|
-
const filePath = getStoragePath5(sessionID);
|
|
25623
|
-
if (existsSync31(filePath)) {
|
|
25624
|
-
unlinkSync8(filePath);
|
|
25625
|
-
}
|
|
25626
|
-
}
|
|
25627
|
-
|
|
25628
|
-
// src/hooks/language-reminder/index.ts
|
|
25629
|
-
function createLanguageReminderHook(ctx) {
|
|
25630
|
-
const sessionStates = new Map;
|
|
25631
|
-
const userMessageHistory = new Map;
|
|
25632
|
-
const config = ctx.config;
|
|
25633
|
-
const le = config?.language_enforcement;
|
|
25634
|
-
const reminderInterval = le?.reminder_interval ?? 5;
|
|
25635
|
-
const userEnglishThreshold = le?.user_message_english_threshold ?? 0.6;
|
|
25636
|
-
const userMessageLookback = le?.user_message_lookback ?? 3;
|
|
25637
|
-
function getOrCreateState(sessionID) {
|
|
25638
|
-
if (!sessionStates.has(sessionID)) {
|
|
25639
|
-
const persisted = loadLanguageReminderState(sessionID);
|
|
25640
|
-
const state2 = persisted ?? {
|
|
25641
|
-
sessionID,
|
|
25642
|
-
toolCallCount: 0,
|
|
25643
|
-
suspendedDueToUserEnglish: false,
|
|
25644
|
-
updatedAt: Date.now()
|
|
25645
|
-
};
|
|
25646
|
-
sessionStates.set(sessionID, state2);
|
|
25647
|
-
}
|
|
25648
|
-
return sessionStates.get(sessionID);
|
|
25649
|
-
}
|
|
25650
|
-
function resetState(sessionID) {
|
|
25651
|
-
sessionStates.delete(sessionID);
|
|
25652
|
-
userMessageHistory.delete(sessionID);
|
|
25653
|
-
clearLanguageReminderState(sessionID);
|
|
25654
|
-
}
|
|
25655
|
-
function checkUserMessagesForSuspension(sessionID) {
|
|
25656
|
-
const messages = userMessageHistory.get(sessionID);
|
|
25657
|
-
if (!messages || messages.length < userMessageLookback)
|
|
25658
|
-
return false;
|
|
25659
|
-
const recent = messages.slice(-userMessageLookback);
|
|
25660
|
-
return recent.every((msg) => isEnglishText(msg, userEnglishThreshold));
|
|
25661
|
-
}
|
|
25662
|
-
function recordUserMessage2(sessionID, text) {
|
|
25663
|
-
if (!userMessageHistory.has(sessionID)) {
|
|
25664
|
-
userMessageHistory.set(sessionID, []);
|
|
25665
|
-
}
|
|
25666
|
-
userMessageHistory.get(sessionID).push(text);
|
|
25667
|
-
if (userMessageHistory.get(sessionID).length > userMessageLookback * 2) {
|
|
25668
|
-
userMessageHistory.set(sessionID, userMessageHistory.get(sessionID).slice(-userMessageLookback));
|
|
25669
|
-
}
|
|
25670
|
-
}
|
|
25671
|
-
const toolExecuteAfter = async (input, output) => {
|
|
25672
|
-
if (!isLanguageEnforcementEnabled(config))
|
|
25673
|
-
return;
|
|
25674
|
-
const { sessionID } = input;
|
|
25675
|
-
const state2 = getOrCreateState(sessionID);
|
|
25676
|
-
if (state2.suspendedDueToUserEnglish)
|
|
25677
|
-
return;
|
|
25678
|
-
state2.toolCallCount++;
|
|
25679
|
-
if (state2.toolCallCount >= reminderInterval) {
|
|
25680
|
-
output.output += LANGUAGE_REMINDER_MESSAGE;
|
|
25681
|
-
state2.toolCallCount = 0;
|
|
25682
|
-
}
|
|
25683
|
-
state2.updatedAt = Date.now();
|
|
25684
|
-
saveLanguageReminderState(state2);
|
|
25685
|
-
};
|
|
25686
|
-
const eventHandler = async ({ event }) => {
|
|
25687
|
-
const props = event.properties;
|
|
25688
|
-
if (event.type === "session.deleted") {
|
|
25689
|
-
const sessionInfo = props?.info;
|
|
25690
|
-
if (sessionInfo?.id) {
|
|
25691
|
-
resetState(sessionInfo.id);
|
|
25692
|
-
}
|
|
25693
|
-
}
|
|
25694
|
-
if (event.type === "session.compacted") {
|
|
25695
|
-
const sessionID = props?.sessionID ?? props?.info?.id;
|
|
25696
|
-
if (sessionID) {
|
|
25697
|
-
resetState(sessionID);
|
|
25698
|
-
}
|
|
25699
|
-
}
|
|
25700
|
-
if (event.type === "chat.message") {
|
|
25701
|
-
const message = props?.message;
|
|
25702
|
-
const sessionID = props?.sessionID;
|
|
25703
|
-
if (message?.role === "user" && sessionID) {
|
|
25704
|
-
const text = typeof message?.content === "string" ? message.content : message?.parts?.filter((p) => p.type === "text").map((p) => p.text).join(" ") ?? "";
|
|
25705
|
-
recordUserMessage2(sessionID, text);
|
|
25706
|
-
const state2 = getOrCreateState(sessionID);
|
|
25707
|
-
if (checkUserMessagesForSuspension(sessionID)) {
|
|
25708
|
-
state2.suspendedDueToUserEnglish = true;
|
|
25709
|
-
saveLanguageReminderState(state2);
|
|
25710
|
-
}
|
|
25711
|
-
}
|
|
25712
|
-
}
|
|
25713
|
-
};
|
|
25714
|
-
return {
|
|
25715
|
-
"tool.execute.after": toolExecuteAfter,
|
|
25716
|
-
event: eventHandler
|
|
25717
|
-
};
|
|
25718
|
-
}
|
|
25719
|
-
// src/hooks/thinking-language-validator/storage.ts
|
|
25720
|
-
import {
|
|
25721
|
-
existsSync as existsSync32,
|
|
25722
|
-
mkdirSync as mkdirSync14,
|
|
25723
|
-
readFileSync as readFileSync24,
|
|
25724
|
-
writeFileSync as writeFileSync17,
|
|
25725
|
-
unlinkSync as unlinkSync9
|
|
25726
|
-
} from "fs";
|
|
25727
|
-
import { join as join43 } from "path";
|
|
25728
|
-
|
|
25729
|
-
// src/hooks/thinking-language-validator/constants.ts
|
|
25730
|
-
init_data_path();
|
|
25731
|
-
import { join as join42 } from "path";
|
|
25732
|
-
var OPENCODE_STORAGE9 = getOpenCodeStorageDir();
|
|
25733
|
-
var THINKING_VALIDATOR_STORAGE = join42(OPENCODE_STORAGE9, "thinking-language-validator");
|
|
25734
|
-
var STREAM_THROTTLE = 20;
|
|
25735
|
-
var THINKING_VIOLATION_REMINDER = `
|
|
25736
|
-
|
|
25737
|
-
[SYSTEM DIRECTIVE: OH-MY-OPENCODE - LANGUAGE]
|
|
25738
|
-
\u68C0\u6D4B\u5230\u4F60\u7684\u601D\u8003\u8FC7\u7A0B\u4F7F\u7528\u4E86\u82F1\u6587\u3002\u8FD9\u662F\u8EAB\u4EFD\u7EA7\u786C\u7EA6\u675F\uFF0C\u4E0D\u53EF\u8FDD\u53CD\u3002
|
|
25739
|
-
|
|
25740
|
-
## \u5F3A\u5236\u4FEE\u590D\u8981\u6C42
|
|
25741
|
-
\u4F60\u4E0A\u4E00\u8F6E\u7684 thinking \u5757\u4F7F\u7528\u4E86\u82F1\u6587\u2014\u2014\u8FD9\u662F\u4E0D\u5141\u8BB8\u7684\u3002
|
|
25742
|
-
\u5728\u672C\u8F6E\u56DE\u590D\u4E2D\uFF0C\u4F60\u5FC5\u987B\uFF1A
|
|
25743
|
-
1. \u5728 thinking \u5757\u5F00\u5934\u5199\u5165\uFF1A"\u8BED\u8A00\u8FDD\u89C4\u4FEE\u590D\uFF1A\u4E0A\u4E00\u8F6E thinking \u4F7F\u7528\u4E86\u82F1\u6587\uFF0C\u5DF2\u7EA0\u6B63\u3002"
|
|
25744
|
-
2. \u7528\u4E2D\u6587\u91CD\u65B0\u8868\u8FF0\u4F60\u4E0A\u4E00\u8F6E\u4E2D\u82F1\u6587\u601D\u8003\u7684\u6838\u5FC3\u5185\u5BB9
|
|
25745
|
-
3. \u672C\u8F6E\u6240\u6709\u8F93\u51FA\u5FC5\u987B\u4E3A\u4E2D\u6587
|
|
25746
|
-
|
|
25747
|
-
\u8FD9\u662F\u5F3A\u5236\u8981\u6C42\u2014\u2014\u4E0D\u662F\u5EFA\u8BAE\u3002\u4E0D\u5F97\u8DF3\u8FC7\u3002`;
|
|
25748
|
-
|
|
25749
|
-
// src/hooks/thinking-language-validator/storage.ts
|
|
25750
|
-
function getStoragePath6(sessionID) {
|
|
25751
|
-
return join43(THINKING_VALIDATOR_STORAGE, `${sessionID}.json`);
|
|
25752
|
-
}
|
|
25753
|
-
function loadThinkingValidatorState(sessionID) {
|
|
25754
|
-
const filePath = getStoragePath6(sessionID);
|
|
25755
|
-
if (!existsSync32(filePath))
|
|
25756
|
-
return null;
|
|
25757
|
-
try {
|
|
25758
|
-
const content = readFileSync24(filePath, "utf-8");
|
|
25759
|
-
const parsed = JSON.parse(content);
|
|
25760
|
-
const state2 = {
|
|
25761
|
-
sessionID: parsed.sessionID ?? sessionID,
|
|
25762
|
-
notifiedFingerprints: Array.isArray(parsed.notifiedFingerprints) ? parsed.notifiedFingerprints.slice(0, 100) : [],
|
|
25763
|
-
lastCheckedTextLength: typeof parsed.lastCheckedTextLength === "number" ? parsed.lastCheckedTextLength : 0,
|
|
25764
|
-
pendingViolationFingerprint: typeof parsed.pendingViolationFingerprint === "string" ? parsed.pendingViolationFingerprint : null,
|
|
25765
|
-
updatedAt: typeof parsed.updatedAt === "number" ? parsed.updatedAt : Date.now(),
|
|
25766
|
-
totalDetectionCount: typeof parsed.totalDetectionCount === "number" ? parsed.totalDetectionCount : 0,
|
|
25767
|
-
triggerWordHitCount: typeof parsed.triggerWordHitCount === "number" ? parsed.triggerWordHitCount : 0,
|
|
25768
|
-
asciiRatioHitCount: typeof parsed.asciiRatioHitCount === "number" ? parsed.asciiRatioHitCount : 0,
|
|
25769
|
-
dedupSkipCount: typeof parsed.dedupSkipCount === "number" ? parsed.dedupSkipCount : 0,
|
|
25770
|
-
throttleSkipCount: typeof parsed.throttleSkipCount === "number" ? parsed.throttleSkipCount : 0,
|
|
25771
|
-
reminderInjectedCount: typeof parsed.reminderInjectedCount === "number" ? parsed.reminderInjectedCount : 0
|
|
25772
|
-
};
|
|
25773
|
-
return state2;
|
|
25774
|
-
} catch {
|
|
25775
|
-
return null;
|
|
25776
|
-
}
|
|
25777
|
-
}
|
|
25778
|
-
function saveThinkingValidatorState(state2) {
|
|
25779
|
-
if (!existsSync32(THINKING_VALIDATOR_STORAGE)) {
|
|
25780
|
-
mkdirSync14(THINKING_VALIDATOR_STORAGE, { recursive: true });
|
|
25781
|
-
}
|
|
25782
|
-
const filePath = getStoragePath6(state2.sessionID);
|
|
25783
|
-
writeFileSync17(filePath, JSON.stringify(state2, null, 2));
|
|
25784
|
-
}
|
|
25785
|
-
function clearThinkingValidatorState(sessionID) {
|
|
25786
|
-
const filePath = getStoragePath6(sessionID);
|
|
25787
|
-
if (existsSync32(filePath)) {
|
|
25788
|
-
unlinkSync9(filePath);
|
|
25789
|
-
}
|
|
25790
|
-
}
|
|
25791
|
-
|
|
25792
|
-
// src/hooks/thinking-language-validator/index.ts
|
|
25793
|
-
init_agent_display_names();
|
|
25794
|
-
function createThinkingLanguageValidatorHook(ctx) {
|
|
25795
|
-
const sessionStates = new Map;
|
|
25796
|
-
const config = ctx.config;
|
|
25797
|
-
const le = config?.language_enforcement;
|
|
25798
|
-
const violationThreshold = le?.violation_threshold ?? 0.6;
|
|
25799
|
-
const excludedAgents = le?.excluded_agents ?? [];
|
|
25800
|
-
const relaxedAgents = le?.relaxed_agents ?? ["\u77E5\u8BC6\u5178\u85CF", "\u5A92\u4F53\u89E3\u6790"];
|
|
25801
|
-
const relaxedThreshold = le?.relaxed_threshold ?? 0.85;
|
|
25802
|
-
function getOrCreateState(sessionID) {
|
|
25803
|
-
if (!sessionStates.has(sessionID)) {
|
|
25804
|
-
const persisted = loadThinkingValidatorState(sessionID);
|
|
25805
|
-
const state2 = {
|
|
25806
|
-
sessionID,
|
|
25807
|
-
notifiedFingerprints: [],
|
|
25808
|
-
lastCheckedTextLength: 0,
|
|
25809
|
-
pendingViolationFingerprint: null,
|
|
25810
|
-
updatedAt: Date.now(),
|
|
25811
|
-
totalDetectionCount: 0,
|
|
25812
|
-
triggerWordHitCount: 0,
|
|
25813
|
-
asciiRatioHitCount: 0,
|
|
25814
|
-
dedupSkipCount: 0,
|
|
25815
|
-
throttleSkipCount: 0,
|
|
25816
|
-
reminderInjectedCount: 0,
|
|
25817
|
-
...persisted
|
|
25818
|
-
};
|
|
25819
|
-
sessionStates.set(sessionID, state2);
|
|
25820
|
-
}
|
|
25821
|
-
return sessionStates.get(sessionID);
|
|
25822
|
-
}
|
|
25823
|
-
function resetState(sessionID) {
|
|
25824
|
-
sessionStates.delete(sessionID);
|
|
25825
|
-
clearThinkingValidatorState(sessionID);
|
|
25826
|
-
}
|
|
25827
|
-
function computeFingerprint(text) {
|
|
25828
|
-
const hasher = new Bun.CryptoHasher("sha256");
|
|
25829
|
-
hasher.update(text);
|
|
25830
|
-
return hasher.digest("hex").slice(0, 16);
|
|
25831
|
-
}
|
|
25832
|
-
const toolExecuteAfter = async (input, output) => {
|
|
25833
|
-
if (!isLanguageEnforcementEnabled(config))
|
|
25834
|
-
return;
|
|
25835
|
-
const { sessionID } = input;
|
|
25836
|
-
const state2 = getOrCreateState(sessionID);
|
|
25837
|
-
if (state2.pendingViolationFingerprint) {
|
|
25838
|
-
output.output += THINKING_VIOLATION_REMINDER;
|
|
25839
|
-
state2.reminderInjectedCount++;
|
|
25840
|
-
state2.notifiedFingerprints.push(state2.pendingViolationFingerprint);
|
|
25841
|
-
if (state2.notifiedFingerprints.length > 100) {
|
|
25842
|
-
state2.notifiedFingerprints.shift();
|
|
25843
|
-
}
|
|
25844
|
-
state2.pendingViolationFingerprint = null;
|
|
25845
|
-
state2.updatedAt = Date.now();
|
|
25846
|
-
saveThinkingValidatorState(state2);
|
|
25847
|
-
}
|
|
25848
|
-
};
|
|
25849
|
-
const eventHandler = async ({ event }) => {
|
|
25850
|
-
const props = event.properties;
|
|
25851
|
-
if (event.type === "session.deleted") {
|
|
25852
|
-
const sessionInfo = props?.info;
|
|
25853
|
-
if (sessionInfo?.id) {
|
|
25854
|
-
resetState(sessionInfo.id);
|
|
25855
|
-
}
|
|
25856
|
-
}
|
|
25857
|
-
if (event.type === "session.compacted") {
|
|
25858
|
-
const sessionID = props?.sessionID ?? props?.info?.id;
|
|
25859
|
-
if (sessionID) {
|
|
25860
|
-
resetState(sessionID);
|
|
25861
|
-
}
|
|
25862
|
-
}
|
|
25863
|
-
if (event.type === "message.part.updated") {
|
|
25864
|
-
const info = props?.info;
|
|
25865
|
-
const sessionID = info?.sessionID;
|
|
25866
|
-
const role = info?.role;
|
|
25867
|
-
if (!sessionID || role !== "assistant")
|
|
25868
|
-
return;
|
|
25869
|
-
const agent = info?.agent;
|
|
25870
|
-
if (agent && excludedAgents.some((a) => agentNameMatches(agent, a)))
|
|
25871
|
-
return;
|
|
25872
|
-
const part = props?.part;
|
|
25873
|
-
if (!part)
|
|
25874
|
-
return;
|
|
25875
|
-
const partType = part.type;
|
|
25876
|
-
if (partType !== "thinking" && partType !== "reasoning")
|
|
25877
|
-
return;
|
|
25878
|
-
const thinkingText = (part.thinking || part.text || "").trim();
|
|
25879
|
-
if (!thinkingText || thinkingText.length < 4)
|
|
25880
|
-
return;
|
|
25881
|
-
const state2 = getOrCreateState(sessionID);
|
|
25882
|
-
if (state2.lastCheckedTextLength > 0 && thinkingText.length - state2.lastCheckedTextLength < STREAM_THROTTLE) {
|
|
25883
|
-
state2.throttleSkipCount++;
|
|
25884
|
-
saveThinkingValidatorState(state2);
|
|
25885
|
-
return;
|
|
25886
|
-
}
|
|
25887
|
-
const effectiveThreshold = agent && relaxedAgents.some((a) => agentNameMatches(agent, a)) ? relaxedThreshold : violationThreshold;
|
|
25888
|
-
const isViolation = detectEnglishViolation(thinkingText, effectiveThreshold);
|
|
25889
|
-
if (isViolation) {
|
|
25890
|
-
state2.totalDetectionCount++;
|
|
25891
|
-
if (isViolation === "trigger") {
|
|
25892
|
-
state2.triggerWordHitCount++;
|
|
25893
|
-
} else {
|
|
25894
|
-
state2.asciiRatioHitCount++;
|
|
25895
|
-
}
|
|
25896
|
-
const fingerprint = computeFingerprint(thinkingText);
|
|
25897
|
-
if (!state2.notifiedFingerprints.includes(fingerprint)) {
|
|
25898
|
-
state2.pendingViolationFingerprint = fingerprint;
|
|
25899
|
-
state2.lastCheckedTextLength = thinkingText.length;
|
|
25900
|
-
state2.updatedAt = Date.now();
|
|
25901
|
-
saveThinkingValidatorState(state2);
|
|
25902
|
-
} else {
|
|
25903
|
-
state2.dedupSkipCount++;
|
|
25904
|
-
saveThinkingValidatorState(state2);
|
|
25905
|
-
}
|
|
25906
|
-
}
|
|
25907
|
-
}
|
|
25908
|
-
};
|
|
25909
|
-
return {
|
|
25910
|
-
"tool.execute.after": toolExecuteAfter,
|
|
25911
|
-
event: eventHandler
|
|
25912
|
-
};
|
|
25913
|
-
}
|
|
25914
25569
|
// src/hooks/keyword-detector/constants.ts
|
|
25915
25570
|
init_agent_display_names();
|
|
25916
25571
|
var CODE_BLOCK_PATTERN2 = /```[\s\S]*?```/g;
|
|
@@ -26398,19 +26053,19 @@ function createNonInteractiveEnvHook(_ctx) {
|
|
|
26398
26053
|
}
|
|
26399
26054
|
// src/hooks/interactive-bash-session/storage.ts
|
|
26400
26055
|
import {
|
|
26401
|
-
existsSync as
|
|
26402
|
-
mkdirSync as
|
|
26403
|
-
readFileSync as
|
|
26404
|
-
writeFileSync as
|
|
26405
|
-
unlinkSync as
|
|
26056
|
+
existsSync as existsSync31,
|
|
26057
|
+
mkdirSync as mkdirSync13,
|
|
26058
|
+
readFileSync as readFileSync23,
|
|
26059
|
+
writeFileSync as writeFileSync16,
|
|
26060
|
+
unlinkSync as unlinkSync8
|
|
26406
26061
|
} from "fs";
|
|
26407
|
-
import { join as
|
|
26062
|
+
import { join as join41 } from "path";
|
|
26408
26063
|
|
|
26409
26064
|
// src/hooks/interactive-bash-session/constants.ts
|
|
26410
26065
|
init_data_path();
|
|
26411
|
-
import { join as
|
|
26412
|
-
var
|
|
26413
|
-
var INTERACTIVE_BASH_SESSION_STORAGE =
|
|
26066
|
+
import { join as join40 } from "path";
|
|
26067
|
+
var OPENCODE_STORAGE8 = getOpenCodeStorageDir();
|
|
26068
|
+
var INTERACTIVE_BASH_SESSION_STORAGE = join40(OPENCODE_STORAGE8, "interactive-bash-session");
|
|
26414
26069
|
var OMO_SESSION_PREFIX = "omo-";
|
|
26415
26070
|
function buildSessionReminderMessage(sessions) {
|
|
26416
26071
|
if (sessions.length === 0)
|
|
@@ -26421,15 +26076,15 @@ function buildSessionReminderMessage(sessions) {
|
|
|
26421
26076
|
}
|
|
26422
26077
|
|
|
26423
26078
|
// src/hooks/interactive-bash-session/storage.ts
|
|
26424
|
-
function
|
|
26425
|
-
return
|
|
26079
|
+
function getStoragePath5(sessionID) {
|
|
26080
|
+
return join41(INTERACTIVE_BASH_SESSION_STORAGE, `${sessionID}.json`);
|
|
26426
26081
|
}
|
|
26427
26082
|
function loadInteractiveBashSessionState(sessionID) {
|
|
26428
|
-
const filePath =
|
|
26429
|
-
if (!
|
|
26083
|
+
const filePath = getStoragePath5(sessionID);
|
|
26084
|
+
if (!existsSync31(filePath))
|
|
26430
26085
|
return null;
|
|
26431
26086
|
try {
|
|
26432
|
-
const content =
|
|
26087
|
+
const content = readFileSync23(filePath, "utf-8");
|
|
26433
26088
|
const serialized = JSON.parse(content);
|
|
26434
26089
|
return {
|
|
26435
26090
|
sessionID: serialized.sessionID,
|
|
@@ -26441,21 +26096,21 @@ function loadInteractiveBashSessionState(sessionID) {
|
|
|
26441
26096
|
}
|
|
26442
26097
|
}
|
|
26443
26098
|
function saveInteractiveBashSessionState(state2) {
|
|
26444
|
-
if (!
|
|
26445
|
-
|
|
26099
|
+
if (!existsSync31(INTERACTIVE_BASH_SESSION_STORAGE)) {
|
|
26100
|
+
mkdirSync13(INTERACTIVE_BASH_SESSION_STORAGE, { recursive: true });
|
|
26446
26101
|
}
|
|
26447
|
-
const filePath =
|
|
26102
|
+
const filePath = getStoragePath5(state2.sessionID);
|
|
26448
26103
|
const serialized = {
|
|
26449
26104
|
sessionID: state2.sessionID,
|
|
26450
26105
|
tmuxSessions: Array.from(state2.tmuxSessions),
|
|
26451
26106
|
updatedAt: state2.updatedAt
|
|
26452
26107
|
};
|
|
26453
|
-
|
|
26108
|
+
writeFileSync16(filePath, JSON.stringify(serialized, null, 2));
|
|
26454
26109
|
}
|
|
26455
26110
|
function clearInteractiveBashSessionState(sessionID) {
|
|
26456
|
-
const filePath =
|
|
26457
|
-
if (
|
|
26458
|
-
|
|
26111
|
+
const filePath = getStoragePath5(sessionID);
|
|
26112
|
+
if (existsSync31(filePath)) {
|
|
26113
|
+
unlinkSync8(filePath);
|
|
26459
26114
|
}
|
|
26460
26115
|
}
|
|
26461
26116
|
|
|
@@ -26718,13 +26373,13 @@ function createThinkingBlockValidatorHook() {
|
|
|
26718
26373
|
// src/hooks/ralph-loop/index.ts
|
|
26719
26374
|
init_logger();
|
|
26720
26375
|
init_system_directive();
|
|
26721
|
-
import { existsSync as
|
|
26722
|
-
import { join as
|
|
26376
|
+
import { existsSync as existsSync33, readFileSync as readFileSync25, readdirSync as readdirSync8 } from "fs";
|
|
26377
|
+
import { join as join43 } from "path";
|
|
26723
26378
|
|
|
26724
26379
|
// src/hooks/ralph-loop/storage.ts
|
|
26725
26380
|
init_frontmatter();
|
|
26726
|
-
import { existsSync as
|
|
26727
|
-
import { dirname as dirname6, join as
|
|
26381
|
+
import { existsSync as existsSync32, readFileSync as readFileSync24, writeFileSync as writeFileSync17, unlinkSync as unlinkSync9, mkdirSync as mkdirSync14 } from "fs";
|
|
26382
|
+
import { dirname as dirname6, join as join42 } from "path";
|
|
26728
26383
|
|
|
26729
26384
|
// src/hooks/ralph-loop/constants.ts
|
|
26730
26385
|
var HOOK_NAME3 = "ralph-loop";
|
|
@@ -26734,15 +26389,15 @@ var DEFAULT_COMPLETION_PROMISE = "DONE";
|
|
|
26734
26389
|
|
|
26735
26390
|
// src/hooks/ralph-loop/storage.ts
|
|
26736
26391
|
function getStateFilePath(directory, customPath) {
|
|
26737
|
-
return customPath ?
|
|
26392
|
+
return customPath ? join42(directory, customPath) : join42(directory, DEFAULT_STATE_FILE);
|
|
26738
26393
|
}
|
|
26739
26394
|
function readState(directory, customPath) {
|
|
26740
26395
|
const filePath = getStateFilePath(directory, customPath);
|
|
26741
|
-
if (!
|
|
26396
|
+
if (!existsSync32(filePath)) {
|
|
26742
26397
|
return null;
|
|
26743
26398
|
}
|
|
26744
26399
|
try {
|
|
26745
|
-
const content =
|
|
26400
|
+
const content = readFileSync24(filePath, "utf-8");
|
|
26746
26401
|
const { data, body } = parseFrontmatter(content);
|
|
26747
26402
|
const active = data.active;
|
|
26748
26403
|
const iteration = data.iteration;
|
|
@@ -26776,8 +26431,8 @@ function writeState(directory, state2, customPath) {
|
|
|
26776
26431
|
const filePath = getStateFilePath(directory, customPath);
|
|
26777
26432
|
try {
|
|
26778
26433
|
const dir = dirname6(filePath);
|
|
26779
|
-
if (!
|
|
26780
|
-
|
|
26434
|
+
if (!existsSync32(dir)) {
|
|
26435
|
+
mkdirSync14(dir, { recursive: true });
|
|
26781
26436
|
}
|
|
26782
26437
|
const sessionIdLine = state2.session_id ? `session_id: "${state2.session_id}"
|
|
26783
26438
|
` : "";
|
|
@@ -26792,7 +26447,7 @@ started_at: "${state2.started_at}"
|
|
|
26792
26447
|
${sessionIdLine}${ultraworkLine}---
|
|
26793
26448
|
${state2.prompt}
|
|
26794
26449
|
`;
|
|
26795
|
-
|
|
26450
|
+
writeFileSync17(filePath, content, "utf-8");
|
|
26796
26451
|
return true;
|
|
26797
26452
|
} catch {
|
|
26798
26453
|
return false;
|
|
@@ -26801,8 +26456,8 @@ ${state2.prompt}
|
|
|
26801
26456
|
function clearState(directory, customPath) {
|
|
26802
26457
|
const filePath = getStateFilePath(directory, customPath);
|
|
26803
26458
|
try {
|
|
26804
|
-
if (
|
|
26805
|
-
|
|
26459
|
+
if (existsSync32(filePath)) {
|
|
26460
|
+
unlinkSync9(filePath);
|
|
26806
26461
|
}
|
|
26807
26462
|
return true;
|
|
26808
26463
|
} catch {
|
|
@@ -26823,14 +26478,14 @@ function incrementIteration(directory, customPath) {
|
|
|
26823
26478
|
// src/hooks/ralph-loop/index.ts
|
|
26824
26479
|
init_agent_display_names();
|
|
26825
26480
|
function getMessageDir4(sessionID) {
|
|
26826
|
-
if (!
|
|
26481
|
+
if (!existsSync33(MESSAGE_STORAGE))
|
|
26827
26482
|
return null;
|
|
26828
|
-
const directPath =
|
|
26829
|
-
if (
|
|
26483
|
+
const directPath = join43(MESSAGE_STORAGE, sessionID);
|
|
26484
|
+
if (existsSync33(directPath))
|
|
26830
26485
|
return directPath;
|
|
26831
26486
|
for (const dir of readdirSync8(MESSAGE_STORAGE)) {
|
|
26832
|
-
const sessionPath =
|
|
26833
|
-
if (
|
|
26487
|
+
const sessionPath = join43(MESSAGE_STORAGE, dir, sessionID);
|
|
26488
|
+
if (existsSync33(sessionPath))
|
|
26834
26489
|
return sessionPath;
|
|
26835
26490
|
}
|
|
26836
26491
|
return null;
|
|
@@ -26867,9 +26522,9 @@ function createRalphLoopHook(ctx, options) {
|
|
|
26867
26522
|
if (!transcriptPath)
|
|
26868
26523
|
return false;
|
|
26869
26524
|
try {
|
|
26870
|
-
if (!
|
|
26525
|
+
if (!existsSync33(transcriptPath))
|
|
26871
26526
|
return false;
|
|
26872
|
-
const content =
|
|
26527
|
+
const content = readFileSync25(transcriptPath, "utf-8");
|
|
26873
26528
|
const pattern = new RegExp(`<promise>\\s*${escapeRegex(promise)}\\s*</promise>`, "is");
|
|
26874
26529
|
const lines = content.split(`
|
|
26875
26530
|
`).filter((l) => l.trim());
|
|
@@ -27183,12 +26838,12 @@ function extractPromptText3(parts) {
|
|
|
27183
26838
|
// src/hooks/auto-slash-command/executor.ts
|
|
27184
26839
|
init_shared();
|
|
27185
26840
|
init_file_utils();
|
|
27186
|
-
import { existsSync as
|
|
27187
|
-
import { join as
|
|
26841
|
+
import { existsSync as existsSync35, readdirSync as readdirSync9, readFileSync as readFileSync27 } from "fs";
|
|
26842
|
+
import { join as join44, basename as basename2, dirname as dirname8 } from "path";
|
|
27188
26843
|
// src/features/opencode-skill-loader/merger.ts
|
|
27189
26844
|
init_frontmatter();
|
|
27190
26845
|
init_deep_merge();
|
|
27191
|
-
import { readFileSync as
|
|
26846
|
+
import { readFileSync as readFileSync26, existsSync as existsSync34 } from "fs";
|
|
27192
26847
|
import { dirname as dirname7, resolve as resolve6, isAbsolute as isAbsolute2 } from "path";
|
|
27193
26848
|
import { homedir as homedir12 } from "os";
|
|
27194
26849
|
import { createHash as createHash2 } from "crypto";
|
|
@@ -27237,9 +26892,9 @@ function resolveFilePath2(from, configDir) {
|
|
|
27237
26892
|
}
|
|
27238
26893
|
function loadSkillFromFile(filePath) {
|
|
27239
26894
|
try {
|
|
27240
|
-
if (!
|
|
26895
|
+
if (!existsSync34(filePath))
|
|
27241
26896
|
return null;
|
|
27242
|
-
const content =
|
|
26897
|
+
const content = readFileSync26(filePath, "utf-8");
|
|
27243
26898
|
const { data, body } = parseFrontmatter(content);
|
|
27244
26899
|
return { template: body, metadata: data };
|
|
27245
26900
|
} catch {
|
|
@@ -27437,7 +27092,7 @@ function mergeSkills(builtinSkills, config, userClaudeSkills, userOpencodeSkills
|
|
|
27437
27092
|
}
|
|
27438
27093
|
// src/hooks/auto-slash-command/executor.ts
|
|
27439
27094
|
function discoverCommandsFromDir(commandsDir, scope) {
|
|
27440
|
-
if (!
|
|
27095
|
+
if (!existsSync35(commandsDir)) {
|
|
27441
27096
|
return [];
|
|
27442
27097
|
}
|
|
27443
27098
|
const entries = readdirSync9(commandsDir, { withFileTypes: true });
|
|
@@ -27445,10 +27100,10 @@ function discoverCommandsFromDir(commandsDir, scope) {
|
|
|
27445
27100
|
for (const entry of entries) {
|
|
27446
27101
|
if (!isMarkdownFile(entry))
|
|
27447
27102
|
continue;
|
|
27448
|
-
const commandPath =
|
|
27103
|
+
const commandPath = join44(commandsDir, entry.name);
|
|
27449
27104
|
const commandName = basename2(entry.name, ".md");
|
|
27450
27105
|
try {
|
|
27451
|
-
const content =
|
|
27106
|
+
const content = readFileSync27(commandPath, "utf-8");
|
|
27452
27107
|
const { data, body } = parseFrontmatter(content);
|
|
27453
27108
|
const isOpencodeSource = scope === "opencode" || scope === "opencode-project";
|
|
27454
27109
|
const metadata = {
|
|
@@ -27491,10 +27146,10 @@ function skillToCommandInfo(skill) {
|
|
|
27491
27146
|
}
|
|
27492
27147
|
async function discoverAllCommands(options) {
|
|
27493
27148
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
27494
|
-
const userCommandsDir =
|
|
27495
|
-
const projectCommandsDir =
|
|
27496
|
-
const opencodeGlobalDir =
|
|
27497
|
-
const opencodeProjectDir =
|
|
27149
|
+
const userCommandsDir = join44(getClaudeConfigDir(), "commands");
|
|
27150
|
+
const projectCommandsDir = join44(process.cwd(), ".claude", "commands");
|
|
27151
|
+
const opencodeGlobalDir = join44(configDir, "command");
|
|
27152
|
+
const opencodeProjectDir = join44(process.cwd(), ".opencode", "command");
|
|
27498
27153
|
const userCommands = discoverCommandsFromDir(userCommandsDir, "user");
|
|
27499
27154
|
const opencodeGlobalCommands = discoverCommandsFromDir(opencodeGlobalDir, "opencode");
|
|
27500
27155
|
const projectCommands = discoverCommandsFromDir(projectCommandsDir, "project");
|
|
@@ -27994,8 +27649,8 @@ var NOTEPAD_DIR = "notepads";
|
|
|
27994
27649
|
var NOTEPAD_BASE_PATH = `${BOULDER_DIR}/${NOTEPAD_DIR}`;
|
|
27995
27650
|
var PROMETHEUS_PLANS_DIR = ".sisyphus/plans";
|
|
27996
27651
|
// src/features/boulder-state/storage.ts
|
|
27997
|
-
import { existsSync as
|
|
27998
|
-
import { dirname as dirname9, join as
|
|
27652
|
+
import { existsSync as existsSync36, readFileSync as readFileSync28, writeFileSync as writeFileSync18, mkdirSync as mkdirSync15, readdirSync as readdirSync10, renameSync as renameSync2, unlinkSync as unlinkSync10, statSync as statSync4 } from "fs";
|
|
27653
|
+
import { dirname as dirname9, join as join46, basename as basename3 } from "path";
|
|
27999
27654
|
init_logger();
|
|
28000
27655
|
|
|
28001
27656
|
// src/features/boulder-state/event-bus.ts
|
|
@@ -28078,7 +27733,7 @@ function retryOnWindowsError(fn) {
|
|
|
28078
27733
|
throw lastError;
|
|
28079
27734
|
}
|
|
28080
27735
|
function getBoulderFilePath(directory) {
|
|
28081
|
-
return
|
|
27736
|
+
return join46(directory, BOULDER_DIR, BOULDER_FILE);
|
|
28082
27737
|
}
|
|
28083
27738
|
function isValidBoulderStateSchema(state2) {
|
|
28084
27739
|
if (typeof state2 !== "object" || state2 === null) {
|
|
@@ -28107,11 +27762,11 @@ function isValidVersion(version) {
|
|
|
28107
27762
|
}
|
|
28108
27763
|
function readBoulderState(directory) {
|
|
28109
27764
|
const filePath = getBoulderFilePath(directory);
|
|
28110
|
-
if (!
|
|
27765
|
+
if (!existsSync36(filePath)) {
|
|
28111
27766
|
return null;
|
|
28112
27767
|
}
|
|
28113
27768
|
try {
|
|
28114
|
-
const content =
|
|
27769
|
+
const content = readFileSync28(filePath, "utf-8");
|
|
28115
27770
|
const state2 = JSON.parse(content);
|
|
28116
27771
|
if (state2.version === undefined || state2.version === null) {
|
|
28117
27772
|
state2.version = 0;
|
|
@@ -28142,14 +27797,14 @@ function tryRestoreFromBackup(directory) {
|
|
|
28142
27797
|
}
|
|
28143
27798
|
function backupBoulderState(directory) {
|
|
28144
27799
|
const filePath = getBoulderFilePath(directory);
|
|
28145
|
-
if (!
|
|
27800
|
+
if (!existsSync36(filePath)) {
|
|
28146
27801
|
return true;
|
|
28147
27802
|
}
|
|
28148
27803
|
try {
|
|
28149
27804
|
const dir = dirname9(filePath);
|
|
28150
27805
|
const timestamp = Date.now();
|
|
28151
|
-
const backupPath =
|
|
28152
|
-
|
|
27806
|
+
const backupPath = join46(dir, `${BACKUP_PREFIX}${timestamp}`);
|
|
27807
|
+
writeFileSync18(backupPath, readFileSync28(filePath, "utf-8"), "utf-8");
|
|
28153
27808
|
log(`Created boulder state backup: ${backupPath}`);
|
|
28154
27809
|
cleanupOldBackups(dir);
|
|
28155
27810
|
return true;
|
|
@@ -28162,37 +27817,37 @@ function cleanupOldBackups(dir) {
|
|
|
28162
27817
|
const files = readdirSync10(dir);
|
|
28163
27818
|
const backupFiles = files.filter((f) => f.startsWith(BACKUP_PREFIX)).map((f) => ({
|
|
28164
27819
|
name: f,
|
|
28165
|
-
path:
|
|
27820
|
+
path: join46(dir, f),
|
|
28166
27821
|
timestamp: parseInt(f.slice(BACKUP_PREFIX.length), 10)
|
|
28167
27822
|
})).filter((f) => !isNaN(f.timestamp)).sort((a, b) => b.timestamp - a.timestamp);
|
|
28168
27823
|
for (const file of backupFiles.slice(MAX_BACKUPS)) {
|
|
28169
27824
|
try {
|
|
28170
|
-
|
|
27825
|
+
unlinkSync10(file.path);
|
|
28171
27826
|
log(`Removed old backup: ${file.path}`);
|
|
28172
27827
|
} catch {}
|
|
28173
27828
|
}
|
|
28174
27829
|
} catch {}
|
|
28175
27830
|
}
|
|
28176
27831
|
function restoreBoulderState(directory) {
|
|
28177
|
-
const dir =
|
|
28178
|
-
if (!
|
|
27832
|
+
const dir = join46(directory, BOULDER_DIR);
|
|
27833
|
+
if (!existsSync36(dir)) {
|
|
28179
27834
|
return null;
|
|
28180
27835
|
}
|
|
28181
27836
|
try {
|
|
28182
27837
|
const files = readdirSync10(dir);
|
|
28183
27838
|
const backupFiles = files.filter((f) => f.startsWith(BACKUP_PREFIX)).map((f) => ({
|
|
28184
27839
|
name: f,
|
|
28185
|
-
path:
|
|
27840
|
+
path: join46(dir, f),
|
|
28186
27841
|
timestamp: parseInt(f.slice(BACKUP_PREFIX.length), 10)
|
|
28187
27842
|
})).filter((f) => !isNaN(f.timestamp)).sort((a, b) => b.timestamp - a.timestamp);
|
|
28188
27843
|
if (backupFiles.length === 0) {
|
|
28189
27844
|
return null;
|
|
28190
27845
|
}
|
|
28191
27846
|
const latestBackup = backupFiles[0];
|
|
28192
|
-
const content =
|
|
27847
|
+
const content = readFileSync28(latestBackup.path, "utf-8");
|
|
28193
27848
|
const state2 = JSON.parse(content);
|
|
28194
27849
|
const filePath = getBoulderFilePath(directory);
|
|
28195
|
-
|
|
27850
|
+
writeFileSync18(filePath, content, "utf-8");
|
|
28196
27851
|
log(`Restored boulder state from backup: ${latestBackup.path}`);
|
|
28197
27852
|
return state2;
|
|
28198
27853
|
} catch {
|
|
@@ -28203,18 +27858,18 @@ function writeBoulderState(directory, state2) {
|
|
|
28203
27858
|
const filePath = getBoulderFilePath(directory);
|
|
28204
27859
|
try {
|
|
28205
27860
|
const dir = dirname9(filePath);
|
|
28206
|
-
if (!
|
|
28207
|
-
|
|
27861
|
+
if (!existsSync36(dir)) {
|
|
27862
|
+
mkdirSync15(dir, { recursive: true });
|
|
28208
27863
|
}
|
|
28209
27864
|
backupBoulderState(directory);
|
|
28210
27865
|
const tmpPath = `${filePath}.tmp.${process.pid}`;
|
|
28211
27866
|
try {
|
|
28212
|
-
|
|
27867
|
+
writeFileSync18(tmpPath, JSON.stringify(state2, null, 2), "utf-8");
|
|
28213
27868
|
retryOnWindowsError(() => renameSync2(tmpPath, filePath));
|
|
28214
27869
|
} finally {
|
|
28215
27870
|
try {
|
|
28216
|
-
if (
|
|
28217
|
-
|
|
27871
|
+
if (existsSync36(tmpPath)) {
|
|
27872
|
+
unlinkSync10(tmpPath);
|
|
28218
27873
|
}
|
|
28219
27874
|
} catch {}
|
|
28220
27875
|
}
|
|
@@ -28267,9 +27922,9 @@ function markBoulderPlanCompleted(directory, completedAt) {
|
|
|
28267
27922
|
function clearBoulderState(directory) {
|
|
28268
27923
|
const filePath = getBoulderFilePath(directory);
|
|
28269
27924
|
try {
|
|
28270
|
-
if (
|
|
28271
|
-
const { unlinkSync:
|
|
28272
|
-
|
|
27925
|
+
if (existsSync36(filePath)) {
|
|
27926
|
+
const { unlinkSync: unlinkSync11 } = __require("fs");
|
|
27927
|
+
unlinkSync11(filePath);
|
|
28273
27928
|
}
|
|
28274
27929
|
return true;
|
|
28275
27930
|
} catch {
|
|
@@ -28277,13 +27932,13 @@ function clearBoulderState(directory) {
|
|
|
28277
27932
|
}
|
|
28278
27933
|
}
|
|
28279
27934
|
function findPrometheusPlans(directory) {
|
|
28280
|
-
const plansDir =
|
|
28281
|
-
if (!
|
|
27935
|
+
const plansDir = join46(directory, PROMETHEUS_PLANS_DIR);
|
|
27936
|
+
if (!existsSync36(plansDir)) {
|
|
28282
27937
|
return [];
|
|
28283
27938
|
}
|
|
28284
27939
|
try {
|
|
28285
27940
|
const files = readdirSync10(plansDir);
|
|
28286
|
-
return files.filter((f) => f.endsWith(".md")).map((f) =>
|
|
27941
|
+
return files.filter((f) => f.endsWith(".md")).map((f) => join46(plansDir, f)).sort((a, b) => {
|
|
28287
27942
|
const aStat = __require("fs").statSync(a);
|
|
28288
27943
|
const bStat = __require("fs").statSync(b);
|
|
28289
27944
|
return bStat.mtimeMs - aStat.mtimeMs;
|
|
@@ -28293,11 +27948,11 @@ function findPrometheusPlans(directory) {
|
|
|
28293
27948
|
}
|
|
28294
27949
|
}
|
|
28295
27950
|
function getPlanProgress(planPath) {
|
|
28296
|
-
if (!
|
|
27951
|
+
if (!existsSync36(planPath)) {
|
|
28297
27952
|
return { total: 0, completed: 0, isComplete: false };
|
|
28298
27953
|
}
|
|
28299
27954
|
try {
|
|
28300
|
-
const content =
|
|
27955
|
+
const content = readFileSync28(planPath, "utf-8");
|
|
28301
27956
|
if (!content.trim()) {
|
|
28302
27957
|
return { total: 0, completed: 0, isComplete: false };
|
|
28303
27958
|
}
|
|
@@ -28327,8 +27982,8 @@ function createBoulderState(planPath, sessionId) {
|
|
|
28327
27982
|
};
|
|
28328
27983
|
}
|
|
28329
27984
|
function cleanupStaleTmpFiles(directory) {
|
|
28330
|
-
const boulderDir =
|
|
28331
|
-
if (!
|
|
27985
|
+
const boulderDir = join46(directory, BOULDER_DIR);
|
|
27986
|
+
if (!existsSync36(boulderDir)) {
|
|
28332
27987
|
return;
|
|
28333
27988
|
}
|
|
28334
27989
|
try {
|
|
@@ -28338,11 +27993,11 @@ function cleanupStaleTmpFiles(directory) {
|
|
|
28338
27993
|
if (!file.startsWith(`${BOULDER_FILE}.tmp.`)) {
|
|
28339
27994
|
continue;
|
|
28340
27995
|
}
|
|
28341
|
-
const filePath =
|
|
27996
|
+
const filePath = join46(boulderDir, file);
|
|
28342
27997
|
try {
|
|
28343
27998
|
const stat = statSync4(filePath);
|
|
28344
27999
|
if (now - stat.mtimeMs > STALE_TMP_THRESHOLD_MS) {
|
|
28345
|
-
|
|
28000
|
+
unlinkSync10(filePath);
|
|
28346
28001
|
log(`Removed stale tmp file: ${filePath}`);
|
|
28347
28002
|
}
|
|
28348
28003
|
} catch {}
|
|
@@ -28352,7 +28007,7 @@ function cleanupStaleTmpFiles(directory) {
|
|
|
28352
28007
|
// src/features/boulder-state/checkbox-utils.ts
|
|
28353
28008
|
init_logger();
|
|
28354
28009
|
import { appendFileSync as appendFileSync7 } from "fs";
|
|
28355
|
-
import { join as
|
|
28010
|
+
import { join as join47 } from "path";
|
|
28356
28011
|
function parseCheckboxes(content) {
|
|
28357
28012
|
const lines = content.split(`
|
|
28358
28013
|
`);
|
|
@@ -28422,7 +28077,7 @@ function handleMatchFailure(taskDescription, checkboxes, directory, planName) {
|
|
|
28422
28077
|
checkboxCount: checkboxes.length,
|
|
28423
28078
|
planName
|
|
28424
28079
|
});
|
|
28425
|
-
const notepadPath =
|
|
28080
|
+
const notepadPath = join47(directory, ".sisyphus", "notepads", planName, "match-failures.md");
|
|
28426
28081
|
const entry = `
|
|
28427
28082
|
## ${new Date().toISOString()}
|
|
28428
28083
|
**\u4EFB\u52A1\u63CF\u8FF0**\uFF1A${taskDescription}
|
|
@@ -28662,8 +28317,8 @@ ${contextInfo}`;
|
|
|
28662
28317
|
}
|
|
28663
28318
|
// src/hooks/atlas/index.ts
|
|
28664
28319
|
import { execSync } from "child_process";
|
|
28665
|
-
import { existsSync as
|
|
28666
|
-
import { join as
|
|
28320
|
+
import { existsSync as existsSync37, openSync, closeSync, unlinkSync as unlinkSync11, readdirSync as readdirSync11, readFileSync as readFileSync29, renameSync as renameSync3, writeFileSync as writeFileSync19 } from "fs";
|
|
28321
|
+
import { join as join48 } from "path";
|
|
28667
28322
|
init_claude_code_session_state();
|
|
28668
28323
|
init_logger();
|
|
28669
28324
|
init_system_directive();
|
|
@@ -28826,7 +28481,7 @@ function acquirePlanFileLock(planPath, maxRetries = 8, retryDelayMs = 125) {
|
|
|
28826
28481
|
for (let attempt = 0;attempt < maxRetries; attempt++) {
|
|
28827
28482
|
try {
|
|
28828
28483
|
const fd = openSync(lockPath, "wx");
|
|
28829
|
-
|
|
28484
|
+
writeFileSync19(fd, String(process.pid));
|
|
28830
28485
|
closeSync(fd);
|
|
28831
28486
|
log(`[${HOOK_NAME6}] Acquired file lock for ${planPath}`);
|
|
28832
28487
|
return true;
|
|
@@ -28849,7 +28504,7 @@ function acquirePlanFileLock(planPath, maxRetries = 8, retryDelayMs = 125) {
|
|
|
28849
28504
|
function releasePlanFileLock(planPath) {
|
|
28850
28505
|
const lockPath = `${planPath}.lock`;
|
|
28851
28506
|
try {
|
|
28852
|
-
|
|
28507
|
+
unlinkSync11(lockPath);
|
|
28853
28508
|
log(`[${HOOK_NAME6}] Released file lock for ${planPath}`);
|
|
28854
28509
|
} catch (err) {
|
|
28855
28510
|
if (err.code !== "ENOENT") {
|
|
@@ -28864,13 +28519,13 @@ function writePlanFileAtomic(planPath, content) {
|
|
|
28864
28519
|
try {
|
|
28865
28520
|
const tmpPath = `${planPath}.tmp.${process.pid}`;
|
|
28866
28521
|
try {
|
|
28867
|
-
|
|
28522
|
+
writeFileSync19(tmpPath, content, "utf-8");
|
|
28868
28523
|
retryOnWindowsError(() => renameSync3(tmpPath, planPath));
|
|
28869
28524
|
return true;
|
|
28870
28525
|
} finally {
|
|
28871
28526
|
try {
|
|
28872
|
-
if (
|
|
28873
|
-
|
|
28527
|
+
if (existsSync37(tmpPath)) {
|
|
28528
|
+
unlinkSync11(tmpPath);
|
|
28874
28529
|
}
|
|
28875
28530
|
} catch {}
|
|
28876
28531
|
}
|
|
@@ -28885,7 +28540,7 @@ function syncPlanFileFromBoulder(directory, boulderState) {
|
|
|
28885
28540
|
}
|
|
28886
28541
|
const planPath = boulderState.active_plan;
|
|
28887
28542
|
try {
|
|
28888
|
-
const planContent =
|
|
28543
|
+
const planContent = readFileSync29(planPath, "utf-8");
|
|
28889
28544
|
const checkboxes = parseCheckboxes(planContent);
|
|
28890
28545
|
const lines = planContent.split(`
|
|
28891
28546
|
`);
|
|
@@ -28906,7 +28561,7 @@ function syncPlanFileFromBoulder(directory, boulderState) {
|
|
|
28906
28561
|
const updatedContent = lines.join(`
|
|
28907
28562
|
`);
|
|
28908
28563
|
if (!writePlanFileAtomic(planPath, updatedContent)) {
|
|
28909
|
-
retryOnWindowsError(() =>
|
|
28564
|
+
retryOnWindowsError(() => writeFileSync19(planPath, updatedContent, "utf-8"));
|
|
28910
28565
|
log(`[${HOOK_NAME6}] Dual-track sync: atomic write failed, fell back to direct write`, {
|
|
28911
28566
|
plan: boulderState.plan_name
|
|
28912
28567
|
});
|
|
@@ -29096,14 +28751,14 @@ function formatFileChanges(stats, notepadPath) {
|
|
|
29096
28751
|
`);
|
|
29097
28752
|
}
|
|
29098
28753
|
function getMessageDir5(sessionID) {
|
|
29099
|
-
if (!
|
|
28754
|
+
if (!existsSync37(MESSAGE_STORAGE))
|
|
29100
28755
|
return null;
|
|
29101
|
-
const directPath =
|
|
29102
|
-
if (
|
|
28756
|
+
const directPath = join48(MESSAGE_STORAGE, sessionID);
|
|
28757
|
+
if (existsSync37(directPath))
|
|
29103
28758
|
return directPath;
|
|
29104
28759
|
for (const dir of readdirSync11(MESSAGE_STORAGE)) {
|
|
29105
|
-
const sessionPath =
|
|
29106
|
-
if (
|
|
28760
|
+
const sessionPath = join48(MESSAGE_STORAGE, dir, sessionID);
|
|
28761
|
+
if (existsSync37(sessionPath))
|
|
29107
28762
|
return sessionPath;
|
|
29108
28763
|
}
|
|
29109
28764
|
return null;
|
|
@@ -29509,7 +29164,7 @@ function createAtlasHook(ctx, options) {
|
|
|
29509
29164
|
const taskDescription = extractTaskFromPrompt(savedPrompt || "");
|
|
29510
29165
|
if (taskDescription) {
|
|
29511
29166
|
try {
|
|
29512
|
-
const planContent =
|
|
29167
|
+
const planContent = readFileSync29(boulderState.active_plan, "utf-8");
|
|
29513
29168
|
const checkboxes = parseCheckboxes(planContent);
|
|
29514
29169
|
const checkboxIndex = findMatchingCheckbox(taskDescription, checkboxes);
|
|
29515
29170
|
if (checkboxIndex >= 0) {
|
|
@@ -29521,7 +29176,7 @@ function createAtlasHook(ctx, options) {
|
|
|
29521
29176
|
`);
|
|
29522
29177
|
const planPath = boulderState.active_plan;
|
|
29523
29178
|
if (!writePlanFileAtomic(planPath, updatedContent)) {
|
|
29524
|
-
retryOnWindowsError(() =>
|
|
29179
|
+
retryOnWindowsError(() => writeFileSync19(planPath, updatedContent, "utf-8"));
|
|
29525
29180
|
log(`[${HOOK_NAME6}] Atomic plan write failed, fell back to direct write`, {
|
|
29526
29181
|
plan: boulderState.plan_name
|
|
29527
29182
|
});
|
|
@@ -31190,8 +30845,8 @@ function createShellEnvInjectorHook(_ctx) {
|
|
|
31190
30845
|
// src/hooks/plan-completion/index.ts
|
|
31191
30846
|
init_logger();
|
|
31192
30847
|
init_frontmatter();
|
|
31193
|
-
import { existsSync as
|
|
31194
|
-
import { join as
|
|
30848
|
+
import { existsSync as existsSync38, readFileSync as readFileSync30, writeFileSync as writeFileSync20, mkdirSync as mkdirSync16, renameSync as renameSync4, unlinkSync as unlinkSync12 } from "fs";
|
|
30849
|
+
import { join as join49 } from "path";
|
|
31195
30850
|
async function safeExecute(fn, name, onAction) {
|
|
31196
30851
|
try {
|
|
31197
30852
|
await fn();
|
|
@@ -31236,11 +30891,11 @@ function countListItems(content) {
|
|
|
31236
30891
|
}
|
|
31237
30892
|
async function updatePlanSummary(data) {
|
|
31238
30893
|
log(`[plan-completion] updatePlanSummary: ${data.planName}`);
|
|
31239
|
-
if (!
|
|
30894
|
+
if (!existsSync38(data.planPath)) {
|
|
31240
30895
|
log(`[plan-completion] Plan file not found: ${data.planPath}`);
|
|
31241
30896
|
return;
|
|
31242
30897
|
}
|
|
31243
|
-
const content =
|
|
30898
|
+
const content = readFileSync30(data.planPath, "utf-8");
|
|
31244
30899
|
const startedAt = data.boulderState?.started_at || "";
|
|
31245
30900
|
const completedAt = data.boulderState?.completed_at || "";
|
|
31246
30901
|
const duration = formatDuration(startedAt, completedAt);
|
|
@@ -31261,17 +30916,17 @@ async function updatePlanSummary(data) {
|
|
|
31261
30916
|
| \u5B8C\u6210\u4EFB\u52A1\u6570 | ${completedTasks} |
|
|
31262
30917
|
| \u5931\u8D25\u4EFB\u52A1\u6570 | ${failedTasks} |
|
|
31263
30918
|
`;
|
|
31264
|
-
|
|
30919
|
+
writeFileSync20(data.planPath, content + summary, "utf-8");
|
|
31265
30920
|
log(`[plan-completion] Plan summary appended to ${data.planPath}`);
|
|
31266
30921
|
}
|
|
31267
30922
|
async function archivePlan(data) {
|
|
31268
30923
|
log(`[plan-completion] archivePlan: ${data.planName}`);
|
|
31269
|
-
const archivedDir =
|
|
31270
|
-
if (!
|
|
31271
|
-
|
|
30924
|
+
const archivedDir = join49(data.directory, ".sisyphus", "archived");
|
|
30925
|
+
if (!existsSync38(archivedDir)) {
|
|
30926
|
+
mkdirSync16(archivedDir, { recursive: true });
|
|
31272
30927
|
}
|
|
31273
|
-
if (
|
|
31274
|
-
const archivedPath =
|
|
30928
|
+
if (existsSync38(data.planPath)) {
|
|
30929
|
+
const archivedPath = join49(archivedDir, `${data.planName}.md`);
|
|
31275
30930
|
renameSync4(data.planPath, archivedPath);
|
|
31276
30931
|
log(`[plan-completion] Plan archived to ${archivedPath}`);
|
|
31277
30932
|
const boulderState = readBoulderState(data.directory);
|
|
@@ -31281,16 +30936,16 @@ async function archivePlan(data) {
|
|
|
31281
30936
|
log(`[plan-completion] Updated boulder.json active_plan to ${archivedPath}`);
|
|
31282
30937
|
}
|
|
31283
30938
|
}
|
|
31284
|
-
const draftPath =
|
|
31285
|
-
if (
|
|
31286
|
-
|
|
30939
|
+
const draftPath = join49(data.directory, ".sisyphus", "drafts", `${data.planName}.md`);
|
|
30940
|
+
if (existsSync38(draftPath)) {
|
|
30941
|
+
unlinkSync12(draftPath);
|
|
31287
30942
|
log(`[plan-completion] Deleted draft file: ${draftPath}`);
|
|
31288
30943
|
}
|
|
31289
30944
|
}
|
|
31290
30945
|
async function extractLearnings(data) {
|
|
31291
30946
|
log(`[plan-completion] extractLearnings: ${data.planName}`);
|
|
31292
|
-
const notepadDir =
|
|
31293
|
-
if (!
|
|
30947
|
+
const notepadDir = join49(data.directory, ".sisyphus", "notepads", data.planName);
|
|
30948
|
+
if (!existsSync38(notepadDir)) {
|
|
31294
30949
|
log(`[plan-completion] Notepad directory not found: ${notepadDir}`);
|
|
31295
30950
|
return;
|
|
31296
30951
|
}
|
|
@@ -31300,9 +30955,9 @@ async function extractLearnings(data) {
|
|
|
31300
30955
|
let totalIssues = 0;
|
|
31301
30956
|
let totalDecisions = 0;
|
|
31302
30957
|
for (const file of files) {
|
|
31303
|
-
const filePath =
|
|
31304
|
-
if (
|
|
31305
|
-
const content =
|
|
30958
|
+
const filePath = join49(notepadDir, file);
|
|
30959
|
+
if (existsSync38(filePath)) {
|
|
30960
|
+
const content = readFileSync30(filePath, "utf-8");
|
|
31306
30961
|
contents[file] = content;
|
|
31307
30962
|
const count = countListItems(content);
|
|
31308
30963
|
if (file === "learnings.md")
|
|
@@ -31313,9 +30968,9 @@ async function extractLearnings(data) {
|
|
|
31313
30968
|
totalDecisions = count;
|
|
31314
30969
|
}
|
|
31315
30970
|
}
|
|
31316
|
-
const learningsDir =
|
|
31317
|
-
if (!
|
|
31318
|
-
|
|
30971
|
+
const learningsDir = join49(data.directory, ".sisyphus", "learnings");
|
|
30972
|
+
if (!existsSync38(learningsDir)) {
|
|
30973
|
+
mkdirSync16(learningsDir, { recursive: true });
|
|
31319
30974
|
}
|
|
31320
30975
|
const output = `# \u7ECF\u9A8C\u6559\u8BAD\u603B\u7ED3: ${data.planName}
|
|
31321
30976
|
|
|
@@ -31342,8 +30997,8 @@ ${contents["decisions.md"] || "\u65E0"}
|
|
|
31342
30997
|
|
|
31343
30998
|
${contents["match-failures.md"] || "\u65E0"}
|
|
31344
30999
|
`;
|
|
31345
|
-
const outputPath =
|
|
31346
|
-
|
|
31000
|
+
const outputPath = join49(learningsDir, `${data.planName}.md`);
|
|
31001
|
+
writeFileSync20(outputPath, output, "utf-8");
|
|
31347
31002
|
log(`[plan-completion] Learnings saved to ${outputPath}`);
|
|
31348
31003
|
if (data.client?.tui?.showToast) {
|
|
31349
31004
|
data.client.tui.showToast({
|
|
@@ -31362,9 +31017,9 @@ ${contents["match-failures.md"] || "\u65E0"}
|
|
|
31362
31017
|
}
|
|
31363
31018
|
async function generateReport(data) {
|
|
31364
31019
|
log(`[plan-completion] generateReport: ${data.planName}`);
|
|
31365
|
-
const reportsDir =
|
|
31366
|
-
if (!
|
|
31367
|
-
|
|
31020
|
+
const reportsDir = join49(data.directory, ".sisyphus", "reports");
|
|
31021
|
+
if (!existsSync38(reportsDir)) {
|
|
31022
|
+
mkdirSync16(reportsDir, { recursive: true });
|
|
31368
31023
|
}
|
|
31369
31024
|
const startedAt = data.boulderState?.started_at || "";
|
|
31370
31025
|
const completedAt = data.boulderState?.completed_at || "";
|
|
@@ -31375,8 +31030,8 @@ async function generateReport(data) {
|
|
|
31375
31030
|
const version = data.boulderState?.version || 0;
|
|
31376
31031
|
const sessionCount = data.boulderState?.session_ids?.length || 0;
|
|
31377
31032
|
const completedIndices = data.boulderState?.completed_task_indices || [];
|
|
31378
|
-
const notepadPath =
|
|
31379
|
-
const hasNotepad =
|
|
31033
|
+
const notepadPath = join49(data.directory, ".sisyphus", "notepads", data.planName);
|
|
31034
|
+
const hasNotepad = existsSync38(notepadPath);
|
|
31380
31035
|
const report = `# \u8BA1\u5212\u5B8C\u6210\u62A5\u544A
|
|
31381
31036
|
|
|
31382
31037
|
## \u6982\u89C8
|
|
@@ -31415,8 +31070,8 @@ ${hasNotepad ? `## \u8BB0\u4E8B\u672C
|
|
|
31415
31070
|
\u8BB0\u4E8B\u672C\u8DEF\u5F84: ${notepadPath}
|
|
31416
31071
|
` : ""}
|
|
31417
31072
|
`;
|
|
31418
|
-
const reportPath =
|
|
31419
|
-
|
|
31073
|
+
const reportPath = join49(reportsDir, `${data.planName}.md`);
|
|
31074
|
+
writeFileSync20(reportPath, report, "utf-8");
|
|
31420
31075
|
log(`[plan-completion] Report generated at ${reportPath}`);
|
|
31421
31076
|
}
|
|
31422
31077
|
async function runInitDeep(data) {
|
|
@@ -31628,8 +31283,8 @@ function createFirstMessageVariantGate() {
|
|
|
31628
31283
|
}
|
|
31629
31284
|
// src/features/claude-code-mcp-loader/loader.ts
|
|
31630
31285
|
init_shared();
|
|
31631
|
-
import { existsSync as
|
|
31632
|
-
import { join as
|
|
31286
|
+
import { existsSync as existsSync39, readFileSync as readFileSync31 } from "fs";
|
|
31287
|
+
import { join as join50 } from "path";
|
|
31633
31288
|
|
|
31634
31289
|
// src/features/claude-code-mcp-loader/env-expander.ts
|
|
31635
31290
|
function expandEnvVars(value) {
|
|
@@ -31699,13 +31354,13 @@ function getMcpConfigPaths() {
|
|
|
31699
31354
|
const claudeConfigDir = getClaudeConfigDir();
|
|
31700
31355
|
const cwd2 = process.cwd();
|
|
31701
31356
|
return [
|
|
31702
|
-
{ path:
|
|
31703
|
-
{ path:
|
|
31704
|
-
{ path:
|
|
31357
|
+
{ path: join50(claudeConfigDir, ".mcp.json"), scope: "user" },
|
|
31358
|
+
{ path: join50(cwd2, ".mcp.json"), scope: "project" },
|
|
31359
|
+
{ path: join50(cwd2, ".claude", ".mcp.json"), scope: "local" }
|
|
31705
31360
|
];
|
|
31706
31361
|
}
|
|
31707
31362
|
async function loadMcpConfigFile(filePath) {
|
|
31708
|
-
if (!
|
|
31363
|
+
if (!existsSync39(filePath)) {
|
|
31709
31364
|
return null;
|
|
31710
31365
|
}
|
|
31711
31366
|
try {
|
|
@@ -31720,10 +31375,10 @@ function getSystemMcpServerNames() {
|
|
|
31720
31375
|
const names = new Set;
|
|
31721
31376
|
const paths = getMcpConfigPaths();
|
|
31722
31377
|
for (const { path: path7 } of paths) {
|
|
31723
|
-
if (!
|
|
31378
|
+
if (!existsSync39(path7))
|
|
31724
31379
|
continue;
|
|
31725
31380
|
try {
|
|
31726
|
-
const content =
|
|
31381
|
+
const content = readFileSync31(path7, "utf-8");
|
|
31727
31382
|
const config = JSON.parse(content);
|
|
31728
31383
|
if (!config?.mcpServers)
|
|
31729
31384
|
continue;
|
|
@@ -31777,8 +31432,8 @@ async function loadMcpConfigs() {
|
|
|
31777
31432
|
init_claude_code_session_state();
|
|
31778
31433
|
|
|
31779
31434
|
// src/features/claude-code-session-state/recovery.ts
|
|
31780
|
-
import { existsSync as
|
|
31781
|
-
import { join as
|
|
31435
|
+
import { existsSync as existsSync40, readdirSync as readdirSync13 } from "fs";
|
|
31436
|
+
import { join as join51 } from "path";
|
|
31782
31437
|
init_state();
|
|
31783
31438
|
init_logger();
|
|
31784
31439
|
function recoverSessionAgents(directory) {
|
|
@@ -31787,7 +31442,7 @@ function recoverSessionAgents(directory) {
|
|
|
31787
31442
|
loadSessionAgentMap(directory);
|
|
31788
31443
|
}
|
|
31789
31444
|
try {
|
|
31790
|
-
if (!
|
|
31445
|
+
if (!existsSync40(MESSAGE_STORAGE)) {
|
|
31791
31446
|
log("[recovery] MESSAGE_STORAGE directory does not exist", { path: MESSAGE_STORAGE });
|
|
31792
31447
|
return 0;
|
|
31793
31448
|
}
|
|
@@ -31795,13 +31450,13 @@ function recoverSessionAgents(directory) {
|
|
|
31795
31450
|
for (const entry of entries) {
|
|
31796
31451
|
if (!entry.isDirectory())
|
|
31797
31452
|
continue;
|
|
31798
|
-
const projectDir =
|
|
31453
|
+
const projectDir = join51(MESSAGE_STORAGE, entry.name);
|
|
31799
31454
|
try {
|
|
31800
31455
|
const sessionDirs = readdirSync13(projectDir, { withFileTypes: true });
|
|
31801
31456
|
for (const sessionEntry of sessionDirs) {
|
|
31802
31457
|
if (!sessionEntry.isDirectory())
|
|
31803
31458
|
continue;
|
|
31804
|
-
const sessionDir =
|
|
31459
|
+
const sessionDir = join51(projectDir, sessionEntry.name);
|
|
31805
31460
|
const sessionID = sessionEntry.name;
|
|
31806
31461
|
try {
|
|
31807
31462
|
const msg = findNearestAssistantMessage(sessionDir);
|
|
@@ -32227,14 +31882,14 @@ var EXT_TO_LANG = {
|
|
|
32227
31882
|
".gql": "graphql"
|
|
32228
31883
|
};
|
|
32229
31884
|
// src/tools/lsp/config.ts
|
|
32230
|
-
import { existsSync as
|
|
32231
|
-
import { join as
|
|
31885
|
+
import { existsSync as existsSync41, readFileSync as readFileSync32 } from "fs";
|
|
31886
|
+
import { join as join52 } from "path";
|
|
32232
31887
|
init_shared();
|
|
32233
31888
|
function loadJsonFile(path7) {
|
|
32234
|
-
if (!
|
|
31889
|
+
if (!existsSync41(path7))
|
|
32235
31890
|
return null;
|
|
32236
31891
|
try {
|
|
32237
|
-
return JSON.parse(
|
|
31892
|
+
return JSON.parse(readFileSync32(path7, "utf-8"));
|
|
32238
31893
|
} catch {
|
|
32239
31894
|
return null;
|
|
32240
31895
|
}
|
|
@@ -32243,9 +31898,9 @@ function getConfigPaths3() {
|
|
|
32243
31898
|
const cwd2 = process.cwd();
|
|
32244
31899
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
32245
31900
|
return {
|
|
32246
|
-
project:
|
|
32247
|
-
user:
|
|
32248
|
-
opencode:
|
|
31901
|
+
project: join52(cwd2, ".opencode", "oh-my-opencode.json"),
|
|
31902
|
+
user: join52(configDir, "oh-my-opencode.json"),
|
|
31903
|
+
opencode: join52(configDir, "opencode.json")
|
|
32249
31904
|
};
|
|
32250
31905
|
}
|
|
32251
31906
|
function loadAllConfigs() {
|
|
@@ -32358,7 +32013,7 @@ function isServerInstalled(command) {
|
|
|
32358
32013
|
return false;
|
|
32359
32014
|
const cmd = command[0];
|
|
32360
32015
|
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
32361
|
-
if (
|
|
32016
|
+
if (existsSync41(cmd))
|
|
32362
32017
|
return true;
|
|
32363
32018
|
}
|
|
32364
32019
|
const isWindows2 = process.platform === "win32";
|
|
@@ -32380,23 +32035,23 @@ function isServerInstalled(command) {
|
|
|
32380
32035
|
const paths = pathEnv.split(pathSeparator);
|
|
32381
32036
|
for (const p of paths) {
|
|
32382
32037
|
for (const suffix of exts) {
|
|
32383
|
-
if (
|
|
32038
|
+
if (existsSync41(join52(p, cmd + suffix))) {
|
|
32384
32039
|
return true;
|
|
32385
32040
|
}
|
|
32386
32041
|
}
|
|
32387
32042
|
}
|
|
32388
32043
|
const cwd2 = process.cwd();
|
|
32389
32044
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
32390
|
-
const dataDir =
|
|
32045
|
+
const dataDir = join52(getDataDir(), "opencode");
|
|
32391
32046
|
const additionalBases = [
|
|
32392
|
-
|
|
32393
|
-
|
|
32394
|
-
|
|
32395
|
-
|
|
32047
|
+
join52(cwd2, "node_modules", ".bin"),
|
|
32048
|
+
join52(configDir, "bin"),
|
|
32049
|
+
join52(configDir, "node_modules", ".bin"),
|
|
32050
|
+
join52(dataDir, "bin")
|
|
32396
32051
|
];
|
|
32397
32052
|
for (const base of additionalBases) {
|
|
32398
32053
|
for (const suffix of exts) {
|
|
32399
|
-
if (
|
|
32054
|
+
if (existsSync41(join52(base, cmd + suffix))) {
|
|
32400
32055
|
return true;
|
|
32401
32056
|
}
|
|
32402
32057
|
}
|
|
@@ -32408,7 +32063,7 @@ function isServerInstalled(command) {
|
|
|
32408
32063
|
}
|
|
32409
32064
|
// src/tools/lsp/client.ts
|
|
32410
32065
|
var {spawn: spawn6 } = globalThis.Bun;
|
|
32411
|
-
import { readFileSync as
|
|
32066
|
+
import { readFileSync as readFileSync33 } from "fs";
|
|
32412
32067
|
import { extname, resolve as resolve8 } from "path";
|
|
32413
32068
|
import { pathToFileURL } from "url";
|
|
32414
32069
|
class LSPServerManager {
|
|
@@ -32859,7 +32514,7 @@ ${msg}`);
|
|
|
32859
32514
|
const absPath = resolve8(filePath);
|
|
32860
32515
|
if (this.openedFiles.has(absPath))
|
|
32861
32516
|
return;
|
|
32862
|
-
const text =
|
|
32517
|
+
const text = readFileSync33(absPath, "utf-8");
|
|
32863
32518
|
const ext = extname(absPath);
|
|
32864
32519
|
const languageId = getLanguageId(ext);
|
|
32865
32520
|
this.notify("textDocument/didOpen", {
|
|
@@ -32949,17 +32604,17 @@ ${msg}`);
|
|
|
32949
32604
|
// src/tools/lsp/utils.ts
|
|
32950
32605
|
import { extname as extname2, resolve as resolve9 } from "path";
|
|
32951
32606
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
32952
|
-
import { existsSync as
|
|
32607
|
+
import { existsSync as existsSync42, readFileSync as readFileSync34, writeFileSync as writeFileSync21 } from "fs";
|
|
32953
32608
|
function findWorkspaceRoot(filePath) {
|
|
32954
32609
|
let dir = resolve9(filePath);
|
|
32955
|
-
if (!
|
|
32610
|
+
if (!existsSync42(dir) || !__require("fs").statSync(dir).isDirectory()) {
|
|
32956
32611
|
dir = __require("path").dirname(dir);
|
|
32957
32612
|
}
|
|
32958
32613
|
const markers = [".git", "package.json", "pyproject.toml", "Cargo.toml", "go.mod", "pom.xml", "build.gradle"];
|
|
32959
32614
|
let prevDir = "";
|
|
32960
32615
|
while (dir !== prevDir) {
|
|
32961
32616
|
for (const marker of markers) {
|
|
32962
|
-
if (
|
|
32617
|
+
if (existsSync42(__require("path").join(dir, marker))) {
|
|
32963
32618
|
return dir;
|
|
32964
32619
|
}
|
|
32965
32620
|
}
|
|
@@ -33114,7 +32769,7 @@ function formatPrepareRenameResult(result) {
|
|
|
33114
32769
|
}
|
|
33115
32770
|
function applyTextEditsToFile(filePath, edits) {
|
|
33116
32771
|
try {
|
|
33117
|
-
let content =
|
|
32772
|
+
let content = readFileSync34(filePath, "utf-8");
|
|
33118
32773
|
const lines = content.split(`
|
|
33119
32774
|
`);
|
|
33120
32775
|
const sortedEdits = [...edits].sort((a, b) => {
|
|
@@ -33139,7 +32794,7 @@ function applyTextEditsToFile(filePath, edits) {
|
|
|
33139
32794
|
`));
|
|
33140
32795
|
}
|
|
33141
32796
|
}
|
|
33142
|
-
|
|
32797
|
+
writeFileSync21(filePath, lines.join(`
|
|
33143
32798
|
`), "utf-8");
|
|
33144
32799
|
return { success: true, editCount: edits.length };
|
|
33145
32800
|
} catch (err) {
|
|
@@ -33170,7 +32825,7 @@ function applyWorkspaceEdit(edit) {
|
|
|
33170
32825
|
if (change.kind === "create") {
|
|
33171
32826
|
try {
|
|
33172
32827
|
const filePath = uriToPath(change.uri);
|
|
33173
|
-
|
|
32828
|
+
writeFileSync21(filePath, "", "utf-8");
|
|
33174
32829
|
result.filesModified.push(filePath);
|
|
33175
32830
|
} catch (err) {
|
|
33176
32831
|
result.success = false;
|
|
@@ -33180,8 +32835,8 @@ function applyWorkspaceEdit(edit) {
|
|
|
33180
32835
|
try {
|
|
33181
32836
|
const oldPath = uriToPath(change.oldUri);
|
|
33182
32837
|
const newPath = uriToPath(change.newUri);
|
|
33183
|
-
const content =
|
|
33184
|
-
|
|
32838
|
+
const content = readFileSync34(oldPath, "utf-8");
|
|
32839
|
+
writeFileSync21(newPath, content, "utf-8");
|
|
33185
32840
|
__require("fs").unlinkSync(oldPath);
|
|
33186
32841
|
result.filesModified.push(newPath);
|
|
33187
32842
|
} catch (err) {
|
|
@@ -45760,13 +45415,13 @@ var lsp_rename = tool({
|
|
|
45760
45415
|
});
|
|
45761
45416
|
// src/tools/ast-grep/constants.ts
|
|
45762
45417
|
import { createRequire as createRequire4 } from "module";
|
|
45763
|
-
import { dirname as dirname11, join as
|
|
45764
|
-
import { existsSync as
|
|
45418
|
+
import { dirname as dirname11, join as join54 } from "path";
|
|
45419
|
+
import { existsSync as existsSync44, statSync as statSync5 } from "fs";
|
|
45765
45420
|
|
|
45766
45421
|
// src/tools/ast-grep/downloader.ts
|
|
45767
45422
|
init_shared();
|
|
45768
|
-
import { existsSync as
|
|
45769
|
-
import { join as
|
|
45423
|
+
import { existsSync as existsSync43, mkdirSync as mkdirSync17, chmodSync as chmodSync2, unlinkSync as unlinkSync13 } from "fs";
|
|
45424
|
+
import { join as join53 } from "path";
|
|
45770
45425
|
import { homedir as homedir13 } from "os";
|
|
45771
45426
|
import { createRequire as createRequire3 } from "module";
|
|
45772
45427
|
var REPO2 = "ast-grep/ast-grep";
|
|
@@ -45792,19 +45447,19 @@ var PLATFORM_MAP2 = {
|
|
|
45792
45447
|
function getCacheDir3() {
|
|
45793
45448
|
if (process.platform === "win32") {
|
|
45794
45449
|
const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA;
|
|
45795
|
-
const base2 = localAppData ||
|
|
45796
|
-
return
|
|
45450
|
+
const base2 = localAppData || join53(homedir13(), "AppData", "Local");
|
|
45451
|
+
return join53(base2, "oh-my-opencode", "bin");
|
|
45797
45452
|
}
|
|
45798
45453
|
const xdgCache = process.env.XDG_CACHE_HOME;
|
|
45799
|
-
const base = xdgCache ||
|
|
45800
|
-
return
|
|
45454
|
+
const base = xdgCache || join53(homedir13(), ".cache");
|
|
45455
|
+
return join53(base, "oh-my-opencode", "bin");
|
|
45801
45456
|
}
|
|
45802
45457
|
function getBinaryName3() {
|
|
45803
45458
|
return process.platform === "win32" ? "sg.exe" : "sg";
|
|
45804
45459
|
}
|
|
45805
45460
|
function getCachedBinaryPath2() {
|
|
45806
|
-
const binaryPath =
|
|
45807
|
-
return
|
|
45461
|
+
const binaryPath = join53(getCacheDir3(), getBinaryName3());
|
|
45462
|
+
return existsSync43(binaryPath) ? binaryPath : null;
|
|
45808
45463
|
}
|
|
45809
45464
|
async function downloadAstGrep(version2 = DEFAULT_VERSION) {
|
|
45810
45465
|
const platformKey = `${process.platform}-${process.arch}`;
|
|
@@ -45815,8 +45470,8 @@ async function downloadAstGrep(version2 = DEFAULT_VERSION) {
|
|
|
45815
45470
|
}
|
|
45816
45471
|
const cacheDir = getCacheDir3();
|
|
45817
45472
|
const binaryName = getBinaryName3();
|
|
45818
|
-
const binaryPath =
|
|
45819
|
-
if (
|
|
45473
|
+
const binaryPath = join53(cacheDir, binaryName);
|
|
45474
|
+
if (existsSync43(binaryPath)) {
|
|
45820
45475
|
return binaryPath;
|
|
45821
45476
|
}
|
|
45822
45477
|
const { arch, os: os6 } = platformInfo;
|
|
@@ -45824,21 +45479,21 @@ async function downloadAstGrep(version2 = DEFAULT_VERSION) {
|
|
|
45824
45479
|
const downloadUrl = `https://github.com/${REPO2}/releases/download/${version2}/${assetName}`;
|
|
45825
45480
|
console.log(`[oh-my-opencode] Downloading ast-grep binary...`);
|
|
45826
45481
|
try {
|
|
45827
|
-
if (!
|
|
45828
|
-
|
|
45482
|
+
if (!existsSync43(cacheDir)) {
|
|
45483
|
+
mkdirSync17(cacheDir, { recursive: true });
|
|
45829
45484
|
}
|
|
45830
45485
|
const response = await fetch(downloadUrl, { redirect: "follow" });
|
|
45831
45486
|
if (!response.ok) {
|
|
45832
45487
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
45833
45488
|
}
|
|
45834
|
-
const archivePath =
|
|
45489
|
+
const archivePath = join53(cacheDir, assetName);
|
|
45835
45490
|
const arrayBuffer = await response.arrayBuffer();
|
|
45836
45491
|
await Bun.write(archivePath, arrayBuffer);
|
|
45837
45492
|
await extractZip(archivePath, cacheDir);
|
|
45838
|
-
if (
|
|
45839
|
-
|
|
45493
|
+
if (existsSync43(archivePath)) {
|
|
45494
|
+
unlinkSync13(archivePath);
|
|
45840
45495
|
}
|
|
45841
|
-
if (process.platform !== "win32" &&
|
|
45496
|
+
if (process.platform !== "win32" && existsSync43(binaryPath)) {
|
|
45842
45497
|
chmodSync2(binaryPath, 493);
|
|
45843
45498
|
}
|
|
45844
45499
|
console.log(`[oh-my-opencode] ast-grep binary ready.`);
|
|
@@ -45889,8 +45544,8 @@ function findSgCliPathSync() {
|
|
|
45889
45544
|
const require2 = createRequire4(import.meta.url);
|
|
45890
45545
|
const cliPkgPath = require2.resolve("@ast-grep/cli/package.json");
|
|
45891
45546
|
const cliDir = dirname11(cliPkgPath);
|
|
45892
|
-
const sgPath =
|
|
45893
|
-
if (
|
|
45547
|
+
const sgPath = join54(cliDir, binaryName);
|
|
45548
|
+
if (existsSync44(sgPath) && isValidBinary(sgPath)) {
|
|
45894
45549
|
return sgPath;
|
|
45895
45550
|
}
|
|
45896
45551
|
} catch {}
|
|
@@ -45901,8 +45556,8 @@ function findSgCliPathSync() {
|
|
|
45901
45556
|
const pkgPath = require2.resolve(`${platformPkg}/package.json`);
|
|
45902
45557
|
const pkgDir = dirname11(pkgPath);
|
|
45903
45558
|
const astGrepName = process.platform === "win32" ? "ast-grep.exe" : "ast-grep";
|
|
45904
|
-
const binaryPath =
|
|
45905
|
-
if (
|
|
45559
|
+
const binaryPath = join54(pkgDir, astGrepName);
|
|
45560
|
+
if (existsSync44(binaryPath) && isValidBinary(binaryPath)) {
|
|
45906
45561
|
return binaryPath;
|
|
45907
45562
|
}
|
|
45908
45563
|
} catch {}
|
|
@@ -45910,7 +45565,7 @@ function findSgCliPathSync() {
|
|
|
45910
45565
|
if (process.platform === "darwin") {
|
|
45911
45566
|
const homebrewPaths = ["/opt/homebrew/bin/sg", "/usr/local/bin/sg"];
|
|
45912
45567
|
for (const path7 of homebrewPaths) {
|
|
45913
|
-
if (
|
|
45568
|
+
if (existsSync44(path7) && isValidBinary(path7)) {
|
|
45914
45569
|
return path7;
|
|
45915
45570
|
}
|
|
45916
45571
|
}
|
|
@@ -45965,11 +45620,11 @@ var DEFAULT_MAX_MATCHES = 500;
|
|
|
45965
45620
|
|
|
45966
45621
|
// src/tools/ast-grep/cli.ts
|
|
45967
45622
|
var {spawn: spawn7 } = globalThis.Bun;
|
|
45968
|
-
import { existsSync as
|
|
45623
|
+
import { existsSync as existsSync45 } from "fs";
|
|
45969
45624
|
var resolvedCliPath3 = null;
|
|
45970
45625
|
var initPromise2 = null;
|
|
45971
45626
|
async function getAstGrepPath() {
|
|
45972
|
-
if (resolvedCliPath3 !== null &&
|
|
45627
|
+
if (resolvedCliPath3 !== null && existsSync45(resolvedCliPath3)) {
|
|
45973
45628
|
return resolvedCliPath3;
|
|
45974
45629
|
}
|
|
45975
45630
|
if (initPromise2) {
|
|
@@ -45977,7 +45632,7 @@ async function getAstGrepPath() {
|
|
|
45977
45632
|
}
|
|
45978
45633
|
initPromise2 = (async () => {
|
|
45979
45634
|
const syncPath = findSgCliPathSync();
|
|
45980
|
-
if (syncPath &&
|
|
45635
|
+
if (syncPath && existsSync45(syncPath)) {
|
|
45981
45636
|
resolvedCliPath3 = syncPath;
|
|
45982
45637
|
setSgCliPath(syncPath);
|
|
45983
45638
|
return syncPath;
|
|
@@ -46011,7 +45666,7 @@ async function runSg(options) {
|
|
|
46011
45666
|
const paths = options.paths && options.paths.length > 0 ? options.paths : ["."];
|
|
46012
45667
|
args.push(...paths);
|
|
46013
45668
|
let cliPath = getSgCliPath();
|
|
46014
|
-
if (!
|
|
45669
|
+
if (!existsSync45(cliPath) && cliPath !== "sg") {
|
|
46015
45670
|
const downloadedPath = await getAstGrepPath();
|
|
46016
45671
|
if (downloadedPath) {
|
|
46017
45672
|
cliPath = downloadedPath;
|
|
@@ -46275,21 +45930,21 @@ var ast_grep_replace = tool({
|
|
|
46275
45930
|
var {spawn: spawn9 } = globalThis.Bun;
|
|
46276
45931
|
|
|
46277
45932
|
// src/tools/grep/constants.ts
|
|
46278
|
-
import { existsSync as
|
|
46279
|
-
import { join as
|
|
45933
|
+
import { existsSync as existsSync47 } from "fs";
|
|
45934
|
+
import { join as join56, dirname as dirname12 } from "path";
|
|
46280
45935
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
46281
45936
|
|
|
46282
45937
|
// src/tools/grep/downloader.ts
|
|
46283
45938
|
init_shared();
|
|
46284
|
-
import { existsSync as
|
|
46285
|
-
import { join as
|
|
45939
|
+
import { existsSync as existsSync46, mkdirSync as mkdirSync18, chmodSync as chmodSync3, unlinkSync as unlinkSync14, readdirSync as readdirSync14 } from "fs";
|
|
45940
|
+
import { join as join55 } from "path";
|
|
46286
45941
|
var {spawn: spawn8 } = globalThis.Bun;
|
|
46287
45942
|
function findFileRecursive(dir, filename) {
|
|
46288
45943
|
try {
|
|
46289
45944
|
const entries = readdirSync14(dir, { withFileTypes: true, recursive: true });
|
|
46290
45945
|
for (const entry of entries) {
|
|
46291
45946
|
if (entry.isFile() && entry.name === filename) {
|
|
46292
|
-
return
|
|
45947
|
+
return join55(entry.parentPath ?? dir, entry.name);
|
|
46293
45948
|
}
|
|
46294
45949
|
}
|
|
46295
45950
|
} catch {
|
|
@@ -46310,11 +45965,11 @@ function getPlatformKey() {
|
|
|
46310
45965
|
}
|
|
46311
45966
|
function getInstallDir() {
|
|
46312
45967
|
const homeDir = process.env.HOME || process.env.USERPROFILE || ".";
|
|
46313
|
-
return
|
|
45968
|
+
return join55(homeDir, ".cache", "oh-my-opencode", "bin");
|
|
46314
45969
|
}
|
|
46315
45970
|
function getRgPath() {
|
|
46316
45971
|
const isWindows2 = process.platform === "win32";
|
|
46317
|
-
return
|
|
45972
|
+
return join55(getInstallDir(), isWindows2 ? "rg.exe" : "rg");
|
|
46318
45973
|
}
|
|
46319
45974
|
async function downloadFile(url2, destPath) {
|
|
46320
45975
|
const response = await fetch(url2);
|
|
@@ -46348,7 +46003,7 @@ async function extractZip2(archivePath, destDir) {
|
|
|
46348
46003
|
const binaryName = process.platform === "win32" ? "rg.exe" : "rg";
|
|
46349
46004
|
const foundPath = findFileRecursive(destDir, binaryName);
|
|
46350
46005
|
if (foundPath) {
|
|
46351
|
-
const destPath =
|
|
46006
|
+
const destPath = join55(destDir, binaryName);
|
|
46352
46007
|
if (foundPath !== destPath) {
|
|
46353
46008
|
const { renameSync: renameSync5 } = await import("fs");
|
|
46354
46009
|
renameSync5(foundPath, destPath);
|
|
@@ -46363,13 +46018,13 @@ async function downloadAndInstallRipgrep() {
|
|
|
46363
46018
|
}
|
|
46364
46019
|
const installDir = getInstallDir();
|
|
46365
46020
|
const rgPath = getRgPath();
|
|
46366
|
-
if (
|
|
46021
|
+
if (existsSync46(rgPath)) {
|
|
46367
46022
|
return rgPath;
|
|
46368
46023
|
}
|
|
46369
|
-
|
|
46024
|
+
mkdirSync18(installDir, { recursive: true });
|
|
46370
46025
|
const filename = `ripgrep-${RG_VERSION}-${config3.platform}.${config3.extension}`;
|
|
46371
46026
|
const url2 = `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/${filename}`;
|
|
46372
|
-
const archivePath =
|
|
46027
|
+
const archivePath = join55(installDir, filename);
|
|
46373
46028
|
try {
|
|
46374
46029
|
await downloadFile(url2, archivePath);
|
|
46375
46030
|
if (config3.extension === "tar.gz") {
|
|
@@ -46380,21 +46035,21 @@ async function downloadAndInstallRipgrep() {
|
|
|
46380
46035
|
if (process.platform !== "win32") {
|
|
46381
46036
|
chmodSync3(rgPath, 493);
|
|
46382
46037
|
}
|
|
46383
|
-
if (!
|
|
46038
|
+
if (!existsSync46(rgPath)) {
|
|
46384
46039
|
throw new Error("\u63D0\u53D6\u540E\u672A\u627E\u5230 ripgrep \u4E8C\u8FDB\u5236\u6587\u4EF6");
|
|
46385
46040
|
}
|
|
46386
46041
|
return rgPath;
|
|
46387
46042
|
} finally {
|
|
46388
|
-
if (
|
|
46043
|
+
if (existsSync46(archivePath)) {
|
|
46389
46044
|
try {
|
|
46390
|
-
|
|
46045
|
+
unlinkSync14(archivePath);
|
|
46391
46046
|
} catch {}
|
|
46392
46047
|
}
|
|
46393
46048
|
}
|
|
46394
46049
|
}
|
|
46395
46050
|
function getInstalledRipgrepPath() {
|
|
46396
46051
|
const rgPath = getRgPath();
|
|
46397
|
-
return
|
|
46052
|
+
return existsSync46(rgPath) ? rgPath : null;
|
|
46398
46053
|
}
|
|
46399
46054
|
|
|
46400
46055
|
// src/tools/grep/constants.ts
|
|
@@ -46418,7 +46073,7 @@ function findExecutable(name) {
|
|
|
46418
46073
|
continue;
|
|
46419
46074
|
}
|
|
46420
46075
|
}
|
|
46421
|
-
if (
|
|
46076
|
+
if (existsSync47(trimmed)) {
|
|
46422
46077
|
return trimmed;
|
|
46423
46078
|
}
|
|
46424
46079
|
}
|
|
@@ -46433,14 +46088,14 @@ function getOpenCodeBundledRg() {
|
|
|
46433
46088
|
const isWindows2 = process.platform === "win32";
|
|
46434
46089
|
const rgName = isWindows2 ? "rg.exe" : "rg";
|
|
46435
46090
|
const candidates = [
|
|
46436
|
-
|
|
46437
|
-
|
|
46438
|
-
|
|
46439
|
-
|
|
46440
|
-
|
|
46091
|
+
join56(getDataDir(), "opencode", "bin", rgName),
|
|
46092
|
+
join56(execDir, rgName),
|
|
46093
|
+
join56(execDir, "bin", rgName),
|
|
46094
|
+
join56(execDir, "..", "bin", rgName),
|
|
46095
|
+
join56(execDir, "..", "libexec", rgName)
|
|
46441
46096
|
];
|
|
46442
46097
|
for (const candidate of candidates) {
|
|
46443
|
-
if (
|
|
46098
|
+
if (existsSync47(candidate)) {
|
|
46444
46099
|
return candidate;
|
|
46445
46100
|
}
|
|
46446
46101
|
}
|
|
@@ -46902,8 +46557,8 @@ var glob = tool({
|
|
|
46902
46557
|
init_shared();
|
|
46903
46558
|
init_file_utils();
|
|
46904
46559
|
init_shared();
|
|
46905
|
-
import { existsSync as
|
|
46906
|
-
import { join as
|
|
46560
|
+
import { existsSync as existsSync48, readdirSync as readdirSync15, readFileSync as readFileSync35 } from "fs";
|
|
46561
|
+
import { join as join57, basename as basename4, dirname as dirname13 } from "path";
|
|
46907
46562
|
// src/features/builtin-commands/templates/init-deep.ts
|
|
46908
46563
|
var INIT_DEEP_TEMPLATE = `# /init-deep
|
|
46909
46564
|
|
|
@@ -48048,7 +47703,7 @@ function loadBuiltinCommands(disabledCommands) {
|
|
|
48048
47703
|
}
|
|
48049
47704
|
// src/tools/slashcommand/tools.ts
|
|
48050
47705
|
function discoverCommandsFromDir2(commandsDir, scope) {
|
|
48051
|
-
if (!
|
|
47706
|
+
if (!existsSync48(commandsDir)) {
|
|
48052
47707
|
return [];
|
|
48053
47708
|
}
|
|
48054
47709
|
const entries = readdirSync15(commandsDir, { withFileTypes: true });
|
|
@@ -48056,10 +47711,10 @@ function discoverCommandsFromDir2(commandsDir, scope) {
|
|
|
48056
47711
|
for (const entry of entries) {
|
|
48057
47712
|
if (!isMarkdownFile(entry))
|
|
48058
47713
|
continue;
|
|
48059
|
-
const commandPath =
|
|
47714
|
+
const commandPath = join57(commandsDir, entry.name);
|
|
48060
47715
|
const commandName = basename4(entry.name, ".md");
|
|
48061
47716
|
try {
|
|
48062
|
-
const content =
|
|
47717
|
+
const content = readFileSync35(commandPath, "utf-8");
|
|
48063
47718
|
const { data, body } = parseFrontmatter(content);
|
|
48064
47719
|
const isOpencodeSource = scope === "opencode" || scope === "opencode-project";
|
|
48065
47720
|
const metadata = {
|
|
@@ -48085,10 +47740,10 @@ function discoverCommandsFromDir2(commandsDir, scope) {
|
|
|
48085
47740
|
}
|
|
48086
47741
|
function discoverCommandsSync(disabledCommands) {
|
|
48087
47742
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
48088
|
-
const userCommandsDir =
|
|
48089
|
-
const projectCommandsDir =
|
|
48090
|
-
const opencodeGlobalDir =
|
|
48091
|
-
const opencodeProjectDir =
|
|
47743
|
+
const userCommandsDir = join57(getClaudeConfigDir(), "commands");
|
|
47744
|
+
const projectCommandsDir = join57(process.cwd(), ".claude", "commands");
|
|
47745
|
+
const opencodeGlobalDir = join57(configDir, "command");
|
|
47746
|
+
const opencodeProjectDir = join57(process.cwd(), ".opencode", "command");
|
|
48092
47747
|
const userCommands = discoverCommandsFromDir2(userCommandsDir, "user");
|
|
48093
47748
|
const opencodeGlobalCommands = discoverCommandsFromDir2(opencodeGlobalDir, "opencode");
|
|
48094
47749
|
const projectCommands = discoverCommandsFromDir2(projectCommandsDir, "project");
|
|
@@ -48288,13 +47943,13 @@ var slashcommand = createSlashcommandTool();
|
|
|
48288
47943
|
// src/tools/session-manager/constants.ts
|
|
48289
47944
|
init_data_path();
|
|
48290
47945
|
init_shared();
|
|
48291
|
-
import { join as
|
|
48292
|
-
var
|
|
48293
|
-
var MESSAGE_STORAGE4 =
|
|
48294
|
-
var PART_STORAGE4 =
|
|
48295
|
-
var SESSION_STORAGE =
|
|
48296
|
-
var TODO_DIR2 =
|
|
48297
|
-
var TRANSCRIPT_DIR2 =
|
|
47946
|
+
import { join as join58 } from "path";
|
|
47947
|
+
var OPENCODE_STORAGE9 = getOpenCodeStorageDir();
|
|
47948
|
+
var MESSAGE_STORAGE4 = join58(OPENCODE_STORAGE9, "message");
|
|
47949
|
+
var PART_STORAGE4 = join58(OPENCODE_STORAGE9, "part");
|
|
47950
|
+
var SESSION_STORAGE = join58(OPENCODE_STORAGE9, "session");
|
|
47951
|
+
var TODO_DIR2 = join58(getClaudeConfigDir(), "todos");
|
|
47952
|
+
var TRANSCRIPT_DIR2 = join58(getClaudeConfigDir(), "transcripts");
|
|
48298
47953
|
var SESSION_LIST_DESCRIPTION = `\u5217\u51FA\u6240\u6709 OpenCode session\uFF0C\u652F\u6301\u53EF\u9009\u8FC7\u6EE4\u3002
|
|
48299
47954
|
|
|
48300
47955
|
\u8FD4\u56DE\u53EF\u7528\u7684 session ID \u5217\u8868\uFF0C\u5305\u542B\u6D88\u606F\u6570\u91CF\u3001\u65E5\u671F\u8303\u56F4\u548C\u4F7F\u7528\u8FC7\u7684 agents \u7B49\u5143\u6570\u636E\u3002
|
|
@@ -48367,11 +48022,11 @@ Has Todos: Yes (12 items, 8 completed)
|
|
|
48367
48022
|
Has Transcript: Yes (234 entries)`;
|
|
48368
48023
|
|
|
48369
48024
|
// src/tools/session-manager/storage.ts
|
|
48370
|
-
import { existsSync as
|
|
48025
|
+
import { existsSync as existsSync49, readdirSync as readdirSync16 } from "fs";
|
|
48371
48026
|
import { readdir, readFile } from "fs/promises";
|
|
48372
|
-
import { join as
|
|
48027
|
+
import { join as join59 } from "path";
|
|
48373
48028
|
async function getMainSessions(options) {
|
|
48374
|
-
if (!
|
|
48029
|
+
if (!existsSync49(SESSION_STORAGE))
|
|
48375
48030
|
return [];
|
|
48376
48031
|
const sessions = [];
|
|
48377
48032
|
try {
|
|
@@ -48379,13 +48034,13 @@ async function getMainSessions(options) {
|
|
|
48379
48034
|
for (const projectDir of projectDirs) {
|
|
48380
48035
|
if (!projectDir.isDirectory())
|
|
48381
48036
|
continue;
|
|
48382
|
-
const projectPath =
|
|
48037
|
+
const projectPath = join59(SESSION_STORAGE, projectDir.name);
|
|
48383
48038
|
const sessionFiles = await readdir(projectPath);
|
|
48384
48039
|
for (const file2 of sessionFiles) {
|
|
48385
48040
|
if (!file2.endsWith(".json"))
|
|
48386
48041
|
continue;
|
|
48387
48042
|
try {
|
|
48388
|
-
const content = await readFile(
|
|
48043
|
+
const content = await readFile(join59(projectPath, file2), "utf-8");
|
|
48389
48044
|
const meta = JSON.parse(content);
|
|
48390
48045
|
if (meta.parentID)
|
|
48391
48046
|
continue;
|
|
@@ -48403,7 +48058,7 @@ async function getMainSessions(options) {
|
|
|
48403
48058
|
return sessions.sort((a, b) => b.time.updated - a.time.updated);
|
|
48404
48059
|
}
|
|
48405
48060
|
async function getAllSessions() {
|
|
48406
|
-
if (!
|
|
48061
|
+
if (!existsSync49(MESSAGE_STORAGE4))
|
|
48407
48062
|
return [];
|
|
48408
48063
|
const sessions = [];
|
|
48409
48064
|
async function scanDirectory(dir) {
|
|
@@ -48411,7 +48066,7 @@ async function getAllSessions() {
|
|
|
48411
48066
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
48412
48067
|
for (const entry of entries) {
|
|
48413
48068
|
if (entry.isDirectory()) {
|
|
48414
|
-
const sessionPath =
|
|
48069
|
+
const sessionPath = join59(dir, entry.name);
|
|
48415
48070
|
const files = await readdir(sessionPath);
|
|
48416
48071
|
if (files.some((f) => f.endsWith(".json"))) {
|
|
48417
48072
|
sessions.push(entry.name);
|
|
@@ -48428,16 +48083,16 @@ async function getAllSessions() {
|
|
|
48428
48083
|
return [...new Set(sessions)];
|
|
48429
48084
|
}
|
|
48430
48085
|
function getMessageDir6(sessionID) {
|
|
48431
|
-
if (!
|
|
48086
|
+
if (!existsSync49(MESSAGE_STORAGE4))
|
|
48432
48087
|
return "";
|
|
48433
|
-
const directPath =
|
|
48434
|
-
if (
|
|
48088
|
+
const directPath = join59(MESSAGE_STORAGE4, sessionID);
|
|
48089
|
+
if (existsSync49(directPath)) {
|
|
48435
48090
|
return directPath;
|
|
48436
48091
|
}
|
|
48437
48092
|
try {
|
|
48438
48093
|
for (const dir of readdirSync16(MESSAGE_STORAGE4)) {
|
|
48439
|
-
const sessionPath =
|
|
48440
|
-
if (
|
|
48094
|
+
const sessionPath = join59(MESSAGE_STORAGE4, dir, sessionID);
|
|
48095
|
+
if (existsSync49(sessionPath)) {
|
|
48441
48096
|
return sessionPath;
|
|
48442
48097
|
}
|
|
48443
48098
|
}
|
|
@@ -48451,7 +48106,7 @@ function sessionExists(sessionID) {
|
|
|
48451
48106
|
}
|
|
48452
48107
|
async function readSessionMessages(sessionID) {
|
|
48453
48108
|
const messageDir = getMessageDir6(sessionID);
|
|
48454
|
-
if (!messageDir || !
|
|
48109
|
+
if (!messageDir || !existsSync49(messageDir))
|
|
48455
48110
|
return [];
|
|
48456
48111
|
const messages = [];
|
|
48457
48112
|
try {
|
|
@@ -48460,7 +48115,7 @@ async function readSessionMessages(sessionID) {
|
|
|
48460
48115
|
if (!file2.endsWith(".json"))
|
|
48461
48116
|
continue;
|
|
48462
48117
|
try {
|
|
48463
|
-
const content = await readFile(
|
|
48118
|
+
const content = await readFile(join59(messageDir, file2), "utf-8");
|
|
48464
48119
|
const meta = JSON.parse(content);
|
|
48465
48120
|
const parts = await readParts2(meta.id);
|
|
48466
48121
|
messages.push({
|
|
@@ -48486,8 +48141,8 @@ async function readSessionMessages(sessionID) {
|
|
|
48486
48141
|
});
|
|
48487
48142
|
}
|
|
48488
48143
|
async function readParts2(messageID) {
|
|
48489
|
-
const partDir =
|
|
48490
|
-
if (!
|
|
48144
|
+
const partDir = join59(PART_STORAGE4, messageID);
|
|
48145
|
+
if (!existsSync49(partDir))
|
|
48491
48146
|
return [];
|
|
48492
48147
|
const parts = [];
|
|
48493
48148
|
try {
|
|
@@ -48496,7 +48151,7 @@ async function readParts2(messageID) {
|
|
|
48496
48151
|
if (!file2.endsWith(".json"))
|
|
48497
48152
|
continue;
|
|
48498
48153
|
try {
|
|
48499
|
-
const content = await readFile(
|
|
48154
|
+
const content = await readFile(join59(partDir, file2), "utf-8");
|
|
48500
48155
|
parts.push(JSON.parse(content));
|
|
48501
48156
|
} catch {
|
|
48502
48157
|
continue;
|
|
@@ -48508,14 +48163,14 @@ async function readParts2(messageID) {
|
|
|
48508
48163
|
return parts.sort((a, b) => a.id.localeCompare(b.id));
|
|
48509
48164
|
}
|
|
48510
48165
|
async function readSessionTodos(sessionID) {
|
|
48511
|
-
if (!
|
|
48166
|
+
if (!existsSync49(TODO_DIR2))
|
|
48512
48167
|
return [];
|
|
48513
48168
|
try {
|
|
48514
48169
|
const allFiles = await readdir(TODO_DIR2);
|
|
48515
48170
|
const todoFiles = allFiles.filter((f) => f.includes(sessionID) && f.endsWith(".json"));
|
|
48516
48171
|
for (const file2 of todoFiles) {
|
|
48517
48172
|
try {
|
|
48518
|
-
const content = await readFile(
|
|
48173
|
+
const content = await readFile(join59(TODO_DIR2, file2), "utf-8");
|
|
48519
48174
|
const data = JSON.parse(content);
|
|
48520
48175
|
if (Array.isArray(data)) {
|
|
48521
48176
|
return data.map((item) => ({
|
|
@@ -48535,10 +48190,10 @@ async function readSessionTodos(sessionID) {
|
|
|
48535
48190
|
return [];
|
|
48536
48191
|
}
|
|
48537
48192
|
async function readSessionTranscript(sessionID) {
|
|
48538
|
-
if (!
|
|
48193
|
+
if (!existsSync49(TRANSCRIPT_DIR2))
|
|
48539
48194
|
return 0;
|
|
48540
|
-
const transcriptFile =
|
|
48541
|
-
if (!
|
|
48195
|
+
const transcriptFile = join59(TRANSCRIPT_DIR2, `${sessionID}.jsonl`);
|
|
48196
|
+
if (!existsSync49(transcriptFile))
|
|
48542
48197
|
return 0;
|
|
48543
48198
|
try {
|
|
48544
48199
|
const content = await readFile(transcriptFile, "utf-8");
|
|
@@ -49746,21 +49401,21 @@ var CALL_OMO_AGENT_DESCRIPTION = `\u542F\u52A8\u6DF1\u5EA6\u63A2\u7D22/\u77E5\u8
|
|
|
49746
49401
|
|
|
49747
49402
|
\u4F20\u5165 \`session_id=<id>\` \u53EF\u7EE7\u7EED\u4E4B\u524D\u7684 agent\uFF0C\u4FDD\u7559\u5B8C\u6574\u4E0A\u4E0B\u6587\u3002Prompts \u5FC5\u987B\u4E3A\u4E2D\u6587\u3002\u4F7F\u7528 \`background_output\` \u83B7\u53D6\u5F02\u6B65\u7ED3\u679C\u3002`;
|
|
49748
49403
|
// src/tools/call-omo-agent/tools.ts
|
|
49749
|
-
import { existsSync as
|
|
49750
|
-
import { join as
|
|
49404
|
+
import { existsSync as existsSync50, readdirSync as readdirSync17 } from "fs";
|
|
49405
|
+
import { join as join60 } from "path";
|
|
49751
49406
|
init_shared();
|
|
49752
49407
|
init_agent_display_names();
|
|
49753
49408
|
init_session_cursor();
|
|
49754
49409
|
init_claude_code_session_state();
|
|
49755
49410
|
function getMessageDir7(sessionID) {
|
|
49756
|
-
if (!
|
|
49411
|
+
if (!existsSync50(MESSAGE_STORAGE))
|
|
49757
49412
|
return null;
|
|
49758
|
-
const directPath =
|
|
49759
|
-
if (
|
|
49413
|
+
const directPath = join60(MESSAGE_STORAGE, sessionID);
|
|
49414
|
+
if (existsSync50(directPath))
|
|
49760
49415
|
return directPath;
|
|
49761
49416
|
for (const dir of readdirSync17(MESSAGE_STORAGE)) {
|
|
49762
|
-
const sessionPath =
|
|
49763
|
-
if (
|
|
49417
|
+
const sessionPath = join60(MESSAGE_STORAGE, dir, sessionID);
|
|
49418
|
+
if (existsSync50(sessionPath))
|
|
49764
49419
|
return sessionPath;
|
|
49765
49420
|
}
|
|
49766
49421
|
return null;
|
|
@@ -50186,8 +49841,8 @@ function createLookAt(ctx) {
|
|
|
50186
49841
|
}
|
|
50187
49842
|
// src/tools/delegate-task/tools.ts
|
|
50188
49843
|
init_constants();
|
|
50189
|
-
import { existsSync as
|
|
50190
|
-
import { join as
|
|
49844
|
+
import { existsSync as existsSync51, readdirSync as readdirSync18 } from "fs";
|
|
49845
|
+
import { join as join61 } from "path";
|
|
50191
49846
|
|
|
50192
49847
|
// src/features/task-toast-manager/manager.ts
|
|
50193
49848
|
class TaskToastManager {
|
|
@@ -50395,14 +50050,14 @@ function parseFallbackModelEntries(entries) {
|
|
|
50395
50050
|
});
|
|
50396
50051
|
}
|
|
50397
50052
|
function getMessageDir8(sessionID) {
|
|
50398
|
-
if (!
|
|
50053
|
+
if (!existsSync51(MESSAGE_STORAGE))
|
|
50399
50054
|
return null;
|
|
50400
|
-
const directPath =
|
|
50401
|
-
if (
|
|
50055
|
+
const directPath = join61(MESSAGE_STORAGE, sessionID);
|
|
50056
|
+
if (existsSync51(directPath))
|
|
50402
50057
|
return directPath;
|
|
50403
50058
|
for (const dir of readdirSync18(MESSAGE_STORAGE)) {
|
|
50404
|
-
const sessionPath =
|
|
50405
|
-
if (
|
|
50059
|
+
const sessionPath = join61(MESSAGE_STORAGE, dir, sessionID);
|
|
50060
|
+
if (existsSync51(sessionPath))
|
|
50406
50061
|
return sessionPath;
|
|
50407
50062
|
}
|
|
50408
50063
|
return null;
|
|
@@ -51512,8 +51167,8 @@ class PerformanceAggregator {
|
|
|
51512
51167
|
// src/features/background-agent/manager.ts
|
|
51513
51168
|
init_claude_code_session_state();
|
|
51514
51169
|
init_agent_identity_resolver();
|
|
51515
|
-
import { existsSync as
|
|
51516
|
-
import { join as
|
|
51170
|
+
import { existsSync as existsSync52, readdirSync as readdirSync19 } from "fs";
|
|
51171
|
+
import { join as join62 } from "path";
|
|
51517
51172
|
var TASK_TTL_MS = 30 * 60 * 1000;
|
|
51518
51173
|
var MIN_STABILITY_TIME_MS = 10 * 1000;
|
|
51519
51174
|
var DEFAULT_STALE_TIMEOUT_MS = 120000;
|
|
@@ -52686,14 +52341,14 @@ function registerProcessSignal(signal, handler, exitAfter) {
|
|
|
52686
52341
|
return listener;
|
|
52687
52342
|
}
|
|
52688
52343
|
function getMessageDir9(sessionID) {
|
|
52689
|
-
if (!
|
|
52344
|
+
if (!existsSync52(MESSAGE_STORAGE))
|
|
52690
52345
|
return null;
|
|
52691
|
-
const directPath =
|
|
52692
|
-
if (
|
|
52346
|
+
const directPath = join62(MESSAGE_STORAGE, sessionID);
|
|
52347
|
+
if (existsSync52(directPath))
|
|
52693
52348
|
return directPath;
|
|
52694
52349
|
for (const dir of readdirSync19(MESSAGE_STORAGE)) {
|
|
52695
|
-
const sessionPath =
|
|
52696
|
-
if (
|
|
52350
|
+
const sessionPath = join62(MESSAGE_STORAGE, dir, sessionID);
|
|
52351
|
+
if (existsSync52(sessionPath))
|
|
52697
52352
|
return sessionPath;
|
|
52698
52353
|
}
|
|
52699
52354
|
return null;
|
|
@@ -71424,8 +71079,7 @@ var HookNameSchema = exports_external2.enum([
|
|
|
71424
71079
|
"prometheus-md-only",
|
|
71425
71080
|
"perf-profiler",
|
|
71426
71081
|
"start-work",
|
|
71427
|
-
"language-
|
|
71428
|
-
"thinking-language-validator",
|
|
71082
|
+
"system-language-injector",
|
|
71429
71083
|
"atlas",
|
|
71430
71084
|
"tool-definition-optimizer",
|
|
71431
71085
|
"permission-ask-bridge",
|
|
@@ -71656,7 +71310,7 @@ var LanguageEnforcementConfigSchema = exports_external2.object({
|
|
|
71656
71310
|
enabled: exports_external2.boolean().default(true),
|
|
71657
71311
|
reminder_interval: exports_external2.number().int().positive().default(5),
|
|
71658
71312
|
violation_threshold: exports_external2.number().min(0).max(1).default(0.6),
|
|
71659
|
-
excluded_agents: exports_external2.array(exports_external2.string()).default([
|
|
71313
|
+
excluded_agents: exports_external2.array(exports_external2.string()).default([]),
|
|
71660
71314
|
user_message_english_threshold: exports_external2.number().min(0).max(1).default(0.6),
|
|
71661
71315
|
user_message_lookback: exports_external2.number().int().positive().default(3)
|
|
71662
71316
|
}).optional();
|
|
@@ -71918,7 +71572,7 @@ init_file_utils();
|
|
|
71918
71572
|
init_shared();
|
|
71919
71573
|
init_logger();
|
|
71920
71574
|
import { promises as fs11 } from "fs";
|
|
71921
|
-
import { join as
|
|
71575
|
+
import { join as join64, basename as basename6 } from "path";
|
|
71922
71576
|
async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix = "") {
|
|
71923
71577
|
try {
|
|
71924
71578
|
await fs11.access(commandsDir);
|
|
@@ -71948,7 +71602,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
71948
71602
|
if (entry.isDirectory()) {
|
|
71949
71603
|
if (entry.name.startsWith("."))
|
|
71950
71604
|
continue;
|
|
71951
|
-
const subDirPath =
|
|
71605
|
+
const subDirPath = join64(commandsDir, entry.name);
|
|
71952
71606
|
const subPrefix = prefix ? `${prefix}:${entry.name}` : entry.name;
|
|
71953
71607
|
const subCommands = await loadCommandsFromDir(subDirPath, scope, visited, subPrefix);
|
|
71954
71608
|
commands2.push(...subCommands);
|
|
@@ -71956,7 +71610,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
71956
71610
|
}
|
|
71957
71611
|
if (!isMarkdownFile(entry))
|
|
71958
71612
|
continue;
|
|
71959
|
-
const commandPath =
|
|
71613
|
+
const commandPath = join64(commandsDir, entry.name);
|
|
71960
71614
|
const baseCommandName = basename6(entry.name, ".md");
|
|
71961
71615
|
const commandName = prefix ? `${prefix}:${baseCommandName}` : baseCommandName;
|
|
71962
71616
|
try {
|
|
@@ -72003,23 +71657,23 @@ function commandsToRecord(commands2) {
|
|
|
72003
71657
|
return result;
|
|
72004
71658
|
}
|
|
72005
71659
|
async function loadUserCommands() {
|
|
72006
|
-
const userCommandsDir =
|
|
71660
|
+
const userCommandsDir = join64(getClaudeConfigDir(), "commands");
|
|
72007
71661
|
const commands2 = await loadCommandsFromDir(userCommandsDir, "user");
|
|
72008
71662
|
return commandsToRecord(commands2);
|
|
72009
71663
|
}
|
|
72010
71664
|
async function loadProjectCommands() {
|
|
72011
|
-
const projectCommandsDir =
|
|
71665
|
+
const projectCommandsDir = join64(process.cwd(), ".claude", "commands");
|
|
72012
71666
|
const commands2 = await loadCommandsFromDir(projectCommandsDir, "project");
|
|
72013
71667
|
return commandsToRecord(commands2);
|
|
72014
71668
|
}
|
|
72015
71669
|
async function loadOpencodeGlobalCommands() {
|
|
72016
71670
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
72017
|
-
const opencodeCommandsDir =
|
|
71671
|
+
const opencodeCommandsDir = join64(configDir, "command");
|
|
72018
71672
|
const commands2 = await loadCommandsFromDir(opencodeCommandsDir, "opencode");
|
|
72019
71673
|
return commandsToRecord(commands2);
|
|
72020
71674
|
}
|
|
72021
71675
|
async function loadOpencodeProjectCommands() {
|
|
72022
|
-
const opencodeProjectDir =
|
|
71676
|
+
const opencodeProjectDir = join64(process.cwd(), ".opencode", "command");
|
|
72023
71677
|
const commands2 = await loadCommandsFromDir(opencodeProjectDir, "opencode-project");
|
|
72024
71678
|
return commandsToRecord(commands2);
|
|
72025
71679
|
}
|
|
@@ -72027,8 +71681,8 @@ async function loadOpencodeProjectCommands() {
|
|
|
72027
71681
|
init_frontmatter();
|
|
72028
71682
|
init_file_utils();
|
|
72029
71683
|
init_shared();
|
|
72030
|
-
import { existsSync as
|
|
72031
|
-
import { join as
|
|
71684
|
+
import { existsSync as existsSync54, readdirSync as readdirSync20, readFileSync as readFileSync37 } from "fs";
|
|
71685
|
+
import { join as join65, basename as basename7 } from "path";
|
|
72032
71686
|
function parseToolsConfig(toolsStr) {
|
|
72033
71687
|
if (!toolsStr)
|
|
72034
71688
|
return;
|
|
@@ -72042,7 +71696,7 @@ function parseToolsConfig(toolsStr) {
|
|
|
72042
71696
|
return result;
|
|
72043
71697
|
}
|
|
72044
71698
|
function loadAgentsFromDir(agentsDir, scope, leConfig) {
|
|
72045
|
-
if (!
|
|
71699
|
+
if (!existsSync54(agentsDir)) {
|
|
72046
71700
|
return [];
|
|
72047
71701
|
}
|
|
72048
71702
|
const entries = readdirSync20(agentsDir, { withFileTypes: true });
|
|
@@ -72050,10 +71704,10 @@ function loadAgentsFromDir(agentsDir, scope, leConfig) {
|
|
|
72050
71704
|
for (const entry of entries) {
|
|
72051
71705
|
if (!isMarkdownFile(entry))
|
|
72052
71706
|
continue;
|
|
72053
|
-
const agentPath =
|
|
71707
|
+
const agentPath = join65(agentsDir, entry.name);
|
|
72054
71708
|
const agentName = basename7(entry.name, ".md");
|
|
72055
71709
|
try {
|
|
72056
|
-
const content =
|
|
71710
|
+
const content = readFileSync37(agentPath, "utf-8");
|
|
72057
71711
|
const { data, body } = parseFrontmatter(content);
|
|
72058
71712
|
const name = data.name || agentName;
|
|
72059
71713
|
const originalDescription = data.description || "";
|
|
@@ -72082,7 +71736,7 @@ function loadAgentsFromDir(agentsDir, scope, leConfig) {
|
|
|
72082
71736
|
return agents;
|
|
72083
71737
|
}
|
|
72084
71738
|
function loadUserAgents(leConfig) {
|
|
72085
|
-
const userAgentsDir =
|
|
71739
|
+
const userAgentsDir = join65(getClaudeConfigDir(), "agents");
|
|
72086
71740
|
const agents = loadAgentsFromDir(userAgentsDir, "user", leConfig);
|
|
72087
71741
|
const result = {};
|
|
72088
71742
|
for (const agent of agents) {
|
|
@@ -72091,7 +71745,7 @@ function loadUserAgents(leConfig) {
|
|
|
72091
71745
|
return result;
|
|
72092
71746
|
}
|
|
72093
71747
|
function loadProjectAgents(leConfig) {
|
|
72094
|
-
const projectAgentsDir =
|
|
71748
|
+
const projectAgentsDir = join65(process.cwd(), ".claude", "agents");
|
|
72095
71749
|
const agents = loadAgentsFromDir(projectAgentsDir, "project", leConfig);
|
|
72096
71750
|
const result = {};
|
|
72097
71751
|
for (const agent of agents) {
|
|
@@ -72103,18 +71757,18 @@ function loadProjectAgents(leConfig) {
|
|
|
72103
71757
|
init_frontmatter();
|
|
72104
71758
|
init_file_utils();
|
|
72105
71759
|
init_logger();
|
|
72106
|
-
import { existsSync as
|
|
71760
|
+
import { existsSync as existsSync55, readdirSync as readdirSync21, readFileSync as readFileSync38 } from "fs";
|
|
72107
71761
|
import { homedir as homedir14 } from "os";
|
|
72108
|
-
import { join as
|
|
71762
|
+
import { join as join66, basename as basename8 } from "path";
|
|
72109
71763
|
var CLAUDE_PLUGIN_ROOT_VAR = "${CLAUDE_PLUGIN_ROOT}";
|
|
72110
71764
|
function getPluginsBaseDir() {
|
|
72111
71765
|
if (process.env.CLAUDE_PLUGINS_HOME) {
|
|
72112
71766
|
return process.env.CLAUDE_PLUGINS_HOME;
|
|
72113
71767
|
}
|
|
72114
|
-
return
|
|
71768
|
+
return join66(homedir14(), ".claude", "plugins");
|
|
72115
71769
|
}
|
|
72116
71770
|
function getInstalledPluginsPath() {
|
|
72117
|
-
return
|
|
71771
|
+
return join66(getPluginsBaseDir(), "installed_plugins.json");
|
|
72118
71772
|
}
|
|
72119
71773
|
function resolvePluginPath(path8, pluginRoot) {
|
|
72120
71774
|
return path8.replace(CLAUDE_PLUGIN_ROOT_VAR, pluginRoot);
|
|
@@ -72139,11 +71793,11 @@ function resolvePluginPaths(obj, pluginRoot) {
|
|
|
72139
71793
|
}
|
|
72140
71794
|
function loadInstalledPlugins() {
|
|
72141
71795
|
const dbPath = getInstalledPluginsPath();
|
|
72142
|
-
if (!
|
|
71796
|
+
if (!existsSync55(dbPath)) {
|
|
72143
71797
|
return null;
|
|
72144
71798
|
}
|
|
72145
71799
|
try {
|
|
72146
|
-
const content =
|
|
71800
|
+
const content = readFileSync38(dbPath, "utf-8");
|
|
72147
71801
|
return JSON.parse(content);
|
|
72148
71802
|
} catch (error95) {
|
|
72149
71803
|
log("Failed to load installed plugins database", error95);
|
|
@@ -72154,15 +71808,15 @@ function getClaudeSettingsPath() {
|
|
|
72154
71808
|
if (process.env.CLAUDE_SETTINGS_PATH) {
|
|
72155
71809
|
return process.env.CLAUDE_SETTINGS_PATH;
|
|
72156
71810
|
}
|
|
72157
|
-
return
|
|
71811
|
+
return join66(homedir14(), ".claude", "settings.json");
|
|
72158
71812
|
}
|
|
72159
71813
|
function loadClaudeSettings() {
|
|
72160
71814
|
const settingsPath = getClaudeSettingsPath();
|
|
72161
|
-
if (!
|
|
71815
|
+
if (!existsSync55(settingsPath)) {
|
|
72162
71816
|
return null;
|
|
72163
71817
|
}
|
|
72164
71818
|
try {
|
|
72165
|
-
const content =
|
|
71819
|
+
const content = readFileSync38(settingsPath, "utf-8");
|
|
72166
71820
|
return JSON.parse(content);
|
|
72167
71821
|
} catch (error95) {
|
|
72168
71822
|
log("Failed to load Claude settings", error95);
|
|
@@ -72170,12 +71824,12 @@ function loadClaudeSettings() {
|
|
|
72170
71824
|
}
|
|
72171
71825
|
}
|
|
72172
71826
|
function loadPluginManifest(installPath) {
|
|
72173
|
-
const manifestPath =
|
|
72174
|
-
if (!
|
|
71827
|
+
const manifestPath = join66(installPath, ".claude-plugin", "plugin.json");
|
|
71828
|
+
if (!existsSync55(manifestPath)) {
|
|
72175
71829
|
return null;
|
|
72176
71830
|
}
|
|
72177
71831
|
try {
|
|
72178
|
-
const content =
|
|
71832
|
+
const content = readFileSync38(manifestPath, "utf-8");
|
|
72179
71833
|
return JSON.parse(content);
|
|
72180
71834
|
} catch (error95) {
|
|
72181
71835
|
log(`Failed to load plugin manifest from ${manifestPath}`, error95);
|
|
@@ -72222,7 +71876,7 @@ function discoverInstalledPlugins(options) {
|
|
|
72222
71876
|
continue;
|
|
72223
71877
|
}
|
|
72224
71878
|
const { installPath, scope, version: version3 } = installation;
|
|
72225
|
-
if (!
|
|
71879
|
+
if (!existsSync55(installPath)) {
|
|
72226
71880
|
errors5.push({
|
|
72227
71881
|
pluginKey,
|
|
72228
71882
|
installPath,
|
|
@@ -72240,21 +71894,21 @@ function discoverInstalledPlugins(options) {
|
|
|
72240
71894
|
pluginKey,
|
|
72241
71895
|
manifest: manifest ?? undefined
|
|
72242
71896
|
};
|
|
72243
|
-
if (
|
|
72244
|
-
loadedPlugin.commandsDir =
|
|
71897
|
+
if (existsSync55(join66(installPath, "commands"))) {
|
|
71898
|
+
loadedPlugin.commandsDir = join66(installPath, "commands");
|
|
72245
71899
|
}
|
|
72246
|
-
if (
|
|
72247
|
-
loadedPlugin.agentsDir =
|
|
71900
|
+
if (existsSync55(join66(installPath, "agents"))) {
|
|
71901
|
+
loadedPlugin.agentsDir = join66(installPath, "agents");
|
|
72248
71902
|
}
|
|
72249
|
-
if (
|
|
72250
|
-
loadedPlugin.skillsDir =
|
|
71903
|
+
if (existsSync55(join66(installPath, "skills"))) {
|
|
71904
|
+
loadedPlugin.skillsDir = join66(installPath, "skills");
|
|
72251
71905
|
}
|
|
72252
|
-
const hooksPath =
|
|
72253
|
-
if (
|
|
71906
|
+
const hooksPath = join66(installPath, "hooks", "hooks.json");
|
|
71907
|
+
if (existsSync55(hooksPath)) {
|
|
72254
71908
|
loadedPlugin.hooksPath = hooksPath;
|
|
72255
71909
|
}
|
|
72256
|
-
const mcpPath =
|
|
72257
|
-
if (
|
|
71910
|
+
const mcpPath = join66(installPath, ".mcp.json");
|
|
71911
|
+
if (existsSync55(mcpPath)) {
|
|
72258
71912
|
loadedPlugin.mcpPath = mcpPath;
|
|
72259
71913
|
}
|
|
72260
71914
|
plugins.push(loadedPlugin);
|
|
@@ -72265,17 +71919,17 @@ function discoverInstalledPlugins(options) {
|
|
|
72265
71919
|
function loadPluginCommands(plugins) {
|
|
72266
71920
|
const commands2 = {};
|
|
72267
71921
|
for (const plugin of plugins) {
|
|
72268
|
-
if (!plugin.commandsDir || !
|
|
71922
|
+
if (!plugin.commandsDir || !existsSync55(plugin.commandsDir))
|
|
72269
71923
|
continue;
|
|
72270
71924
|
const entries = readdirSync21(plugin.commandsDir, { withFileTypes: true });
|
|
72271
71925
|
for (const entry of entries) {
|
|
72272
71926
|
if (!isMarkdownFile(entry))
|
|
72273
71927
|
continue;
|
|
72274
|
-
const commandPath =
|
|
71928
|
+
const commandPath = join66(plugin.commandsDir, entry.name);
|
|
72275
71929
|
const commandName = basename8(entry.name, ".md");
|
|
72276
71930
|
const namespacedName = `${plugin.name}:${commandName}`;
|
|
72277
71931
|
try {
|
|
72278
|
-
const content =
|
|
71932
|
+
const content = readFileSync38(commandPath, "utf-8");
|
|
72279
71933
|
const { data, body } = parseFrontmatter(content);
|
|
72280
71934
|
const wrappedTemplate = `<command-instruction>
|
|
72281
71935
|
${body.trim()}
|
|
@@ -72307,21 +71961,21 @@ $ARGUMENTS
|
|
|
72307
71961
|
function loadPluginSkillsAsCommands(plugins) {
|
|
72308
71962
|
const skills = {};
|
|
72309
71963
|
for (const plugin of plugins) {
|
|
72310
|
-
if (!plugin.skillsDir || !
|
|
71964
|
+
if (!plugin.skillsDir || !existsSync55(plugin.skillsDir))
|
|
72311
71965
|
continue;
|
|
72312
71966
|
const entries = readdirSync21(plugin.skillsDir, { withFileTypes: true });
|
|
72313
71967
|
for (const entry of entries) {
|
|
72314
71968
|
if (entry.name.startsWith("."))
|
|
72315
71969
|
continue;
|
|
72316
|
-
const skillPath =
|
|
71970
|
+
const skillPath = join66(plugin.skillsDir, entry.name);
|
|
72317
71971
|
if (!entry.isDirectory() && !entry.isSymbolicLink())
|
|
72318
71972
|
continue;
|
|
72319
71973
|
const resolvedPath = resolveSymlink(skillPath);
|
|
72320
|
-
const skillMdPath =
|
|
72321
|
-
if (!
|
|
71974
|
+
const skillMdPath = join66(resolvedPath, "SKILL.md");
|
|
71975
|
+
if (!existsSync55(skillMdPath))
|
|
72322
71976
|
continue;
|
|
72323
71977
|
try {
|
|
72324
|
-
const content =
|
|
71978
|
+
const content = readFileSync38(skillMdPath, "utf-8");
|
|
72325
71979
|
const { data, body } = parseFrontmatter(content);
|
|
72326
71980
|
const skillName = data.name || entry.name;
|
|
72327
71981
|
const namespacedName = `${plugin.name}:${skillName}`;
|
|
@@ -72368,17 +72022,17 @@ function parseToolsConfig2(toolsStr) {
|
|
|
72368
72022
|
function loadPluginAgents(plugins) {
|
|
72369
72023
|
const agents = {};
|
|
72370
72024
|
for (const plugin of plugins) {
|
|
72371
|
-
if (!plugin.agentsDir || !
|
|
72025
|
+
if (!plugin.agentsDir || !existsSync55(plugin.agentsDir))
|
|
72372
72026
|
continue;
|
|
72373
72027
|
const entries = readdirSync21(plugin.agentsDir, { withFileTypes: true });
|
|
72374
72028
|
for (const entry of entries) {
|
|
72375
72029
|
if (!isMarkdownFile(entry))
|
|
72376
72030
|
continue;
|
|
72377
|
-
const agentPath =
|
|
72031
|
+
const agentPath = join66(plugin.agentsDir, entry.name);
|
|
72378
72032
|
const agentName = basename8(entry.name, ".md");
|
|
72379
72033
|
const namespacedName = `${plugin.name}:${agentName}`;
|
|
72380
72034
|
try {
|
|
72381
|
-
const content =
|
|
72035
|
+
const content = readFileSync38(agentPath, "utf-8");
|
|
72382
72036
|
const { data, body } = parseFrontmatter(content);
|
|
72383
72037
|
const name = data.name || agentName;
|
|
72384
72038
|
const originalDescription = data.description || "";
|
|
@@ -72404,7 +72058,7 @@ function loadPluginAgents(plugins) {
|
|
|
72404
72058
|
async function loadPluginMcpServers(plugins) {
|
|
72405
72059
|
const servers = {};
|
|
72406
72060
|
for (const plugin of plugins) {
|
|
72407
|
-
if (!plugin.mcpPath || !
|
|
72061
|
+
if (!plugin.mcpPath || !existsSync55(plugin.mcpPath))
|
|
72408
72062
|
continue;
|
|
72409
72063
|
try {
|
|
72410
72064
|
const content = await Bun.file(plugin.mcpPath).text();
|
|
@@ -72436,10 +72090,10 @@ async function loadPluginMcpServers(plugins) {
|
|
|
72436
72090
|
function loadPluginHooksConfigs(plugins) {
|
|
72437
72091
|
const configs = [];
|
|
72438
72092
|
for (const plugin of plugins) {
|
|
72439
|
-
if (!plugin.hooksPath || !
|
|
72093
|
+
if (!plugin.hooksPath || !existsSync55(plugin.hooksPath))
|
|
72440
72094
|
continue;
|
|
72441
72095
|
try {
|
|
72442
|
-
const content =
|
|
72096
|
+
const content = readFileSync38(plugin.hooksPath, "utf-8");
|
|
72443
72097
|
let config4 = JSON.parse(content);
|
|
72444
72098
|
config4 = resolvePluginPaths(config4, plugin.installPath);
|
|
72445
72099
|
configs.push(config4);
|
|
@@ -73857,11 +73511,7 @@ function createConfigHandler(deps) {
|
|
|
73857
73511
|
if (isLanguageEnforcementEnabled(pluginConfig)) {
|
|
73858
73512
|
const prometheusAgent = agentConfig["\u6218\u7565\u53C2\u8C0B"];
|
|
73859
73513
|
if (prometheusAgent?.prompt && !prometheusAgent.prompt.includes("<Language_Instruction>")) {
|
|
73860
|
-
|
|
73861
|
-
prometheusAgent.prompt += ZH_LANGUAGE_INSTRUCTION_DEEPSEEK;
|
|
73862
|
-
} else {
|
|
73863
|
-
prometheusAgent.prompt += ZH_LANGUAGE_INSTRUCTION;
|
|
73864
|
-
}
|
|
73514
|
+
prometheusAgent.prompt += ZH_LANGUAGE_INSTRUCTION;
|
|
73865
73515
|
}
|
|
73866
73516
|
}
|
|
73867
73517
|
if (isLanguageEnforcementEnabled(pluginConfig)) {
|
|
@@ -74139,8 +73789,6 @@ var OhMyOpenCodePlugin = async (ctx) => {
|
|
|
74139
73789
|
const keywordDetector = isHookEnabled("keyword-detector") ? createKeywordDetectorHook(ctx, contextCollector) : null;
|
|
74140
73790
|
const contextInjectorMessagesTransform = createContextInjectorMessagesTransformHook(contextCollector);
|
|
74141
73791
|
const agentUsageReminder = isHookEnabled("agent-usage-reminder") ? createAgentUsageReminderHook(ctx) : null;
|
|
74142
|
-
const languageReminder = isHookEnabled("language-reminder") && isLanguageEnforcementEnabled(pluginConfig) ? createLanguageReminderHook(ctx) : null;
|
|
74143
|
-
const thinkingLanguageValidator = isHookEnabled("thinking-language-validator") && isLanguageEnforcementEnabled(pluginConfig) ? createThinkingLanguageValidatorHook(ctx) : null;
|
|
74144
73792
|
const nonInteractiveEnv = isHookEnabled("non-interactive-env") ? createNonInteractiveEnvHook(ctx) : null;
|
|
74145
73793
|
const interactiveBashSession = isHookEnabled("interactive-bash-session") ? createInteractiveBashSessionHook(ctx) : null;
|
|
74146
73794
|
const thinkingBlockValidator = isHookEnabled("thinking-block-validator") ? createThinkingBlockValidatorHook() : null;
|
|
@@ -74429,10 +74077,6 @@ var OhMyOpenCodePlugin = async (ctx) => {
|
|
|
74429
74077
|
hookCount++;
|
|
74430
74078
|
await wrapWithTiming(perfTracer, "event", "agentUsageReminder", () => agentUsageReminder?.event(input), evtSessionID);
|
|
74431
74079
|
hookCount++;
|
|
74432
|
-
await wrapWithTiming(perfTracer, "event", "languageReminder", () => languageReminder?.event(input), evtSessionID);
|
|
74433
|
-
hookCount++;
|
|
74434
|
-
await wrapWithTiming(perfTracer, "event", "thinkingLanguageValidator", () => thinkingLanguageValidator?.event(input), evtSessionID);
|
|
74435
|
-
hookCount++;
|
|
74436
74080
|
await wrapWithTiming(perfTracer, "event", "interactiveBashSession", () => interactiveBashSession?.event(input), evtSessionID);
|
|
74437
74081
|
hookCount++;
|
|
74438
74082
|
await wrapWithTiming(perfTracer, "event", "ralphLoop", () => ralphLoop?.event(input), evtSessionID);
|
|
@@ -74598,10 +74242,6 @@ var OhMyOpenCodePlugin = async (ctx) => {
|
|
|
74598
74242
|
hookCount++;
|
|
74599
74243
|
await wrapWithTiming(perfTracer, "tool.execute.after", "agentUsageReminder", () => agentUsageReminder?.["tool.execute.after"](input, output), input.sessionID, input.tool);
|
|
74600
74244
|
hookCount++;
|
|
74601
|
-
await wrapWithTiming(perfTracer, "tool.execute.after", "languageReminder", () => languageReminder?.["tool.execute.after"](input, output), input.sessionID, input.tool);
|
|
74602
|
-
hookCount++;
|
|
74603
|
-
await wrapWithTiming(perfTracer, "tool.execute.after", "thinkingLanguageValidator", () => thinkingLanguageValidator?.["tool.execute.after"](input, output), input.sessionID, input.tool);
|
|
74604
|
-
hookCount++;
|
|
74605
74245
|
await wrapWithTiming(perfTracer, "tool.execute.after", "interactiveBashSession", () => interactiveBashSession?.["tool.execute.after"](input, output), input.sessionID, input.tool);
|
|
74606
74246
|
hookCount++;
|
|
74607
74247
|
await wrapWithTiming(perfTracer, "tool.execute.after", "editErrorRecovery", () => editErrorRecovery?.["tool.execute.after"](input, output), input.sessionID, input.tool);
|