adhdev 0.9.4 → 0.9.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/cli/index.js +161 -282
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +142 -187
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -729,35 +729,6 @@ var init_saved_sessions = __esm({
|
|
|
729
729
|
}
|
|
730
730
|
});
|
|
731
731
|
|
|
732
|
-
// ../../oss/packages/daemon-core/src/providers/provider-session-id.ts
|
|
733
|
-
function normalizeProviderSessionId(providerType, providerSessionId) {
|
|
734
|
-
const normalizedProviderType = typeof providerType === "string" ? providerType.trim() : "";
|
|
735
|
-
const normalizedId = typeof providerSessionId === "string" ? providerSessionId.trim() : "";
|
|
736
|
-
if (!normalizedId) return "";
|
|
737
|
-
const lowered = normalizedId.toLowerCase();
|
|
738
|
-
if (lowered === "undefined" || lowered === "null") return "";
|
|
739
|
-
if (normalizedProviderType === "hermes-cli" && !HERMES_SESSION_ID_RE.test(normalizedId)) {
|
|
740
|
-
return "";
|
|
741
|
-
}
|
|
742
|
-
if (normalizedProviderType === "claude-cli" && !CLAUDE_SESSION_ID_RE.test(normalizedId)) {
|
|
743
|
-
return "";
|
|
744
|
-
}
|
|
745
|
-
return normalizedId;
|
|
746
|
-
}
|
|
747
|
-
function isLegacyVolatileSessionReadKey(key) {
|
|
748
|
-
const normalizedKey = typeof key === "string" ? key.trim() : "";
|
|
749
|
-
if (!normalizedKey) return false;
|
|
750
|
-
return normalizedKey.startsWith("provider:codex:vscode-webview://");
|
|
751
|
-
}
|
|
752
|
-
var HERMES_SESSION_ID_RE, CLAUDE_SESSION_ID_RE;
|
|
753
|
-
var init_provider_session_id = __esm({
|
|
754
|
-
"../../oss/packages/daemon-core/src/providers/provider-session-id.ts"() {
|
|
755
|
-
"use strict";
|
|
756
|
-
HERMES_SESSION_ID_RE = /^\d{8}_\d{6}_[a-z0-9]+$/i;
|
|
757
|
-
CLAUDE_SESSION_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
758
|
-
}
|
|
759
|
-
});
|
|
760
|
-
|
|
761
732
|
// ../../oss/packages/daemon-core/src/config/state-store.ts
|
|
762
733
|
function isPlainObject2(value) {
|
|
763
734
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
@@ -769,31 +740,24 @@ function normalizeState(raw) {
|
|
|
769
740
|
const parsed = isPlainObject2(raw) ? raw : {};
|
|
770
741
|
const recentActivity = (Array.isArray(parsed.recentActivity) ? parsed.recentActivity : []).filter((entry) => {
|
|
771
742
|
if (!isPlainObject2(entry)) return false;
|
|
772
|
-
|
|
773
|
-
typeof entry.providerType === "string" ? entry.providerType : "",
|
|
774
|
-
typeof entry.providerSessionId === "string" ? entry.providerSessionId : ""
|
|
775
|
-
);
|
|
776
|
-
if (typeof entry.providerSessionId === "string" && !normalizedId) return false;
|
|
743
|
+
if (typeof entry.providerSessionId === "string" && !entry.providerSessionId.trim()) return false;
|
|
777
744
|
return true;
|
|
778
745
|
});
|
|
779
746
|
const savedProviderSessions = (Array.isArray(parsed.savedProviderSessions) ? parsed.savedProviderSessions : []).filter((entry) => {
|
|
780
747
|
if (!isPlainObject2(entry)) return false;
|
|
781
|
-
return !!
|
|
782
|
-
typeof entry.providerType === "string" ? entry.providerType : "",
|
|
783
|
-
typeof entry.providerSessionId === "string" ? entry.providerSessionId : ""
|
|
784
|
-
);
|
|
748
|
+
return typeof entry.providerSessionId === "string" && !!entry.providerSessionId.trim();
|
|
785
749
|
});
|
|
786
750
|
const sessionReads = Object.fromEntries(
|
|
787
|
-
Object.entries(isPlainObject2(parsed.sessionReads) ? parsed.sessionReads : {}).filter(([
|
|
751
|
+
Object.entries(isPlainObject2(parsed.sessionReads) ? parsed.sessionReads : {}).filter(([, value]) => typeof value === "number" && Number.isFinite(value))
|
|
788
752
|
);
|
|
789
753
|
const sessionReadMarkers = Object.fromEntries(
|
|
790
|
-
Object.entries(isPlainObject2(parsed.sessionReadMarkers) ? parsed.sessionReadMarkers : {}).filter(([
|
|
754
|
+
Object.entries(isPlainObject2(parsed.sessionReadMarkers) ? parsed.sessionReadMarkers : {}).filter(([, value]) => typeof value === "string")
|
|
791
755
|
);
|
|
792
756
|
const sessionNotificationDismissals = Object.fromEntries(
|
|
793
|
-
Object.entries(isPlainObject2(parsed.sessionNotificationDismissals) ? parsed.sessionNotificationDismissals : {}).filter(([
|
|
757
|
+
Object.entries(isPlainObject2(parsed.sessionNotificationDismissals) ? parsed.sessionNotificationDismissals : {}).filter(([, value]) => typeof value === "string" && value.length > 0)
|
|
794
758
|
);
|
|
795
759
|
const sessionNotificationUnreadOverrides = Object.fromEntries(
|
|
796
|
-
Object.entries(isPlainObject2(parsed.sessionNotificationUnreadOverrides) ? parsed.sessionNotificationUnreadOverrides : {}).filter(([
|
|
760
|
+
Object.entries(isPlainObject2(parsed.sessionNotificationUnreadOverrides) ? parsed.sessionNotificationUnreadOverrides : {}).filter(([, value]) => typeof value === "string" && value.length > 0)
|
|
797
761
|
);
|
|
798
762
|
return {
|
|
799
763
|
recentActivity,
|
|
@@ -831,7 +795,6 @@ var init_state_store = __esm({
|
|
|
831
795
|
import_fs2 = require("fs");
|
|
832
796
|
import_path2 = require("path");
|
|
833
797
|
init_config();
|
|
834
|
-
init_provider_session_id();
|
|
835
798
|
DEFAULT_STATE = {
|
|
836
799
|
recentActivity: [],
|
|
837
800
|
savedProviderSessions: [],
|
|
@@ -3526,12 +3489,21 @@ var init_control_effects = __esm({
|
|
|
3526
3489
|
function normalizeHistoryComparable(text) {
|
|
3527
3490
|
return String(text || "").replace(/\s+/g, " ").trim();
|
|
3528
3491
|
}
|
|
3529
|
-
function cleanupHistoryContent(agentType, role, content) {
|
|
3492
|
+
function cleanupHistoryContent(agentType, role, content, historyBehavior) {
|
|
3530
3493
|
let value = String(content || "").replace(/\r\n/g, "\n").trim();
|
|
3531
3494
|
if (!value) return "";
|
|
3532
|
-
if (
|
|
3533
|
-
const
|
|
3534
|
-
|
|
3495
|
+
if (role === "assistant" && historyBehavior?.filterAssistantPatterns?.length) {
|
|
3496
|
+
const filters = historyBehavior.filterAssistantPatterns.map((p) => {
|
|
3497
|
+
try {
|
|
3498
|
+
return new RegExp(p, "i");
|
|
3499
|
+
} catch {
|
|
3500
|
+
return null;
|
|
3501
|
+
}
|
|
3502
|
+
}).filter(Boolean);
|
|
3503
|
+
if (filters.length > 0) {
|
|
3504
|
+
const filtered = value.split("\n").filter((line) => !filters.some((re) => re.test(line.trim()))).join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
3505
|
+
value = filtered;
|
|
3506
|
+
}
|
|
3535
3507
|
}
|
|
3536
3508
|
return value;
|
|
3537
3509
|
}
|
|
@@ -3548,8 +3520,8 @@ function isAdjacentHistoryDuplicate(agentType, previous, next) {
|
|
|
3548
3520
|
if (!previous || !next) return false;
|
|
3549
3521
|
return buildHistoryMessageSignature(agentType, previous) === buildHistoryMessageSignature(agentType, next);
|
|
3550
3522
|
}
|
|
3551
|
-
function collapseReplayAssistantTurns(
|
|
3552
|
-
if (
|
|
3523
|
+
function collapseReplayAssistantTurns(messages, historyBehavior) {
|
|
3524
|
+
if (!historyBehavior?.collapseConsecutiveAssistantTurns) return messages;
|
|
3553
3525
|
const collapsed = [];
|
|
3554
3526
|
let sawAssistantSinceLastUser = false;
|
|
3555
3527
|
for (const message of messages) {
|
|
@@ -3654,16 +3626,12 @@ function listHistoryFiles(dir, historySessionId) {
|
|
|
3654
3626
|
return true;
|
|
3655
3627
|
}).sort().reverse();
|
|
3656
3628
|
}
|
|
3657
|
-
function normalizeSavedHistorySessionId(
|
|
3658
|
-
|
|
3659
|
-
if (!normalizedId) return "";
|
|
3660
|
-
const strictProviderId = normalizeProviderSessionId(agentType, normalizedId);
|
|
3661
|
-
if (strictProviderId) return strictProviderId;
|
|
3662
|
-
return agentType === "hermes-cli" ? "" : normalizedId;
|
|
3629
|
+
function normalizeSavedHistorySessionId(historySessionId) {
|
|
3630
|
+
return String(historySessionId || "").trim();
|
|
3663
3631
|
}
|
|
3664
|
-
function extractSavedHistorySessionIdFromFile(
|
|
3632
|
+
function extractSavedHistorySessionIdFromFile(file2) {
|
|
3665
3633
|
const match = file2.match(/^([A-Za-z0-9_-]+)_\d{4}-\d{2}-\d{2}\.jsonl$/);
|
|
3666
|
-
return normalizeSavedHistorySessionId(
|
|
3634
|
+
return normalizeSavedHistorySessionId(match?.[1] || "");
|
|
3667
3635
|
}
|
|
3668
3636
|
function buildSavedHistoryFileSignatureMap(dir, files) {
|
|
3669
3637
|
return new Map(files.map((file2) => {
|
|
@@ -3842,7 +3810,7 @@ function persistSavedHistoryFileSummaryEntry(agentType, dir, file2, updater) {
|
|
|
3842
3810
|
}
|
|
3843
3811
|
}
|
|
3844
3812
|
function updateSavedHistoryIndexForSessionStart(agentType, dir, file2, historySessionId, workspace) {
|
|
3845
|
-
const normalizedSessionId = normalizeSavedHistorySessionId(
|
|
3813
|
+
const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId);
|
|
3846
3814
|
const normalizedWorkspace = String(workspace || "").trim();
|
|
3847
3815
|
if (!normalizedSessionId || !normalizedWorkspace) return;
|
|
3848
3816
|
persistSavedHistoryFileSummaryEntry(agentType, dir, file2, (currentSummary) => ({
|
|
@@ -3857,7 +3825,7 @@ function updateSavedHistoryIndexForSessionStart(agentType, dir, file2, historySe
|
|
|
3857
3825
|
}));
|
|
3858
3826
|
}
|
|
3859
3827
|
function updateSavedHistoryIndexForAppendedMessages(agentType, dir, file2, historySessionId, messages) {
|
|
3860
|
-
const normalizedSessionId = normalizeSavedHistorySessionId(
|
|
3828
|
+
const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId || "");
|
|
3861
3829
|
if (!normalizedSessionId || messages.length === 0) return;
|
|
3862
3830
|
persistSavedHistoryFileSummaryEntry(agentType, dir, file2, (currentSummary) => {
|
|
3863
3831
|
const nextSummary = {
|
|
@@ -3894,8 +3862,8 @@ function updateSavedHistoryIndexForAppendedMessages(agentType, dir, file2, histo
|
|
|
3894
3862
|
return nextSummary;
|
|
3895
3863
|
});
|
|
3896
3864
|
}
|
|
3897
|
-
function computeSavedHistoryFileSummary(
|
|
3898
|
-
const historySessionId = extractSavedHistorySessionIdFromFile(
|
|
3865
|
+
function computeSavedHistoryFileSummary(dir, file2) {
|
|
3866
|
+
const historySessionId = extractSavedHistorySessionIdFromFile(file2);
|
|
3899
3867
|
if (!historySessionId) return null;
|
|
3900
3868
|
const filePath = path7.join(dir, file2);
|
|
3901
3869
|
const content = fs3.readFileSync(filePath, "utf-8");
|
|
@@ -3989,7 +3957,7 @@ function computeSavedHistorySessionSummaries(agentType, dir, files, fileSignatur
|
|
|
3989
3957
|
const cached2 = savedHistoryFileSummaryCache.get(filePath);
|
|
3990
3958
|
const persisted = persistedEntries.get(file2);
|
|
3991
3959
|
const reusableEntry = cached2?.signature === signature ? cached2 : persisted?.signature === signature ? persisted : null;
|
|
3992
|
-
const fileSummary = reusableEntry?.summary || computeSavedHistoryFileSummary(
|
|
3960
|
+
const fileSummary = reusableEntry?.summary || computeSavedHistoryFileSummary(dir, file2);
|
|
3993
3961
|
const nextEntry = reusableEntry || {
|
|
3994
3962
|
signature,
|
|
3995
3963
|
summary: fileSummary
|
|
@@ -4035,7 +4003,7 @@ function computeSavedHistorySessionSummaries(agentType, dir, files, fileSignatur
|
|
|
4035
4003
|
persistedEntries: nextPersistedEntries
|
|
4036
4004
|
};
|
|
4037
4005
|
}
|
|
4038
|
-
function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, excludeRecentCount = 0) {
|
|
4006
|
+
function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, excludeRecentCount = 0, historyBehavior) {
|
|
4039
4007
|
try {
|
|
4040
4008
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
4041
4009
|
const dir = path7.join(HISTORY_DIR, sanitized);
|
|
@@ -4070,7 +4038,7 @@ function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, ex
|
|
|
4070
4038
|
chronological.push(message);
|
|
4071
4039
|
if (message.role !== "system") lastTurn = message;
|
|
4072
4040
|
}
|
|
4073
|
-
const collapsed = collapseReplayAssistantTurns(
|
|
4041
|
+
const collapsed = collapseReplayAssistantTurns(chronological, historyBehavior);
|
|
4074
4042
|
const boundedLimit = Math.max(1, limit);
|
|
4075
4043
|
const boundedOffset = Math.max(0, offset);
|
|
4076
4044
|
const boundedExclude = Math.max(0, Math.min(excludeRecentCount, collapsed.length));
|
|
@@ -4083,7 +4051,7 @@ function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, ex
|
|
|
4083
4051
|
return { messages: [], hasMore: false };
|
|
4084
4052
|
}
|
|
4085
4053
|
}
|
|
4086
|
-
function listSavedHistorySessions(agentType, options = {}) {
|
|
4054
|
+
function listSavedHistorySessions(agentType, options = {}, historyBehavior) {
|
|
4087
4055
|
try {
|
|
4088
4056
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
4089
4057
|
const dir = path7.join(HISTORY_DIR, sanitized);
|
|
@@ -4214,7 +4182,7 @@ function rewriteCanonicalSavedHistory(agentType, historySessionId, records) {
|
|
|
4214
4182
|
}
|
|
4215
4183
|
}
|
|
4216
4184
|
function rebuildHermesSavedHistoryFromCanonicalSession(historySessionId) {
|
|
4217
|
-
const normalizedSessionId = normalizeSavedHistorySessionId(
|
|
4185
|
+
const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId);
|
|
4218
4186
|
if (!normalizedSessionId) return false;
|
|
4219
4187
|
try {
|
|
4220
4188
|
const sessionFilePath = path7.join(os5.homedir(), ".hermes", "sessions", `session_${normalizedSessionId}.json`);
|
|
@@ -4363,7 +4331,7 @@ function extractClaudeUserContentParts(content) {
|
|
|
4363
4331
|
return parts;
|
|
4364
4332
|
}
|
|
4365
4333
|
function rebuildClaudeSavedHistoryFromNativeProject(historySessionId, workspace) {
|
|
4366
|
-
const normalizedSessionId = normalizeSavedHistorySessionId(
|
|
4334
|
+
const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId);
|
|
4367
4335
|
if (!normalizedSessionId) return false;
|
|
4368
4336
|
try {
|
|
4369
4337
|
const transcriptPath = resolveClaudeProjectTranscriptPath(normalizedSessionId, workspace);
|
|
@@ -4440,7 +4408,7 @@ function rebuildClaudeSavedHistoryFromNativeProject(historySessionId, workspace)
|
|
|
4440
4408
|
return false;
|
|
4441
4409
|
}
|
|
4442
4410
|
}
|
|
4443
|
-
var fs3, path7, os5, HISTORY_DIR, RETAIN_DAYS, SAVED_HISTORY_INDEX_VERSION, SAVED_HISTORY_INDEX_FILE, SAVED_HISTORY_INDEX_LOCK_SUFFIX, SAVED_HISTORY_INDEX_LOCK_WAIT_MS, SAVED_HISTORY_INDEX_LOCK_STALE_MS, SAVED_HISTORY_INDEX_LOCK_POLL_MS, SAVED_HISTORY_ROLLUP_THRESHOLD_BYTES, savedHistorySessionCache, savedHistoryFileSummaryCache, savedHistoryBackgroundRefresh, savedHistoryRollupInFlight,
|
|
4411
|
+
var fs3, path7, os5, HISTORY_DIR, RETAIN_DAYS, SAVED_HISTORY_INDEX_VERSION, SAVED_HISTORY_INDEX_FILE, SAVED_HISTORY_INDEX_LOCK_SUFFIX, SAVED_HISTORY_INDEX_LOCK_WAIT_MS, SAVED_HISTORY_INDEX_LOCK_STALE_MS, SAVED_HISTORY_INDEX_LOCK_POLL_MS, SAVED_HISTORY_ROLLUP_THRESHOLD_BYTES, savedHistorySessionCache, savedHistoryFileSummaryCache, savedHistoryBackgroundRefresh, savedHistoryRollupInFlight, ChatHistoryWriter;
|
|
4444
4412
|
var init_chat_history = __esm({
|
|
4445
4413
|
"../../oss/packages/daemon-core/src/config/chat-history.ts"() {
|
|
4446
4414
|
"use strict";
|
|
@@ -4448,7 +4416,6 @@ var init_chat_history = __esm({
|
|
|
4448
4416
|
path7 = __toESM(require("path"));
|
|
4449
4417
|
os5 = __toESM(require("os"));
|
|
4450
4418
|
init_chat_message_normalization();
|
|
4451
|
-
init_provider_session_id();
|
|
4452
4419
|
HISTORY_DIR = path7.join(os5.homedir(), ".adhdev", "history");
|
|
4453
4420
|
RETAIN_DAYS = 30;
|
|
4454
4421
|
SAVED_HISTORY_INDEX_VERSION = 1;
|
|
@@ -4462,7 +4429,6 @@ var init_chat_history = __esm({
|
|
|
4462
4429
|
savedHistoryFileSummaryCache = /* @__PURE__ */ new Map();
|
|
4463
4430
|
savedHistoryBackgroundRefresh = /* @__PURE__ */ new Set();
|
|
4464
4431
|
savedHistoryRollupInFlight = /* @__PURE__ */ new Set();
|
|
4465
|
-
CODEX_STARTER_PROMPT_RE = /^(?:[›❯]\s*)?(?:Find and fix a bug in @filename|Improve documentation in @filename|Write tests for @filename|Explain this codebase|Summarize recent commits|Implement \{feature\}|Use \/skills(?: to list available skills)?|Run \/review on my current changes)$/i;
|
|
4466
4432
|
ChatHistoryWriter = class {
|
|
4467
4433
|
/** Last seen message count per agent (deduplication) */
|
|
4468
4434
|
lastSeenCounts = /* @__PURE__ */ new Map();
|
|
@@ -4715,7 +4681,7 @@ var init_chat_history = __esm({
|
|
|
4715
4681
|
} catch {
|
|
4716
4682
|
}
|
|
4717
4683
|
}
|
|
4718
|
-
compactHistorySession(agentType, historySessionId) {
|
|
4684
|
+
compactHistorySession(agentType, historySessionId, historyBehavior) {
|
|
4719
4685
|
const sessionId = String(historySessionId || "").trim();
|
|
4720
4686
|
if (!sessionId) return;
|
|
4721
4687
|
try {
|
|
@@ -4753,7 +4719,7 @@ var init_chat_history = __esm({
|
|
|
4753
4719
|
dedupedAdjacent.push(entry);
|
|
4754
4720
|
if (entry.role !== "system") lastTurn = entry;
|
|
4755
4721
|
}
|
|
4756
|
-
const collapsed = collapseReplayAssistantTurns(
|
|
4722
|
+
const collapsed = collapseReplayAssistantTurns(dedupedAdjacent, historyBehavior);
|
|
4757
4723
|
if (collapsed.length === 0) {
|
|
4758
4724
|
fs3.unlinkSync(filePath);
|
|
4759
4725
|
continue;
|
|
@@ -9198,7 +9164,8 @@ async function executeProviderScript(h, args, scriptName) {
|
|
|
9198
9164
|
}
|
|
9199
9165
|
const managed = runtimeSessionId ? h.agentStream?.getManagedSession(runtimeSessionId) : null;
|
|
9200
9166
|
const targetSessionId = managed?.cdpSessionId || null;
|
|
9201
|
-
const
|
|
9167
|
+
const DEFAULT_IDE_LEVEL_SCRIPTS = ["listModes", "setMode", "listModels", "setModel"];
|
|
9168
|
+
const IDE_LEVEL_SCRIPTS = provider.ideLevelScripts ?? DEFAULT_IDE_LEVEL_SCRIPTS;
|
|
9202
9169
|
if (IDE_LEVEL_SCRIPTS.includes(scriptName)) {
|
|
9203
9170
|
if (targetSessionId) {
|
|
9204
9171
|
try {
|
|
@@ -13643,6 +13610,28 @@ ${data.message || ""}`.trim();
|
|
|
13643
13610
|
}
|
|
13644
13611
|
});
|
|
13645
13612
|
|
|
13613
|
+
// ../../oss/packages/daemon-core/src/providers/provider-session-id.ts
|
|
13614
|
+
function normalizeProviderSessionId(provider, providerSessionId) {
|
|
13615
|
+
const normalizedId = typeof providerSessionId === "string" ? providerSessionId.trim() : "";
|
|
13616
|
+
if (!normalizedId) return "";
|
|
13617
|
+
const lowered = normalizedId.toLowerCase();
|
|
13618
|
+
if (lowered === "undefined" || lowered === "null") return "";
|
|
13619
|
+
const sessionIdPattern = provider?.sessionIdPattern;
|
|
13620
|
+
if (sessionIdPattern) {
|
|
13621
|
+
try {
|
|
13622
|
+
const re = new RegExp(sessionIdPattern, "i");
|
|
13623
|
+
if (!re.test(normalizedId)) return "";
|
|
13624
|
+
} catch {
|
|
13625
|
+
}
|
|
13626
|
+
}
|
|
13627
|
+
return normalizedId;
|
|
13628
|
+
}
|
|
13629
|
+
var init_provider_session_id = __esm({
|
|
13630
|
+
"../../oss/packages/daemon-core/src/providers/provider-session-id.ts"() {
|
|
13631
|
+
"use strict";
|
|
13632
|
+
}
|
|
13633
|
+
});
|
|
13634
|
+
|
|
13646
13635
|
// ../../oss/packages/daemon-core/src/providers/cli-provider-instance.ts
|
|
13647
13636
|
function normalizePersistableCliHistoryContent(content) {
|
|
13648
13637
|
return flattenContent(content).replace(/\s+/g, " ").trim();
|
|
@@ -13820,32 +13809,10 @@ var init_cli_provider_instance = __esm({
|
|
|
13820
13809
|
}
|
|
13821
13810
|
async onTick() {
|
|
13822
13811
|
if (this.providerSessionId) return;
|
|
13823
|
-
if (this.
|
|
13824
|
-
let probedSessionId = null;
|
|
13812
|
+
if (this.provider.resume?.skipProbeOnNewSession && this.launchMode === "new") return;
|
|
13825
13813
|
const probeConfig = this.provider.sessionProbe;
|
|
13826
|
-
if (probeConfig)
|
|
13827
|
-
|
|
13828
|
-
} else {
|
|
13829
|
-
if (this.type === "opencode-cli") {
|
|
13830
|
-
probedSessionId = this.probeSessionIdFromConfig({
|
|
13831
|
-
dbPath: "~/.local/share/opencode/opencode.db",
|
|
13832
|
-
query: "select id from session where directory in ({dirs}) and time_created >= ? and time_archived is null order by time_updated desc limit 1",
|
|
13833
|
-
timestampFormat: "unix_ms"
|
|
13834
|
-
});
|
|
13835
|
-
} else if (this.type === "codex-cli") {
|
|
13836
|
-
probedSessionId = this.probeSessionIdFromConfig({
|
|
13837
|
-
dbPath: "~/.codex/state_5.sqlite",
|
|
13838
|
-
query: "select id from threads where cwd in ({dirs}) and updated_at >= ? and archived = 0 order by updated_at desc limit 1",
|
|
13839
|
-
timestampFormat: "unix_s"
|
|
13840
|
-
});
|
|
13841
|
-
} else if (this.type === "goose-cli") {
|
|
13842
|
-
probedSessionId = this.probeSessionIdFromConfig({
|
|
13843
|
-
dbPath: "~/.local/share/goose/sessions/sessions.db",
|
|
13844
|
-
query: "select id from sessions where working_dir in ({dirs}) and created_at >= ? order by updated_at desc limit 1",
|
|
13845
|
-
timestampFormat: "iso"
|
|
13846
|
-
});
|
|
13847
|
-
}
|
|
13848
|
-
}
|
|
13814
|
+
if (!probeConfig) return;
|
|
13815
|
+
const probedSessionId = this.probeSessionIdFromConfig(probeConfig);
|
|
13849
13816
|
if (probedSessionId) {
|
|
13850
13817
|
this.promoteProviderSessionId(probedSessionId);
|
|
13851
13818
|
}
|
|
@@ -13897,7 +13864,7 @@ var init_cli_provider_instance = __esm({
|
|
|
13897
13864
|
const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
|
|
13898
13865
|
const visibleStatus = parseErrorMessage ? "error" : autoApproveActive ? "generating" : adapterStatus.status;
|
|
13899
13866
|
const parsedProviderSessionId = normalizeProviderSessionId(
|
|
13900
|
-
this.
|
|
13867
|
+
this.provider,
|
|
13901
13868
|
typeof parsedStatus?.providerSessionId === "string" ? parsedStatus.providerSessionId : ""
|
|
13902
13869
|
);
|
|
13903
13870
|
if (parsedProviderSessionId) {
|
|
@@ -14187,7 +14154,7 @@ var init_cli_provider_instance = __esm({
|
|
|
14187
14154
|
applyProviderResponse(data, options) {
|
|
14188
14155
|
if (!data || typeof data !== "object") return;
|
|
14189
14156
|
const patchedProviderSessionId = normalizeProviderSessionId(
|
|
14190
|
-
this.
|
|
14157
|
+
this.provider,
|
|
14191
14158
|
typeof data.providerSessionId === "string" ? data.providerSessionId : ""
|
|
14192
14159
|
);
|
|
14193
14160
|
if (patchedProviderSessionId) {
|
|
@@ -14425,52 +14392,39 @@ ${effect.notification.body || ""}`.trim();
|
|
|
14425
14392
|
}
|
|
14426
14393
|
syncCanonicalSavedHistoryIfNeeded() {
|
|
14427
14394
|
if (!this.providerSessionId) return false;
|
|
14428
|
-
|
|
14429
|
-
|
|
14430
|
-
|
|
14431
|
-
|
|
14432
|
-
|
|
14395
|
+
const canonicalHistory = this.provider.canonicalHistory;
|
|
14396
|
+
if (!canonicalHistory) return false;
|
|
14397
|
+
try {
|
|
14398
|
+
let rebuilt = false;
|
|
14399
|
+
if (canonicalHistory.format === "hermes-json") {
|
|
14400
|
+
const watchPath = canonicalHistory.watchPath.replace(/^~/, os13.homedir()).replace("{{sessionId}}", this.providerSessionId);
|
|
14401
|
+
if (!fs5.existsSync(watchPath)) return false;
|
|
14402
|
+
const stat4 = fs5.statSync(watchPath);
|
|
14433
14403
|
if (stat4.mtimeMs <= this.lastCanonicalHermesSyncMtimeMs) return true;
|
|
14434
|
-
|
|
14435
|
-
if (
|
|
14436
|
-
|
|
14437
|
-
|
|
14438
|
-
|
|
14439
|
-
|
|
14440
|
-
|
|
14441
|
-
|
|
14442
|
-
|
|
14443
|
-
|
|
14444
|
-
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
}
|
|
14450
|
-
|
|
14451
|
-
try {
|
|
14452
|
-
const rebuilt = rebuildClaudeSavedHistoryFromNativeProject(this.providerSessionId, this.workingDir);
|
|
14453
|
-
if (!rebuilt) return false;
|
|
14454
|
-
const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId);
|
|
14455
|
-
this.lastPersistedHistoryMessages = restoredHistory.messages.map((message) => ({
|
|
14456
|
-
role: message.role,
|
|
14457
|
-
content: message.content,
|
|
14458
|
-
kind: message.kind,
|
|
14459
|
-
senderName: message.senderName,
|
|
14460
|
-
receivedAt: message.receivedAt
|
|
14461
|
-
}));
|
|
14462
|
-
return true;
|
|
14463
|
-
} catch {
|
|
14464
|
-
return false;
|
|
14465
|
-
}
|
|
14404
|
+
rebuilt = rebuildHermesSavedHistoryFromCanonicalSession(this.providerSessionId);
|
|
14405
|
+
if (rebuilt) this.lastCanonicalHermesSyncMtimeMs = stat4.mtimeMs;
|
|
14406
|
+
} else if (canonicalHistory.format === "claude-jsonl") {
|
|
14407
|
+
rebuilt = rebuildClaudeSavedHistoryFromNativeProject(this.providerSessionId, this.workingDir);
|
|
14408
|
+
}
|
|
14409
|
+
if (!rebuilt) return false;
|
|
14410
|
+
const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId, 0, this.provider.historyBehavior);
|
|
14411
|
+
this.lastPersistedHistoryMessages = restoredHistory.messages.map((message) => ({
|
|
14412
|
+
role: message.role,
|
|
14413
|
+
content: message.content,
|
|
14414
|
+
kind: message.kind,
|
|
14415
|
+
senderName: message.senderName,
|
|
14416
|
+
receivedAt: message.receivedAt
|
|
14417
|
+
}));
|
|
14418
|
+
return true;
|
|
14419
|
+
} catch {
|
|
14420
|
+
return false;
|
|
14466
14421
|
}
|
|
14467
|
-
return false;
|
|
14468
14422
|
}
|
|
14469
14423
|
restorePersistedHistoryFromCurrentSession() {
|
|
14470
14424
|
if (!this.providerSessionId) return;
|
|
14471
14425
|
this.syncCanonicalSavedHistoryIfNeeded();
|
|
14472
|
-
this.historyWriter.compactHistorySession(this.type, this.providerSessionId);
|
|
14473
|
-
const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId);
|
|
14426
|
+
this.historyWriter.compactHistorySession(this.type, this.providerSessionId, this.provider.historyBehavior);
|
|
14427
|
+
const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId, 0, this.provider.historyBehavior);
|
|
14474
14428
|
this.historyWriter.seedSessionHistory(
|
|
14475
14429
|
this.type,
|
|
14476
14430
|
restoredHistory.messages,
|
|
@@ -32022,14 +31976,15 @@ function expandResumeArgs(template, sessionId) {
|
|
|
32022
31976
|
if (!Array.isArray(template) || template.length === 0) return void 0;
|
|
32023
31977
|
return template.map((part) => part === "{{id}}" ? sessionId : part);
|
|
32024
31978
|
}
|
|
32025
|
-
function
|
|
32026
|
-
const resumeIndex = args.findIndex((arg) => arg
|
|
31979
|
+
function readSubcommandSessionId(args, subcommands) {
|
|
31980
|
+
const resumeIndex = args.findIndex((arg) => subcommands.includes(arg));
|
|
32027
31981
|
if (resumeIndex < 0) return void 0;
|
|
32028
31982
|
const candidate = args[resumeIndex + 1];
|
|
32029
31983
|
if (!candidate || candidate.startsWith("-")) return void 0;
|
|
32030
31984
|
return candidate;
|
|
32031
31985
|
}
|
|
32032
|
-
function detectExplicitProviderSessionId(
|
|
31986
|
+
function detectExplicitProviderSessionId(provider, args) {
|
|
31987
|
+
const resume = provider?.resume;
|
|
32033
31988
|
const explicitResumeId = readArgValue(args, ["--resume", "-r"]);
|
|
32034
31989
|
if (explicitResumeId) {
|
|
32035
31990
|
return { providerSessionId: explicitResumeId, launchMode: "resume" };
|
|
@@ -32043,19 +31998,20 @@ function detectExplicitProviderSessionId(normalizedType, args) {
|
|
|
32043
31998
|
}
|
|
32044
31999
|
const explicitSessionId = readArgValue(args, ["--session-id"]);
|
|
32045
32000
|
if (explicitSessionId) {
|
|
32046
|
-
if (
|
|
32001
|
+
if (resume?.sessionIdIsNewByDefault && !hasArg(args, ["--resume", "-r"])) {
|
|
32047
32002
|
return { launchMode: "manual" };
|
|
32048
32003
|
}
|
|
32049
|
-
const isResume =
|
|
32004
|
+
const isResume = resume?.sessionIdIsNewByDefault ? hasArg(args, ["--resume", "-r"]) : hasArg(args, ["--continue"]) || hasArg(args, ["--resume", "-r"]);
|
|
32050
32005
|
return {
|
|
32051
32006
|
providerSessionId: explicitSessionId,
|
|
32052
32007
|
launchMode: isResume ? "resume" : "new"
|
|
32053
32008
|
};
|
|
32054
32009
|
}
|
|
32055
|
-
|
|
32056
|
-
|
|
32057
|
-
|
|
32058
|
-
|
|
32010
|
+
const subcommands = resume?.sessionIdFromSubcommand;
|
|
32011
|
+
if (Array.isArray(subcommands) && subcommands.length > 0) {
|
|
32012
|
+
const subcommandSessionId = readSubcommandSessionId(args, subcommands);
|
|
32013
|
+
if (subcommandSessionId) {
|
|
32014
|
+
return { providerSessionId: subcommandSessionId, launchMode: "resume" };
|
|
32059
32015
|
}
|
|
32060
32016
|
}
|
|
32061
32017
|
return { launchMode: "manual" };
|
|
@@ -32072,7 +32028,7 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
|
|
|
32072
32028
|
if (!resume?.supported) {
|
|
32073
32029
|
return { cliArgs: baseArgs, launchMode: "manual" };
|
|
32074
32030
|
}
|
|
32075
|
-
const explicit = detectExplicitProviderSessionId(
|
|
32031
|
+
const explicit = detectExplicitProviderSessionId(provider, baseArgs || []);
|
|
32076
32032
|
if (explicit.providerSessionId) {
|
|
32077
32033
|
return {
|
|
32078
32034
|
cliArgs: baseArgs,
|
|
@@ -32080,6 +32036,12 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
|
|
|
32080
32036
|
launchMode: explicit.launchMode
|
|
32081
32037
|
};
|
|
32082
32038
|
}
|
|
32039
|
+
if (explicit.launchMode === "manual" && hasArg(baseArgs || [], ["--session-id"])) {
|
|
32040
|
+
return {
|
|
32041
|
+
cliArgs: baseArgs,
|
|
32042
|
+
launchMode: "manual"
|
|
32043
|
+
};
|
|
32044
|
+
}
|
|
32083
32045
|
if (requestedResumeSessionId) {
|
|
32084
32046
|
if (resume.sessionIdFormat === "uuid" && !isUuid(requestedResumeSessionId)) {
|
|
32085
32047
|
throw new Error(`Invalid ${provider?.displayName || provider?.name || normalizedType} session ID: ${requestedResumeSessionId}`);
|
|
@@ -34682,6 +34644,11 @@ var init_provider_schema = __esm({
|
|
|
34682
34644
|
"resume",
|
|
34683
34645
|
"sessionProbe",
|
|
34684
34646
|
"approvalPositiveHints",
|
|
34647
|
+
"sessionIdPattern",
|
|
34648
|
+
"historyBehavior",
|
|
34649
|
+
"canonicalHistory",
|
|
34650
|
+
"autoFixProfile",
|
|
34651
|
+
"ideLevelScripts",
|
|
34685
34652
|
"scripts",
|
|
34686
34653
|
"vscodeCommands",
|
|
34687
34654
|
"inputMethod",
|
|
@@ -42033,20 +42000,13 @@ function tryKillAutoImplProcess(processRef, signal) {
|
|
|
42033
42000
|
} catch {
|
|
42034
42001
|
}
|
|
42035
42002
|
}
|
|
42003
|
+
function shouldScheduleAutoStopOnQuiet(options) {
|
|
42004
|
+
return !!options.verification && options.autoImpl?.autoStopOnQuiet === true;
|
|
42005
|
+
}
|
|
42036
42006
|
function getDefaultAutoImplReference(ctx, category, type) {
|
|
42037
|
-
|
|
42038
|
-
|
|
42039
|
-
|
|
42040
|
-
if (category === "extension") {
|
|
42041
|
-
const preferred = ["claude-code-vscode", "codex", "cline", "roo-code"];
|
|
42042
|
-
for (const ref of preferred) {
|
|
42043
|
-
if (ref === type) continue;
|
|
42044
|
-
if (ctx.providerLoader.resolve(ref) || ctx.providerLoader.getMeta(ref)) return ref;
|
|
42045
|
-
}
|
|
42046
|
-
const all = ctx.providerLoader.getAll();
|
|
42047
|
-
const fb = all.find((p) => p.category === "extension" && p.type !== type);
|
|
42048
|
-
if (fb?.type) return fb.type;
|
|
42049
|
-
}
|
|
42007
|
+
const all = ctx.providerLoader.getAll();
|
|
42008
|
+
const sameCategoryOther = all.find((p) => p.category === category && p.type !== type);
|
|
42009
|
+
if (sameCategoryOther?.type) return sameCategoryOther.type;
|
|
42050
42010
|
return "antigravity";
|
|
42051
42011
|
}
|
|
42052
42012
|
function resolveAutoImplReference(ctx, category, requestedReference, targetType) {
|
|
@@ -42364,37 +42324,33 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
42364
42324
|
return;
|
|
42365
42325
|
}
|
|
42366
42326
|
const command = spawn6.command;
|
|
42327
|
+
const autoImpl = spawn6.autoImpl;
|
|
42367
42328
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
42368
42329
|
const baseArgs = [...spawn6.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
42369
42330
|
let shellCmd;
|
|
42370
42331
|
const isWin = os21.platform() === "win32";
|
|
42371
42332
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
42372
|
-
|
|
42373
|
-
|
|
42333
|
+
const promptMode = autoImpl?.promptMode ?? "stdin";
|
|
42334
|
+
const extraArgs = autoImpl?.extraArgs ?? [];
|
|
42335
|
+
const rawMetaPrompt = autoImpl?.metaPrompt ? autoImpl.metaPrompt.replace("{{promptFile}}", promptFile) : `Read the file at ${promptFile} and follow ALL the instructions in it exactly. Do not ask questions, just execute.`;
|
|
42336
|
+
if (promptMode === "flag") {
|
|
42337
|
+
const flag = autoImpl?.promptFlag ?? "-p";
|
|
42338
|
+
const args = [...baseArgs, ...extraArgs];
|
|
42374
42339
|
if (model) args.push("--model", model);
|
|
42375
42340
|
const escapedArgs = args.map(escapeArg).join(" ");
|
|
42376
|
-
|
|
42377
|
-
|
|
42378
|
-
|
|
42379
|
-
const args = [...baseArgs
|
|
42380
|
-
|
|
42381
|
-
|
|
42382
|
-
const metaPrompt = `Read the file at ${promptFile} and follow ALL the instructions in it exactly. Do not ask questions, just execute.`;
|
|
42383
|
-
shellCmd = `${command} ${escapedArgs} -p ${escapeArg(metaPrompt)}`;
|
|
42384
|
-
} else if (command === "codex") {
|
|
42385
|
-
const args = ["exec", ...baseArgs];
|
|
42386
|
-
if (!args.includes("--dangerously-bypass-approvals-and-sandbox")) {
|
|
42387
|
-
args.push("--dangerously-bypass-approvals-and-sandbox");
|
|
42388
|
-
}
|
|
42389
|
-
if (!args.includes("--skip-git-repo-check")) {
|
|
42390
|
-
args.push("--skip-git-repo-check");
|
|
42341
|
+
shellCmd = `${command} ${escapedArgs} ${flag} ${escapeArg(rawMetaPrompt)}`;
|
|
42342
|
+
} else if (promptMode === "subcommand") {
|
|
42343
|
+
const subcommand = autoImpl?.subcommand ?? "";
|
|
42344
|
+
const args = subcommand ? [subcommand, ...baseArgs] : [...baseArgs];
|
|
42345
|
+
for (const extra of extraArgs) {
|
|
42346
|
+
if (!args.includes(extra)) args.push(extra);
|
|
42391
42347
|
}
|
|
42392
42348
|
if (model) args.push("--model", model);
|
|
42393
42349
|
const escapedArgs = args.map(escapeArg).join(" ");
|
|
42394
|
-
|
|
42395
|
-
shellCmd = `${command} ${escapedArgs} ${escapeArg(metaPrompt)}`;
|
|
42350
|
+
shellCmd = `${command} ${escapedArgs} ${escapeArg(rawMetaPrompt)}`;
|
|
42396
42351
|
} else {
|
|
42397
|
-
const
|
|
42352
|
+
const args = [...baseArgs, ...extraArgs];
|
|
42353
|
+
const escapedArgs = args.map(escapeArg).join(" ");
|
|
42398
42354
|
if (isWin) {
|
|
42399
42355
|
shellCmd = `type "${promptFile}" | ${command} ${escapedArgs}`;
|
|
42400
42356
|
} else {
|
|
@@ -42429,8 +42385,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
42429
42385
|
stdio: ["pipe", "pipe", "pipe"],
|
|
42430
42386
|
env: {
|
|
42431
42387
|
...process.env,
|
|
42432
|
-
...spawn6.env || {}
|
|
42433
|
-
...command === "gemini" ? { SANDBOX: "1", GEMINI_CLI_NO_RELAUNCH: "1" } : {}
|
|
42388
|
+
...spawn6.env || {}
|
|
42434
42389
|
}
|
|
42435
42390
|
});
|
|
42436
42391
|
child.on("error", (err2) => {
|
|
@@ -42492,7 +42447,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
42492
42447
|
}
|
|
42493
42448
|
};
|
|
42494
42449
|
const scheduleAutoStopForVerification = () => {
|
|
42495
|
-
if (!verification
|
|
42450
|
+
if (!shouldScheduleAutoStopOnQuiet({ verification, autoImpl }) || completionSignalSeen || autoStopIssued) return;
|
|
42496
42451
|
const elapsed = Date.now() - spawnedAt;
|
|
42497
42452
|
if (elapsed < 3e4) return;
|
|
42498
42453
|
clearAutoStopTimer();
|
|
@@ -55455,7 +55410,7 @@ var init_adhdev_daemon = __esm({
|
|
|
55455
55410
|
init_version();
|
|
55456
55411
|
init_src();
|
|
55457
55412
|
init_runtime_defaults();
|
|
55458
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.
|
|
55413
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.5" });
|
|
55459
55414
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
55460
55415
|
localHttpServer = null;
|
|
55461
55416
|
localWss = null;
|