localclawd 2.2.6 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +855 -572
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -87646,7 +87646,7 @@ var init_isEqual = __esm(() => {
|
|
|
87646
87646
|
|
|
87647
87647
|
// src/utils/userAgent.ts
|
|
87648
87648
|
function getClaudeCodeUserAgent() {
|
|
87649
|
-
return `claude-code/${"2.
|
|
87649
|
+
return `claude-code/${"2.3.1"}`;
|
|
87650
87650
|
}
|
|
87651
87651
|
|
|
87652
87652
|
// src/utils/workloadContext.ts
|
|
@@ -87668,7 +87668,7 @@ function getUserAgent() {
|
|
|
87668
87668
|
const clientApp = process.env.CLAUDE_AGENT_SDK_CLIENT_APP ? `, client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}` : "";
|
|
87669
87669
|
const workload = getWorkload();
|
|
87670
87670
|
const workloadSuffix = workload ? `, workload/${workload}` : "";
|
|
87671
|
-
return `claude-cli/${"2.
|
|
87671
|
+
return `claude-cli/${"2.3.1"} (${process.env.USER_TYPE}, ${process.env.CLAUDE_CODE_ENTRYPOINT ?? "cli"}${agentSdkVersion}${clientApp}${workloadSuffix})`;
|
|
87672
87672
|
}
|
|
87673
87673
|
function getMCPUserAgent() {
|
|
87674
87674
|
const parts = [];
|
|
@@ -87682,7 +87682,7 @@ function getMCPUserAgent() {
|
|
|
87682
87682
|
parts.push(`client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`);
|
|
87683
87683
|
}
|
|
87684
87684
|
const suffix = parts.length > 0 ? ` (${parts.join(", ")})` : "";
|
|
87685
|
-
return `claude-code/${"2.
|
|
87685
|
+
return `claude-code/${"2.3.1"}${suffix}`;
|
|
87686
87686
|
}
|
|
87687
87687
|
function getWebFetchUserAgent() {
|
|
87688
87688
|
return `Claude-User (${getClaudeCodeUserAgent()}; +https://support.anthropic.com/)`;
|
|
@@ -130780,7 +130780,7 @@ function getAttributionHeader(fingerprint) {
|
|
|
130780
130780
|
if (!isAttributionHeaderEnabled()) {
|
|
130781
130781
|
return "";
|
|
130782
130782
|
}
|
|
130783
|
-
const version = `${"2.
|
|
130783
|
+
const version = `${"2.3.1"}.${fingerprint}`;
|
|
130784
130784
|
const entrypoint = process.env.CLAUDE_CODE_ENTRYPOINT ?? "unknown";
|
|
130785
130785
|
const cch = "";
|
|
130786
130786
|
const workload = getWorkload();
|
|
@@ -146967,7 +146967,7 @@ var init_metadata = __esm(() => {
|
|
|
146967
146967
|
COMPOUND_OPERATOR_REGEX = /\s*(?:&&|\|\||[;|])\s*/;
|
|
146968
146968
|
WHITESPACE_REGEX = /\s+/;
|
|
146969
146969
|
getVersionBase = memoize_default(() => {
|
|
146970
|
-
const match = "2.
|
|
146970
|
+
const match = "2.3.1".match(/^\d+\.\d+\.\d+(?:-[a-z]+)?/);
|
|
146971
146971
|
return match ? match[0] : undefined;
|
|
146972
146972
|
});
|
|
146973
146973
|
buildEnvContext = memoize_default(async () => {
|
|
@@ -147007,9 +147007,9 @@ var init_metadata = __esm(() => {
|
|
|
147007
147007
|
isGithubAction: isEnvTruthy(process.env.GITHUB_ACTIONS),
|
|
147008
147008
|
isClaudeCodeAction: isEnvTruthy(process.env.CLAUDE_CODE_ACTION),
|
|
147009
147009
|
isClaudeAiAuth: isClaudeAISubscriber(),
|
|
147010
|
-
version: "2.
|
|
147010
|
+
version: "2.3.1",
|
|
147011
147011
|
versionBase: getVersionBase(),
|
|
147012
|
-
buildTime: "2026-05-
|
|
147012
|
+
buildTime: "2026-05-10T18:34:55.265Z",
|
|
147013
147013
|
deploymentEnvironment: env3.detectDeploymentEnvironment(),
|
|
147014
147014
|
...isEnvTruthy(process.env.GITHUB_ACTIONS) && {
|
|
147015
147015
|
githubEventName: process.env.GITHUB_EVENT_NAME,
|
|
@@ -172830,6 +172830,80 @@ ${text}`);
|
|
|
172830
172830
|
|
|
172831
172831
|
` + full.slice(full.length - maxChars);
|
|
172832
172832
|
}
|
|
172833
|
+
async function tryDirectLocalCompact({
|
|
172834
|
+
messages,
|
|
172835
|
+
summaryRequest,
|
|
172836
|
+
context: context4,
|
|
172837
|
+
preCompactTokenCount
|
|
172838
|
+
}) {
|
|
172839
|
+
const baseUrl = getLocalLLMBaseUrl();
|
|
172840
|
+
const model = getLocalLLMModel() ?? context4.options.mainLoopModel;
|
|
172841
|
+
const apiKey = getLocalLLMApiKey();
|
|
172842
|
+
if (!baseUrl || !model)
|
|
172843
|
+
return null;
|
|
172844
|
+
const contextTokens = getContextWindowForModel(model, []);
|
|
172845
|
+
const charBudget = Math.max(4000, Math.floor(contextTokens * 0.5 * 3.5));
|
|
172846
|
+
const serialized = serializeMessagesForCleanRoom(messages, charBudget);
|
|
172847
|
+
if (!serialized.trim())
|
|
172848
|
+
return null;
|
|
172849
|
+
const promptContent = summaryRequest.message.content;
|
|
172850
|
+
const compactPromptText = typeof promptContent === "string" ? promptContent : Array.isArray(promptContent) ? promptContent.filter((b3) => b3.type === "text").map((b3) => b3.text).join(`
|
|
172851
|
+
`) : "";
|
|
172852
|
+
const userText = `<conversation>
|
|
172853
|
+
${serialized}
|
|
172854
|
+
</conversation>
|
|
172855
|
+
|
|
172856
|
+
${compactPromptText}`;
|
|
172857
|
+
const timeoutMs = parseInt(process.env.COMPACT_TIMEOUT_MS || "", 10) || 5 * 60000;
|
|
172858
|
+
const timeoutController = new AbortController;
|
|
172859
|
+
const timer = setTimeout(() => timeoutController.abort(new Error("compact timeout")), timeoutMs);
|
|
172860
|
+
const onAbort = () => timeoutController.abort(context4.abortController.signal.reason);
|
|
172861
|
+
context4.abortController.signal.addEventListener("abort", onAbort, { once: true });
|
|
172862
|
+
try {
|
|
172863
|
+
const url2 = `${baseUrl.replace(/\/$/, "")}/chat/completions`;
|
|
172864
|
+
const res = await fetch(url2, {
|
|
172865
|
+
method: "POST",
|
|
172866
|
+
headers: {
|
|
172867
|
+
"Content-Type": "application/json",
|
|
172868
|
+
...apiKey ? { Authorization: `Bearer ${apiKey}` } : {}
|
|
172869
|
+
},
|
|
172870
|
+
body: JSON.stringify({
|
|
172871
|
+
model,
|
|
172872
|
+
messages: [
|
|
172873
|
+
{ role: "system", content: "You are a helpful assistant that summarizes conversations." },
|
|
172874
|
+
{ role: "user", content: userText }
|
|
172875
|
+
],
|
|
172876
|
+
max_tokens: COMPACT_MAX_OUTPUT_TOKENS,
|
|
172877
|
+
temperature: 0.2,
|
|
172878
|
+
stream: false
|
|
172879
|
+
}),
|
|
172880
|
+
signal: timeoutController.signal
|
|
172881
|
+
});
|
|
172882
|
+
if (!res.ok) {
|
|
172883
|
+
logForDebugging(`compact direct-local: HTTP ${res.status}`, { level: "warn" });
|
|
172884
|
+
return null;
|
|
172885
|
+
}
|
|
172886
|
+
const data = await res.json();
|
|
172887
|
+
const text = data.choices?.[0]?.message?.content?.trim();
|
|
172888
|
+
if (!text)
|
|
172889
|
+
return null;
|
|
172890
|
+
logForDebugging(`compact direct-local: success (pre=${preCompactTokenCount} out=${data.usage?.completion_tokens ?? 0})`);
|
|
172891
|
+
const usage = {
|
|
172892
|
+
input_tokens: data.usage?.prompt_tokens ?? 0,
|
|
172893
|
+
output_tokens: data.usage?.completion_tokens ?? 0,
|
|
172894
|
+
cache_creation_input_tokens: 0,
|
|
172895
|
+
cache_read_input_tokens: 0
|
|
172896
|
+
};
|
|
172897
|
+
return createAssistantMessage({ content: text, usage });
|
|
172898
|
+
} catch (e) {
|
|
172899
|
+
const reason = e?.name === "AbortError" ? "aborted/timeout" : String(e);
|
|
172900
|
+
logForDebugging(`compact direct-local: ${reason}`, { level: "warn" });
|
|
172901
|
+
return null;
|
|
172902
|
+
} finally {
|
|
172903
|
+
clearTimeout(timer);
|
|
172904
|
+
context4.abortController.signal.removeEventListener("abort", onAbort);
|
|
172905
|
+
}
|
|
172906
|
+
}
|
|
172833
172907
|
async function tryCleanRoomCompactSummary({
|
|
172834
172908
|
messages,
|
|
172835
172909
|
summaryRequest,
|
|
@@ -172910,6 +172984,18 @@ async function streamCompactSummary({
|
|
|
172910
172984
|
statusSetter?.("compacting");
|
|
172911
172985
|
}, 30000, context4.setSDKStatus) : undefined;
|
|
172912
172986
|
try {
|
|
172987
|
+
const directResp = await tryDirectLocalCompact({
|
|
172988
|
+
messages,
|
|
172989
|
+
summaryRequest,
|
|
172990
|
+
context: context4,
|
|
172991
|
+
preCompactTokenCount
|
|
172992
|
+
});
|
|
172993
|
+
if (directResp) {
|
|
172994
|
+
const directText = getAssistantMessageText(directResp);
|
|
172995
|
+
if (directText && !directResp.isApiErrorMessage && !directText.startsWith(PROMPT_TOO_LONG_ERROR_MESSAGE)) {
|
|
172996
|
+
return directResp;
|
|
172997
|
+
}
|
|
172998
|
+
}
|
|
172913
172999
|
const cleanRoomFirst = await tryCleanRoomCompactSummary({
|
|
172914
173000
|
messages,
|
|
172915
173001
|
summaryRequest,
|
|
@@ -173218,6 +173304,7 @@ var init_compact = __esm(() => {
|
|
|
173218
173304
|
init_forkedAgent();
|
|
173219
173305
|
init_hooks5();
|
|
173220
173306
|
init_log2();
|
|
173307
|
+
init_providers();
|
|
173221
173308
|
init_types4();
|
|
173222
173309
|
init_messages3();
|
|
173223
173310
|
init_path2();
|
|
@@ -179551,7 +179638,7 @@ function getTelemetryAttributes() {
|
|
|
179551
179638
|
attributes["session.id"] = sessionId;
|
|
179552
179639
|
}
|
|
179553
179640
|
if (shouldIncludeAttribute("OTEL_METRICS_INCLUDE_VERSION")) {
|
|
179554
|
-
attributes["app.version"] = "2.
|
|
179641
|
+
attributes["app.version"] = "2.3.1";
|
|
179555
179642
|
}
|
|
179556
179643
|
const oauthAccount = getOauthAccountInfo();
|
|
179557
179644
|
if (oauthAccount) {
|
|
@@ -241839,7 +241926,7 @@ function getInstallationEnv() {
|
|
|
241839
241926
|
return;
|
|
241840
241927
|
}
|
|
241841
241928
|
function getClaudeCodeVersion() {
|
|
241842
|
-
return "2.
|
|
241929
|
+
return "2.3.1";
|
|
241843
241930
|
}
|
|
241844
241931
|
async function getInstalledVSCodeExtensionVersion(command) {
|
|
241845
241932
|
const { stdout } = await execFileNoThrow(command, ["--list-extensions", "--show-versions"], {
|
|
@@ -247113,7 +247200,7 @@ async function setupSdkMcpClients(sdkMcpConfigs, sendMcpMessage) {
|
|
|
247113
247200
|
const client4 = new Client({
|
|
247114
247201
|
name: "localclawd",
|
|
247115
247202
|
title: "localclawd",
|
|
247116
|
-
version: "2.
|
|
247203
|
+
version: "2.3.1",
|
|
247117
247204
|
description: "local-first AI coding tool",
|
|
247118
247205
|
websiteUrl: PRODUCT_URL
|
|
247119
247206
|
}, {
|
|
@@ -247455,7 +247542,7 @@ var init_client9 = __esm(() => {
|
|
|
247455
247542
|
const client4 = new Client({
|
|
247456
247543
|
name: "localclawd",
|
|
247457
247544
|
title: "localclawd",
|
|
247458
|
-
version: "2.
|
|
247545
|
+
version: "2.3.1",
|
|
247459
247546
|
description: "local-first AI coding tool",
|
|
247460
247547
|
websiteUrl: PRODUCT_URL
|
|
247461
247548
|
}, {
|
|
@@ -261854,7 +261941,7 @@ function computeFingerprint(messageText, version) {
|
|
|
261854
261941
|
}
|
|
261855
261942
|
function computeFingerprintFromMessages(messages) {
|
|
261856
261943
|
const firstMessageText = extractFirstMessageText(messages);
|
|
261857
|
-
return computeFingerprint(firstMessageText, "2.
|
|
261944
|
+
return computeFingerprint(firstMessageText, "2.3.1");
|
|
261858
261945
|
}
|
|
261859
261946
|
var FINGERPRINT_SALT = "59cf53e54c78";
|
|
261860
261947
|
var init_fingerprint = () => {};
|
|
@@ -261896,7 +261983,7 @@ async function sideQuery(opts) {
|
|
|
261896
261983
|
betas.push(STRUCTURED_OUTPUTS_BETA_HEADER);
|
|
261897
261984
|
}
|
|
261898
261985
|
const messageText = extractFirstUserMessageText(messages);
|
|
261899
|
-
const fingerprint = computeFingerprint(messageText, "2.
|
|
261986
|
+
const fingerprint = computeFingerprint(messageText, "2.3.1");
|
|
261900
261987
|
const attributionHeader = getAttributionHeader(fingerprint);
|
|
261901
261988
|
const systemBlocks = [
|
|
261902
261989
|
attributionHeader ? { type: "text", text: attributionHeader } : null,
|
|
@@ -282648,7 +282735,7 @@ var init_user = __esm(() => {
|
|
|
282648
282735
|
deviceId,
|
|
282649
282736
|
sessionId: getSessionId(),
|
|
282650
282737
|
email: getEmail(),
|
|
282651
|
-
appVersion: "2.
|
|
282738
|
+
appVersion: "2.3.1",
|
|
282652
282739
|
platform: getHostPlatformForAnalytics(),
|
|
282653
282740
|
organizationUuid,
|
|
282654
282741
|
accountUuid,
|
|
@@ -283713,7 +283800,7 @@ async function initializeBetaTracing(resource) {
|
|
|
283713
283800
|
});
|
|
283714
283801
|
logs.setGlobalLoggerProvider(loggerProvider);
|
|
283715
283802
|
setLoggerProvider(loggerProvider);
|
|
283716
|
-
const eventLogger = logs.getLogger("com.anthropic.claude_code.events", "2.
|
|
283803
|
+
const eventLogger = logs.getLogger("com.anthropic.claude_code.events", "2.3.1");
|
|
283717
283804
|
setEventLogger(eventLogger);
|
|
283718
283805
|
process.on("beforeExit", async () => {
|
|
283719
283806
|
await loggerProvider?.forceFlush();
|
|
@@ -283753,7 +283840,7 @@ async function initializeTelemetry() {
|
|
|
283753
283840
|
const platform2 = getPlatform();
|
|
283754
283841
|
const baseAttributes = {
|
|
283755
283842
|
[ATTR_SERVICE_NAME4]: "claude-code",
|
|
283756
|
-
[ATTR_SERVICE_VERSION4]: "2.
|
|
283843
|
+
[ATTR_SERVICE_VERSION4]: "2.3.1"
|
|
283757
283844
|
};
|
|
283758
283845
|
if (platform2 === "wsl") {
|
|
283759
283846
|
const wslVersion = getWslVersion();
|
|
@@ -283798,7 +283885,7 @@ async function initializeTelemetry() {
|
|
|
283798
283885
|
} catch {}
|
|
283799
283886
|
};
|
|
283800
283887
|
registerCleanup(shutdownTelemetry2);
|
|
283801
|
-
return meterProvider2.getMeter("com.anthropic.claude_code", "2.
|
|
283888
|
+
return meterProvider2.getMeter("com.anthropic.claude_code", "2.3.1");
|
|
283802
283889
|
}
|
|
283803
283890
|
const meterProvider = new MeterProvider4({
|
|
283804
283891
|
resource,
|
|
@@ -283818,7 +283905,7 @@ async function initializeTelemetry() {
|
|
|
283818
283905
|
});
|
|
283819
283906
|
logs.setGlobalLoggerProvider(loggerProvider);
|
|
283820
283907
|
setLoggerProvider(loggerProvider);
|
|
283821
|
-
const eventLogger = logs.getLogger("com.anthropic.claude_code.events", "2.
|
|
283908
|
+
const eventLogger = logs.getLogger("com.anthropic.claude_code.events", "2.3.1");
|
|
283822
283909
|
setEventLogger(eventLogger);
|
|
283823
283910
|
logForDebugging("[3P telemetry] Event logger set successfully");
|
|
283824
283911
|
process.on("beforeExit", async () => {
|
|
@@ -283880,7 +283967,7 @@ Current timeout: ${timeoutMs}ms
|
|
|
283880
283967
|
}
|
|
283881
283968
|
};
|
|
283882
283969
|
registerCleanup(shutdownTelemetry);
|
|
283883
|
-
return meterProvider.getMeter("com.anthropic.claude_code", "2.
|
|
283970
|
+
return meterProvider.getMeter("com.anthropic.claude_code", "2.3.1");
|
|
283884
283971
|
}
|
|
283885
283972
|
async function flushTelemetry() {
|
|
283886
283973
|
const meterProvider = getMeterProvider();
|
|
@@ -285070,7 +285157,7 @@ function detectLinuxGlobPatternWarnings() {
|
|
|
285070
285157
|
}
|
|
285071
285158
|
async function getDoctorDiagnostic() {
|
|
285072
285159
|
const installationType = await getCurrentInstallationType();
|
|
285073
|
-
const version = typeof MACRO !== "undefined" ? "2.
|
|
285160
|
+
const version = typeof MACRO !== "undefined" ? "2.3.1" : "unknown";
|
|
285074
285161
|
const installationPath = await getInstallationPath();
|
|
285075
285162
|
const invokedBinary = getInvokedBinary();
|
|
285076
285163
|
const multipleInstallations = await detectMultipleInstallations();
|
|
@@ -286011,8 +286098,8 @@ async function updateLatest(channelOrVersion, forceReinstall = false) {
|
|
|
286011
286098
|
const maxVersion = await getMaxVersion();
|
|
286012
286099
|
if (maxVersion && gt(version, maxVersion)) {
|
|
286013
286100
|
logForDebugging(`Native installer: maxVersion ${maxVersion} is set, capping update from ${version} to ${maxVersion}`);
|
|
286014
|
-
if (gte("2.
|
|
286015
|
-
logForDebugging(`Native installer: current version ${"2.
|
|
286101
|
+
if (gte("2.3.1", maxVersion)) {
|
|
286102
|
+
logForDebugging(`Native installer: current version ${"2.3.1"} is already at or above maxVersion ${maxVersion}, skipping update`);
|
|
286016
286103
|
logEvent("tengu_native_update_skipped_max_version", {
|
|
286017
286104
|
latency_ms: Date.now() - startTime,
|
|
286018
286105
|
max_version: maxVersion,
|
|
@@ -286023,7 +286110,7 @@ async function updateLatest(channelOrVersion, forceReinstall = false) {
|
|
|
286023
286110
|
version = maxVersion;
|
|
286024
286111
|
}
|
|
286025
286112
|
}
|
|
286026
|
-
if (!forceReinstall && version === "2.
|
|
286113
|
+
if (!forceReinstall && version === "2.3.1" && await versionIsAvailable(version) && await isPossibleLocalClawdBinary(executablePath)) {
|
|
286027
286114
|
logForDebugging(`Found ${version} at ${executablePath}, skipping install`);
|
|
286028
286115
|
logEvent("tengu_native_update_complete", {
|
|
286029
286116
|
latency_ms: Date.now() - startTime,
|
|
@@ -332298,7 +332385,7 @@ function getAnthropicEnvMetadata() {
|
|
|
332298
332385
|
function getBuildAgeMinutes() {
|
|
332299
332386
|
if (false)
|
|
332300
332387
|
;
|
|
332301
|
-
const buildTime = new Date("2026-05-
|
|
332388
|
+
const buildTime = new Date("2026-05-10T18:34:55.265Z").getTime();
|
|
332302
332389
|
if (isNaN(buildTime))
|
|
332303
332390
|
return;
|
|
332304
332391
|
return Math.floor((Date.now() - buildTime) / 60000);
|
|
@@ -360327,7 +360414,7 @@ function Feedback({
|
|
|
360327
360414
|
platform: env3.platform,
|
|
360328
360415
|
gitRepo: envInfo.isGit,
|
|
360329
360416
|
terminal: env3.terminal,
|
|
360330
|
-
version: "2.
|
|
360417
|
+
version: "2.3.1",
|
|
360331
360418
|
transcript: normalizeMessagesForAPI(messages),
|
|
360332
360419
|
errors: sanitizedErrors,
|
|
360333
360420
|
lastApiRequest: getLastAPIRequest(),
|
|
@@ -360519,7 +360606,7 @@ function Feedback({
|
|
|
360519
360606
|
", ",
|
|
360520
360607
|
env3.terminal,
|
|
360521
360608
|
", v",
|
|
360522
|
-
"2.
|
|
360609
|
+
"2.3.1"
|
|
360523
360610
|
]
|
|
360524
360611
|
}, undefined, true, undefined, this)
|
|
360525
360612
|
]
|
|
@@ -360625,7 +360712,7 @@ ${sanitizedDescription}
|
|
|
360625
360712
|
` + `**Environment Info**
|
|
360626
360713
|
` + `- Platform: ${env3.platform}
|
|
360627
360714
|
` + `- Terminal: ${env3.terminal}
|
|
360628
|
-
` + `- Version: ${"2.
|
|
360715
|
+
` + `- Version: ${"2.3.1"}
|
|
360629
360716
|
` + `- Feedback ID: ${feedbackId}
|
|
360630
360717
|
` + `
|
|
360631
360718
|
**Errors**
|
|
@@ -363234,7 +363321,7 @@ function buildPrimarySection() {
|
|
|
363234
363321
|
}, undefined, false, undefined, this);
|
|
363235
363322
|
return [{
|
|
363236
363323
|
label: "Version",
|
|
363237
|
-
value: "2.
|
|
363324
|
+
value: "2.3.1"
|
|
363238
363325
|
}, {
|
|
363239
363326
|
label: "Session name",
|
|
363240
363327
|
value: nameValue
|
|
@@ -367915,7 +368002,7 @@ function Config({
|
|
|
367915
368002
|
}
|
|
367916
368003
|
}, undefined, false, undefined, this)
|
|
367917
368004
|
}, undefined, false, undefined, this) : showSubmenu === "ChannelDowngrade" ? /* @__PURE__ */ jsx_dev_runtime176.jsxDEV(ChannelDowngradeDialog, {
|
|
367918
|
-
currentVersion: "2.
|
|
368005
|
+
currentVersion: "2.3.1",
|
|
367919
368006
|
onChoice: (choice) => {
|
|
367920
368007
|
setShowSubmenu(null);
|
|
367921
368008
|
setTabsHidden(false);
|
|
@@ -367927,7 +368014,7 @@ function Config({
|
|
|
367927
368014
|
autoUpdatesChannel: "stable"
|
|
367928
368015
|
};
|
|
367929
368016
|
if (choice === "stay") {
|
|
367930
|
-
newSettings.minimumVersion = "2.
|
|
368017
|
+
newSettings.minimumVersion = "2.3.1";
|
|
367931
368018
|
}
|
|
367932
368019
|
updateSettingsForSource("userSettings", newSettings);
|
|
367933
368020
|
setSettingsData((prev_27) => ({
|
|
@@ -375163,6 +375250,172 @@ var init_telegramKill = __esm(() => {
|
|
|
375163
375250
|
init_debug();
|
|
375164
375251
|
});
|
|
375165
375252
|
|
|
375253
|
+
// src/services/telegram/telegramAgent.ts
|
|
375254
|
+
var exports_telegramAgent = {};
|
|
375255
|
+
__export(exports_telegramAgent, {
|
|
375256
|
+
respondToTelegramMessage: () => respondToTelegramMessage,
|
|
375257
|
+
recordMainAgentActivity: () => recordMainAgentActivity,
|
|
375258
|
+
clearTelegramHistory: () => clearTelegramHistory
|
|
375259
|
+
});
|
|
375260
|
+
import { mkdir as mkdir37, readFile as readFile44, writeFile as writeFile39 } from "fs/promises";
|
|
375261
|
+
import { homedir as homedir25 } from "os";
|
|
375262
|
+
import { join as join116, dirname as dirname48 } from "path";
|
|
375263
|
+
function recordMainAgentActivity(line) {
|
|
375264
|
+
if (!line.trim())
|
|
375265
|
+
return;
|
|
375266
|
+
_activityLog.push(line.trim().slice(0, 200));
|
|
375267
|
+
if (_activityLog.length > 8)
|
|
375268
|
+
_activityLog = _activityLog.slice(-8);
|
|
375269
|
+
}
|
|
375270
|
+
async function loadHistory() {
|
|
375271
|
+
if (_historyLoaded)
|
|
375272
|
+
return;
|
|
375273
|
+
_historyLoaded = true;
|
|
375274
|
+
try {
|
|
375275
|
+
const raw = await readFile44(HISTORY_FILE, "utf-8");
|
|
375276
|
+
const parsed = JSON.parse(raw);
|
|
375277
|
+
if (Array.isArray(parsed))
|
|
375278
|
+
_history = parsed.slice(-HISTORY_LIMIT);
|
|
375279
|
+
} catch {}
|
|
375280
|
+
}
|
|
375281
|
+
async function persistHistory() {
|
|
375282
|
+
try {
|
|
375283
|
+
await mkdir37(dirname48(HISTORY_FILE), { recursive: true });
|
|
375284
|
+
await writeFile39(HISTORY_FILE, JSON.stringify(_history.slice(-HISTORY_LIMIT)), "utf-8");
|
|
375285
|
+
} catch (e) {
|
|
375286
|
+
logForDebugging(`[telegram-agent] persist history failed: ${e}`, { level: "warn" });
|
|
375287
|
+
}
|
|
375288
|
+
}
|
|
375289
|
+
function buildSystemPrompt() {
|
|
375290
|
+
const queueLen = getCommandQueueLength();
|
|
375291
|
+
const queueSnap = getCommandQueueSnapshot();
|
|
375292
|
+
const queuePreview = queueSnap.slice(0, 3).map((q2) => `- ${(q2.value ?? "").slice(0, 80)}`).join(`
|
|
375293
|
+
`) || " (none)";
|
|
375294
|
+
const recent = _activityLog.length > 0 ? _activityLog.slice(-5).join(`
|
|
375295
|
+
`) : "(no recent updates)";
|
|
375296
|
+
return [
|
|
375297
|
+
"You are the Telegram assistant for localclawd, a local-first coding agent.",
|
|
375298
|
+
"",
|
|
375299
|
+
"You are a SEPARATE agent from the MAIN agent. The MAIN agent runs in the user's",
|
|
375300
|
+
"terminal and does the actual coding. Your job is to chat with the user over Telegram",
|
|
375301
|
+
"and, when appropriate, forward instructions to the MAIN agent.",
|
|
375302
|
+
"",
|
|
375303
|
+
"Capabilities — decide which to use for THIS message:",
|
|
375304
|
+
" • reply: always required; brief, conversational, helpful",
|
|
375305
|
+
" • action=prompt: enqueue a NEW task for the main agent (it picks it up after current work)",
|
|
375306
|
+
" • action=steer: INTERRUPT the main agent with urgent new instructions (use sparingly)",
|
|
375307
|
+
" • action=none: just chat — questions, status checks, acknowledgements",
|
|
375308
|
+
"",
|
|
375309
|
+
"Rules:",
|
|
375310
|
+
" • Always reply to the user, even if you also enqueue/steer.",
|
|
375311
|
+
' • If the user asks "what are you working on" or "status", answer from the snapshot below.',
|
|
375312
|
+
" • If the user gives a coding task, default to action=prompt.",
|
|
375313
|
+
' • If the user says "stop", "wait", "actually do X instead", use action=steer.',
|
|
375314
|
+
" • If the user is just chatting / clarifying, action=none.",
|
|
375315
|
+
"",
|
|
375316
|
+
"Strict output format (no extra text outside these tags):",
|
|
375317
|
+
"<reply>",
|
|
375318
|
+
"your reply to the user — short, no markdown headers",
|
|
375319
|
+
"</reply>",
|
|
375320
|
+
'<action type="prompt|steer|none">',
|
|
375321
|
+
"exact instruction text for the main agent (omit body when type=none)",
|
|
375322
|
+
"</action>",
|
|
375323
|
+
"",
|
|
375324
|
+
"────── MAIN AGENT SNAPSHOT ──────",
|
|
375325
|
+
`Queued tasks: ${queueLen}`,
|
|
375326
|
+
queuePreview,
|
|
375327
|
+
"",
|
|
375328
|
+
"Recent activity:",
|
|
375329
|
+
recent,
|
|
375330
|
+
"─────────────────────────────────"
|
|
375331
|
+
].join(`
|
|
375332
|
+
`);
|
|
375333
|
+
}
|
|
375334
|
+
async function callLLM(systemPrompt, history) {
|
|
375335
|
+
try {
|
|
375336
|
+
const baseUrl = getLocalLLMBaseUrl();
|
|
375337
|
+
const model = getLocalLLMModel();
|
|
375338
|
+
const apiKey = getLocalLLMApiKey();
|
|
375339
|
+
if (!baseUrl || !model)
|
|
375340
|
+
return null;
|
|
375341
|
+
const messages = [
|
|
375342
|
+
{ role: "system", content: systemPrompt },
|
|
375343
|
+
...history.slice(-HISTORY_LIMIT)
|
|
375344
|
+
];
|
|
375345
|
+
const res = await fetch(`${baseUrl.replace(/\/$/, "")}/chat/completions`, {
|
|
375346
|
+
method: "POST",
|
|
375347
|
+
headers: {
|
|
375348
|
+
"Content-Type": "application/json",
|
|
375349
|
+
...apiKey ? { Authorization: `Bearer ${apiKey}` } : {}
|
|
375350
|
+
},
|
|
375351
|
+
body: JSON.stringify({
|
|
375352
|
+
model,
|
|
375353
|
+
messages,
|
|
375354
|
+
max_tokens: 500,
|
|
375355
|
+
temperature: 0.3
|
|
375356
|
+
}),
|
|
375357
|
+
signal: AbortSignal.timeout(60000)
|
|
375358
|
+
});
|
|
375359
|
+
if (!res.ok) {
|
|
375360
|
+
logForDebugging(`[telegram-agent] LLM HTTP ${res.status}`, { level: "warn" });
|
|
375361
|
+
return null;
|
|
375362
|
+
}
|
|
375363
|
+
const data = await res.json();
|
|
375364
|
+
return data.choices?.[0]?.message?.content ?? null;
|
|
375365
|
+
} catch (e) {
|
|
375366
|
+
logForDebugging(`[telegram-agent] LLM call failed: ${e}`, { level: "warn" });
|
|
375367
|
+
return null;
|
|
375368
|
+
}
|
|
375369
|
+
}
|
|
375370
|
+
function parseResponse(raw) {
|
|
375371
|
+
const replyMatch = raw.match(/<reply>([\s\S]*?)<\/reply>/i);
|
|
375372
|
+
const actionMatch = raw.match(/<action\s+type="(prompt|steer|none)"\s*>([\s\S]*?)<\/action>/i);
|
|
375373
|
+
const reply = (replyMatch?.[1] ?? raw).trim();
|
|
375374
|
+
const actionType = actionMatch?.[1] ?? "none";
|
|
375375
|
+
const actionText = (actionMatch?.[2] ?? "").trim();
|
|
375376
|
+
return { reply, actionType, actionText };
|
|
375377
|
+
}
|
|
375378
|
+
async function respondToTelegramMessage(userText) {
|
|
375379
|
+
await loadHistory();
|
|
375380
|
+
_history.push({ role: "user", content: userText });
|
|
375381
|
+
const systemPrompt = buildSystemPrompt();
|
|
375382
|
+
const raw = await callLLM(systemPrompt, _history);
|
|
375383
|
+
if (!raw) {
|
|
375384
|
+
const fallback = "I couldn't reach the model. Forwarding your message to the main agent.";
|
|
375385
|
+
_history.push({ role: "assistant", content: fallback });
|
|
375386
|
+
await persistHistory();
|
|
375387
|
+
enqueue({ value: userText, mode: "prompt", priority: "next" });
|
|
375388
|
+
return { reply: fallback, action: { type: "prompt", text: userText } };
|
|
375389
|
+
}
|
|
375390
|
+
const parsed = parseResponse(raw);
|
|
375391
|
+
_history.push({ role: "assistant", content: raw });
|
|
375392
|
+
if (_history.length > HISTORY_LIMIT)
|
|
375393
|
+
_history = _history.slice(-HISTORY_LIMIT);
|
|
375394
|
+
await persistHistory();
|
|
375395
|
+
if (parsed.actionType === "prompt" && parsed.actionText) {
|
|
375396
|
+
enqueue({ value: parsed.actionText, mode: "prompt", priority: "next" });
|
|
375397
|
+
} else if (parsed.actionType === "steer" && parsed.actionText) {
|
|
375398
|
+
enqueue({ value: parsed.actionText, mode: "prompt", priority: "now" });
|
|
375399
|
+
}
|
|
375400
|
+
return {
|
|
375401
|
+
reply: parsed.reply || "Got it.",
|
|
375402
|
+
action: { type: parsed.actionType, text: parsed.actionText }
|
|
375403
|
+
};
|
|
375404
|
+
}
|
|
375405
|
+
function clearTelegramHistory() {
|
|
375406
|
+
_history = [];
|
|
375407
|
+
persistHistory();
|
|
375408
|
+
}
|
|
375409
|
+
var HISTORY_LIMIT = 24, HISTORY_FILE, _history, _historyLoaded = false, _activityLog;
|
|
375410
|
+
var init_telegramAgent = __esm(() => {
|
|
375411
|
+
init_debug();
|
|
375412
|
+
init_providers();
|
|
375413
|
+
init_messageQueueManager();
|
|
375414
|
+
HISTORY_FILE = join116(homedir25(), ".claude", "telegram", "history.json");
|
|
375415
|
+
_history = [];
|
|
375416
|
+
_activityLog = [];
|
|
375417
|
+
});
|
|
375418
|
+
|
|
375166
375419
|
// src/services/director/directorMemory.ts
|
|
375167
375420
|
function createEmptyState() {
|
|
375168
375421
|
return {
|
|
@@ -375175,14 +375428,14 @@ function createEmptyState() {
|
|
|
375175
375428
|
}
|
|
375176
375429
|
|
|
375177
375430
|
// src/services/director/directorMemoryOps.ts
|
|
375178
|
-
import { mkdir as
|
|
375179
|
-
import { basename as basename36, join as
|
|
375431
|
+
import { mkdir as mkdir38, readdir as readdir24, readFile as readFile45, stat as stat39, writeFile as writeFile40 } from "fs/promises";
|
|
375432
|
+
import { basename as basename36, join as join117, resolve as resolve37 } from "path";
|
|
375180
375433
|
function setDirectorProjectRoot(projectPath) {
|
|
375181
|
-
_projectStateDir =
|
|
375434
|
+
_projectStateDir = join117(projectPath, ".localclawd");
|
|
375182
375435
|
}
|
|
375183
375436
|
function getStatePath() {
|
|
375184
375437
|
if (_projectStateDir)
|
|
375185
|
-
return
|
|
375438
|
+
return join117(_projectStateDir, "director-memory.json");
|
|
375186
375439
|
return null;
|
|
375187
375440
|
}
|
|
375188
375441
|
async function loadDirectorState() {
|
|
@@ -375190,7 +375443,7 @@ async function loadDirectorState() {
|
|
|
375190
375443
|
if (!path12)
|
|
375191
375444
|
return createEmptyState();
|
|
375192
375445
|
try {
|
|
375193
|
-
const raw = await
|
|
375446
|
+
const raw = await readFile45(path12, "utf-8");
|
|
375194
375447
|
const parsed = JSON.parse(raw);
|
|
375195
375448
|
if (parsed.version !== 1)
|
|
375196
375449
|
return createEmptyState();
|
|
@@ -375202,16 +375455,16 @@ async function loadDirectorState() {
|
|
|
375202
375455
|
async function saveDirectorState(state) {
|
|
375203
375456
|
if (!_projectStateDir)
|
|
375204
375457
|
return;
|
|
375205
|
-
await
|
|
375206
|
-
await
|
|
375458
|
+
await mkdir38(_projectStateDir, { recursive: true });
|
|
375459
|
+
await writeFile40(join117(_projectStateDir, "director-memory.json"), JSON.stringify(state, null, 2), "utf-8");
|
|
375207
375460
|
}
|
|
375208
375461
|
function slugify4(path12) {
|
|
375209
375462
|
return basename36(resolve37(path12)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
375210
375463
|
}
|
|
375211
375464
|
async function detectGitRemote(projectPath) {
|
|
375212
375465
|
try {
|
|
375213
|
-
const configPath =
|
|
375214
|
-
const config2 = await
|
|
375466
|
+
const configPath = join117(projectPath, ".git", "config");
|
|
375467
|
+
const config2 = await readFile45(configPath, "utf-8");
|
|
375215
375468
|
const match = config2.match(/\[remote "origin"\][^[]*url\s*=\s*(.+)/m);
|
|
375216
375469
|
return match?.[1]?.trim();
|
|
375217
375470
|
} catch {
|
|
@@ -375220,12 +375473,12 @@ async function detectGitRemote(projectPath) {
|
|
|
375220
375473
|
}
|
|
375221
375474
|
async function detectDescription(projectPath) {
|
|
375222
375475
|
try {
|
|
375223
|
-
const pkg = JSON.parse(await
|
|
375476
|
+
const pkg = JSON.parse(await readFile45(join117(projectPath, "package.json"), "utf-8"));
|
|
375224
375477
|
if (pkg.description)
|
|
375225
375478
|
return pkg.description;
|
|
375226
375479
|
} catch {}
|
|
375227
375480
|
try {
|
|
375228
|
-
const readme = await
|
|
375481
|
+
const readme = await readFile45(join117(projectPath, "README.md"), "utf-8");
|
|
375229
375482
|
const firstLine = readme.split(`
|
|
375230
375483
|
`).find((l) => l.trim() && !l.startsWith("#"));
|
|
375231
375484
|
if (firstLine)
|
|
@@ -375279,9 +375532,9 @@ async function indexProjectFiles(state, projectId, projectPath) {
|
|
|
375279
375532
|
const absPath = resolve37(projectPath);
|
|
375280
375533
|
for (const name of KEY_FILES) {
|
|
375281
375534
|
try {
|
|
375282
|
-
const filePath =
|
|
375535
|
+
const filePath = join117(absPath, name);
|
|
375283
375536
|
await stat39(filePath);
|
|
375284
|
-
const content = await
|
|
375537
|
+
const content = await readFile45(filePath, "utf-8");
|
|
375285
375538
|
const firstLine = content.split(`
|
|
375286
375539
|
`).find((l) => l.trim())?.trim() ?? name;
|
|
375287
375540
|
entries.push({
|
|
@@ -375294,7 +375547,7 @@ async function indexProjectFiles(state, projectId, projectPath) {
|
|
|
375294
375547
|
} catch {}
|
|
375295
375548
|
}
|
|
375296
375549
|
try {
|
|
375297
|
-
const srcDir =
|
|
375550
|
+
const srcDir = join117(absPath, "src");
|
|
375298
375551
|
const srcFiles = await readdir24(srcDir);
|
|
375299
375552
|
for (const file of srcFiles.slice(0, 30)) {
|
|
375300
375553
|
if (!file.endsWith(".ts") && !file.endsWith(".tsx") && !file.endsWith(".js") && !file.endsWith(".py") && !file.endsWith(".rs") && !file.endsWith(".go"))
|
|
@@ -375717,19 +375970,19 @@ async function initSlack() {
|
|
|
375717
375970
|
let userId = process.env.SLACK_USER_ID;
|
|
375718
375971
|
if (!token || !channelId) {
|
|
375719
375972
|
try {
|
|
375720
|
-
const { readFile:
|
|
375721
|
-
const { join:
|
|
375722
|
-
const { homedir:
|
|
375973
|
+
const { readFile: readFile46 } = await import("fs/promises");
|
|
375974
|
+
const { join: join118 } = await import("path");
|
|
375975
|
+
const { homedir: homedir26 } = await import("os");
|
|
375723
375976
|
const { getClaudeConfigHomeDir: getClaudeConfigHomeDir3 } = await Promise.resolve().then(() => (init_envUtils(), exports_envUtils));
|
|
375724
|
-
const newPath =
|
|
375725
|
-
const legacyPath =
|
|
375977
|
+
const newPath = join118(getClaudeConfigHomeDir3(), "slack.json");
|
|
375978
|
+
const legacyPath = join118(homedir26(), ".claude", "slack.json");
|
|
375726
375979
|
let configPath = newPath;
|
|
375727
375980
|
try {
|
|
375728
375981
|
await (await import("fs/promises")).stat(newPath);
|
|
375729
375982
|
} catch {
|
|
375730
375983
|
configPath = legacyPath;
|
|
375731
375984
|
}
|
|
375732
|
-
const raw = await
|
|
375985
|
+
const raw = await readFile46(configPath, "utf-8");
|
|
375733
375986
|
const config2 = JSON.parse(raw);
|
|
375734
375987
|
if (config2.token && config2.channelId) {
|
|
375735
375988
|
token = config2.token;
|
|
@@ -376037,19 +376290,19 @@ async function initDiscord() {
|
|
|
376037
376290
|
let userId = process.env.DISCORD_USER_ID;
|
|
376038
376291
|
if (!token || !channelId) {
|
|
376039
376292
|
try {
|
|
376040
|
-
const { readFile:
|
|
376041
|
-
const { join:
|
|
376042
|
-
const { homedir:
|
|
376293
|
+
const { readFile: readFile46 } = await import("fs/promises");
|
|
376294
|
+
const { join: join118 } = await import("path");
|
|
376295
|
+
const { homedir: homedir26 } = await import("os");
|
|
376043
376296
|
const { getClaudeConfigHomeDir: getClaudeConfigHomeDir3 } = await Promise.resolve().then(() => (init_envUtils(), exports_envUtils));
|
|
376044
|
-
const newPath =
|
|
376045
|
-
const legacyPath =
|
|
376297
|
+
const newPath = join118(getClaudeConfigHomeDir3(), "discord.json");
|
|
376298
|
+
const legacyPath = join118(homedir26(), ".claude", "discord.json");
|
|
376046
376299
|
let configPath = newPath;
|
|
376047
376300
|
try {
|
|
376048
376301
|
await (await import("fs/promises")).stat(newPath);
|
|
376049
376302
|
} catch {
|
|
376050
376303
|
configPath = legacyPath;
|
|
376051
376304
|
}
|
|
376052
|
-
const raw = await
|
|
376305
|
+
const raw = await readFile46(configPath, "utf-8");
|
|
376053
376306
|
const config2 = JSON.parse(raw);
|
|
376054
376307
|
if (config2.token && config2.channelId) {
|
|
376055
376308
|
token = config2.token;
|
|
@@ -376435,11 +376688,11 @@ __export(exports_scheduler, {
|
|
|
376435
376688
|
getSchedules: () => getSchedules,
|
|
376436
376689
|
addSchedule: () => addSchedule
|
|
376437
376690
|
});
|
|
376438
|
-
import { mkdir as
|
|
376439
|
-
import { join as
|
|
376691
|
+
import { mkdir as mkdir39, readFile as readFile46, writeFile as writeFile41 } from "fs/promises";
|
|
376692
|
+
import { join as join118 } from "path";
|
|
376440
376693
|
async function loadSchedules() {
|
|
376441
376694
|
try {
|
|
376442
|
-
const raw = await
|
|
376695
|
+
const raw = await readFile46(SCHEDULES_PATH, "utf-8");
|
|
376443
376696
|
const parsed = JSON.parse(raw);
|
|
376444
376697
|
if (parsed.version !== 1)
|
|
376445
376698
|
return { version: 1, schedules: [] };
|
|
@@ -376449,8 +376702,8 @@ async function loadSchedules() {
|
|
|
376449
376702
|
}
|
|
376450
376703
|
}
|
|
376451
376704
|
async function saveSchedules(file) {
|
|
376452
|
-
await
|
|
376453
|
-
await
|
|
376705
|
+
await mkdir39(getClaudeConfigHomeDir(), { recursive: true });
|
|
376706
|
+
await writeFile41(SCHEDULES_PATH, JSON.stringify(file, null, 2), "utf-8");
|
|
376454
376707
|
}
|
|
376455
376708
|
function nextRunTime(expr, from = Date.now()) {
|
|
376456
376709
|
const trimmed = expr.trim().toLowerCase();
|
|
@@ -376654,7 +376907,7 @@ var SCHEDULES_PATH, TICK_INTERVAL_MS = 30000, _tickTimer = null;
|
|
|
376654
376907
|
var init_scheduler = __esm(() => {
|
|
376655
376908
|
init_debug();
|
|
376656
376909
|
init_envUtils();
|
|
376657
|
-
SCHEDULES_PATH =
|
|
376910
|
+
SCHEDULES_PATH = join118(getClaudeConfigHomeDir(), "schedules.json");
|
|
376658
376911
|
});
|
|
376659
376912
|
|
|
376660
376913
|
// src/services/telegram/telegramBot.ts
|
|
@@ -376693,6 +376946,10 @@ function isTelegramActive() {
|
|
|
376693
376946
|
async function sendTelegramMessage(text) {
|
|
376694
376947
|
if (!_polling4 || !_chatId)
|
|
376695
376948
|
return;
|
|
376949
|
+
try {
|
|
376950
|
+
const { recordMainAgentActivity: recordMainAgentActivity2 } = await Promise.resolve().then(() => (init_telegramAgent(), exports_telegramAgent));
|
|
376951
|
+
recordMainAgentActivity2(text);
|
|
376952
|
+
} catch {}
|
|
376696
376953
|
const chunks = chunkText4(text, 4000);
|
|
376697
376954
|
for (const chunk of chunks) {
|
|
376698
376955
|
try {
|
|
@@ -376785,19 +377042,19 @@ async function initTelegram() {
|
|
|
376785
377042
|
let chatIdStr = process.env.TELEGRAM_CHAT_ID;
|
|
376786
377043
|
if (!token || !chatIdStr) {
|
|
376787
377044
|
try {
|
|
376788
|
-
const { readFile:
|
|
376789
|
-
const { join:
|
|
376790
|
-
const { homedir:
|
|
377045
|
+
const { readFile: readFile47, stat: stat40 } = await import("fs/promises");
|
|
377046
|
+
const { join: join119 } = await import("path");
|
|
377047
|
+
const { homedir: homedir26 } = await import("os");
|
|
376791
377048
|
const { getClaudeConfigHomeDir: getClaudeConfigHomeDir3 } = await Promise.resolve().then(() => (init_envUtils(), exports_envUtils));
|
|
376792
377049
|
const { getOriginalCwd: getOriginalCwd2 } = await Promise.resolve().then(() => (init_state(), exports_state));
|
|
376793
377050
|
const candidates = [];
|
|
376794
377051
|
try {
|
|
376795
377052
|
const cwd2 = getOriginalCwd2();
|
|
376796
377053
|
if (cwd2)
|
|
376797
|
-
candidates.push(
|
|
377054
|
+
candidates.push(join119(cwd2, ".localclawd", "telegram.json"));
|
|
376798
377055
|
} catch {}
|
|
376799
|
-
candidates.push(
|
|
376800
|
-
candidates.push(
|
|
377056
|
+
candidates.push(join119(getClaudeConfigHomeDir3(), "telegram.json"));
|
|
377057
|
+
candidates.push(join119(homedir26(), ".claude", "telegram.json"));
|
|
376801
377058
|
let configPath = null;
|
|
376802
377059
|
for (const p of candidates) {
|
|
376803
377060
|
try {
|
|
@@ -376808,7 +377065,7 @@ async function initTelegram() {
|
|
|
376808
377065
|
}
|
|
376809
377066
|
if (!configPath)
|
|
376810
377067
|
throw new Error("no telegram config found");
|
|
376811
|
-
const raw = await
|
|
377068
|
+
const raw = await readFile47(configPath, "utf-8");
|
|
376812
377069
|
const config2 = JSON.parse(raw);
|
|
376813
377070
|
logForDebugging(`[telegram] using config from ${configPath}`);
|
|
376814
377071
|
if (config2.token && config2.chatId) {
|
|
@@ -376913,12 +377170,18 @@ ${text}`;
|
|
|
376913
377170
|
}
|
|
376914
377171
|
if (text === "/start") {
|
|
376915
377172
|
sendTelegramMessage(`*localclawd ready*
|
|
376916
|
-
|
|
377173
|
+
I'm a separate Telegram agent — I chat with you and steer the main coding agent when needed.
|
|
376917
377174
|
|
|
376918
377175
|
Commands:
|
|
376919
377176
|
/stop — stop current task
|
|
376920
377177
|
/kill — kill all instances
|
|
376921
|
-
/status — show current status
|
|
377178
|
+
/status — show current status
|
|
377179
|
+
/reset — clear Telegram conversation history`);
|
|
377180
|
+
return;
|
|
377181
|
+
}
|
|
377182
|
+
if (text === "/reset") {
|
|
377183
|
+
clearTelegramHistory();
|
|
377184
|
+
sendTelegramMessage("Telegram conversation history cleared. (Main agent context is unchanged.)");
|
|
376922
377185
|
return;
|
|
376923
377186
|
}
|
|
376924
377187
|
if (text === "/status") {
|
|
@@ -376941,9 +377204,10 @@ ${text2}`);
|
|
|
376941
377204
|
` + `/kill — kill all instances
|
|
376942
377205
|
` + `/status — project status
|
|
376943
377206
|
` + `/schedules — list scheduled jobs
|
|
377207
|
+
` + `/reset — clear Telegram chat history
|
|
376944
377208
|
` + `/help — this message
|
|
376945
377209
|
|
|
376946
|
-
` + "Any other message is
|
|
377210
|
+
` + "Any other message is handled by a separate Telegram agent that talks to you and steers the main coding agent when needed.");
|
|
376947
377211
|
return;
|
|
376948
377212
|
}
|
|
376949
377213
|
sendTelegramMessage(`Unknown command: ${text}
|
|
@@ -376951,13 +377215,31 @@ ${text2}`);
|
|
|
376951
377215
|
Available: /stop /kill /status /schedules /help`);
|
|
376952
377216
|
return;
|
|
376953
377217
|
}
|
|
376954
|
-
|
|
377218
|
+
startTypingIndicator();
|
|
376955
377219
|
try {
|
|
376956
|
-
const {
|
|
376957
|
-
|
|
377220
|
+
const { reply, action: action2 } = await respondToTelegramMessage(text);
|
|
377221
|
+
let suffix = "";
|
|
377222
|
+
if (action2.type === "prompt")
|
|
377223
|
+
suffix = `
|
|
377224
|
+
|
|
377225
|
+
_(forwarded to main agent)_`;
|
|
377226
|
+
else if (action2.type === "steer")
|
|
377227
|
+
suffix = `
|
|
377228
|
+
|
|
377229
|
+
_(steering main agent)_`;
|
|
377230
|
+
await sendTelegramMessage(reply + suffix);
|
|
376958
377231
|
} catch (e) {
|
|
376959
|
-
|
|
376960
|
-
|
|
377232
|
+
logForDebugging(`[telegram] agent failed: ${e}`, { level: "warn" });
|
|
377233
|
+
try {
|
|
377234
|
+
const { enqueue: enqueue2 } = await Promise.resolve().then(() => (init_messageQueueManager(), exports_messageQueueManager));
|
|
377235
|
+
enqueue2({ value: text, mode: "prompt", priority: "next" });
|
|
377236
|
+
await sendTelegramMessage("I had trouble responding, but I forwarded your message to the main agent.");
|
|
377237
|
+
} catch (e2) {
|
|
377238
|
+
_queue4.push(text);
|
|
377239
|
+
logForDebugging(`[telegram] Failed to enqueue fallback: ${e2}`);
|
|
377240
|
+
}
|
|
377241
|
+
} finally {
|
|
377242
|
+
stopTypingIndicator();
|
|
376961
377243
|
}
|
|
376962
377244
|
for (const cb of _listeners2) {
|
|
376963
377245
|
try {
|
|
@@ -377005,6 +377287,7 @@ var init_telegramBot = __esm(() => {
|
|
|
377005
377287
|
init_debug();
|
|
377006
377288
|
init_telegramSignals();
|
|
377007
377289
|
init_telegramKill();
|
|
377290
|
+
init_telegramAgent();
|
|
377008
377291
|
_queue4 = [];
|
|
377009
377292
|
_listeners2 = [];
|
|
377010
377293
|
});
|
|
@@ -377248,11 +377531,11 @@ function logKgCrash(error5, context7) {
|
|
|
377248
377531
|
const msg = error5 instanceof Error ? error5.stack ?? error5.message : String(error5);
|
|
377249
377532
|
try {
|
|
377250
377533
|
const { appendFileSync: appendFileSync3, mkdirSync: mkdirSync6 } = __require("fs");
|
|
377251
|
-
const { homedir:
|
|
377252
|
-
const { join:
|
|
377253
|
-
const dir =
|
|
377534
|
+
const { homedir: homedir26 } = __require("os");
|
|
377535
|
+
const { join: join119 } = __require("path");
|
|
377536
|
+
const dir = join119(homedir26(), ".claude");
|
|
377254
377537
|
mkdirSync6(dir, { recursive: true });
|
|
377255
|
-
appendFileSync3(
|
|
377538
|
+
appendFileSync3(join119(dir, "crash.log"), `[${new Date().toISOString()}] keepgoing ${context7}: ${msg}
|
|
377256
377539
|
`);
|
|
377257
377540
|
} catch {}
|
|
377258
377541
|
}
|
|
@@ -377428,8 +377711,8 @@ var exports_telegram = {};
|
|
|
377428
377711
|
__export(exports_telegram, {
|
|
377429
377712
|
call: () => call23
|
|
377430
377713
|
});
|
|
377431
|
-
import { writeFile as
|
|
377432
|
-
import { join as
|
|
377714
|
+
import { writeFile as writeFile42, mkdir as mkdir40 } from "fs/promises";
|
|
377715
|
+
import { join as join119 } from "path";
|
|
377433
377716
|
function TelegramSetup({ onDone }) {
|
|
377434
377717
|
const [step, setStep] = React59.useState("instructions");
|
|
377435
377718
|
const [token, setToken] = React59.useState("");
|
|
@@ -377715,20 +377998,20 @@ async function saveTelegramConfig(token, chatId) {
|
|
|
377715
377998
|
const { getOriginalCwd: getOriginalCwd2 } = await Promise.resolve().then(() => (init_state(), exports_state));
|
|
377716
377999
|
const cwd2 = getOriginalCwd2();
|
|
377717
378000
|
if (cwd2) {
|
|
377718
|
-
const projDir =
|
|
377719
|
-
await
|
|
377720
|
-
configPath =
|
|
378001
|
+
const projDir = join119(cwd2, ".localclawd");
|
|
378002
|
+
await mkdir40(projDir, { recursive: true });
|
|
378003
|
+
configPath = join119(projDir, "telegram.json");
|
|
377721
378004
|
} else {
|
|
377722
378005
|
const dir = getClaudeConfigHomeDir();
|
|
377723
|
-
await
|
|
377724
|
-
configPath =
|
|
378006
|
+
await mkdir40(dir, { recursive: true });
|
|
378007
|
+
configPath = join119(dir, "telegram.json");
|
|
377725
378008
|
}
|
|
377726
378009
|
} catch {
|
|
377727
378010
|
const dir = getClaudeConfigHomeDir();
|
|
377728
|
-
await
|
|
377729
|
-
configPath =
|
|
378011
|
+
await mkdir40(dir, { recursive: true });
|
|
378012
|
+
configPath = join119(dir, "telegram.json");
|
|
377730
378013
|
}
|
|
377731
|
-
await
|
|
378014
|
+
await writeFile42(configPath, JSON.stringify({ token, chatId }, null, 2), "utf-8");
|
|
377732
378015
|
}
|
|
377733
378016
|
function TelegramStatus({
|
|
377734
378017
|
onDone
|
|
@@ -377938,8 +378221,8 @@ var exports_slack = {};
|
|
|
377938
378221
|
__export(exports_slack, {
|
|
377939
378222
|
call: () => call24
|
|
377940
378223
|
});
|
|
377941
|
-
import { writeFile as
|
|
377942
|
-
import { join as
|
|
378224
|
+
import { writeFile as writeFile43, mkdir as mkdir41 } from "fs/promises";
|
|
378225
|
+
import { join as join120 } from "path";
|
|
377943
378226
|
function SlackSetup({ onDone }) {
|
|
377944
378227
|
const [step, setStep] = React60.useState("instructions");
|
|
377945
378228
|
const [token, setToken] = React60.useState("");
|
|
@@ -378294,9 +378577,9 @@ function SlackSetupDone({
|
|
|
378294
378577
|
}
|
|
378295
378578
|
async function saveSlackConfig(token, channelId, userId) {
|
|
378296
378579
|
const configDir = getClaudeConfigHomeDir();
|
|
378297
|
-
await
|
|
378298
|
-
const configPath =
|
|
378299
|
-
await
|
|
378580
|
+
await mkdir41(configDir, { recursive: true });
|
|
378581
|
+
const configPath = join120(configDir, "slack.json");
|
|
378582
|
+
await writeFile43(configPath, JSON.stringify({ token, channelId, userId: userId ?? null }, null, 2), "utf-8");
|
|
378300
378583
|
}
|
|
378301
378584
|
function SlackStatus({
|
|
378302
378585
|
onDone
|
|
@@ -378521,8 +378804,8 @@ var exports_discord = {};
|
|
|
378521
378804
|
__export(exports_discord, {
|
|
378522
378805
|
call: () => call25
|
|
378523
378806
|
});
|
|
378524
|
-
import { writeFile as
|
|
378525
|
-
import { join as
|
|
378807
|
+
import { writeFile as writeFile44, mkdir as mkdir42 } from "fs/promises";
|
|
378808
|
+
import { join as join121 } from "path";
|
|
378526
378809
|
function DiscordSetup({ onDone }) {
|
|
378527
378810
|
const [step, setStep] = React62.useState("instructions");
|
|
378528
378811
|
const [token, setToken] = React62.useState("");
|
|
@@ -378816,8 +379099,8 @@ function DiscordSetupDone({
|
|
|
378816
379099
|
}
|
|
378817
379100
|
async function saveConfig3(token, channelId, userId) {
|
|
378818
379101
|
const configDir = getClaudeConfigHomeDir();
|
|
378819
|
-
await
|
|
378820
|
-
await
|
|
379102
|
+
await mkdir42(configDir, { recursive: true });
|
|
379103
|
+
await writeFile44(join121(configDir, "discord.json"), JSON.stringify({ token, channelId, userId: userId ?? null }, null, 2), "utf-8");
|
|
378821
379104
|
}
|
|
378822
379105
|
function DiscordStatus({
|
|
378823
379106
|
onDone
|
|
@@ -379188,9 +379471,9 @@ var init_schedule2 = __esm(() => {
|
|
|
379188
379471
|
});
|
|
379189
379472
|
|
|
379190
379473
|
// src/services/sessionSearch/sessionSummarize.ts
|
|
379191
|
-
import { readdir as readdir25, readFile as
|
|
379192
|
-
import { join as
|
|
379193
|
-
import { homedir as
|
|
379474
|
+
import { readdir as readdir25, readFile as readFile47, writeFile as writeFile45, mkdir as mkdir43, stat as stat40 } from "fs/promises";
|
|
379475
|
+
import { join as join122 } from "path";
|
|
379476
|
+
import { homedir as homedir26 } from "os";
|
|
379194
379477
|
function extractText(obj) {
|
|
379195
379478
|
if (typeof obj === "string")
|
|
379196
379479
|
return obj;
|
|
@@ -379218,7 +379501,7 @@ async function listUnsummarized() {
|
|
|
379218
379501
|
for (const f of files) {
|
|
379219
379502
|
if (!f.endsWith(".json"))
|
|
379220
379503
|
continue;
|
|
379221
|
-
const s = await stat40(
|
|
379504
|
+
const s = await stat40(join122(SUMMARIES_DIR2, f)).catch(() => null);
|
|
379222
379505
|
if (s)
|
|
379223
379506
|
existing.set(f.replace(/\.json$/, ""), s.mtimeMs);
|
|
379224
379507
|
}
|
|
@@ -379232,7 +379515,7 @@ async function listUnsummarized() {
|
|
|
379232
379515
|
continue;
|
|
379233
379516
|
}
|
|
379234
379517
|
for (const slug of slugs) {
|
|
379235
|
-
const slugDir =
|
|
379518
|
+
const slugDir = join122(projectsDir, slug);
|
|
379236
379519
|
try {
|
|
379237
379520
|
const entries = await readdir25(slugDir);
|
|
379238
379521
|
for (const entry of entries) {
|
|
@@ -379242,7 +379525,7 @@ async function listUnsummarized() {
|
|
|
379242
379525
|
if (seen.has(sessionId))
|
|
379243
379526
|
continue;
|
|
379244
379527
|
seen.add(sessionId);
|
|
379245
|
-
const full =
|
|
379528
|
+
const full = join122(slugDir, entry);
|
|
379246
379529
|
const s = await stat40(full).catch(() => null);
|
|
379247
379530
|
if (!s)
|
|
379248
379531
|
continue;
|
|
@@ -379284,7 +379567,7 @@ function buildTranscript(content) {
|
|
|
379284
379567
|
return { transcript: parts.join(`
|
|
379285
379568
|
`), messageCount: lines.length, firstUser };
|
|
379286
379569
|
}
|
|
379287
|
-
async function
|
|
379570
|
+
async function callLLM2(prompt) {
|
|
379288
379571
|
try {
|
|
379289
379572
|
const baseUrl = getLocalLLMBaseUrl();
|
|
379290
379573
|
const model = getLocalLLMModel();
|
|
@@ -379322,7 +379605,7 @@ function parseSummaryResponse(text) {
|
|
|
379322
379605
|
return { summary, tags };
|
|
379323
379606
|
}
|
|
379324
379607
|
async function summarizeSession(sessionId, slug, filePath, mtime) {
|
|
379325
|
-
const content = await
|
|
379608
|
+
const content = await readFile47(filePath, "utf-8").catch(() => "");
|
|
379326
379609
|
if (!content)
|
|
379327
379610
|
return null;
|
|
379328
379611
|
const { transcript, messageCount, firstUser } = buildTranscript(content);
|
|
@@ -379336,7 +379619,7 @@ TAGS: tag1, tag2, tag3
|
|
|
379336
379619
|
|
|
379337
379620
|
` + `Transcript:
|
|
379338
379621
|
${transcript}`;
|
|
379339
|
-
const response = await
|
|
379622
|
+
const response = await callLLM2(prompt);
|
|
379340
379623
|
if (!response)
|
|
379341
379624
|
return null;
|
|
379342
379625
|
const { summary, tags } = parseSummaryResponse(response);
|
|
@@ -379353,7 +379636,7 @@ ${transcript}`;
|
|
|
379353
379636
|
};
|
|
379354
379637
|
}
|
|
379355
379638
|
async function summarizeAllPending(limit = 20, onProgress) {
|
|
379356
|
-
await
|
|
379639
|
+
await mkdir43(SUMMARIES_DIR2, { recursive: true });
|
|
379357
379640
|
const pending = await listUnsummarized();
|
|
379358
379641
|
pending.sort((a, b3) => b3.mtime - a.mtime);
|
|
379359
379642
|
const slice = pending.slice(0, limit);
|
|
@@ -379368,7 +379651,7 @@ async function summarizeAllPending(limit = 20, onProgress) {
|
|
|
379368
379651
|
continue;
|
|
379369
379652
|
}
|
|
379370
379653
|
try {
|
|
379371
|
-
await
|
|
379654
|
+
await writeFile45(join122(SUMMARIES_DIR2, `${p.sessionId}.json`), JSON.stringify(summary, null, 2), "utf-8");
|
|
379372
379655
|
summarized++;
|
|
379373
379656
|
} catch (e) {
|
|
379374
379657
|
logForDebugging(`[session-summarize] write failed: ${e}`);
|
|
@@ -379385,7 +379668,7 @@ async function loadAllSummaries() {
|
|
|
379385
379668
|
if (!f.endsWith(".json"))
|
|
379386
379669
|
continue;
|
|
379387
379670
|
try {
|
|
379388
|
-
const raw = await
|
|
379671
|
+
const raw = await readFile47(join122(SUMMARIES_DIR2, f), "utf-8");
|
|
379389
379672
|
summaries.push(JSON.parse(raw));
|
|
379390
379673
|
} catch {}
|
|
379391
379674
|
}
|
|
@@ -379400,15 +379683,15 @@ var init_sessionSummarize = __esm(() => {
|
|
|
379400
379683
|
init_envUtils();
|
|
379401
379684
|
init_providers();
|
|
379402
379685
|
PROJECTS_DIRS = [
|
|
379403
|
-
|
|
379404
|
-
|
|
379686
|
+
join122(getClaudeConfigHomeDir(), "projects"),
|
|
379687
|
+
join122(homedir26(), ".claude", "projects")
|
|
379405
379688
|
];
|
|
379406
|
-
SUMMARIES_DIR2 =
|
|
379689
|
+
SUMMARIES_DIR2 = join122(getClaudeConfigHomeDir(), "session-summaries");
|
|
379407
379690
|
});
|
|
379408
379691
|
|
|
379409
379692
|
// src/services/sessionSearch/fts5Index.ts
|
|
379410
|
-
import { readdir as readdir26, readFile as
|
|
379411
|
-
import { join as
|
|
379693
|
+
import { readdir as readdir26, readFile as readFile48, stat as stat41 } from "fs/promises";
|
|
379694
|
+
import { join as join123 } from "path";
|
|
379412
379695
|
async function tryOpenDatabase() {
|
|
379413
379696
|
if (_db)
|
|
379414
379697
|
return _db;
|
|
@@ -379473,7 +379756,7 @@ async function rebuildIndex() {
|
|
|
379473
379756
|
continue;
|
|
379474
379757
|
const sessionId = entry.replace(/\.json$/, "");
|
|
379475
379758
|
seen.add(sessionId);
|
|
379476
|
-
const filePath =
|
|
379759
|
+
const filePath = join123(SUMMARIES_DIR3, entry);
|
|
379477
379760
|
let s;
|
|
379478
379761
|
try {
|
|
379479
379762
|
s = await stat41(filePath);
|
|
@@ -379485,7 +379768,7 @@ async function rebuildIndex() {
|
|
|
379485
379768
|
continue;
|
|
379486
379769
|
let raw;
|
|
379487
379770
|
try {
|
|
379488
|
-
raw = await
|
|
379771
|
+
raw = await readFile48(filePath, "utf-8");
|
|
379489
379772
|
} catch {
|
|
379490
379773
|
continue;
|
|
379491
379774
|
}
|
|
@@ -379544,14 +379827,14 @@ var DB_PATH, SUMMARIES_DIR3, _db = null, _available = null;
|
|
|
379544
379827
|
var init_fts5Index = __esm(() => {
|
|
379545
379828
|
init_debug();
|
|
379546
379829
|
init_envUtils();
|
|
379547
|
-
DB_PATH =
|
|
379548
|
-
SUMMARIES_DIR3 =
|
|
379830
|
+
DB_PATH = join123(getClaudeConfigHomeDir(), "sessions.db");
|
|
379831
|
+
SUMMARIES_DIR3 = join123(getClaudeConfigHomeDir(), "session-summaries");
|
|
379549
379832
|
});
|
|
379550
379833
|
|
|
379551
379834
|
// src/services/sessionSearch/sessionSearch.ts
|
|
379552
|
-
import { readdir as readdir27, readFile as
|
|
379553
|
-
import { join as
|
|
379554
|
-
import { homedir as
|
|
379835
|
+
import { readdir as readdir27, readFile as readFile49, stat as stat42 } from "fs/promises";
|
|
379836
|
+
import { join as join124 } from "path";
|
|
379837
|
+
import { homedir as homedir27 } from "os";
|
|
379555
379838
|
function tokenize6(text) {
|
|
379556
379839
|
return text.toLowerCase().split(/[^a-z0-9_]+/).filter((t) => t.length >= 2);
|
|
379557
379840
|
}
|
|
@@ -379585,13 +379868,13 @@ async function listSessionFiles() {
|
|
|
379585
379868
|
continue;
|
|
379586
379869
|
}
|
|
379587
379870
|
for (const slug of projects) {
|
|
379588
|
-
const slugDir =
|
|
379871
|
+
const slugDir = join124(projectsDir, slug);
|
|
379589
379872
|
try {
|
|
379590
379873
|
const entries = await readdir27(slugDir);
|
|
379591
379874
|
for (const entry of entries) {
|
|
379592
379875
|
if (!entry.endsWith(".jsonl"))
|
|
379593
379876
|
continue;
|
|
379594
|
-
const full =
|
|
379877
|
+
const full = join124(slugDir, entry);
|
|
379595
379878
|
if (seen.has(entry))
|
|
379596
379879
|
continue;
|
|
379597
379880
|
seen.add(entry);
|
|
@@ -379611,7 +379894,7 @@ async function listSessionFiles() {
|
|
|
379611
379894
|
async function scoreSession(terms, filePath) {
|
|
379612
379895
|
let content;
|
|
379613
379896
|
try {
|
|
379614
|
-
content = await
|
|
379897
|
+
content = await readFile49(filePath, "utf-8");
|
|
379615
379898
|
} catch {
|
|
379616
379899
|
return { score: 0, messageCount: 0, snippet: "", preview: "" };
|
|
379617
379900
|
}
|
|
@@ -379807,8 +380090,8 @@ var init_sessionSearch = __esm(() => {
|
|
|
379807
380090
|
init_sessionSummarize();
|
|
379808
380091
|
init_fts5Index();
|
|
379809
380092
|
PROJECTS_DIRS2 = [
|
|
379810
|
-
|
|
379811
|
-
|
|
380093
|
+
join124(getClaudeConfigHomeDir(), "projects"),
|
|
380094
|
+
join124(homedir27(), ".claude", "projects")
|
|
379812
380095
|
];
|
|
379813
380096
|
MAX_FILE_BYTES = 5 * 1024 * 1024;
|
|
379814
380097
|
});
|
|
@@ -379911,9 +380194,9 @@ var init_summarize_sessions2 = __esm(() => {
|
|
|
379911
380194
|
});
|
|
379912
380195
|
|
|
379913
380196
|
// src/services/sessionSearch/trajectoryCompress.ts
|
|
379914
|
-
import { readFile as
|
|
379915
|
-
import { join as
|
|
379916
|
-
import { homedir as
|
|
380197
|
+
import { readFile as readFile50, writeFile as writeFile46, readdir as readdir28, mkdir as mkdir44, stat as stat43 } from "fs/promises";
|
|
380198
|
+
import { join as join125 } from "path";
|
|
380199
|
+
import { homedir as homedir28 } from "os";
|
|
379917
380200
|
function flattenText(obj) {
|
|
379918
380201
|
if (typeof obj === "string")
|
|
379919
380202
|
return obj;
|
|
@@ -379996,9 +380279,9 @@ async function compressSession(sessionId, projectSlug) {
|
|
|
379996
380279
|
let source = null;
|
|
379997
380280
|
let sourceStat = null;
|
|
379998
380281
|
for (const projectsDir of PROJECTS_DIRS3) {
|
|
379999
|
-
const candidate =
|
|
380282
|
+
const candidate = join125(projectsDir, projectSlug, `${sessionId}.jsonl`);
|
|
380000
380283
|
try {
|
|
380001
|
-
const text = await
|
|
380284
|
+
const text = await readFile50(candidate, "utf-8");
|
|
380002
380285
|
const s = await stat43(candidate);
|
|
380003
380286
|
sourcePath = candidate;
|
|
380004
380287
|
source = text;
|
|
@@ -380030,8 +380313,8 @@ async function compressSession(sessionId, projectSlug) {
|
|
|
380030
380313
|
};
|
|
380031
380314
|
const serialized = JSON.stringify(trajectory, null, 0);
|
|
380032
380315
|
trajectory.compressedBytes = Buffer.byteLength(serialized, "utf-8");
|
|
380033
|
-
await
|
|
380034
|
-
await
|
|
380316
|
+
await mkdir44(TRAJECTORIES_DIR2, { recursive: true });
|
|
380317
|
+
await writeFile46(join125(TRAJECTORIES_DIR2, `${sessionId}.json`), JSON.stringify(trajectory), "utf-8");
|
|
380035
380318
|
return trajectory;
|
|
380036
380319
|
}
|
|
380037
380320
|
async function compressAllPending(limit = 20) {
|
|
@@ -380041,7 +380324,7 @@ async function compressAllPending(limit = 20) {
|
|
|
380041
380324
|
for (const f of files) {
|
|
380042
380325
|
if (!f.endsWith(".json"))
|
|
380043
380326
|
continue;
|
|
380044
|
-
const s = await stat43(
|
|
380327
|
+
const s = await stat43(join125(TRAJECTORIES_DIR2, f)).catch(() => null);
|
|
380045
380328
|
if (s)
|
|
380046
380329
|
existing.set(f.replace(/\.json$/, ""), s.mtimeMs);
|
|
380047
380330
|
}
|
|
@@ -380057,7 +380340,7 @@ async function compressAllPending(limit = 20) {
|
|
|
380057
380340
|
}
|
|
380058
380341
|
for (const slug of slugs) {
|
|
380059
380342
|
try {
|
|
380060
|
-
const entries = await readdir28(
|
|
380343
|
+
const entries = await readdir28(join125(projectsDir, slug));
|
|
380061
380344
|
for (const entry of entries) {
|
|
380062
380345
|
if (!entry.endsWith(".jsonl"))
|
|
380063
380346
|
continue;
|
|
@@ -380065,7 +380348,7 @@ async function compressAllPending(limit = 20) {
|
|
|
380065
380348
|
if (seen.has(sessionId))
|
|
380066
380349
|
continue;
|
|
380067
380350
|
seen.add(sessionId);
|
|
380068
|
-
const s = await stat43(
|
|
380351
|
+
const s = await stat43(join125(projectsDir, slug, entry)).catch(() => null);
|
|
380069
380352
|
if (!s)
|
|
380070
380353
|
continue;
|
|
380071
380354
|
const have = existing.get(sessionId);
|
|
@@ -380105,10 +380388,10 @@ var init_trajectoryCompress = __esm(() => {
|
|
|
380105
380388
|
init_debug();
|
|
380106
380389
|
init_envUtils();
|
|
380107
380390
|
PROJECTS_DIRS3 = [
|
|
380108
|
-
|
|
380109
|
-
|
|
380391
|
+
join125(getClaudeConfigHomeDir(), "projects"),
|
|
380392
|
+
join125(homedir28(), ".claude", "projects")
|
|
380110
380393
|
];
|
|
380111
|
-
TRAJECTORIES_DIR2 =
|
|
380394
|
+
TRAJECTORIES_DIR2 = join125(getClaudeConfigHomeDir(), "trajectories");
|
|
380112
380395
|
});
|
|
380113
380396
|
|
|
380114
380397
|
// src/commands/compress-sessions/compress-sessions.tsx
|
|
@@ -380157,9 +380440,9 @@ var init_compress_sessions2 = __esm(() => {
|
|
|
380157
380440
|
});
|
|
380158
380441
|
|
|
380159
380442
|
// src/services/skills/skillDistill.ts
|
|
380160
|
-
import { readFile as
|
|
380161
|
-
import { join as
|
|
380162
|
-
import { homedir as
|
|
380443
|
+
import { readFile as readFile51, readdir as readdir29, stat as stat44 } from "fs/promises";
|
|
380444
|
+
import { join as join126 } from "path";
|
|
380445
|
+
import { homedir as homedir29 } from "os";
|
|
380163
380446
|
function extractText3(obj) {
|
|
380164
380447
|
if (typeof obj === "string")
|
|
380165
380448
|
return obj;
|
|
@@ -380189,13 +380472,13 @@ async function findMostRecentSession() {
|
|
|
380189
380472
|
continue;
|
|
380190
380473
|
}
|
|
380191
380474
|
for (const slug of slugs) {
|
|
380192
|
-
const slugDir =
|
|
380475
|
+
const slugDir = join126(projectsDir, slug);
|
|
380193
380476
|
try {
|
|
380194
380477
|
const entries = await readdir29(slugDir);
|
|
380195
380478
|
for (const entry of entries) {
|
|
380196
380479
|
if (!entry.endsWith(".jsonl"))
|
|
380197
380480
|
continue;
|
|
380198
|
-
const full =
|
|
380481
|
+
const full = join126(slugDir, entry);
|
|
380199
380482
|
const s = await stat44(full).catch(() => null);
|
|
380200
380483
|
if (!s)
|
|
380201
380484
|
continue;
|
|
@@ -380209,7 +380492,7 @@ async function findMostRecentSession() {
|
|
|
380209
380492
|
return best?.path ?? null;
|
|
380210
380493
|
}
|
|
380211
380494
|
async function buildTranscript2(sessionPath) {
|
|
380212
|
-
const content = await
|
|
380495
|
+
const content = await readFile51(sessionPath, "utf-8");
|
|
380213
380496
|
const lines = content.split(`
|
|
380214
380497
|
`).filter(Boolean);
|
|
380215
380498
|
const parts = [];
|
|
@@ -380234,7 +380517,7 @@ async function buildTranscript2(sessionPath) {
|
|
|
380234
380517
|
return parts.join(`
|
|
380235
380518
|
`);
|
|
380236
380519
|
}
|
|
380237
|
-
async function
|
|
380520
|
+
async function callLLM3(prompt) {
|
|
380238
380521
|
try {
|
|
380239
380522
|
const baseUrl = getLocalLLMBaseUrl();
|
|
380240
380523
|
const model = getLocalLLMModel();
|
|
@@ -380306,7 +380589,7 @@ async function distillRecentSessionToSkill() {
|
|
|
380306
380589
|
|
|
380307
380590
|
` + `Transcript:
|
|
380308
380591
|
${transcript}`;
|
|
380309
|
-
const response = await
|
|
380592
|
+
const response = await callLLM3(prompt);
|
|
380310
380593
|
if (!response)
|
|
380311
380594
|
return null;
|
|
380312
380595
|
if (/NO_SKILL/i.test(response.trim().slice(0, 100)))
|
|
@@ -380319,8 +380602,8 @@ var init_skillDistill = __esm(() => {
|
|
|
380319
380602
|
init_envUtils();
|
|
380320
380603
|
init_providers();
|
|
380321
380604
|
PROJECTS_DIRS4 = [
|
|
380322
|
-
|
|
380323
|
-
|
|
380605
|
+
join126(getClaudeConfigHomeDir(), "projects"),
|
|
380606
|
+
join126(homedir29(), ".claude", "projects")
|
|
380324
380607
|
];
|
|
380325
380608
|
});
|
|
380326
380609
|
|
|
@@ -381035,8 +381318,8 @@ var init_daytona_run2 = __esm(() => {
|
|
|
381035
381318
|
});
|
|
381036
381319
|
|
|
381037
381320
|
// src/services/skills/skillPortable.ts
|
|
381038
|
-
import { readdir as readdir30, readFile as
|
|
381039
|
-
import { join as
|
|
381321
|
+
import { readdir as readdir30, readFile as readFile52, writeFile as writeFile47, mkdir as mkdir45, stat as stat45 } from "fs/promises";
|
|
381322
|
+
import { join as join127, basename as basename37, extname as extname13, resolve as resolve38 } from "path";
|
|
381040
381323
|
function parseFrontmatter2(raw) {
|
|
381041
381324
|
const m2 = raw.match(/^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/);
|
|
381042
381325
|
if (!m2)
|
|
@@ -381088,7 +381371,7 @@ async function listSkills() {
|
|
|
381088
381371
|
out.push(entry.replace(/\.md$/, ""));
|
|
381089
381372
|
} else {
|
|
381090
381373
|
try {
|
|
381091
|
-
const sub = await stat45(
|
|
381374
|
+
const sub = await stat45(join127(USER_SKILLS_DIR, entry, "SKILL.md"));
|
|
381092
381375
|
if (sub.isFile())
|
|
381093
381376
|
out.push(entry);
|
|
381094
381377
|
} catch {}
|
|
@@ -381100,14 +381383,14 @@ async function listSkills() {
|
|
|
381100
381383
|
}
|
|
381101
381384
|
}
|
|
381102
381385
|
async function readSkillFile(name) {
|
|
381103
|
-
const flatPath =
|
|
381386
|
+
const flatPath = join127(USER_SKILLS_DIR, `${name}.md`);
|
|
381104
381387
|
try {
|
|
381105
|
-
const raw = await
|
|
381388
|
+
const raw = await readFile52(flatPath, "utf-8");
|
|
381106
381389
|
return { raw, path: flatPath };
|
|
381107
381390
|
} catch {}
|
|
381108
|
-
const dirPath =
|
|
381391
|
+
const dirPath = join127(USER_SKILLS_DIR, name, "SKILL.md");
|
|
381109
381392
|
try {
|
|
381110
|
-
const raw = await
|
|
381393
|
+
const raw = await readFile52(dirPath, "utf-8");
|
|
381111
381394
|
return { raw, path: dirPath };
|
|
381112
381395
|
} catch {
|
|
381113
381396
|
return null;
|
|
@@ -381127,14 +381410,14 @@ async function exportSkill(name, destDir) {
|
|
|
381127
381410
|
body
|
|
381128
381411
|
};
|
|
381129
381412
|
const outPath = resolve38(destDir, `${skill.name}.md`);
|
|
381130
|
-
await
|
|
381131
|
-
await
|
|
381413
|
+
await mkdir45(destDir, { recursive: true });
|
|
381414
|
+
await writeFile47(outPath, buildFrontmatter(skill), "utf-8");
|
|
381132
381415
|
return { ok: true, path: outPath };
|
|
381133
381416
|
}
|
|
381134
381417
|
async function importSkill(filePath) {
|
|
381135
381418
|
let raw;
|
|
381136
381419
|
try {
|
|
381137
|
-
raw = await
|
|
381420
|
+
raw = await readFile52(filePath, "utf-8");
|
|
381138
381421
|
} catch (e) {
|
|
381139
381422
|
return { ok: false, error: `Could not read ${filePath}: ${e}` };
|
|
381140
381423
|
}
|
|
@@ -381149,10 +381432,10 @@ async function importSkill(filePath) {
|
|
|
381149
381432
|
const description = typeof meta.description === "string" ? meta.description : "";
|
|
381150
381433
|
const tags = Array.isArray(meta.tags) ? meta.tags : [];
|
|
381151
381434
|
const skill = { name, description, tags, body };
|
|
381152
|
-
const outPath =
|
|
381435
|
+
const outPath = join127(USER_SKILLS_DIR, `${name}.md`);
|
|
381153
381436
|
try {
|
|
381154
|
-
await
|
|
381155
|
-
await
|
|
381437
|
+
await mkdir45(USER_SKILLS_DIR, { recursive: true });
|
|
381438
|
+
await writeFile47(outPath, buildFrontmatter(skill), "utf-8");
|
|
381156
381439
|
logForDebugging(`[skills] imported ${name} → ${outPath}`);
|
|
381157
381440
|
return { ok: true, name, path: outPath };
|
|
381158
381441
|
} catch (e) {
|
|
@@ -381163,7 +381446,7 @@ var USER_SKILLS_DIR;
|
|
|
381163
381446
|
var init_skillPortable = __esm(() => {
|
|
381164
381447
|
init_debug();
|
|
381165
381448
|
init_envUtils();
|
|
381166
|
-
USER_SKILLS_DIR =
|
|
381449
|
+
USER_SKILLS_DIR = join127(getClaudeConfigHomeDir(), "skills");
|
|
381167
381450
|
});
|
|
381168
381451
|
|
|
381169
381452
|
// src/commands/skills-export/skills-export.tsx
|
|
@@ -381274,11 +381557,11 @@ var init_skills_import2 = __esm(() => {
|
|
|
381274
381557
|
});
|
|
381275
381558
|
|
|
381276
381559
|
// src/services/skills/skillUsage.ts
|
|
381277
|
-
import { mkdir as
|
|
381278
|
-
import { join as
|
|
381560
|
+
import { mkdir as mkdir46, readFile as readFile53, writeFile as writeFile48 } from "fs/promises";
|
|
381561
|
+
import { join as join128 } from "path";
|
|
381279
381562
|
async function loadFile() {
|
|
381280
381563
|
try {
|
|
381281
|
-
const raw = await
|
|
381564
|
+
const raw = await readFile53(USAGE_PATH, "utf-8");
|
|
381282
381565
|
const parsed = JSON.parse(raw);
|
|
381283
381566
|
if (parsed.version !== 1)
|
|
381284
381567
|
return { version: 1, records: [] };
|
|
@@ -381309,7 +381592,7 @@ async function shouldNudgeDistillation() {
|
|
|
381309
381592
|
var USAGE_PATH;
|
|
381310
381593
|
var init_skillUsage = __esm(() => {
|
|
381311
381594
|
init_envUtils();
|
|
381312
|
-
USAGE_PATH =
|
|
381595
|
+
USAGE_PATH = join128(getClaudeConfigHomeDir(), "skill-usage.json");
|
|
381313
381596
|
});
|
|
381314
381597
|
|
|
381315
381598
|
// src/commands/skill-stats/skill-stats.tsx
|
|
@@ -381377,21 +381660,21 @@ var init_skill_stats2 = __esm(() => {
|
|
|
381377
381660
|
});
|
|
381378
381661
|
|
|
381379
381662
|
// src/services/skills/skillNotes.ts
|
|
381380
|
-
import { mkdir as
|
|
381381
|
-
import { join as
|
|
381663
|
+
import { mkdir as mkdir47, readFile as readFile54, writeFile as writeFile49, appendFile as appendFile5, stat as stat46 } from "fs/promises";
|
|
381664
|
+
import { join as join129 } from "path";
|
|
381382
381665
|
async function findNotesPath(skillName) {
|
|
381383
|
-
const dirPath =
|
|
381666
|
+
const dirPath = join129(USER_SKILLS_DIR2, skillName, "NOTES.md");
|
|
381384
381667
|
try {
|
|
381385
|
-
const s = await stat46(
|
|
381668
|
+
const s = await stat46(join129(USER_SKILLS_DIR2, skillName));
|
|
381386
381669
|
if (s.isDirectory())
|
|
381387
381670
|
return dirPath;
|
|
381388
381671
|
} catch {}
|
|
381389
|
-
return
|
|
381672
|
+
return join129(USER_SKILLS_DIR2, `${skillName}.notes.md`);
|
|
381390
381673
|
}
|
|
381391
381674
|
async function loadSkillNotes(skillName) {
|
|
381392
381675
|
const path12 = await findNotesPath(skillName);
|
|
381393
381676
|
try {
|
|
381394
|
-
return await
|
|
381677
|
+
return await readFile54(path12, "utf-8");
|
|
381395
381678
|
} catch {
|
|
381396
381679
|
return "";
|
|
381397
381680
|
}
|
|
@@ -381401,10 +381684,10 @@ async function appendSkillNote(skillName, note) {
|
|
|
381401
381684
|
if (!trimmed)
|
|
381402
381685
|
return { ok: false, error: "note is empty" };
|
|
381403
381686
|
const path12 = await findNotesPath(skillName);
|
|
381404
|
-
await
|
|
381687
|
+
await mkdir47(USER_SKILLS_DIR2, { recursive: true });
|
|
381405
381688
|
let existing = "";
|
|
381406
381689
|
try {
|
|
381407
|
-
existing = await
|
|
381690
|
+
existing = await readFile54(path12, "utf-8");
|
|
381408
381691
|
} catch {}
|
|
381409
381692
|
if (existing.length === 0) {
|
|
381410
381693
|
existing = `# Notes for skill: ${skillName}
|
|
@@ -381426,7 +381709,7 @@ async function appendSkillNote(skillName, note) {
|
|
|
381426
381709
|
const compacted = lines.slice(0, headerEnd).concat(lines.slice(trimStart)).join(`
|
|
381427
381710
|
`);
|
|
381428
381711
|
try {
|
|
381429
|
-
await
|
|
381712
|
+
await writeFile49(path12, compacted + entry, "utf-8");
|
|
381430
381713
|
} catch (e) {
|
|
381431
381714
|
return { ok: false, error: String(e) };
|
|
381432
381715
|
}
|
|
@@ -381445,7 +381728,7 @@ var USER_SKILLS_DIR2, MAX_NOTES_BYTES, MAX_NOTE_LENGTH = 500;
|
|
|
381445
381728
|
var init_skillNotes = __esm(() => {
|
|
381446
381729
|
init_debug();
|
|
381447
381730
|
init_envUtils();
|
|
381448
|
-
USER_SKILLS_DIR2 =
|
|
381731
|
+
USER_SKILLS_DIR2 = join129(getClaudeConfigHomeDir(), "skills");
|
|
381449
381732
|
MAX_NOTES_BYTES = 32 * 1024;
|
|
381450
381733
|
});
|
|
381451
381734
|
|
|
@@ -381921,9 +382204,9 @@ __export(exports_webuiServer, {
|
|
|
381921
382204
|
broadcastNewWindow: () => broadcastNewWindow
|
|
381922
382205
|
});
|
|
381923
382206
|
import { createServer as createServer5 } from "http";
|
|
381924
|
-
import { mkdir as
|
|
382207
|
+
import { mkdir as mkdir48, readdir as readdir31, readFile as readFile55, writeFile as writeFile50 } from "fs/promises";
|
|
381925
382208
|
import { createHash as createHash23 } from "crypto";
|
|
381926
|
-
import { join as
|
|
382209
|
+
import { join as join130 } from "path";
|
|
381927
382210
|
function getWebuiPort() {
|
|
381928
382211
|
return _boundPort;
|
|
381929
382212
|
}
|
|
@@ -381948,7 +382231,7 @@ function broadcastNewWindow(label) {
|
|
|
381948
382231
|
}
|
|
381949
382232
|
}
|
|
381950
382233
|
async function listInstances() {
|
|
381951
|
-
const sessionsDir =
|
|
382234
|
+
const sessionsDir = join130(getClaudeConfigHomeDir(), "sessions");
|
|
381952
382235
|
const out = [];
|
|
381953
382236
|
let files;
|
|
381954
382237
|
try {
|
|
@@ -381965,7 +382248,7 @@ async function listInstances() {
|
|
|
381965
382248
|
let cwd2;
|
|
381966
382249
|
let port;
|
|
381967
382250
|
try {
|
|
381968
|
-
const raw = await
|
|
382251
|
+
const raw = await readFile55(join130(sessionsDir, f), "utf-8");
|
|
381969
382252
|
const parsed = JSON.parse(raw);
|
|
381970
382253
|
cwd2 = parsed.cwd;
|
|
381971
382254
|
port = parsed.webuiPort;
|
|
@@ -381976,8 +382259,8 @@ async function listInstances() {
|
|
|
381976
382259
|
}
|
|
381977
382260
|
async function ensureStaticHtml() {
|
|
381978
382261
|
try {
|
|
381979
|
-
await
|
|
381980
|
-
await
|
|
382262
|
+
await mkdir48(getClaudeConfigHomeDir(), { recursive: true });
|
|
382263
|
+
await writeFile50(WEBUI_HTML_PATH, STATIC_HTML, "utf-8");
|
|
381981
382264
|
} catch {}
|
|
381982
382265
|
}
|
|
381983
382266
|
function decodeFrame(buffer) {
|
|
@@ -382131,7 +382414,7 @@ async function startWebuiServer(port) {
|
|
|
382131
382414
|
_boundPort = addr.port;
|
|
382132
382415
|
_server = server;
|
|
382133
382416
|
logForDebugging(`[webui] listening on http://127.0.0.1:${_boundPort}`);
|
|
382134
|
-
|
|
382417
|
+
mkdir48(getClaudeConfigHomeDir(), { recursive: true }).then(() => writeFile50(PORT_FILE, String(_boundPort), "utf-8").catch(() => {}));
|
|
382135
382418
|
resolve40({ ok: true, port: _boundPort });
|
|
382136
382419
|
} else {
|
|
382137
382420
|
resolve40({ ok: false, error: "no address bound" });
|
|
@@ -382353,8 +382636,8 @@ var DEFAULT_PORT = 7150, PORT_FILE, WEBUI_HTML_PATH, _server = null, _boundPort
|
|
|
382353
382636
|
var init_webuiServer = __esm(() => {
|
|
382354
382637
|
init_debug();
|
|
382355
382638
|
init_envUtils();
|
|
382356
|
-
PORT_FILE =
|
|
382357
|
-
WEBUI_HTML_PATH =
|
|
382639
|
+
PORT_FILE = join130(getClaudeConfigHomeDir(), "webui-port");
|
|
382640
|
+
WEBUI_HTML_PATH = join130(getClaudeConfigHomeDir(), "webui-static.html");
|
|
382358
382641
|
_websockets = new Set;
|
|
382359
382642
|
_outputBuffer = [];
|
|
382360
382643
|
});
|
|
@@ -382717,12 +383000,12 @@ var init_windows_setup2 = __esm(() => {
|
|
|
382717
383000
|
|
|
382718
383001
|
// src/services/rpc/toolRpcServer.ts
|
|
382719
383002
|
import { createServer as createServer6 } from "http";
|
|
382720
|
-
import { readFile as
|
|
383003
|
+
import { readFile as readFile56, writeFile as writeFile51, mkdir as mkdir49, readdir as readdir32, stat as stat47 } from "fs/promises";
|
|
382721
383004
|
import { spawn as spawn12 } from "child_process";
|
|
382722
|
-
import { join as
|
|
383005
|
+
import { join as join131, resolve as resolvePath, relative as relative24 } from "path";
|
|
382723
383006
|
async function handleRead(p) {
|
|
382724
383007
|
try {
|
|
382725
|
-
const raw = await
|
|
383008
|
+
const raw = await readFile56(p.path, "utf-8");
|
|
382726
383009
|
const content = p.maxBytes && raw.length > p.maxBytes ? raw.slice(0, p.maxBytes) : raw;
|
|
382727
383010
|
return { ok: true, data: content };
|
|
382728
383011
|
} catch (e) {
|
|
@@ -382731,7 +383014,7 @@ async function handleRead(p) {
|
|
|
382731
383014
|
}
|
|
382732
383015
|
async function handleWrite(p) {
|
|
382733
383016
|
try {
|
|
382734
|
-
await
|
|
383017
|
+
await writeFile51(p.path, p.content, "utf-8");
|
|
382735
383018
|
return { ok: true, data: { bytes: Buffer.byteLength(p.content, "utf-8") } };
|
|
382736
383019
|
} catch (e) {
|
|
382737
383020
|
return { ok: false, error: String(e) };
|
|
@@ -382739,7 +383022,7 @@ async function handleWrite(p) {
|
|
|
382739
383022
|
}
|
|
382740
383023
|
async function handleEdit(p) {
|
|
382741
383024
|
try {
|
|
382742
|
-
const content = await
|
|
383025
|
+
const content = await readFile56(p.path, "utf-8");
|
|
382743
383026
|
let updated;
|
|
382744
383027
|
let replacements2 = 0;
|
|
382745
383028
|
if (p.replaceAll) {
|
|
@@ -382758,7 +383041,7 @@ async function handleEdit(p) {
|
|
|
382758
383041
|
updated = content.replace(p.oldString, p.newString);
|
|
382759
383042
|
replacements2 = 1;
|
|
382760
383043
|
}
|
|
382761
|
-
await
|
|
383044
|
+
await writeFile51(p.path, updated, "utf-8");
|
|
382762
383045
|
return { ok: true, data: { replacements: replacements2 } };
|
|
382763
383046
|
} catch (e) {
|
|
382764
383047
|
return { ok: false, error: String(e) };
|
|
@@ -382830,7 +383113,7 @@ async function walk(root2, out, maxEntries) {
|
|
|
382830
383113
|
for (const entry of entries) {
|
|
382831
383114
|
if (out.length >= maxEntries)
|
|
382832
383115
|
return;
|
|
382833
|
-
const full =
|
|
383116
|
+
const full = join131(root2, entry.name);
|
|
382834
383117
|
if (entry.name === "node_modules" || entry.name === ".git" || entry.name === ".next")
|
|
382835
383118
|
continue;
|
|
382836
383119
|
if (entry.isDirectory()) {
|
|
@@ -382871,7 +383154,7 @@ async function handleGrep(p) {
|
|
|
382871
383154
|
const s = await stat47(f);
|
|
382872
383155
|
if (s.size > 5 * 1024 * 1024)
|
|
382873
383156
|
continue;
|
|
382874
|
-
content = await
|
|
383157
|
+
content = await readFile56(f, "utf-8");
|
|
382875
383158
|
} catch {
|
|
382876
383159
|
continue;
|
|
382877
383160
|
}
|
|
@@ -382976,7 +383259,7 @@ async function startToolRpcServer() {
|
|
|
382976
383259
|
_boundPort2 = addr.port;
|
|
382977
383260
|
_server2 = server;
|
|
382978
383261
|
logForDebugging(`[rpc] listening on 127.0.0.1:${_boundPort2}`);
|
|
382979
|
-
|
|
383262
|
+
mkdir49(getClaudeConfigHomeDir(), { recursive: true }).then(() => writeFile51(PORT_FILE2, String(_boundPort2), "utf-8").catch(() => {}));
|
|
382980
383263
|
}
|
|
382981
383264
|
resolve40();
|
|
382982
383265
|
});
|
|
@@ -382989,7 +383272,7 @@ var DEFAULT_PORT2 = 7149, PORT_FILE2, _server2 = null, _boundPort2 = 0;
|
|
|
382989
383272
|
var init_toolRpcServer = __esm(() => {
|
|
382990
383273
|
init_debug();
|
|
382991
383274
|
init_envUtils();
|
|
382992
|
-
PORT_FILE2 =
|
|
383275
|
+
PORT_FILE2 = join131(getClaudeConfigHomeDir(), "rpc-port");
|
|
382993
383276
|
});
|
|
382994
383277
|
|
|
382995
383278
|
// src/commands/rpc/rpc.tsx
|
|
@@ -383899,13 +384182,13 @@ var init_versions2 = __esm(() => {
|
|
|
383899
384182
|
});
|
|
383900
384183
|
|
|
383901
384184
|
// src/components/memory/MemoryFileSelector.tsx
|
|
383902
|
-
import { join as
|
|
384185
|
+
import { join as join132 } from "path";
|
|
383903
384186
|
function MemoryFileSelector({
|
|
383904
384187
|
onSelect,
|
|
383905
384188
|
onCancel
|
|
383906
384189
|
}) {
|
|
383907
384190
|
const existingMemoryFiles = import_react112.use(getMemoryFiles());
|
|
383908
|
-
const projectMemoryPath =
|
|
384191
|
+
const projectMemoryPath = join132(getOriginalCwd(), "LOCALCLAWD.md");
|
|
383909
384192
|
const hasProjectMemory = existingMemoryFiles.some((f) => f.path === projectMemoryPath);
|
|
383910
384193
|
const allMemoryFiles = [
|
|
383911
384194
|
...existingMemoryFiles.filter((f) => f.type !== "AutoMem" && f.type !== "TeamMem" && f.type !== "User" && f.type !== "Managed").map((f) => ({ ...f, exists: true })),
|
|
@@ -383975,10 +384258,10 @@ var init_MemoryFileSelector = __esm(() => {
|
|
|
383975
384258
|
});
|
|
383976
384259
|
|
|
383977
384260
|
// src/components/memory/MemoryUpdateNotification.tsx
|
|
383978
|
-
import { homedir as
|
|
384261
|
+
import { homedir as homedir30 } from "os";
|
|
383979
384262
|
import { relative as relative25 } from "path";
|
|
383980
384263
|
function getRelativeMemoryPath(path12) {
|
|
383981
|
-
const homeDir =
|
|
384264
|
+
const homeDir = homedir30();
|
|
383982
384265
|
const cwd2 = getCwd();
|
|
383983
384266
|
const relativeToHome = path12.startsWith(homeDir) ? "~" + path12.slice(homeDir.length) : null;
|
|
383984
384267
|
const relativeToCwd = path12.startsWith(cwd2) ? "./" + relative25(cwd2, path12) : null;
|
|
@@ -384225,8 +384508,8 @@ var exports_memory = {};
|
|
|
384225
384508
|
__export(exports_memory, {
|
|
384226
384509
|
call: () => call53
|
|
384227
384510
|
});
|
|
384228
|
-
import { mkdir as
|
|
384229
|
-
import { dirname as
|
|
384511
|
+
import { mkdir as mkdir50, writeFile as writeFile52 } from "fs/promises";
|
|
384512
|
+
import { dirname as dirname49 } from "path";
|
|
384230
384513
|
function formatBytes(bytes) {
|
|
384231
384514
|
if (bytes < 1024)
|
|
384232
384515
|
return `${bytes} B`;
|
|
@@ -384273,9 +384556,9 @@ function MemoryCommand({
|
|
|
384273
384556
|
}) {
|
|
384274
384557
|
const handleSelectMemoryFile = async (memoryPath) => {
|
|
384275
384558
|
try {
|
|
384276
|
-
await
|
|
384559
|
+
await mkdir50(dirname49(memoryPath), { recursive: true });
|
|
384277
384560
|
try {
|
|
384278
|
-
await
|
|
384561
|
+
await writeFile52(memoryPath, "", {
|
|
384279
384562
|
encoding: "utf8",
|
|
384280
384563
|
flag: "wx"
|
|
384281
384564
|
});
|
|
@@ -384384,10 +384667,10 @@ var exports_includememory = {};
|
|
|
384384
384667
|
__export(exports_includememory, {
|
|
384385
384668
|
call: () => call54
|
|
384386
384669
|
});
|
|
384387
|
-
import { join as
|
|
384670
|
+
import { join as join133 } from "path";
|
|
384388
384671
|
var MEMORY_GITIGNORE_PATTERNS, call54 = async () => {
|
|
384389
384672
|
const gitignorePaths = [
|
|
384390
|
-
|
|
384673
|
+
join133(getOriginalCwd(), ".gitignore"),
|
|
384391
384674
|
getGlobalGitignorePath()
|
|
384392
384675
|
];
|
|
384393
384676
|
const results = await Promise.all(gitignorePaths.map((path12) => removeGitignoreRulesFromFile(path12, MEMORY_GITIGNORE_PATTERNS)));
|
|
@@ -385250,7 +385533,7 @@ function Help(t0) {
|
|
|
385250
385533
|
let t6;
|
|
385251
385534
|
if ($2[31] !== tabs) {
|
|
385252
385535
|
t6 = /* @__PURE__ */ jsx_dev_runtime218.jsxDEV(Tabs, {
|
|
385253
|
-
title: `localclawd v${"2.
|
|
385536
|
+
title: `localclawd v${"2.3.1"}`,
|
|
385254
385537
|
color: "professionalBlue",
|
|
385255
385538
|
defaultTab: "general",
|
|
385256
385539
|
children: tabs
|
|
@@ -386628,8 +386911,8 @@ var exports_keybindings = {};
|
|
|
386628
386911
|
__export(exports_keybindings, {
|
|
386629
386912
|
call: () => call57
|
|
386630
386913
|
});
|
|
386631
|
-
import { mkdir as
|
|
386632
|
-
import { dirname as
|
|
386914
|
+
import { mkdir as mkdir51, writeFile as writeFile53 } from "fs/promises";
|
|
386915
|
+
import { dirname as dirname50 } from "path";
|
|
386633
386916
|
async function call57() {
|
|
386634
386917
|
if (!isKeybindingCustomizationEnabled()) {
|
|
386635
386918
|
return {
|
|
@@ -386639,9 +386922,9 @@ async function call57() {
|
|
|
386639
386922
|
}
|
|
386640
386923
|
const keybindingsPath = getKeybindingsPath();
|
|
386641
386924
|
let fileExists = false;
|
|
386642
|
-
await
|
|
386925
|
+
await mkdir51(dirname50(keybindingsPath), { recursive: true });
|
|
386643
386926
|
try {
|
|
386644
|
-
await
|
|
386927
|
+
await writeFile53(keybindingsPath, generateKeybindingsTemplate(), {
|
|
386645
386928
|
encoding: "utf-8",
|
|
386646
386929
|
flag: "wx"
|
|
386647
386930
|
});
|
|
@@ -390951,7 +391234,7 @@ __export(exports_pluginStartupCheck, {
|
|
|
390951
391234
|
findMissingPlugins: () => findMissingPlugins,
|
|
390952
391235
|
checkEnabledPlugins: () => checkEnabledPlugins
|
|
390953
391236
|
});
|
|
390954
|
-
import { join as
|
|
391237
|
+
import { join as join134 } from "path";
|
|
390955
391238
|
async function checkEnabledPlugins() {
|
|
390956
391239
|
const settings = getInitialSettings();
|
|
390957
391240
|
const enabledPlugins = [];
|
|
@@ -391086,7 +391369,7 @@ async function installSelectedPlugins(pluginsToInstall, onProgress, scope = "use
|
|
|
391086
391369
|
} else {
|
|
391087
391370
|
registerPluginInstallation({
|
|
391088
391371
|
pluginId,
|
|
391089
|
-
installPath:
|
|
391372
|
+
installPath: join134(marketplaceInstallLocation, entry.source),
|
|
391090
391373
|
version: entry.version
|
|
391091
391374
|
}, scope, projectPath);
|
|
391092
391375
|
}
|
|
@@ -391118,7 +391401,7 @@ var init_pluginStartupCheck = __esm(() => {
|
|
|
391118
391401
|
});
|
|
391119
391402
|
|
|
391120
391403
|
// src/utils/plugins/parseMarketplaceInput.ts
|
|
391121
|
-
import { homedir as
|
|
391404
|
+
import { homedir as homedir31 } from "os";
|
|
391122
391405
|
import { resolve as resolve40 } from "path";
|
|
391123
391406
|
async function parseMarketplaceInput(input) {
|
|
391124
391407
|
const trimmed = input.trim();
|
|
@@ -391154,7 +391437,7 @@ async function parseMarketplaceInput(input) {
|
|
|
391154
391437
|
const isWindows3 = process.platform === "win32";
|
|
391155
391438
|
const isWindowsPath = isWindows3 && (trimmed.startsWith(".\\") || trimmed.startsWith("..\\") || /^[a-zA-Z]:[/\\]/.test(trimmed));
|
|
391156
391439
|
if (trimmed.startsWith("./") || trimmed.startsWith("../") || trimmed.startsWith("/") || trimmed.startsWith("~") || isWindowsPath) {
|
|
391157
|
-
const resolvedPath = resolve40(trimmed.startsWith("~") ? trimmed.replace(/^~/,
|
|
391440
|
+
const resolvedPath = resolve40(trimmed.startsWith("~") ? trimmed.replace(/^~/, homedir31()) : trimmed);
|
|
391158
391441
|
let stats;
|
|
391159
391442
|
try {
|
|
391160
391443
|
stats = await fs4.stat(resolvedPath);
|
|
@@ -391404,15 +391687,15 @@ var init_AddMarketplace = __esm(() => {
|
|
|
391404
391687
|
|
|
391405
391688
|
// src/utils/plugins/installCounts.ts
|
|
391406
391689
|
import { randomBytes as randomBytes17 } from "crypto";
|
|
391407
|
-
import { readFile as
|
|
391408
|
-
import { join as
|
|
391690
|
+
import { readFile as readFile57, rename as rename7, unlink as unlink17, writeFile as writeFile54 } from "fs/promises";
|
|
391691
|
+
import { join as join135 } from "path";
|
|
391409
391692
|
function getInstallCountsCachePath() {
|
|
391410
|
-
return
|
|
391693
|
+
return join135(getPluginsDirectory(), INSTALL_COUNTS_CACHE_FILENAME);
|
|
391411
391694
|
}
|
|
391412
391695
|
async function loadInstallCountsCache() {
|
|
391413
391696
|
const cachePath = getInstallCountsCachePath();
|
|
391414
391697
|
try {
|
|
391415
|
-
const content = await
|
|
391698
|
+
const content = await readFile57(cachePath, { encoding: "utf-8" });
|
|
391416
391699
|
const parsed = jsonParse(content);
|
|
391417
391700
|
if (typeof parsed !== "object" || parsed === null || !("version" in parsed) || !("fetchedAt" in parsed) || !("counts" in parsed)) {
|
|
391418
391701
|
logForDebugging("Install counts cache has invalid structure");
|
|
@@ -391462,7 +391745,7 @@ async function saveInstallCountsCache(cache3) {
|
|
|
391462
391745
|
const pluginsDir = getPluginsDirectory();
|
|
391463
391746
|
await getFsImplementation().mkdir(pluginsDir);
|
|
391464
391747
|
const content = jsonStringify(cache3, null, 2);
|
|
391465
|
-
await
|
|
391748
|
+
await writeFile54(tempPath, content, {
|
|
391466
391749
|
encoding: "utf-8",
|
|
391467
391750
|
mode: 384
|
|
391468
391751
|
});
|
|
@@ -394149,7 +394432,7 @@ var init_DiscoverPlugins = __esm(() => {
|
|
|
394149
394432
|
});
|
|
394150
394433
|
|
|
394151
394434
|
// src/services/plugins/pluginOperations.ts
|
|
394152
|
-
import { dirname as
|
|
394435
|
+
import { dirname as dirname51, join as join136 } from "path";
|
|
394153
394436
|
function assertInstallableScope(scope) {
|
|
394154
394437
|
if (!VALID_INSTALLABLE_SCOPES.includes(scope)) {
|
|
394155
394438
|
throw new Error(`Invalid scope "${scope}". Must be one of: ${VALID_INSTALLABLE_SCOPES.join(", ")}`);
|
|
@@ -394626,8 +394909,8 @@ async function performPluginUpdate({
|
|
|
394626
394909
|
}
|
|
394627
394910
|
throw e;
|
|
394628
394911
|
}
|
|
394629
|
-
const marketplaceDir = marketplaceStats.isDirectory() ? marketplaceInstallLocation :
|
|
394630
|
-
sourcePath =
|
|
394912
|
+
const marketplaceDir = marketplaceStats.isDirectory() ? marketplaceInstallLocation : dirname51(marketplaceInstallLocation);
|
|
394913
|
+
sourcePath = join136(marketplaceDir, entry.source);
|
|
394631
394914
|
try {
|
|
394632
394915
|
await fs4.stat(sourcePath);
|
|
394633
394916
|
} catch (e) {
|
|
@@ -394642,7 +394925,7 @@ async function performPluginUpdate({
|
|
|
394642
394925
|
throw e;
|
|
394643
394926
|
}
|
|
394644
394927
|
let pluginManifest;
|
|
394645
|
-
const manifestPath =
|
|
394928
|
+
const manifestPath = join136(sourcePath, ".claude-plugin", "plugin.json");
|
|
394646
394929
|
try {
|
|
394647
394930
|
pluginManifest = await loadPluginManifest(manifestPath, entry.name, entry.source);
|
|
394648
394931
|
} catch {}
|
|
@@ -395859,10 +396142,10 @@ var init_ManageMarketplaces = __esm(() => {
|
|
|
395859
396142
|
|
|
395860
396143
|
// src/utils/plugins/pluginFlagging.ts
|
|
395861
396144
|
import { randomBytes as randomBytes18 } from "crypto";
|
|
395862
|
-
import { readFile as
|
|
395863
|
-
import { join as
|
|
396145
|
+
import { readFile as readFile58, rename as rename8, unlink as unlink18, writeFile as writeFile55 } from "fs/promises";
|
|
396146
|
+
import { join as join137 } from "path";
|
|
395864
396147
|
function getFlaggedPluginsPath() {
|
|
395865
|
-
return
|
|
396148
|
+
return join137(getPluginsDirectory(), FLAGGED_PLUGINS_FILENAME);
|
|
395866
396149
|
}
|
|
395867
396150
|
function parsePluginsData(content) {
|
|
395868
396151
|
const parsed = jsonParse(content);
|
|
@@ -395886,7 +396169,7 @@ function parsePluginsData(content) {
|
|
|
395886
396169
|
}
|
|
395887
396170
|
async function readFromDisk() {
|
|
395888
396171
|
try {
|
|
395889
|
-
const content = await
|
|
396172
|
+
const content = await readFile58(getFlaggedPluginsPath(), {
|
|
395890
396173
|
encoding: "utf-8"
|
|
395891
396174
|
});
|
|
395892
396175
|
return parsePluginsData(content);
|
|
@@ -395900,7 +396183,7 @@ async function writeToDisk(plugins) {
|
|
|
395900
396183
|
try {
|
|
395901
396184
|
await getFsImplementation().mkdir(getPluginsDirectory());
|
|
395902
396185
|
const content = jsonStringify({ plugins }, null, 2);
|
|
395903
|
-
await
|
|
396186
|
+
await writeFile55(tempPath, content, {
|
|
395904
396187
|
encoding: "utf-8",
|
|
395905
396188
|
mode: 384
|
|
395906
396189
|
});
|
|
@@ -399154,7 +399437,7 @@ function parsePluginArgs(args) {
|
|
|
399154
399437
|
}
|
|
399155
399438
|
|
|
399156
399439
|
// src/utils/plugins/validatePlugin.ts
|
|
399157
|
-
import { readdir as readdir34, readFile as
|
|
399440
|
+
import { readdir as readdir34, readFile as readFile60, stat as stat49 } from "fs/promises";
|
|
399158
399441
|
import * as path14 from "path";
|
|
399159
399442
|
import { z as z77 } from "zod/v4";
|
|
399160
399443
|
function detectManifestType(filePath) {
|
|
@@ -399195,7 +399478,7 @@ async function validatePluginManifest(filePath) {
|
|
|
399195
399478
|
const absolutePath = path14.resolve(filePath);
|
|
399196
399479
|
let content;
|
|
399197
399480
|
try {
|
|
399198
|
-
content = await
|
|
399481
|
+
content = await readFile60(absolutePath, { encoding: "utf-8" });
|
|
399199
399482
|
} catch (error5) {
|
|
399200
399483
|
const code = getErrnoCode(error5);
|
|
399201
399484
|
let message;
|
|
@@ -399319,7 +399602,7 @@ async function validateMarketplaceManifest(filePath) {
|
|
|
399319
399602
|
const absolutePath = path14.resolve(filePath);
|
|
399320
399603
|
let content;
|
|
399321
399604
|
try {
|
|
399322
|
-
content = await
|
|
399605
|
+
content = await readFile60(absolutePath, { encoding: "utf-8" });
|
|
399323
399606
|
} catch (error5) {
|
|
399324
399607
|
const code = getErrnoCode(error5);
|
|
399325
399608
|
let message;
|
|
@@ -399405,7 +399688,7 @@ async function validateMarketplaceManifest(filePath) {
|
|
|
399405
399688
|
const pluginJsonPath = path14.join(marketplaceRoot, entry.source, ".claude-plugin", "plugin.json");
|
|
399406
399689
|
let manifestVersion;
|
|
399407
399690
|
try {
|
|
399408
|
-
const raw = await
|
|
399691
|
+
const raw = await readFile60(pluginJsonPath, { encoding: "utf-8" });
|
|
399409
399692
|
const parsed2 = jsonParse(raw);
|
|
399410
399693
|
if (typeof parsed2.version === "string") {
|
|
399411
399694
|
manifestVersion = parsed2.version;
|
|
@@ -399522,7 +399805,7 @@ function validateComponentFile(filePath, content, fileType) {
|
|
|
399522
399805
|
async function validateHooksJson(filePath) {
|
|
399523
399806
|
let content;
|
|
399524
399807
|
try {
|
|
399525
|
-
content = await
|
|
399808
|
+
content = await readFile60(filePath, { encoding: "utf-8" });
|
|
399526
399809
|
} catch (e) {
|
|
399527
399810
|
const code = getErrnoCode(e);
|
|
399528
399811
|
if (code === "ENOENT") {
|
|
@@ -399615,7 +399898,7 @@ async function validatePluginContents(pluginDir) {
|
|
|
399615
399898
|
for (const filePath of files) {
|
|
399616
399899
|
let content;
|
|
399617
399900
|
try {
|
|
399618
|
-
content = await
|
|
399901
|
+
content = await readFile60(filePath, { encoding: "utf-8" });
|
|
399619
399902
|
} catch (e) {
|
|
399620
399903
|
if (isENOENT(e))
|
|
399621
399904
|
continue;
|
|
@@ -399684,7 +399967,7 @@ async function validateManifest2(filePath) {
|
|
|
399684
399967
|
return validateMarketplaceManifest(filePath);
|
|
399685
399968
|
case "unknown": {
|
|
399686
399969
|
try {
|
|
399687
|
-
const content = await
|
|
399970
|
+
const content = await readFile60(absolutePath, { encoding: "utf-8" });
|
|
399688
399971
|
const parsed = jsonParse(content);
|
|
399689
399972
|
if (Array.isArray(parsed.plugins)) {
|
|
399690
399973
|
return validateMarketplaceManifest(filePath);
|
|
@@ -402409,10 +402692,10 @@ var init_transcriptSearch = __esm(() => {
|
|
|
402409
402692
|
});
|
|
402410
402693
|
|
|
402411
402694
|
// src/utils/releaseNotes.ts
|
|
402412
|
-
import { mkdir as
|
|
402413
|
-
import { dirname as
|
|
402695
|
+
import { mkdir as mkdir52, readFile as readFile61, writeFile as writeFile56 } from "fs/promises";
|
|
402696
|
+
import { dirname as dirname53, join as join140 } from "path";
|
|
402414
402697
|
function getChangelogCachePath() {
|
|
402415
|
-
return
|
|
402698
|
+
return join140(getClaudeConfigHomeDir(), "cache", "changelog.md");
|
|
402416
402699
|
}
|
|
402417
402700
|
async function migrateChangelogFromConfig() {
|
|
402418
402701
|
const config2 = getGlobalConfig();
|
|
@@ -402421,8 +402704,8 @@ async function migrateChangelogFromConfig() {
|
|
|
402421
402704
|
}
|
|
402422
402705
|
const cachePath = getChangelogCachePath();
|
|
402423
402706
|
try {
|
|
402424
|
-
await
|
|
402425
|
-
await
|
|
402707
|
+
await mkdir52(dirname53(cachePath), { recursive: true });
|
|
402708
|
+
await writeFile56(cachePath, config2.cachedChangelog, {
|
|
402426
402709
|
encoding: "utf-8",
|
|
402427
402710
|
flag: "wx"
|
|
402428
402711
|
});
|
|
@@ -402443,8 +402726,8 @@ async function fetchAndStoreChangelog() {
|
|
|
402443
402726
|
return;
|
|
402444
402727
|
}
|
|
402445
402728
|
const cachePath = getChangelogCachePath();
|
|
402446
|
-
await
|
|
402447
|
-
await
|
|
402729
|
+
await mkdir52(dirname53(cachePath), { recursive: true });
|
|
402730
|
+
await writeFile56(cachePath, changelogContent, { encoding: "utf-8" });
|
|
402448
402731
|
changelogMemoryCache = changelogContent;
|
|
402449
402732
|
const changelogLastFetched = Date.now();
|
|
402450
402733
|
saveGlobalConfig((current) => ({
|
|
@@ -402459,7 +402742,7 @@ async function getStoredChangelog() {
|
|
|
402459
402742
|
}
|
|
402460
402743
|
const cachePath = getChangelogCachePath();
|
|
402461
402744
|
try {
|
|
402462
|
-
const content = await
|
|
402745
|
+
const content = await readFile61(cachePath, "utf-8");
|
|
402463
402746
|
changelogMemoryCache = content;
|
|
402464
402747
|
return content;
|
|
402465
402748
|
} catch {
|
|
@@ -402512,7 +402795,7 @@ function getRecentReleaseNotes(currentVersion, previousVersion, changelogContent
|
|
|
402512
402795
|
}
|
|
402513
402796
|
return [];
|
|
402514
402797
|
}
|
|
402515
|
-
async function checkForReleaseNotes(lastSeenVersion, currentVersion = "2.
|
|
402798
|
+
async function checkForReleaseNotes(lastSeenVersion, currentVersion = "2.3.1") {
|
|
402516
402799
|
if (process.env.USER_TYPE === "ant") {
|
|
402517
402800
|
const changelog = MACRO.VERSION_CHANGELOG;
|
|
402518
402801
|
if (changelog) {
|
|
@@ -402539,7 +402822,7 @@ async function checkForReleaseNotes(lastSeenVersion, currentVersion = "2.2.6") {
|
|
|
402539
402822
|
releaseNotes
|
|
402540
402823
|
};
|
|
402541
402824
|
}
|
|
402542
|
-
function checkForReleaseNotesSync(lastSeenVersion, currentVersion = "2.
|
|
402825
|
+
function checkForReleaseNotesSync(lastSeenVersion, currentVersion = "2.3.1") {
|
|
402543
402826
|
if (process.env.USER_TYPE === "ant") {
|
|
402544
402827
|
const changelog = MACRO.VERSION_CHANGELOG;
|
|
402545
402828
|
if (changelog) {
|
|
@@ -402696,7 +402979,7 @@ function getRecentActivitySync() {
|
|
|
402696
402979
|
return cachedActivity;
|
|
402697
402980
|
}
|
|
402698
402981
|
function getLogoDisplayData() {
|
|
402699
|
-
const version = process.env.DEMO_VERSION ?? "2.
|
|
402982
|
+
const version = process.env.DEMO_VERSION ?? "2.3.1";
|
|
402700
402983
|
const serverUrl = getDirectConnectServerUrl();
|
|
402701
402984
|
const displayPath = process.env.DEMO_VERSION ? "/code/claude" : getDisplayPath(getCwd());
|
|
402702
402985
|
const cwd2 = serverUrl ? `${displayPath} in ${serverUrl.replace(/^https?:\/\//, "")}` : displayPath;
|
|
@@ -403202,7 +403485,7 @@ var init_referral = __esm(() => {
|
|
|
403202
403485
|
});
|
|
403203
403486
|
|
|
403204
403487
|
// src/components/Logo/feedConfigs.tsx
|
|
403205
|
-
import { homedir as
|
|
403488
|
+
import { homedir as homedir32 } from "os";
|
|
403206
403489
|
function createRecentActivityFeed(activities) {
|
|
403207
403490
|
const lines = activities.map((log2) => {
|
|
403208
403491
|
const time = formatRelativeTimeAgo(log2.modified);
|
|
@@ -403247,7 +403530,7 @@ function createProjectOnboardingFeed(steps) {
|
|
|
403247
403530
|
text: `${checkmark}${text}`
|
|
403248
403531
|
};
|
|
403249
403532
|
});
|
|
403250
|
-
const warningText = getCwd() ===
|
|
403533
|
+
const warningText = getCwd() === homedir32() ? "Note: You have launched claude in your home directory. For the best experience, launch it in a project directory instead." : undefined;
|
|
403251
403534
|
if (warningText) {
|
|
403252
403535
|
lines.push({
|
|
403253
403536
|
text: warningText
|
|
@@ -403796,7 +404079,7 @@ function Logo() {
|
|
|
403796
404079
|
if ($2[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
403797
404080
|
t2 = () => {
|
|
403798
404081
|
const currentConfig = getGlobalConfig();
|
|
403799
|
-
if (currentConfig.lastReleaseNotesSeen === "2.
|
|
404082
|
+
if (currentConfig.lastReleaseNotesSeen === "2.3.1") {
|
|
403800
404083
|
return;
|
|
403801
404084
|
}
|
|
403802
404085
|
saveGlobalConfig(_temp325);
|
|
@@ -404455,12 +404738,12 @@ function Logo() {
|
|
|
404455
404738
|
return t41;
|
|
404456
404739
|
}
|
|
404457
404740
|
function _temp325(current) {
|
|
404458
|
-
if (current.lastReleaseNotesSeen === "2.
|
|
404741
|
+
if (current.lastReleaseNotesSeen === "2.3.1") {
|
|
404459
404742
|
return current;
|
|
404460
404743
|
}
|
|
404461
404744
|
return {
|
|
404462
404745
|
...current,
|
|
404463
|
-
lastReleaseNotesSeen: "2.
|
|
404746
|
+
lastReleaseNotesSeen: "2.3.1"
|
|
404464
404747
|
};
|
|
404465
404748
|
}
|
|
404466
404749
|
function _temp240(s_0) {
|
|
@@ -421817,8 +422100,8 @@ __export(exports_thinkback, {
|
|
|
421817
422100
|
call: () => call70
|
|
421818
422101
|
});
|
|
421819
422102
|
import { execa as execa11 } from "execa";
|
|
421820
|
-
import { readFile as
|
|
421821
|
-
import { join as
|
|
422103
|
+
import { readFile as readFile62 } from "fs/promises";
|
|
422104
|
+
import { join as join141 } from "path";
|
|
421822
422105
|
function getMarketplaceName() {
|
|
421823
422106
|
return OFFICIAL_MARKETPLACE_NAME;
|
|
421824
422107
|
}
|
|
@@ -421836,17 +422119,17 @@ async function getThinkbackSkillDir() {
|
|
|
421836
422119
|
if (!thinkbackPlugin) {
|
|
421837
422120
|
return null;
|
|
421838
422121
|
}
|
|
421839
|
-
const skillDir =
|
|
422122
|
+
const skillDir = join141(thinkbackPlugin.path, "skills", SKILL_NAME);
|
|
421840
422123
|
if (await pathExists(skillDir)) {
|
|
421841
422124
|
return skillDir;
|
|
421842
422125
|
}
|
|
421843
422126
|
return null;
|
|
421844
422127
|
}
|
|
421845
422128
|
async function playAnimation(skillDir) {
|
|
421846
|
-
const dataPath =
|
|
421847
|
-
const playerPath =
|
|
422129
|
+
const dataPath = join141(skillDir, "year_in_review.js");
|
|
422130
|
+
const playerPath = join141(skillDir, "player.js");
|
|
421848
422131
|
try {
|
|
421849
|
-
await
|
|
422132
|
+
await readFile62(dataPath);
|
|
421850
422133
|
} catch (e) {
|
|
421851
422134
|
if (isENOENT(e)) {
|
|
421852
422135
|
return {
|
|
@@ -421861,7 +422144,7 @@ async function playAnimation(skillDir) {
|
|
|
421861
422144
|
};
|
|
421862
422145
|
}
|
|
421863
422146
|
try {
|
|
421864
|
-
await
|
|
422147
|
+
await readFile62(playerPath);
|
|
421865
422148
|
} catch (e) {
|
|
421866
422149
|
if (isENOENT(e)) {
|
|
421867
422150
|
return {
|
|
@@ -421892,7 +422175,7 @@ async function playAnimation(skillDir) {
|
|
|
421892
422175
|
} catch {} finally {
|
|
421893
422176
|
inkInstance.exitAlternateScreen();
|
|
421894
422177
|
}
|
|
421895
|
-
const htmlPath =
|
|
422178
|
+
const htmlPath = join141(skillDir, "year_in_review.html");
|
|
421896
422179
|
if (await pathExists(htmlPath)) {
|
|
421897
422180
|
const platform3 = getPlatform();
|
|
421898
422181
|
const openCmd = platform3 === "macos" ? "open" : platform3 === "windows" ? "start" : "xdg-open";
|
|
@@ -422228,7 +422511,7 @@ function ThinkbackFlow(t0) {
|
|
|
422228
422511
|
if (!skillDir) {
|
|
422229
422512
|
return;
|
|
422230
422513
|
}
|
|
422231
|
-
const dataPath =
|
|
422514
|
+
const dataPath = join141(skillDir, "year_in_review.js");
|
|
422232
422515
|
pathExists(dataPath).then((exists) => {
|
|
422233
422516
|
logForDebugging(`Checking for ${dataPath}: ${exists ? "found" : "not found"}`);
|
|
422234
422517
|
setHasGenerated(exists);
|
|
@@ -422399,7 +422682,7 @@ var exports_thinkback_play = {};
|
|
|
422399
422682
|
__export(exports_thinkback_play, {
|
|
422400
422683
|
call: () => call71
|
|
422401
422684
|
});
|
|
422402
|
-
import { join as
|
|
422685
|
+
import { join as join142 } from "path";
|
|
422403
422686
|
function getPluginId2() {
|
|
422404
422687
|
const marketplaceName = process.env.USER_TYPE === "ant" ? INTERNAL_MARKETPLACE_NAME : OFFICIAL_MARKETPLACE_NAME;
|
|
422405
422688
|
return `thinkback@${marketplaceName}`;
|
|
@@ -422421,7 +422704,7 @@ async function call71() {
|
|
|
422421
422704
|
value: "Thinkback plugin installation path not found."
|
|
422422
422705
|
};
|
|
422423
422706
|
}
|
|
422424
|
-
const skillDir =
|
|
422707
|
+
const skillDir = join142(firstInstall.installPath, "skills", SKILL_NAME2);
|
|
422425
422708
|
const result = await playAnimation(skillDir);
|
|
422426
422709
|
return { type: "text", value: result.message };
|
|
422427
422710
|
}
|
|
@@ -428456,7 +428739,7 @@ __export(exports_branch, {
|
|
|
428456
428739
|
call: () => call79
|
|
428457
428740
|
});
|
|
428458
428741
|
import { randomUUID as randomUUID28 } from "crypto";
|
|
428459
|
-
import { mkdir as
|
|
428742
|
+
import { mkdir as mkdir53, readFile as readFile63, writeFile as writeFile57 } from "fs/promises";
|
|
428460
428743
|
function deriveFirstPrompt(firstUserMessage) {
|
|
428461
428744
|
const content = firstUserMessage?.message?.content;
|
|
428462
428745
|
if (!content)
|
|
@@ -428472,10 +428755,10 @@ async function createFork(customTitle) {
|
|
|
428472
428755
|
const projectDir = getProjectDir2(getOriginalCwd());
|
|
428473
428756
|
const forkSessionPath = getTranscriptPathForSession(forkSessionId);
|
|
428474
428757
|
const currentTranscriptPath = getTranscriptPath();
|
|
428475
|
-
await
|
|
428758
|
+
await mkdir53(projectDir, { recursive: true, mode: 448 });
|
|
428476
428759
|
let transcriptContent;
|
|
428477
428760
|
try {
|
|
428478
|
-
transcriptContent = await
|
|
428761
|
+
transcriptContent = await readFile63(currentTranscriptPath);
|
|
428479
428762
|
} catch {
|
|
428480
428763
|
throw new Error("No conversation to branch");
|
|
428481
428764
|
}
|
|
@@ -428520,7 +428803,7 @@ async function createFork(customTitle) {
|
|
|
428520
428803
|
};
|
|
428521
428804
|
lines.push(jsonStringify(forkedReplacementEntry));
|
|
428522
428805
|
}
|
|
428523
|
-
await
|
|
428806
|
+
await writeFile57(forkSessionPath, lines.join(`
|
|
428524
428807
|
`) + `
|
|
428525
428808
|
`, {
|
|
428526
428809
|
encoding: "utf8",
|
|
@@ -428782,8 +429065,8 @@ var init_types11 = __esm(() => {
|
|
|
428782
429065
|
});
|
|
428783
429066
|
|
|
428784
429067
|
// src/components/agents/agentFileUtils.ts
|
|
428785
|
-
import { mkdir as
|
|
428786
|
-
import { join as
|
|
429068
|
+
import { mkdir as mkdir54, open as open12, unlink as unlink19 } from "fs/promises";
|
|
429069
|
+
import { join as join143 } from "path";
|
|
428787
429070
|
function formatAgentAsMarkdown(agentType, whenToUse, tools, systemPrompt, color3, model, memory2, effort) {
|
|
428788
429071
|
const escapedWhenToUse = whenToUse.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\n/g, "\\\\n");
|
|
428789
429072
|
const isAllTools = tools === undefined || tools.length === 1 && tools[0] === "*";
|
|
@@ -428810,26 +429093,26 @@ function getAgentDirectoryPath(location) {
|
|
|
428810
429093
|
case "flagSettings":
|
|
428811
429094
|
throw new Error(`Cannot get directory path for ${location} agents`);
|
|
428812
429095
|
case "userSettings":
|
|
428813
|
-
return
|
|
429096
|
+
return join143(getClaudeConfigHomeDir(), AGENT_PATHS.AGENTS_DIR);
|
|
428814
429097
|
case "projectSettings":
|
|
428815
|
-
return
|
|
429098
|
+
return join143(getCwd(), AGENT_PATHS.FOLDER_NAME, AGENT_PATHS.AGENTS_DIR);
|
|
428816
429099
|
case "policySettings":
|
|
428817
|
-
return
|
|
429100
|
+
return join143(getManagedFilePath(), AGENT_PATHS.FOLDER_NAME, AGENT_PATHS.AGENTS_DIR);
|
|
428818
429101
|
case "localSettings":
|
|
428819
|
-
return
|
|
429102
|
+
return join143(getCwd(), AGENT_PATHS.FOLDER_NAME, AGENT_PATHS.AGENTS_DIR);
|
|
428820
429103
|
}
|
|
428821
429104
|
}
|
|
428822
429105
|
function getRelativeAgentDirectoryPath(location) {
|
|
428823
429106
|
switch (location) {
|
|
428824
429107
|
case "projectSettings":
|
|
428825
|
-
return
|
|
429108
|
+
return join143(".", AGENT_PATHS.FOLDER_NAME, AGENT_PATHS.AGENTS_DIR);
|
|
428826
429109
|
default:
|
|
428827
429110
|
return getAgentDirectoryPath(location);
|
|
428828
429111
|
}
|
|
428829
429112
|
}
|
|
428830
429113
|
function getNewAgentFilePath(agent) {
|
|
428831
429114
|
const dirPath = getAgentDirectoryPath(agent.source);
|
|
428832
|
-
return
|
|
429115
|
+
return join143(dirPath, `${agent.agentType}.md`);
|
|
428833
429116
|
}
|
|
428834
429117
|
function getActualAgentFilePath(agent) {
|
|
428835
429118
|
if (agent.source === "built-in") {
|
|
@@ -428840,14 +429123,14 @@ function getActualAgentFilePath(agent) {
|
|
|
428840
429123
|
}
|
|
428841
429124
|
const dirPath = getAgentDirectoryPath(agent.source);
|
|
428842
429125
|
const filename = agent.filename || agent.agentType;
|
|
428843
|
-
return
|
|
429126
|
+
return join143(dirPath, `${filename}.md`);
|
|
428844
429127
|
}
|
|
428845
429128
|
function getNewRelativeAgentFilePath(agent) {
|
|
428846
429129
|
if (agent.source === "built-in") {
|
|
428847
429130
|
return "Built-in";
|
|
428848
429131
|
}
|
|
428849
429132
|
const dirPath = getRelativeAgentDirectoryPath(agent.source);
|
|
428850
|
-
return
|
|
429133
|
+
return join143(dirPath, `${agent.agentType}.md`);
|
|
428851
429134
|
}
|
|
428852
429135
|
function getActualRelativeAgentFilePath(agent) {
|
|
428853
429136
|
if (isBuiltInAgent(agent)) {
|
|
@@ -428861,11 +429144,11 @@ function getActualRelativeAgentFilePath(agent) {
|
|
|
428861
429144
|
}
|
|
428862
429145
|
const dirPath = getRelativeAgentDirectoryPath(agent.source);
|
|
428863
429146
|
const filename = agent.filename || agent.agentType;
|
|
428864
|
-
return
|
|
429147
|
+
return join143(dirPath, `${filename}.md`);
|
|
428865
429148
|
}
|
|
428866
429149
|
async function ensureAgentDirectoryExists(source) {
|
|
428867
429150
|
const dirPath = getAgentDirectoryPath(source);
|
|
428868
|
-
await
|
|
429151
|
+
await mkdir54(dirPath, { recursive: true });
|
|
428869
429152
|
return dirPath;
|
|
428870
429153
|
}
|
|
428871
429154
|
async function saveAgentToFile(source, agentType, whenToUse, tools, systemPrompt, checkExists = true, color3, model, memory2, effort) {
|
|
@@ -434828,8 +435111,8 @@ var init_rewind = __esm(() => {
|
|
|
434828
435111
|
|
|
434829
435112
|
// src/utils/heapDumpService.ts
|
|
434830
435113
|
import { createWriteStream as createWriteStream2, writeFileSync as writeFileSync4 } from "fs";
|
|
434831
|
-
import { readdir as readdir35, readFile as
|
|
434832
|
-
import { join as
|
|
435114
|
+
import { readdir as readdir35, readFile as readFile64, writeFile as writeFile58 } from "fs/promises";
|
|
435115
|
+
import { join as join144 } from "path";
|
|
434833
435116
|
import { pipeline as pipeline2 } from "stream/promises";
|
|
434834
435117
|
import {
|
|
434835
435118
|
getHeapSnapshot,
|
|
@@ -434853,7 +435136,7 @@ async function captureMemoryDiagnostics(trigger, dumpNumber = 0) {
|
|
|
434853
435136
|
} catch {}
|
|
434854
435137
|
let smapsRollup;
|
|
434855
435138
|
try {
|
|
434856
|
-
smapsRollup = await
|
|
435139
|
+
smapsRollup = await readFile64("/proc/self/smaps_rollup", "utf8");
|
|
434857
435140
|
} catch {}
|
|
434858
435141
|
const nativeMemory = usage.rss - usage.heapUsed;
|
|
434859
435142
|
const bytesPerSecond = uptimeSeconds > 0 ? usage.rss / uptimeSeconds : 0;
|
|
@@ -434919,7 +435202,7 @@ async function captureMemoryDiagnostics(trigger, dumpNumber = 0) {
|
|
|
434919
435202
|
smapsRollup,
|
|
434920
435203
|
platform: process.platform,
|
|
434921
435204
|
nodeVersion: process.version,
|
|
434922
|
-
ccVersion: "2.
|
|
435205
|
+
ccVersion: "2.3.1"
|
|
434923
435206
|
};
|
|
434924
435207
|
}
|
|
434925
435208
|
async function performHeapDump(trigger = "manual", dumpNumber = 0) {
|
|
@@ -434937,9 +435220,9 @@ async function performHeapDump(trigger = "manual", dumpNumber = 0) {
|
|
|
434937
435220
|
const suffix = dumpNumber > 0 ? `-dump${dumpNumber}` : "";
|
|
434938
435221
|
const heapFilename = `${sessionId}${suffix}.heapsnapshot`;
|
|
434939
435222
|
const diagFilename = `${sessionId}${suffix}-diagnostics.json`;
|
|
434940
|
-
const heapPath =
|
|
434941
|
-
const diagPath =
|
|
434942
|
-
await
|
|
435223
|
+
const heapPath = join144(dumpDir, heapFilename);
|
|
435224
|
+
const diagPath = join144(dumpDir, diagFilename);
|
|
435225
|
+
await writeFile58(diagPath, jsonStringify(diagnostics, null, 2), {
|
|
434943
435226
|
mode: 384
|
|
434944
435227
|
});
|
|
434945
435228
|
logForDebugging(`[HeapDump] Diagnostics written to ${diagPath}`);
|
|
@@ -435504,7 +435787,7 @@ var init_bridge_kick = __esm(() => {
|
|
|
435504
435787
|
var call86 = async () => {
|
|
435505
435788
|
return {
|
|
435506
435789
|
type: "text",
|
|
435507
|
-
value: `${"2.
|
|
435790
|
+
value: `${"2.3.1"} (built ${"2026-05-10T18:34:55.265Z"})`
|
|
435508
435791
|
};
|
|
435509
435792
|
}, version, version_default;
|
|
435510
435793
|
var init_version = __esm(() => {
|
|
@@ -436871,8 +437154,8 @@ var init_advisor2 = __esm(() => {
|
|
|
436871
437154
|
|
|
436872
437155
|
// src/skills/bundledSkills.ts
|
|
436873
437156
|
import { constants as fsConstants4 } from "fs";
|
|
436874
|
-
import { mkdir as
|
|
436875
|
-
import { dirname as
|
|
437157
|
+
import { mkdir as mkdir55, open as open13 } from "fs/promises";
|
|
437158
|
+
import { dirname as dirname54, isAbsolute as isAbsolute23, join as join145, normalize as normalize12, sep as pathSep2 } from "path";
|
|
436876
437159
|
function registerBundledSkill(definition) {
|
|
436877
437160
|
const { files: files2 } = definition;
|
|
436878
437161
|
let skillRoot;
|
|
@@ -436920,7 +437203,7 @@ function getBundledSkills() {
|
|
|
436920
437203
|
return [...bundledSkills];
|
|
436921
437204
|
}
|
|
436922
437205
|
function getBundledSkillExtractDir(skillName) {
|
|
436923
|
-
return
|
|
437206
|
+
return join145(getBundledSkillsRoot(), skillName);
|
|
436924
437207
|
}
|
|
436925
437208
|
async function extractBundledSkillFiles(skillName, files2) {
|
|
436926
437209
|
const dir = getBundledSkillExtractDir(skillName);
|
|
@@ -436936,7 +437219,7 @@ async function writeSkillFiles(dir, files2) {
|
|
|
436936
437219
|
const byParent = new Map;
|
|
436937
437220
|
for (const [relPath, content] of Object.entries(files2)) {
|
|
436938
437221
|
const target = resolveSkillFilePath(dir, relPath);
|
|
436939
|
-
const parent2 =
|
|
437222
|
+
const parent2 = dirname54(target);
|
|
436940
437223
|
const entry = [target, content];
|
|
436941
437224
|
const group = byParent.get(parent2);
|
|
436942
437225
|
if (group)
|
|
@@ -436945,7 +437228,7 @@ async function writeSkillFiles(dir, files2) {
|
|
|
436945
437228
|
byParent.set(parent2, [entry]);
|
|
436946
437229
|
}
|
|
436947
437230
|
await Promise.all([...byParent].map(async ([parent2, entries]) => {
|
|
436948
|
-
await
|
|
437231
|
+
await mkdir55(parent2, { recursive: true, mode: 448 });
|
|
436949
437232
|
await Promise.all(entries.map(([p, c5]) => safeWriteFile(p, c5)));
|
|
436950
437233
|
}));
|
|
436951
437234
|
}
|
|
@@ -436962,7 +437245,7 @@ function resolveSkillFilePath(baseDir, relPath) {
|
|
|
436962
437245
|
if (isAbsolute23(normalized) || normalized.split(pathSep2).includes("..") || normalized.split("/").includes("..")) {
|
|
436963
437246
|
throw new Error(`bundled skill file path escapes skill dir: ${relPath}`);
|
|
436964
437247
|
}
|
|
436965
|
-
return
|
|
437248
|
+
return join145(baseDir, normalized);
|
|
436966
437249
|
}
|
|
436967
437250
|
function prependBaseDir(blocks, baseDir) {
|
|
436968
437251
|
const prefix = `Base directory for this skill: ${baseDir}
|
|
@@ -437321,7 +437604,7 @@ var init_exit2 = __esm(() => {
|
|
|
437321
437604
|
});
|
|
437322
437605
|
|
|
437323
437606
|
// src/components/ExportDialog.tsx
|
|
437324
|
-
import { join as
|
|
437607
|
+
import { join as join146 } from "path";
|
|
437325
437608
|
function ExportDialog({
|
|
437326
437609
|
content,
|
|
437327
437610
|
defaultFilename,
|
|
@@ -437354,7 +437637,7 @@ function ExportDialog({
|
|
|
437354
437637
|
};
|
|
437355
437638
|
const handleFilenameSubmit = () => {
|
|
437356
437639
|
const finalFilename = filename.endsWith(".txt") ? filename : filename.replace(/\.[^.]+$/, "") + ".txt";
|
|
437357
|
-
const filepath =
|
|
437640
|
+
const filepath = join146(getCwd(), finalFilename);
|
|
437358
437641
|
try {
|
|
437359
437642
|
writeFileSync_DEPRECATED(filepath, content, {
|
|
437360
437643
|
encoding: "utf-8",
|
|
@@ -437577,7 +437860,7 @@ __export(exports_export, {
|
|
|
437577
437860
|
extractFirstPrompt: () => extractFirstPrompt,
|
|
437578
437861
|
call: () => call90
|
|
437579
437862
|
});
|
|
437580
|
-
import { join as
|
|
437863
|
+
import { join as join147 } from "path";
|
|
437581
437864
|
function formatTimestamp(date2) {
|
|
437582
437865
|
const year = date2.getFullYear();
|
|
437583
437866
|
const month = String(date2.getMonth() + 1).padStart(2, "0");
|
|
@@ -437621,7 +437904,7 @@ async function call90(onDone, context7, args) {
|
|
|
437621
437904
|
const filename = args.trim();
|
|
437622
437905
|
if (filename) {
|
|
437623
437906
|
const finalFilename = filename.endsWith(".txt") ? filename : filename.replace(/\.[^.]+$/, "") + ".txt";
|
|
437624
|
-
const filepath =
|
|
437907
|
+
const filepath = join147(getCwd(), finalFilename);
|
|
437625
437908
|
try {
|
|
437626
437909
|
writeFileSync_DEPRECATED(filepath, content, {
|
|
437627
437910
|
encoding: "utf-8",
|
|
@@ -439166,7 +439449,7 @@ var init_asciichart = __esm(() => {
|
|
|
439166
439449
|
// src/utils/statsCache.ts
|
|
439167
439450
|
import { randomBytes as randomBytes19 } from "crypto";
|
|
439168
439451
|
import { open as open14 } from "fs/promises";
|
|
439169
|
-
import { join as
|
|
439452
|
+
import { join as join148 } from "path";
|
|
439170
439453
|
async function withStatsCacheLock(fn) {
|
|
439171
439454
|
while (statsCacheLockPromise) {
|
|
439172
439455
|
await statsCacheLockPromise;
|
|
@@ -439183,7 +439466,7 @@ async function withStatsCacheLock(fn) {
|
|
|
439183
439466
|
}
|
|
439184
439467
|
}
|
|
439185
439468
|
function getStatsCachePath() {
|
|
439186
|
-
return
|
|
439469
|
+
return join148(getClaudeConfigHomeDir(), STATS_CACHE_FILENAME);
|
|
439187
439470
|
}
|
|
439188
439471
|
function getEmptyCache() {
|
|
439189
439472
|
return {
|
|
@@ -439849,16 +440132,16 @@ var init_ansiToPng = __esm(() => {
|
|
|
439849
440132
|
});
|
|
439850
440133
|
|
|
439851
440134
|
// src/utils/screenshotClipboard.ts
|
|
439852
|
-
import { mkdir as
|
|
440135
|
+
import { mkdir as mkdir56, unlink as unlink20, writeFile as writeFile59 } from "fs/promises";
|
|
439853
440136
|
import { tmpdir as tmpdir8 } from "os";
|
|
439854
|
-
import { join as
|
|
440137
|
+
import { join as join149 } from "path";
|
|
439855
440138
|
async function copyAnsiToClipboard(ansiText, options) {
|
|
439856
440139
|
try {
|
|
439857
|
-
const tempDir =
|
|
439858
|
-
await
|
|
439859
|
-
const pngPath =
|
|
440140
|
+
const tempDir = join149(tmpdir8(), "claude-code-screenshots");
|
|
440141
|
+
await mkdir56(tempDir, { recursive: true });
|
|
440142
|
+
const pngPath = join149(tempDir, `screenshot-${Date.now()}.png`);
|
|
439860
440143
|
const pngBuffer = ansiToPng(ansiText, options);
|
|
439861
|
-
await
|
|
440144
|
+
await writeFile59(pngPath, pngBuffer);
|
|
439862
440145
|
const result = await copyPngToClipboard(pngPath);
|
|
439863
440146
|
try {
|
|
439864
440147
|
await unlink20(pngPath);
|
|
@@ -439927,7 +440210,7 @@ var init_screenshotClipboard = __esm(() => {
|
|
|
439927
440210
|
|
|
439928
440211
|
// src/utils/stats.ts
|
|
439929
440212
|
import { open as open15 } from "fs/promises";
|
|
439930
|
-
import { basename as basename42, join as
|
|
440213
|
+
import { basename as basename42, join as join150, sep as sep30 } from "path";
|
|
439931
440214
|
async function processSessionFiles(sessionFiles, options = {}) {
|
|
439932
440215
|
const { fromDate, toDate } = options;
|
|
439933
440216
|
const fs5 = getFsImplementation();
|
|
@@ -440105,17 +440388,17 @@ async function getAllSessionFiles() {
|
|
|
440105
440388
|
return [];
|
|
440106
440389
|
throw e;
|
|
440107
440390
|
}
|
|
440108
|
-
const projectDirs = allEntries.filter((dirent) => dirent.isDirectory()).map((dirent) =>
|
|
440391
|
+
const projectDirs = allEntries.filter((dirent) => dirent.isDirectory()).map((dirent) => join150(projectsDir, dirent.name));
|
|
440109
440392
|
const projectResults = await Promise.all(projectDirs.map(async (projectDir) => {
|
|
440110
440393
|
try {
|
|
440111
440394
|
const entries = await fs5.readdir(projectDir);
|
|
440112
|
-
const mainFiles = entries.filter((dirent) => dirent.isFile() && dirent.name.endsWith(".jsonl")).map((dirent) =>
|
|
440395
|
+
const mainFiles = entries.filter((dirent) => dirent.isFile() && dirent.name.endsWith(".jsonl")).map((dirent) => join150(projectDir, dirent.name));
|
|
440113
440396
|
const sessionDirs = entries.filter((dirent) => dirent.isDirectory());
|
|
440114
440397
|
const subagentResults = await Promise.all(sessionDirs.map(async (sessionDir) => {
|
|
440115
|
-
const subagentsDir =
|
|
440398
|
+
const subagentsDir = join150(projectDir, sessionDir.name, "subagents");
|
|
440116
440399
|
try {
|
|
440117
440400
|
const subagentEntries = await fs5.readdir(subagentsDir);
|
|
440118
|
-
return subagentEntries.filter((dirent) => dirent.isFile() && dirent.name.endsWith(".jsonl") && dirent.name.startsWith("agent-")).map((dirent) =>
|
|
440401
|
+
return subagentEntries.filter((dirent) => dirent.isFile() && dirent.name.endsWith(".jsonl") && dirent.name.startsWith("agent-")).map((dirent) => join150(subagentsDir, dirent.name));
|
|
440119
440402
|
} catch {
|
|
440120
440403
|
return [];
|
|
440121
440404
|
}
|
|
@@ -441985,16 +442268,16 @@ import { execFileSync as execFileSync3 } from "child_process";
|
|
|
441985
442268
|
import { constants as fsConstants5 } from "fs";
|
|
441986
442269
|
import {
|
|
441987
442270
|
copyFile as copyFile9,
|
|
441988
|
-
mkdir as
|
|
442271
|
+
mkdir as mkdir57,
|
|
441989
442272
|
mkdtemp,
|
|
441990
442273
|
readdir as readdir36,
|
|
441991
|
-
readFile as
|
|
442274
|
+
readFile as readFile65,
|
|
441992
442275
|
rm as rm11,
|
|
441993
442276
|
unlink as unlink21,
|
|
441994
|
-
writeFile as
|
|
442277
|
+
writeFile as writeFile60
|
|
441995
442278
|
} from "fs/promises";
|
|
441996
442279
|
import { tmpdir as tmpdir9 } from "os";
|
|
441997
|
-
import { extname as extname14, join as
|
|
442280
|
+
import { extname as extname14, join as join151 } from "path";
|
|
441998
442281
|
function getAnalysisModel() {
|
|
441999
442282
|
return getDefaultOpusModel();
|
|
442000
442283
|
}
|
|
@@ -442002,13 +442285,13 @@ function getInsightsModel() {
|
|
|
442002
442285
|
return getDefaultOpusModel();
|
|
442003
442286
|
}
|
|
442004
442287
|
function getDataDir() {
|
|
442005
|
-
return
|
|
442288
|
+
return join151(getClaudeConfigHomeDir(), "usage-data");
|
|
442006
442289
|
}
|
|
442007
442290
|
function getFacetsDir() {
|
|
442008
|
-
return
|
|
442291
|
+
return join151(getDataDir(), "facets");
|
|
442009
442292
|
}
|
|
442010
442293
|
function getSessionMetaDir() {
|
|
442011
|
-
return
|
|
442294
|
+
return join151(getDataDir(), "session-meta");
|
|
442012
442295
|
}
|
|
442013
442296
|
function getLanguageFromPath(filePath) {
|
|
442014
442297
|
const ext = extname14(filePath).toLowerCase();
|
|
@@ -442353,9 +442636,9 @@ async function formatTranscriptWithSummarization(log2) {
|
|
|
442353
442636
|
`);
|
|
442354
442637
|
}
|
|
442355
442638
|
async function loadCachedFacets(sessionId) {
|
|
442356
|
-
const facetPath =
|
|
442639
|
+
const facetPath = join151(getFacetsDir(), `${sessionId}.json`);
|
|
442357
442640
|
try {
|
|
442358
|
-
const content = await
|
|
442641
|
+
const content = await readFile65(facetPath, { encoding: "utf-8" });
|
|
442359
442642
|
const parsed = jsonParse(content);
|
|
442360
442643
|
if (!isValidSessionFacets(parsed)) {
|
|
442361
442644
|
try {
|
|
@@ -442370,18 +442653,18 @@ async function loadCachedFacets(sessionId) {
|
|
|
442370
442653
|
}
|
|
442371
442654
|
async function saveFacets(facets) {
|
|
442372
442655
|
try {
|
|
442373
|
-
await
|
|
442656
|
+
await mkdir57(getFacetsDir(), { recursive: true });
|
|
442374
442657
|
} catch {}
|
|
442375
|
-
const facetPath =
|
|
442376
|
-
await
|
|
442658
|
+
const facetPath = join151(getFacetsDir(), `${facets.session_id}.json`);
|
|
442659
|
+
await writeFile60(facetPath, jsonStringify(facets, null, 2), {
|
|
442377
442660
|
encoding: "utf-8",
|
|
442378
442661
|
mode: 384
|
|
442379
442662
|
});
|
|
442380
442663
|
}
|
|
442381
442664
|
async function loadCachedSessionMeta(sessionId) {
|
|
442382
|
-
const metaPath =
|
|
442665
|
+
const metaPath = join151(getSessionMetaDir(), `${sessionId}.json`);
|
|
442383
442666
|
try {
|
|
442384
|
-
const content = await
|
|
442667
|
+
const content = await readFile65(metaPath, { encoding: "utf-8" });
|
|
442385
442668
|
return jsonParse(content);
|
|
442386
442669
|
} catch {
|
|
442387
442670
|
return null;
|
|
@@ -442389,10 +442672,10 @@ async function loadCachedSessionMeta(sessionId) {
|
|
|
442389
442672
|
}
|
|
442390
442673
|
async function saveSessionMeta(meta) {
|
|
442391
442674
|
try {
|
|
442392
|
-
await
|
|
442675
|
+
await mkdir57(getSessionMetaDir(), { recursive: true });
|
|
442393
442676
|
} catch {}
|
|
442394
|
-
const metaPath =
|
|
442395
|
-
await
|
|
442677
|
+
const metaPath = join151(getSessionMetaDir(), `${meta.session_id}.json`);
|
|
442678
|
+
await writeFile60(metaPath, jsonStringify(meta, null, 2), {
|
|
442396
442679
|
encoding: "utf-8",
|
|
442397
442680
|
mode: 384
|
|
442398
442681
|
});
|
|
@@ -443448,7 +443731,7 @@ function generateHtmlReport(data, insights) {
|
|
|
443448
443731
|
</html>`;
|
|
443449
443732
|
}
|
|
443450
443733
|
function buildExportData(data, insights, facets, remoteStats) {
|
|
443451
|
-
const version2 = typeof MACRO !== "undefined" ? "2.
|
|
443734
|
+
const version2 = typeof MACRO !== "undefined" ? "2.3.1" : "unknown";
|
|
443452
443735
|
const remote_hosts_collected = remoteStats?.hosts.filter((h) => h.sessionCount > 0).map((h) => h.name);
|
|
443453
443736
|
const facets_summary = {
|
|
443454
443737
|
total: facets.size,
|
|
@@ -443499,7 +443782,7 @@ async function scanAllSessions() {
|
|
|
443499
443782
|
} catch {
|
|
443500
443783
|
return [];
|
|
443501
443784
|
}
|
|
443502
|
-
const projectDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) =>
|
|
443785
|
+
const projectDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => join151(projectsDir, dirent.name));
|
|
443503
443786
|
const allSessions = [];
|
|
443504
443787
|
for (let i2 = 0;i2 < projectDirs.length; i2++) {
|
|
443505
443788
|
const sessionFiles = await getSessionFilesWithMtime(projectDirs[i2]);
|
|
@@ -443521,7 +443804,7 @@ async function scanAllSessions() {
|
|
|
443521
443804
|
async function generateUsageReport(options) {
|
|
443522
443805
|
let remoteStats;
|
|
443523
443806
|
if (process.env.USER_TYPE === "ant" && options?.collectRemote) {
|
|
443524
|
-
const destDir =
|
|
443807
|
+
const destDir = join151(getClaudeConfigHomeDir(), "projects");
|
|
443525
443808
|
const { hosts, totalCopied } = await collectAllRemoteHostData(destDir);
|
|
443526
443809
|
remoteStats = { hosts, totalCopied };
|
|
443527
443810
|
}
|
|
@@ -443658,10 +443941,10 @@ async function generateUsageReport(options) {
|
|
|
443658
443941
|
const insights = await generateParallelInsights(aggregated, facets);
|
|
443659
443942
|
const htmlReport = generateHtmlReport(aggregated, insights);
|
|
443660
443943
|
try {
|
|
443661
|
-
await
|
|
443944
|
+
await mkdir57(getDataDir(), { recursive: true });
|
|
443662
443945
|
} catch {}
|
|
443663
|
-
const htmlPath =
|
|
443664
|
-
await
|
|
443946
|
+
const htmlPath = join151(getDataDir(), "report.html");
|
|
443947
|
+
await writeFile60(htmlPath, htmlReport, {
|
|
443665
443948
|
encoding: "utf-8",
|
|
443666
443949
|
mode: 384
|
|
443667
443950
|
});
|
|
@@ -443756,13 +444039,13 @@ var init_insights = __esm(() => {
|
|
|
443756
444039
|
} : async () => 0;
|
|
443757
444040
|
collectFromRemoteHost = process.env.USER_TYPE === "ant" ? async (homespace, destDir) => {
|
|
443758
444041
|
const result = { copied: 0, skipped: 0 };
|
|
443759
|
-
const tempDir = await mkdtemp(
|
|
444042
|
+
const tempDir = await mkdtemp(join151(tmpdir9(), "claude-hs-"));
|
|
443760
444043
|
try {
|
|
443761
444044
|
const scpResult = await execFileNoThrow("scp", ["-rq", `${homespace}.coder:/root/.claude/projects/`, tempDir], { timeout: 300000 });
|
|
443762
444045
|
if (scpResult.code !== 0) {
|
|
443763
444046
|
return result;
|
|
443764
444047
|
}
|
|
443765
|
-
const projectsDir =
|
|
444048
|
+
const projectsDir = join151(tempDir, "projects");
|
|
443766
444049
|
let projectDirents;
|
|
443767
444050
|
try {
|
|
443768
444051
|
projectDirents = await readdir36(projectsDir, { withFileTypes: true });
|
|
@@ -443771,13 +444054,13 @@ var init_insights = __esm(() => {
|
|
|
443771
444054
|
}
|
|
443772
444055
|
await Promise.all(projectDirents.map(async (dirent) => {
|
|
443773
444056
|
const projectName = dirent.name;
|
|
443774
|
-
const projectPath =
|
|
444057
|
+
const projectPath = join151(projectsDir, projectName);
|
|
443775
444058
|
if (!dirent.isDirectory())
|
|
443776
444059
|
return;
|
|
443777
444060
|
const destProjectName = `${projectName}__${homespace}`;
|
|
443778
|
-
const destProjectPath =
|
|
444061
|
+
const destProjectPath = join151(destDir, destProjectName);
|
|
443779
444062
|
try {
|
|
443780
|
-
await
|
|
444063
|
+
await mkdir57(destProjectPath, { recursive: true });
|
|
443781
444064
|
} catch {}
|
|
443782
444065
|
let files2;
|
|
443783
444066
|
try {
|
|
@@ -443789,8 +444072,8 @@ var init_insights = __esm(() => {
|
|
|
443789
444072
|
const fileName = fileDirent.name;
|
|
443790
444073
|
if (!fileName.endsWith(".jsonl"))
|
|
443791
444074
|
return;
|
|
443792
|
-
const srcFile =
|
|
443793
|
-
const destFile =
|
|
444075
|
+
const srcFile = join151(projectPath, fileName);
|
|
444076
|
+
const destFile = join151(destProjectPath, fileName);
|
|
443794
444077
|
try {
|
|
443795
444078
|
await copyFile9(srcFile, destFile, fsConstants5.COPYFILE_EXCL);
|
|
443796
444079
|
result.copied++;
|
|
@@ -444819,14 +445102,14 @@ import { closeSync as closeSync4, fstatSync, openSync as openSync5, readSync as
|
|
|
444819
445102
|
import {
|
|
444820
445103
|
appendFile as fsAppendFile,
|
|
444821
445104
|
open as fsOpen2,
|
|
444822
|
-
mkdir as
|
|
445105
|
+
mkdir as mkdir58,
|
|
444823
445106
|
readdir as readdir37,
|
|
444824
|
-
readFile as
|
|
445107
|
+
readFile as readFile66,
|
|
444825
445108
|
stat as stat50,
|
|
444826
445109
|
unlink as unlink22,
|
|
444827
|
-
writeFile as
|
|
445110
|
+
writeFile as writeFile61
|
|
444828
445111
|
} from "fs/promises";
|
|
444829
|
-
import { basename as basename43, dirname as
|
|
445112
|
+
import { basename as basename43, dirname as dirname56, join as join152 } from "path";
|
|
444830
445113
|
function isTranscriptMessage(entry) {
|
|
444831
445114
|
return entry.type === "user" || entry.type === "assistant" || entry.type === "attachment" || entry.type === "system";
|
|
444832
445115
|
}
|
|
@@ -444840,18 +445123,18 @@ function isEphemeralToolProgress(dataType) {
|
|
|
444840
445123
|
return typeof dataType === "string" && EPHEMERAL_PROGRESS_TYPES.has(dataType);
|
|
444841
445124
|
}
|
|
444842
445125
|
function getProjectsDir2() {
|
|
444843
|
-
return
|
|
445126
|
+
return join152(getClaudeConfigHomeDir(), "projects");
|
|
444844
445127
|
}
|
|
444845
445128
|
function getTranscriptPath() {
|
|
444846
445129
|
const projectDir = getSessionProjectDir() ?? getProjectDir2(getOriginalCwd());
|
|
444847
|
-
return
|
|
445130
|
+
return join152(projectDir, `${getSessionId()}.jsonl`);
|
|
444848
445131
|
}
|
|
444849
445132
|
function getTranscriptPathForSession(sessionId) {
|
|
444850
445133
|
if (sessionId === getSessionId()) {
|
|
444851
445134
|
return getTranscriptPath();
|
|
444852
445135
|
}
|
|
444853
445136
|
const projectDir = getProjectDir2(getOriginalCwd());
|
|
444854
|
-
return
|
|
445137
|
+
return join152(projectDir, `${sessionId}.jsonl`);
|
|
444855
445138
|
}
|
|
444856
445139
|
function setAgentTranscriptSubdir(agentId, subdir) {
|
|
444857
445140
|
agentTranscriptSubdirs.set(agentId, subdir);
|
|
@@ -444863,21 +445146,21 @@ function getAgentTranscriptPath(agentId) {
|
|
|
444863
445146
|
const projectDir = getSessionProjectDir() ?? getProjectDir2(getOriginalCwd());
|
|
444864
445147
|
const sessionId = getSessionId();
|
|
444865
445148
|
const subdir = agentTranscriptSubdirs.get(agentId);
|
|
444866
|
-
const base = subdir ?
|
|
444867
|
-
return
|
|
445149
|
+
const base = subdir ? join152(projectDir, sessionId, "subagents", subdir) : join152(projectDir, sessionId, "subagents");
|
|
445150
|
+
return join152(base, `agent-${agentId}.jsonl`);
|
|
444868
445151
|
}
|
|
444869
445152
|
function getAgentMetadataPath(agentId) {
|
|
444870
445153
|
return getAgentTranscriptPath(agentId).replace(/\.jsonl$/, ".meta.json");
|
|
444871
445154
|
}
|
|
444872
445155
|
async function writeAgentMetadata(agentId, metadata) {
|
|
444873
445156
|
const path15 = getAgentMetadataPath(agentId);
|
|
444874
|
-
await
|
|
444875
|
-
await
|
|
445157
|
+
await mkdir58(dirname56(path15), { recursive: true });
|
|
445158
|
+
await writeFile61(path15, JSON.stringify(metadata));
|
|
444876
445159
|
}
|
|
444877
445160
|
async function readAgentMetadata(agentId) {
|
|
444878
445161
|
const path15 = getAgentMetadataPath(agentId);
|
|
444879
445162
|
try {
|
|
444880
|
-
const raw = await
|
|
445163
|
+
const raw = await readFile66(path15, "utf-8");
|
|
444881
445164
|
return JSON.parse(raw);
|
|
444882
445165
|
} catch (e) {
|
|
444883
445166
|
if (isFsInaccessible(e))
|
|
@@ -444887,20 +445170,20 @@ async function readAgentMetadata(agentId) {
|
|
|
444887
445170
|
}
|
|
444888
445171
|
function getRemoteAgentsDir() {
|
|
444889
445172
|
const projectDir = getSessionProjectDir() ?? getProjectDir2(getOriginalCwd());
|
|
444890
|
-
return
|
|
445173
|
+
return join152(projectDir, getSessionId(), "remote-agents");
|
|
444891
445174
|
}
|
|
444892
445175
|
function getRemoteAgentMetadataPath(taskId) {
|
|
444893
|
-
return
|
|
445176
|
+
return join152(getRemoteAgentsDir(), `remote-agent-${taskId}.meta.json`);
|
|
444894
445177
|
}
|
|
444895
445178
|
async function writeRemoteAgentMetadata(taskId, metadata) {
|
|
444896
445179
|
const path15 = getRemoteAgentMetadataPath(taskId);
|
|
444897
|
-
await
|
|
444898
|
-
await
|
|
445180
|
+
await mkdir58(dirname56(path15), { recursive: true });
|
|
445181
|
+
await writeFile61(path15, JSON.stringify(metadata));
|
|
444899
445182
|
}
|
|
444900
445183
|
async function readRemoteAgentMetadata(taskId) {
|
|
444901
445184
|
const path15 = getRemoteAgentMetadataPath(taskId);
|
|
444902
445185
|
try {
|
|
444903
|
-
const raw = await
|
|
445186
|
+
const raw = await readFile66(path15, "utf-8");
|
|
444904
445187
|
return JSON.parse(raw);
|
|
444905
445188
|
} catch (e) {
|
|
444906
445189
|
if (isFsInaccessible(e))
|
|
@@ -444933,7 +445216,7 @@ async function listRemoteAgentMetadata() {
|
|
|
444933
445216
|
if (!entry.isFile() || !entry.name.endsWith(".meta.json"))
|
|
444934
445217
|
continue;
|
|
444935
445218
|
try {
|
|
444936
|
-
const raw = await
|
|
445219
|
+
const raw = await readFile66(join152(dir, entry.name), "utf-8");
|
|
444937
445220
|
results.push(JSON.parse(raw));
|
|
444938
445221
|
} catch (e) {
|
|
444939
445222
|
logForDebugging(`listRemoteAgentMetadata: skipping ${entry.name}: ${String(e)}`);
|
|
@@ -444943,7 +445226,7 @@ async function listRemoteAgentMetadata() {
|
|
|
444943
445226
|
}
|
|
444944
445227
|
function sessionIdExists(sessionId) {
|
|
444945
445228
|
const projectDir = getProjectDir2(getOriginalCwd());
|
|
444946
|
-
const sessionFile =
|
|
445229
|
+
const sessionFile = join152(projectDir, `${sessionId}.jsonl`);
|
|
444947
445230
|
const fs5 = getFsImplementation();
|
|
444948
445231
|
try {
|
|
444949
445232
|
fs5.statSync(sessionFile);
|
|
@@ -445083,7 +445366,7 @@ class Project {
|
|
|
445083
445366
|
try {
|
|
445084
445367
|
await fsAppendFile(filePath, data, { mode: 384 });
|
|
445085
445368
|
} catch {
|
|
445086
|
-
await
|
|
445369
|
+
await mkdir58(dirname56(filePath), { recursive: true, mode: 448 });
|
|
445087
445370
|
await fsAppendFile(filePath, data, { mode: 384 });
|
|
445088
445371
|
}
|
|
445089
445372
|
}
|
|
@@ -445275,7 +445558,7 @@ class Project {
|
|
|
445275
445558
|
logForDebugging(`Skipping tombstone removal: session file too large (${formatFileSize(fileSize)})`, { level: "warn" });
|
|
445276
445559
|
return;
|
|
445277
445560
|
}
|
|
445278
|
-
const content = await
|
|
445561
|
+
const content = await readFile66(this.sessionFile, { encoding: "utf-8" });
|
|
445279
445562
|
const lines = content.split(`
|
|
445280
445563
|
`).filter((line) => {
|
|
445281
445564
|
if (!line.trim())
|
|
@@ -445287,7 +445570,7 @@ class Project {
|
|
|
445287
445570
|
return true;
|
|
445288
445571
|
}
|
|
445289
445572
|
});
|
|
445290
|
-
await
|
|
445573
|
+
await writeFile61(this.sessionFile, lines.join(`
|
|
445291
445574
|
`), {
|
|
445292
445575
|
encoding: "utf8"
|
|
445293
445576
|
});
|
|
@@ -445624,11 +445907,11 @@ async function hydrateRemoteSession(sessionId, ingressUrl) {
|
|
|
445624
445907
|
try {
|
|
445625
445908
|
const remoteLogs = await getSessionLogs(sessionId, ingressUrl) || [];
|
|
445626
445909
|
const projectDir = getProjectDir2(getOriginalCwd());
|
|
445627
|
-
await
|
|
445910
|
+
await mkdir58(projectDir, { recursive: true, mode: 448 });
|
|
445628
445911
|
const sessionFile = getTranscriptPathForSession(sessionId);
|
|
445629
445912
|
const content = remoteLogs.map((e) => jsonStringify(e) + `
|
|
445630
445913
|
`).join("");
|
|
445631
|
-
await
|
|
445914
|
+
await writeFile61(sessionFile, content, { encoding: "utf8", mode: 384 });
|
|
445632
445915
|
logForDebugging(`Hydrated ${remoteLogs.length} entries from remote`);
|
|
445633
445916
|
return remoteLogs.length > 0;
|
|
445634
445917
|
} catch (error5) {
|
|
@@ -445656,11 +445939,11 @@ async function hydrateFromCCRv2InternalEvents(sessionId) {
|
|
|
445656
445939
|
return false;
|
|
445657
445940
|
}
|
|
445658
445941
|
const projectDir = getProjectDir2(getOriginalCwd());
|
|
445659
|
-
await
|
|
445942
|
+
await mkdir58(projectDir, { recursive: true, mode: 448 });
|
|
445660
445943
|
const sessionFile = getTranscriptPathForSession(sessionId);
|
|
445661
445944
|
const fgContent = events2.map((e) => jsonStringify(e.payload) + `
|
|
445662
445945
|
`).join("");
|
|
445663
|
-
await
|
|
445946
|
+
await writeFile61(sessionFile, fgContent, { encoding: "utf8", mode: 384 });
|
|
445664
445947
|
logForDebugging(`Hydrated ${events2.length} foreground entries from CCR v2 internal events`);
|
|
445665
445948
|
let subagentEventCount = 0;
|
|
445666
445949
|
const subagentReader = project2.getInternalSubagentEventReader();
|
|
@@ -445682,10 +445965,10 @@ async function hydrateFromCCRv2InternalEvents(sessionId) {
|
|
|
445682
445965
|
}
|
|
445683
445966
|
for (const [agentId, entries] of byAgent) {
|
|
445684
445967
|
const agentFile = getAgentTranscriptPath(asAgentId(agentId));
|
|
445685
|
-
await
|
|
445968
|
+
await mkdir58(dirname56(agentFile), { recursive: true, mode: 448 });
|
|
445686
445969
|
const agentContent = entries.map((p) => jsonStringify(p) + `
|
|
445687
445970
|
`).join("");
|
|
445688
|
-
await
|
|
445971
|
+
await writeFile61(agentFile, agentContent, {
|
|
445689
445972
|
encoding: "utf8",
|
|
445690
445973
|
mode: 384
|
|
445691
445974
|
});
|
|
@@ -446085,7 +446368,7 @@ async function loadTranscriptFromFile(filePath) {
|
|
|
446085
446368
|
worktreeSession: worktreeStates.has(sessionId) ? worktreeStates.get(sessionId) : undefined
|
|
446086
446369
|
};
|
|
446087
446370
|
}
|
|
446088
|
-
const content = await
|
|
446371
|
+
const content = await readFile66(filePath, { encoding: "utf-8" });
|
|
446089
446372
|
let parsed;
|
|
446090
446373
|
try {
|
|
446091
446374
|
parsed = jsonParse(content);
|
|
@@ -446219,7 +446502,7 @@ function appendEntryToFile(fullPath, entry) {
|
|
|
446219
446502
|
try {
|
|
446220
446503
|
fs5.appendFileSync(fullPath, line, { mode: 384 });
|
|
446221
446504
|
} catch {
|
|
446222
|
-
fs5.mkdirSync(
|
|
446505
|
+
fs5.mkdirSync(dirname56(fullPath), { mode: 448 });
|
|
446223
446506
|
fs5.appendFileSync(fullPath, line, { mode: 384 });
|
|
446224
446507
|
}
|
|
446225
446508
|
}
|
|
@@ -446747,7 +447030,7 @@ async function loadTranscriptFile(filePath, opts) {
|
|
|
446747
447030
|
}
|
|
446748
447031
|
}
|
|
446749
447032
|
}
|
|
446750
|
-
buf ??= await
|
|
447033
|
+
buf ??= await readFile66(filePath);
|
|
446751
447034
|
if (!opts?.keepAllLeaves && !hasPreservedSegment && !isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_PRECOMPACT_SKIP) && buf.length > SKIP_PRECOMPACT_THRESHOLD) {
|
|
446752
447035
|
buf = walkChainBeforeParse(buf);
|
|
446753
447036
|
}
|
|
@@ -446912,7 +447195,7 @@ async function loadTranscriptFile(filePath, opts) {
|
|
|
446912
447195
|
};
|
|
446913
447196
|
}
|
|
446914
447197
|
async function loadSessionFile(sessionId) {
|
|
446915
|
-
const sessionFile =
|
|
447198
|
+
const sessionFile = join152(getSessionProjectDir() ?? getProjectDir2(getOriginalCwd()), `${sessionId}.jsonl`);
|
|
446916
447199
|
return loadTranscriptFile(sessionFile);
|
|
446917
447200
|
}
|
|
446918
447201
|
function clearSessionMessagesCache() {
|
|
@@ -446980,7 +447263,7 @@ async function loadAllProjectsMessageLogsFull(limit) {
|
|
|
446980
447263
|
} catch {
|
|
446981
447264
|
return [];
|
|
446982
447265
|
}
|
|
446983
|
-
const projectDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) =>
|
|
447266
|
+
const projectDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => join152(projectsDir, dirent.name));
|
|
446984
447267
|
const logsPerProject = await Promise.all(projectDirs.map((projectDir) => getLogsWithoutIndex(projectDir, limit)));
|
|
446985
447268
|
const allLogs = logsPerProject.flat();
|
|
446986
447269
|
const deduped = new Map;
|
|
@@ -447005,7 +447288,7 @@ async function loadAllProjectsMessageLogsProgressive(limit, initialEnrichCount =
|
|
|
447005
447288
|
} catch {
|
|
447006
447289
|
return { logs: [], allStatLogs: [], nextIndex: 0 };
|
|
447007
447290
|
}
|
|
447008
|
-
const projectDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) =>
|
|
447291
|
+
const projectDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => join152(projectsDir, dirent.name));
|
|
447009
447292
|
const rawLogs = [];
|
|
447010
447293
|
for (const projectDir of projectDirs) {
|
|
447011
447294
|
rawLogs.push(...await getSessionFilesLite(projectDir, limit));
|
|
@@ -447066,7 +447349,7 @@ async function getStatOnlyLogsForWorktrees(worktreePaths, limit) {
|
|
|
447066
447349
|
for (const { path: wtPath, prefix } of indexed) {
|
|
447067
447350
|
if (dirName === prefix || dirName.startsWith(prefix + "-")) {
|
|
447068
447351
|
seenDirs.add(dirName);
|
|
447069
|
-
allLogs.push(...await getSessionFilesLite(
|
|
447352
|
+
allLogs.push(...await getSessionFilesLite(join152(projectsDir, dirent.name), undefined, wtPath));
|
|
447070
447353
|
break;
|
|
447071
447354
|
}
|
|
447072
447355
|
}
|
|
@@ -447135,7 +447418,7 @@ async function loadSubagentTranscripts(agentIds) {
|
|
|
447135
447418
|
return transcripts;
|
|
447136
447419
|
}
|
|
447137
447420
|
async function loadAllSubagentTranscriptsFromDisk() {
|
|
447138
|
-
const subagentsDir =
|
|
447421
|
+
const subagentsDir = join152(getSessionProjectDir() ?? getProjectDir2(getOriginalCwd()), getSessionId(), "subagents");
|
|
447139
447422
|
let entries;
|
|
447140
447423
|
try {
|
|
447141
447424
|
entries = await readdir37(subagentsDir, { withFileTypes: true });
|
|
@@ -447263,7 +447546,7 @@ async function getSessionFilesWithMtime(projectDir) {
|
|
|
447263
447546
|
const sessionId = validateUuid2(basename43(dirent.name, ".jsonl"));
|
|
447264
447547
|
if (!sessionId)
|
|
447265
447548
|
continue;
|
|
447266
|
-
candidates.push({ sessionId, filePath:
|
|
447549
|
+
candidates.push({ sessionId, filePath: join152(projectDir, dirent.name) });
|
|
447267
447550
|
}
|
|
447268
447551
|
await Promise.all(candidates.map(async ({ sessionId, filePath }) => {
|
|
447269
447552
|
try {
|
|
@@ -447647,7 +447930,7 @@ var init_sessionStorage = __esm(() => {
|
|
|
447647
447930
|
init_settings2();
|
|
447648
447931
|
init_slowOperations();
|
|
447649
447932
|
init_uuid();
|
|
447650
|
-
VERSION6 = typeof MACRO !== "undefined" ? "2.
|
|
447933
|
+
VERSION6 = typeof MACRO !== "undefined" ? "2.3.1" : "unknown";
|
|
447651
447934
|
MAX_TOMBSTONE_REWRITE_BYTES = 50 * 1024 * 1024;
|
|
447652
447935
|
SKIP_FIRST_PROMPT_PATTERN = /^(?:\s*<[a-z][\w-]*[\s>]|\[Request interrupted by user[^\]]*\])/;
|
|
447653
447936
|
EPHEMERAL_PROGRESS_TYPES = new Set([
|
|
@@ -447659,7 +447942,7 @@ var init_sessionStorage = __esm(() => {
|
|
|
447659
447942
|
MAX_TRANSCRIPT_READ_BYTES = 50 * 1024 * 1024;
|
|
447660
447943
|
agentTranscriptSubdirs = new Map;
|
|
447661
447944
|
getProjectDir2 = memoize_default((projectDir) => {
|
|
447662
|
-
return
|
|
447945
|
+
return join152(getProjectsDir2(), sanitizePath2(projectDir));
|
|
447663
447946
|
});
|
|
447664
447947
|
METADATA_TYPE_MARKERS = [
|
|
447665
447948
|
'"type":"summary"',
|
|
@@ -447870,17 +448153,17 @@ var init_memdir = __esm(() => {
|
|
|
447870
448153
|
});
|
|
447871
448154
|
|
|
447872
448155
|
// src/tools/AgentTool/agentMemory.ts
|
|
447873
|
-
import { join as
|
|
448156
|
+
import { join as join153, normalize as normalize13, sep as sep31 } from "path";
|
|
447874
448157
|
function sanitizeAgentTypeForPath(agentType) {
|
|
447875
448158
|
return agentType.replace(/:/g, "-");
|
|
447876
448159
|
}
|
|
447877
448160
|
function getAgentMemoryDir(agentType, _scope) {
|
|
447878
448161
|
const dirName = sanitizeAgentTypeForPath(agentType);
|
|
447879
|
-
return
|
|
448162
|
+
return join153(getProjectMemoryBaseDir(), "agent-memory", dirName) + sep31;
|
|
447880
448163
|
}
|
|
447881
448164
|
function isAgentMemoryPath(absolutePath) {
|
|
447882
448165
|
const normalizedPath = normalize13(absolutePath);
|
|
447883
|
-
return normalizedPath.startsWith(
|
|
448166
|
+
return normalizedPath.startsWith(join153(getProjectMemoryBaseDir(), "agent-memory") + sep31);
|
|
447884
448167
|
}
|
|
447885
448168
|
function getMemoryScopeDisplay(memory2) {
|
|
447886
448169
|
switch (memory2) {
|
|
@@ -447908,8 +448191,8 @@ var init_agentMemory = __esm(() => {
|
|
|
447908
448191
|
|
|
447909
448192
|
// src/utils/permissions/filesystem.ts
|
|
447910
448193
|
import { randomBytes as randomBytes20 } from "crypto";
|
|
447911
|
-
import { homedir as
|
|
447912
|
-
import { join as
|
|
448194
|
+
import { homedir as homedir33, tmpdir as tmpdir10 } from "os";
|
|
448195
|
+
import { join as join154, normalize as normalize14, posix as posix8, sep as sep32 } from "path";
|
|
447913
448196
|
function normalizeCaseForComparison(path15) {
|
|
447914
448197
|
return path15.toLowerCase();
|
|
447915
448198
|
}
|
|
@@ -447918,11 +448201,11 @@ function getClaudeSkillScope(filePath) {
|
|
|
447918
448201
|
const absolutePathLower = normalizeCaseForComparison(absolutePath);
|
|
447919
448202
|
const bases = [
|
|
447920
448203
|
{
|
|
447921
|
-
dir: expandPath(
|
|
448204
|
+
dir: expandPath(join154(getOriginalCwd(), ".claude", "skills")),
|
|
447922
448205
|
prefix: "/.claude/skills/"
|
|
447923
448206
|
},
|
|
447924
448207
|
{
|
|
447925
|
-
dir: expandPath(
|
|
448208
|
+
dir: expandPath(join154(homedir33(), ".claude", "skills")),
|
|
447926
448209
|
prefix: "~/.claude/skills/"
|
|
447927
448210
|
}
|
|
447928
448211
|
];
|
|
@@ -447977,21 +448260,21 @@ function isClaudeConfigFilePath(filePath) {
|
|
|
447977
448260
|
if (isClaudeSettingsPath(filePath)) {
|
|
447978
448261
|
return true;
|
|
447979
448262
|
}
|
|
447980
|
-
const commandsDir =
|
|
447981
|
-
const agentsDir =
|
|
447982
|
-
const skillsDir =
|
|
448263
|
+
const commandsDir = join154(getOriginalCwd(), ".claude", "commands");
|
|
448264
|
+
const agentsDir = join154(getOriginalCwd(), ".claude", "agents");
|
|
448265
|
+
const skillsDir = join154(getOriginalCwd(), ".claude", "skills");
|
|
447983
448266
|
return pathInWorkingPath(filePath, commandsDir) || pathInWorkingPath(filePath, agentsDir) || pathInWorkingPath(filePath, skillsDir);
|
|
447984
448267
|
}
|
|
447985
448268
|
function isSessionPlanFile(absolutePath) {
|
|
447986
|
-
const expectedPrefix =
|
|
448269
|
+
const expectedPrefix = join154(getPlansDirectory(), getPlanSlug());
|
|
447987
448270
|
const normalizedPath = normalize14(absolutePath);
|
|
447988
448271
|
return normalizedPath.startsWith(expectedPrefix) && normalizedPath.endsWith(".md");
|
|
447989
448272
|
}
|
|
447990
448273
|
function getSessionMemoryDir() {
|
|
447991
|
-
return
|
|
448274
|
+
return join154(getProjectDir2(getCwd()), getSessionId(), "session-memory") + sep32;
|
|
447992
448275
|
}
|
|
447993
448276
|
function getSessionMemoryPath() {
|
|
447994
|
-
return
|
|
448277
|
+
return join154(getSessionMemoryDir(), "summary.md");
|
|
447995
448278
|
}
|
|
447996
448279
|
function isSessionMemoryPath(absolutePath) {
|
|
447997
448280
|
const normalizedPath = normalize14(absolutePath);
|
|
@@ -448013,10 +448296,10 @@ function getClaudeTempDirName() {
|
|
|
448013
448296
|
return `claude-${uid}`;
|
|
448014
448297
|
}
|
|
448015
448298
|
function getProjectTempDir() {
|
|
448016
|
-
return
|
|
448299
|
+
return join154(getClaudeTempDir(), sanitizePath2(getOriginalCwd())) + sep32;
|
|
448017
448300
|
}
|
|
448018
448301
|
function getScratchpadDir() {
|
|
448019
|
-
return
|
|
448302
|
+
return join154(getProjectTempDir(), getSessionId(), "scratchpad");
|
|
448020
448303
|
}
|
|
448021
448304
|
async function ensureScratchpadDir() {
|
|
448022
448305
|
if (!isScratchpadEnabled()) {
|
|
@@ -448236,7 +448519,7 @@ function patternWithRoot(pattern, source) {
|
|
|
448236
448519
|
} else if (pattern.startsWith(`~${DIR_SEP}`)) {
|
|
448237
448520
|
return {
|
|
448238
448521
|
relativePattern: pattern.slice(1),
|
|
448239
|
-
root:
|
|
448522
|
+
root: homedir33().normalize("NFC")
|
|
448240
448523
|
};
|
|
448241
448524
|
} else if (pattern.startsWith(DIR_SEP)) {
|
|
448242
448525
|
return {
|
|
@@ -448594,7 +448877,7 @@ function checkEditableInternalPath(absolutePath, input) {
|
|
|
448594
448877
|
}
|
|
448595
448878
|
};
|
|
448596
448879
|
}
|
|
448597
|
-
if (normalizeCaseForComparison(normalizedPath) === normalizeCaseForComparison(
|
|
448880
|
+
if (normalizeCaseForComparison(normalizedPath) === normalizeCaseForComparison(join154(getOriginalCwd(), ".claude", "launch.json"))) {
|
|
448598
448881
|
return {
|
|
448599
448882
|
behavior: "allow",
|
|
448600
448883
|
updatedInput: input,
|
|
@@ -448691,7 +448974,7 @@ function checkReadableInternalPath(absolutePath, input) {
|
|
|
448691
448974
|
}
|
|
448692
448975
|
};
|
|
448693
448976
|
}
|
|
448694
|
-
const tasksDir =
|
|
448977
|
+
const tasksDir = join154(getClaudeConfigHomeDir(), "tasks") + sep32;
|
|
448695
448978
|
if (normalizedPath === tasksDir.slice(0, -1) || normalizedPath.startsWith(tasksDir)) {
|
|
448696
448979
|
return {
|
|
448697
448980
|
behavior: "allow",
|
|
@@ -448702,7 +448985,7 @@ function checkReadableInternalPath(absolutePath, input) {
|
|
|
448702
448985
|
}
|
|
448703
448986
|
};
|
|
448704
448987
|
}
|
|
448705
|
-
const teamsReadDir =
|
|
448988
|
+
const teamsReadDir = join154(getClaudeConfigHomeDir(), "teams") + sep32;
|
|
448706
448989
|
if (normalizedPath === teamsReadDir.slice(0, -1) || normalizedPath.startsWith(teamsReadDir)) {
|
|
448707
448990
|
return {
|
|
448708
448991
|
behavior: "allow",
|
|
@@ -448774,11 +449057,11 @@ var init_filesystem = __esm(() => {
|
|
|
448774
449057
|
try {
|
|
448775
449058
|
resolvedBaseTmpDir = fs5.realpathSync(baseTmpDir);
|
|
448776
449059
|
} catch {}
|
|
448777
|
-
return
|
|
449060
|
+
return join154(resolvedBaseTmpDir, getClaudeTempDirName()) + sep32;
|
|
448778
449061
|
});
|
|
448779
449062
|
getBundledSkillsRoot = memoize_default(function getBundledSkillsRoot2() {
|
|
448780
449063
|
const nonce = randomBytes20(16).toString("hex");
|
|
448781
|
-
return
|
|
449064
|
+
return join154(getClaudeTempDir(), "bundled-skills", "2.3.1", nonce);
|
|
448782
449065
|
});
|
|
448783
449066
|
getResolvedWorkingDirPaths = memoize_default(getPathsForPermissionCheck);
|
|
448784
449067
|
});
|
|
@@ -448786,24 +449069,24 @@ var init_filesystem = __esm(() => {
|
|
|
448786
449069
|
// src/utils/task/diskOutput.ts
|
|
448787
449070
|
import { constants as fsConstants6 } from "fs";
|
|
448788
449071
|
import {
|
|
448789
|
-
mkdir as
|
|
449072
|
+
mkdir as mkdir59,
|
|
448790
449073
|
open as open16,
|
|
448791
449074
|
stat as stat51,
|
|
448792
449075
|
symlink as symlink4,
|
|
448793
449076
|
unlink as unlink23
|
|
448794
449077
|
} from "fs/promises";
|
|
448795
|
-
import { join as
|
|
449078
|
+
import { join as join155 } from "path";
|
|
448796
449079
|
function getTaskOutputDir() {
|
|
448797
449080
|
if (_taskOutputDir === undefined) {
|
|
448798
|
-
_taskOutputDir =
|
|
449081
|
+
_taskOutputDir = join155(getProjectTempDir(), getSessionId(), "tasks");
|
|
448799
449082
|
}
|
|
448800
449083
|
return _taskOutputDir;
|
|
448801
449084
|
}
|
|
448802
449085
|
async function ensureOutputDir() {
|
|
448803
|
-
await
|
|
449086
|
+
await mkdir59(getTaskOutputDir(), { recursive: true });
|
|
448804
449087
|
}
|
|
448805
449088
|
function getTaskOutputPath(taskId) {
|
|
448806
|
-
return
|
|
449089
|
+
return join155(getTaskOutputDir(), `${taskId}.output`);
|
|
448807
449090
|
}
|
|
448808
449091
|
function track(p) {
|
|
448809
449092
|
_pendingOps.add(p);
|
|
@@ -453062,14 +453345,14 @@ __export(exports_worktree, {
|
|
|
453062
453345
|
import { spawnSync as spawnSync9 } from "child_process";
|
|
453063
453346
|
import {
|
|
453064
453347
|
copyFile as copyFile10,
|
|
453065
|
-
mkdir as
|
|
453348
|
+
mkdir as mkdir60,
|
|
453066
453349
|
readdir as readdir38,
|
|
453067
|
-
readFile as
|
|
453350
|
+
readFile as readFile67,
|
|
453068
453351
|
stat as stat53,
|
|
453069
453352
|
symlink as symlink5,
|
|
453070
453353
|
utimes as utimes2
|
|
453071
453354
|
} from "fs/promises";
|
|
453072
|
-
import { basename as basename45, dirname as
|
|
453355
|
+
import { basename as basename45, dirname as dirname57, join as join156 } from "path";
|
|
453073
453356
|
function validateWorktreeSlug(slug) {
|
|
453074
453357
|
if (slug.length > MAX_WORKTREE_SLUG_LENGTH) {
|
|
453075
453358
|
throw new Error(`Invalid worktree name: must be ${MAX_WORKTREE_SLUG_LENGTH} characters or fewer (got ${slug.length})`);
|
|
@@ -453084,7 +453367,7 @@ function validateWorktreeSlug(slug) {
|
|
|
453084
453367
|
}
|
|
453085
453368
|
}
|
|
453086
453369
|
async function mkdirRecursive(dirPath) {
|
|
453087
|
-
await
|
|
453370
|
+
await mkdir60(dirPath, { recursive: true });
|
|
453088
453371
|
}
|
|
453089
453372
|
async function symlinkDirectories(repoRootPath, worktreePath, dirsToSymlink) {
|
|
453090
453373
|
for (const dir of dirsToSymlink) {
|
|
@@ -453092,8 +453375,8 @@ async function symlinkDirectories(repoRootPath, worktreePath, dirsToSymlink) {
|
|
|
453092
453375
|
logForDebugging(`Skipping symlink for "${dir}": path traversal detected`, { level: "warn" });
|
|
453093
453376
|
continue;
|
|
453094
453377
|
}
|
|
453095
|
-
const sourcePath =
|
|
453096
|
-
const destPath =
|
|
453378
|
+
const sourcePath = join156(repoRootPath, dir);
|
|
453379
|
+
const destPath = join156(worktreePath, dir);
|
|
453097
453380
|
try {
|
|
453098
453381
|
await symlink5(sourcePath, destPath, "dir");
|
|
453099
453382
|
logForDebugging(`Symlinked ${dir} from main repository to worktree to avoid disk bloat`);
|
|
@@ -453117,7 +453400,7 @@ function generateTmuxSessionName(repoPath, branch2) {
|
|
|
453117
453400
|
return combined.replace(/[/.]/g, "_");
|
|
453118
453401
|
}
|
|
453119
453402
|
function worktreesDir(repoRoot) {
|
|
453120
|
-
return
|
|
453403
|
+
return join156(repoRoot, ".claude", "worktrees");
|
|
453121
453404
|
}
|
|
453122
453405
|
function flattenSlug(slug) {
|
|
453123
453406
|
return slug.replaceAll("/", "+");
|
|
@@ -453126,7 +453409,7 @@ function worktreeBranchName(slug) {
|
|
|
453126
453409
|
return `worktree-${flattenSlug(slug)}`;
|
|
453127
453410
|
}
|
|
453128
453411
|
function worktreePathFor(repoRoot, slug) {
|
|
453129
|
-
return
|
|
453412
|
+
return join156(worktreesDir(repoRoot), flattenSlug(slug));
|
|
453130
453413
|
}
|
|
453131
453414
|
async function getOrCreateWorktree(repoRoot, slug, options) {
|
|
453132
453415
|
const worktreePath = worktreePathFor(repoRoot, slug);
|
|
@@ -453140,7 +453423,7 @@ async function getOrCreateWorktree(repoRoot, slug, options) {
|
|
|
453140
453423
|
existed: true
|
|
453141
453424
|
};
|
|
453142
453425
|
}
|
|
453143
|
-
await
|
|
453426
|
+
await mkdir60(worktreesDir(repoRoot), { recursive: true });
|
|
453144
453427
|
const fetchEnv = { ...process.env, ...GIT_NO_PROMPT_ENV2 };
|
|
453145
453428
|
let baseBranch;
|
|
453146
453429
|
let baseSha = null;
|
|
@@ -453207,7 +453490,7 @@ async function getOrCreateWorktree(repoRoot, slug, options) {
|
|
|
453207
453490
|
async function copyWorktreeIncludeFiles(repoRoot, worktreePath) {
|
|
453208
453491
|
let includeContent;
|
|
453209
453492
|
try {
|
|
453210
|
-
includeContent = await
|
|
453493
|
+
includeContent = await readFile67(join156(repoRoot, ".worktreeinclude"), "utf-8");
|
|
453211
453494
|
} catch {
|
|
453212
453495
|
return [];
|
|
453213
453496
|
}
|
|
@@ -453262,10 +453545,10 @@ async function copyWorktreeIncludeFiles(repoRoot, worktreePath) {
|
|
|
453262
453545
|
}
|
|
453263
453546
|
const copied = [];
|
|
453264
453547
|
for (const relativePath2 of files2) {
|
|
453265
|
-
const srcPath =
|
|
453266
|
-
const destPath =
|
|
453548
|
+
const srcPath = join156(repoRoot, relativePath2);
|
|
453549
|
+
const destPath = join156(worktreePath, relativePath2);
|
|
453267
453550
|
try {
|
|
453268
|
-
await
|
|
453551
|
+
await mkdir60(dirname57(destPath), { recursive: true });
|
|
453269
453552
|
await copyFile10(srcPath, destPath);
|
|
453270
453553
|
copied.push(relativePath2);
|
|
453271
453554
|
} catch (e) {
|
|
@@ -453279,10 +453562,10 @@ async function copyWorktreeIncludeFiles(repoRoot, worktreePath) {
|
|
|
453279
453562
|
}
|
|
453280
453563
|
async function performPostCreationSetup(repoRoot, worktreePath) {
|
|
453281
453564
|
const localSettingsRelativePath = getRelativeSettingsFilePathForSource("localSettings");
|
|
453282
|
-
const sourceSettingsLocal =
|
|
453565
|
+
const sourceSettingsLocal = join156(repoRoot, localSettingsRelativePath);
|
|
453283
453566
|
try {
|
|
453284
|
-
const destSettingsLocal =
|
|
453285
|
-
await mkdirRecursive(
|
|
453567
|
+
const destSettingsLocal = join156(worktreePath, localSettingsRelativePath);
|
|
453568
|
+
await mkdirRecursive(dirname57(destSettingsLocal));
|
|
453286
453569
|
await copyFile10(sourceSettingsLocal, destSettingsLocal);
|
|
453287
453570
|
logForDebugging(`Copied settings.local.json to worktree: ${destSettingsLocal}`);
|
|
453288
453571
|
} catch (e) {
|
|
@@ -453291,8 +453574,8 @@ async function performPostCreationSetup(repoRoot, worktreePath) {
|
|
|
453291
453574
|
logForDebugging(`Failed to copy settings.local.json: ${e.message}`, { level: "warn" });
|
|
453292
453575
|
}
|
|
453293
453576
|
}
|
|
453294
|
-
const huskyPath =
|
|
453295
|
-
const gitHooksPath =
|
|
453577
|
+
const huskyPath = join156(repoRoot, ".husky");
|
|
453578
|
+
const gitHooksPath = join156(repoRoot, ".git", "hooks");
|
|
453296
453579
|
let hooksPath = null;
|
|
453297
453580
|
for (const candidatePath of [huskyPath, gitHooksPath]) {
|
|
453298
453581
|
try {
|
|
@@ -453567,7 +453850,7 @@ async function cleanupStaleAgentWorktrees(cutoffDate) {
|
|
|
453567
453850
|
if (!EPHEMERAL_WORKTREE_PATTERNS.some((p) => p.test(slug))) {
|
|
453568
453851
|
continue;
|
|
453569
453852
|
}
|
|
453570
|
-
const worktreePath =
|
|
453853
|
+
const worktreePath = join156(dir, slug);
|
|
453571
453854
|
if (currentPath === worktreePath) {
|
|
453572
453855
|
continue;
|
|
453573
453856
|
}
|
|
@@ -456444,9 +456727,9 @@ __export(exports_upstreamproxy, {
|
|
|
456444
456727
|
getUpstreamProxyEnv: () => getUpstreamProxyEnv,
|
|
456445
456728
|
SESSION_TOKEN_PATH: () => SESSION_TOKEN_PATH
|
|
456446
456729
|
});
|
|
456447
|
-
import { mkdir as
|
|
456448
|
-
import { homedir as
|
|
456449
|
-
import { join as
|
|
456730
|
+
import { mkdir as mkdir61, readFile as readFile68, unlink as unlink24, writeFile as writeFile62 } from "fs/promises";
|
|
456731
|
+
import { homedir as homedir34 } from "os";
|
|
456732
|
+
import { join as join157 } from "path";
|
|
456450
456733
|
async function initUpstreamProxy(opts) {
|
|
456451
456734
|
if (!isEnvTruthy(process.env.CLAUDE_CODE_REMOTE)) {
|
|
456452
456735
|
return state;
|
|
@@ -456467,7 +456750,7 @@ async function initUpstreamProxy(opts) {
|
|
|
456467
456750
|
}
|
|
456468
456751
|
setNonDumpable();
|
|
456469
456752
|
const baseUrl = opts?.ccrBaseUrl ?? process.env.ANTHROPIC_BASE_URL ?? "https://api.anthropic.com";
|
|
456470
|
-
const caBundlePath = opts?.caBundlePath ??
|
|
456753
|
+
const caBundlePath = opts?.caBundlePath ?? join157(homedir34(), ".ccr", "ca-bundle.crt");
|
|
456471
456754
|
const caOk = await downloadCaBundle(baseUrl, opts?.systemCaPath ?? SYSTEM_CA_BUNDLE, caBundlePath);
|
|
456472
456755
|
if (!caOk)
|
|
456473
456756
|
return state;
|
|
@@ -456525,7 +456808,7 @@ function resetUpstreamProxyForTests() {
|
|
|
456525
456808
|
}
|
|
456526
456809
|
async function readToken(path15) {
|
|
456527
456810
|
try {
|
|
456528
|
-
const raw = await
|
|
456811
|
+
const raw = await readFile68(path15, "utf8");
|
|
456529
456812
|
return raw.trim() || null;
|
|
456530
456813
|
} catch (err2) {
|
|
456531
456814
|
if (isENOENT(err2))
|
|
@@ -456566,9 +456849,9 @@ async function downloadCaBundle(baseUrl, systemCaPath, outPath) {
|
|
|
456566
456849
|
return false;
|
|
456567
456850
|
}
|
|
456568
456851
|
const ccrCa = await resp.text();
|
|
456569
|
-
const systemCa = await
|
|
456570
|
-
await
|
|
456571
|
-
await
|
|
456852
|
+
const systemCa = await readFile68(systemCaPath, "utf8").catch(() => "");
|
|
456853
|
+
await mkdir61(join157(outPath, ".."), { recursive: true });
|
|
456854
|
+
await writeFile62(outPath, systemCa + `
|
|
456572
456855
|
` + ccrCa, "utf8");
|
|
456573
456856
|
return true;
|
|
456574
456857
|
} catch (err2) {
|
|
@@ -458015,7 +458298,7 @@ function buildSystemInitMessage(inputs) {
|
|
|
458015
458298
|
slash_commands: inputs.commands.filter((c5) => c5.userInvocable !== false).map((c5) => c5.name),
|
|
458016
458299
|
apiKeySource: getAnthropicApiKeyWithSource().source,
|
|
458017
458300
|
betas: getSdkBetas(),
|
|
458018
|
-
claude_code_version: "2.
|
|
458301
|
+
claude_code_version: "2.3.1",
|
|
458019
458302
|
output_style: outputStyle2,
|
|
458020
458303
|
agents: inputs.agents.map((agent) => agent.agentType),
|
|
458021
458304
|
skills: inputs.skills.filter((s) => s.userInvocable !== false).map((skill) => skill.name),
|
|
@@ -464373,8 +464656,8 @@ var init_ShowInIDEPrompt = __esm(() => {
|
|
|
464373
464656
|
});
|
|
464374
464657
|
|
|
464375
464658
|
// src/components/permissions/FilePermissionDialog/permissionOptions.tsx
|
|
464376
|
-
import { homedir as
|
|
464377
|
-
import { basename as basename49, join as
|
|
464659
|
+
import { homedir as homedir35 } from "os";
|
|
464660
|
+
import { basename as basename49, join as join158, sep as sep33 } from "path";
|
|
464378
464661
|
function isInClaudeFolder(filePath) {
|
|
464379
464662
|
const absolutePath = expandPath(filePath);
|
|
464380
464663
|
const claudeFolderPath = expandPath(`${getOriginalCwd()}/.claude`);
|
|
@@ -464384,7 +464667,7 @@ function isInClaudeFolder(filePath) {
|
|
|
464384
464667
|
}
|
|
464385
464668
|
function isInGlobalClaudeFolder(filePath) {
|
|
464386
464669
|
const absolutePath = expandPath(filePath);
|
|
464387
|
-
const globalClaudeFolderPath =
|
|
464670
|
+
const globalClaudeFolderPath = join158(homedir35(), ".claude");
|
|
464388
464671
|
const normalizedAbsolutePath = normalizeCaseForComparison(absolutePath);
|
|
464389
464672
|
const normalizedGlobalClaudeFolderPath = normalizeCaseForComparison(globalClaudeFolderPath);
|
|
464390
464673
|
return normalizedAbsolutePath.startsWith(normalizedGlobalClaudeFolderPath + sep33.toLowerCase()) || normalizedAbsolutePath.startsWith(normalizedGlobalClaudeFolderPath + "/");
|
|
@@ -472172,7 +472455,7 @@ var init_useVoiceEnabled = __esm(() => {
|
|
|
472172
472455
|
function getSemverPart(version2) {
|
|
472173
472456
|
return `${import_semver10.major(version2, { loose: true })}.${import_semver10.minor(version2, { loose: true })}.${import_semver10.patch(version2, { loose: true })}`;
|
|
472174
472457
|
}
|
|
472175
|
-
function useUpdateNotification(updatedVersion, initialVersion = "2.
|
|
472458
|
+
function useUpdateNotification(updatedVersion, initialVersion = "2.3.1") {
|
|
472176
472459
|
const [lastNotifiedSemver, setLastNotifiedSemver] = import_react214.useState(() => getSemverPart(initialVersion));
|
|
472177
472460
|
if (!updatedVersion) {
|
|
472178
472461
|
return null;
|
|
@@ -472212,7 +472495,7 @@ function AutoUpdater({
|
|
|
472212
472495
|
return;
|
|
472213
472496
|
}
|
|
472214
472497
|
if (false) {}
|
|
472215
|
-
const currentVersion = "2.
|
|
472498
|
+
const currentVersion = "2.3.1";
|
|
472216
472499
|
const channel = getInitialSettings()?.autoUpdatesChannel ?? "latest";
|
|
472217
472500
|
let latestVersion = await getLatestVersion(channel);
|
|
472218
472501
|
const isDisabled = isAutoUpdaterDisabled();
|
|
@@ -472423,12 +472706,12 @@ function NativeAutoUpdater({
|
|
|
472423
472706
|
logEvent("tengu_native_auto_updater_start", {});
|
|
472424
472707
|
try {
|
|
472425
472708
|
const maxVersion = await getMaxVersion();
|
|
472426
|
-
if (maxVersion && gt("2.
|
|
472709
|
+
if (maxVersion && gt("2.3.1", maxVersion)) {
|
|
472427
472710
|
const msg = await getMaxVersionMessage();
|
|
472428
472711
|
setMaxVersionIssue(msg ?? "affects your version");
|
|
472429
472712
|
}
|
|
472430
472713
|
const result = await installLatest(channel);
|
|
472431
|
-
const currentVersion = "2.
|
|
472714
|
+
const currentVersion = "2.3.1";
|
|
472432
472715
|
const latencyMs = Date.now() - startTime;
|
|
472433
472716
|
if (result.lockFailed) {
|
|
472434
472717
|
logEvent("tengu_native_auto_updater_lock_contention", {
|
|
@@ -472563,17 +472846,17 @@ function PackageManagerAutoUpdater(t0) {
|
|
|
472563
472846
|
const maxVersion = await getMaxVersion();
|
|
472564
472847
|
if (maxVersion && latest && gt(latest, maxVersion)) {
|
|
472565
472848
|
logForDebugging(`PackageManagerAutoUpdater: maxVersion ${maxVersion} is set, capping update from ${latest} to ${maxVersion}`);
|
|
472566
|
-
if (gte("2.
|
|
472567
|
-
logForDebugging(`PackageManagerAutoUpdater: current version ${"2.
|
|
472849
|
+
if (gte("2.3.1", maxVersion)) {
|
|
472850
|
+
logForDebugging(`PackageManagerAutoUpdater: current version ${"2.3.1"} is already at or above maxVersion ${maxVersion}, skipping update`);
|
|
472568
472851
|
setUpdateAvailable(false);
|
|
472569
472852
|
return;
|
|
472570
472853
|
}
|
|
472571
472854
|
latest = maxVersion;
|
|
472572
472855
|
}
|
|
472573
|
-
const hasUpdate = latest && !gte("2.
|
|
472856
|
+
const hasUpdate = latest && !gte("2.3.1", latest) && !shouldSkipVersion(latest);
|
|
472574
472857
|
setUpdateAvailable(!!hasUpdate);
|
|
472575
472858
|
if (hasUpdate) {
|
|
472576
|
-
logForDebugging(`PackageManagerAutoUpdater: Update available ${"2.
|
|
472859
|
+
logForDebugging(`PackageManagerAutoUpdater: Update available ${"2.3.1"} -> ${latest}`);
|
|
472577
472860
|
}
|
|
472578
472861
|
};
|
|
472579
472862
|
$2[0] = t1;
|
|
@@ -472607,7 +472890,7 @@ function PackageManagerAutoUpdater(t0) {
|
|
|
472607
472890
|
wrap: "truncate",
|
|
472608
472891
|
children: [
|
|
472609
472892
|
"currentVersion: ",
|
|
472610
|
-
"2.
|
|
472893
|
+
"2.3.1"
|
|
472611
472894
|
]
|
|
472612
472895
|
}, undefined, true, undefined, this);
|
|
472613
472896
|
$2[3] = verbose;
|
|
@@ -480167,7 +480450,7 @@ function buildStatusLineCommandInput(permissionMode, exceedsHalfContext, setting
|
|
|
480167
480450
|
project_dir: getOriginalCwd(),
|
|
480168
480451
|
added_dirs: addedDirs
|
|
480169
480452
|
},
|
|
480170
|
-
version: "2.
|
|
480453
|
+
version: "2.3.1",
|
|
480171
480454
|
output_style: {
|
|
480172
480455
|
name: outputStyleName
|
|
480173
480456
|
},
|
|
@@ -486251,9 +486534,9 @@ function initSkillImprovement() {
|
|
|
486251
486534
|
async function applySkillImprovement(skillName, updates) {
|
|
486252
486535
|
if (!skillName)
|
|
486253
486536
|
return;
|
|
486254
|
-
const { join:
|
|
486537
|
+
const { join: join159 } = await import("path");
|
|
486255
486538
|
const fs5 = await import("fs/promises");
|
|
486256
|
-
const filePath =
|
|
486539
|
+
const filePath = join159(getCwd(), ".claude", "skills", skillName, "SKILL.md");
|
|
486257
486540
|
let currentContent;
|
|
486258
486541
|
try {
|
|
486259
486542
|
currentContent = await fs5.readFile(filePath, "utf-8");
|
|
@@ -486511,8 +486794,8 @@ var init_cacache = __esm(() => {
|
|
|
486511
486794
|
|
|
486512
486795
|
// src/utils/cleanup.ts
|
|
486513
486796
|
import * as fs5 from "fs/promises";
|
|
486514
|
-
import { homedir as
|
|
486515
|
-
import { join as
|
|
486797
|
+
import { homedir as homedir36 } from "os";
|
|
486798
|
+
import { join as join159 } from "path";
|
|
486516
486799
|
function getCutoffDate() {
|
|
486517
486800
|
const settings = getSettings_DEPRECATED() || {};
|
|
486518
486801
|
const cleanupPeriodDays = settings.cleanupPeriodDays ?? DEFAULT_CLEANUP_PERIOD_DAYS;
|
|
@@ -486537,7 +486820,7 @@ async function cleanupOldFilesInDirectory(dirPath, cutoffDate, isMessagePath) {
|
|
|
486537
486820
|
try {
|
|
486538
486821
|
const timestamp3 = convertFileNameToDate(file.name);
|
|
486539
486822
|
if (timestamp3 < cutoffDate) {
|
|
486540
|
-
await getFsImplementation().unlink(
|
|
486823
|
+
await getFsImplementation().unlink(join159(dirPath, file.name));
|
|
486541
486824
|
if (isMessagePath) {
|
|
486542
486825
|
result.messages++;
|
|
486543
486826
|
} else {
|
|
@@ -486568,7 +486851,7 @@ async function cleanupOldMessageFiles() {
|
|
|
486568
486851
|
} catch {
|
|
486569
486852
|
return result;
|
|
486570
486853
|
}
|
|
486571
|
-
const mcpLogDirs = dirents.filter((dirent) => dirent.isDirectory() && dirent.name.startsWith("mcp-logs-")).map((dirent) =>
|
|
486854
|
+
const mcpLogDirs = dirents.filter((dirent) => dirent.isDirectory() && dirent.name.startsWith("mcp-logs-")).map((dirent) => join159(baseCachePath, dirent.name));
|
|
486572
486855
|
for (const mcpLogDir of mcpLogDirs) {
|
|
486573
486856
|
result = addCleanupResults(result, await cleanupOldFilesInDirectory(mcpLogDir, cutoffDate, true));
|
|
486574
486857
|
await tryRmdir(mcpLogDir, fsImpl);
|
|
@@ -486607,7 +486890,7 @@ async function cleanupOldSessionFiles() {
|
|
|
486607
486890
|
for (const projectDirent of projectDirents) {
|
|
486608
486891
|
if (!projectDirent.isDirectory())
|
|
486609
486892
|
continue;
|
|
486610
|
-
const projectDir =
|
|
486893
|
+
const projectDir = join159(projectsDir, projectDirent.name);
|
|
486611
486894
|
let entries;
|
|
486612
486895
|
try {
|
|
486613
486896
|
entries = await fsImpl.readdir(projectDir);
|
|
@@ -486621,15 +486904,15 @@ async function cleanupOldSessionFiles() {
|
|
|
486621
486904
|
continue;
|
|
486622
486905
|
}
|
|
486623
486906
|
try {
|
|
486624
|
-
if (await unlinkIfOld(
|
|
486907
|
+
if (await unlinkIfOld(join159(projectDir, entry.name), cutoffDate, fsImpl)) {
|
|
486625
486908
|
result.messages++;
|
|
486626
486909
|
}
|
|
486627
486910
|
} catch {
|
|
486628
486911
|
result.errors++;
|
|
486629
486912
|
}
|
|
486630
486913
|
} else if (entry.isDirectory()) {
|
|
486631
|
-
const sessionDir =
|
|
486632
|
-
const toolResultsDir =
|
|
486914
|
+
const sessionDir = join159(projectDir, entry.name);
|
|
486915
|
+
const toolResultsDir = join159(sessionDir, TOOL_RESULTS_SUBDIR);
|
|
486633
486916
|
let toolDirs;
|
|
486634
486917
|
try {
|
|
486635
486918
|
toolDirs = await fsImpl.readdir(toolResultsDir);
|
|
@@ -486640,14 +486923,14 @@ async function cleanupOldSessionFiles() {
|
|
|
486640
486923
|
for (const toolEntry of toolDirs) {
|
|
486641
486924
|
if (toolEntry.isFile()) {
|
|
486642
486925
|
try {
|
|
486643
|
-
if (await unlinkIfOld(
|
|
486926
|
+
if (await unlinkIfOld(join159(toolResultsDir, toolEntry.name), cutoffDate, fsImpl)) {
|
|
486644
486927
|
result.messages++;
|
|
486645
486928
|
}
|
|
486646
486929
|
} catch {
|
|
486647
486930
|
result.errors++;
|
|
486648
486931
|
}
|
|
486649
486932
|
} else if (toolEntry.isDirectory()) {
|
|
486650
|
-
const toolDirPath =
|
|
486933
|
+
const toolDirPath = join159(toolResultsDir, toolEntry.name);
|
|
486651
486934
|
let toolFiles;
|
|
486652
486935
|
try {
|
|
486653
486936
|
toolFiles = await fsImpl.readdir(toolDirPath);
|
|
@@ -486658,7 +486941,7 @@ async function cleanupOldSessionFiles() {
|
|
|
486658
486941
|
if (!tf.isFile())
|
|
486659
486942
|
continue;
|
|
486660
486943
|
try {
|
|
486661
|
-
if (await unlinkIfOld(
|
|
486944
|
+
if (await unlinkIfOld(join159(toolDirPath, tf.name), cutoffDate, fsImpl)) {
|
|
486662
486945
|
result.messages++;
|
|
486663
486946
|
}
|
|
486664
486947
|
} catch {
|
|
@@ -486690,7 +486973,7 @@ async function cleanupSingleDirectory(dirPath, extension2, removeEmptyDir = true
|
|
|
486690
486973
|
if (!dirent.isFile() || !dirent.name.endsWith(extension2))
|
|
486691
486974
|
continue;
|
|
486692
486975
|
try {
|
|
486693
|
-
if (await unlinkIfOld(
|
|
486976
|
+
if (await unlinkIfOld(join159(dirPath, dirent.name), cutoffDate, fsImpl)) {
|
|
486694
486977
|
result.messages++;
|
|
486695
486978
|
}
|
|
486696
486979
|
} catch {
|
|
@@ -486703,7 +486986,7 @@ async function cleanupSingleDirectory(dirPath, extension2, removeEmptyDir = true
|
|
|
486703
486986
|
return result;
|
|
486704
486987
|
}
|
|
486705
486988
|
function cleanupOldPlanFiles() {
|
|
486706
|
-
const plansDir =
|
|
486989
|
+
const plansDir = join159(getClaudeConfigHomeDir(), "plans");
|
|
486707
486990
|
return cleanupSingleDirectory(plansDir, ".md");
|
|
486708
486991
|
}
|
|
486709
486992
|
async function cleanupOldFileHistoryBackups() {
|
|
@@ -486712,14 +486995,14 @@ async function cleanupOldFileHistoryBackups() {
|
|
|
486712
486995
|
const fsImpl = getFsImplementation();
|
|
486713
486996
|
try {
|
|
486714
486997
|
const configDir = getClaudeConfigHomeDir();
|
|
486715
|
-
const fileHistoryStorageDir =
|
|
486998
|
+
const fileHistoryStorageDir = join159(configDir, "file-history");
|
|
486716
486999
|
let dirents;
|
|
486717
487000
|
try {
|
|
486718
487001
|
dirents = await fsImpl.readdir(fileHistoryStorageDir);
|
|
486719
487002
|
} catch {
|
|
486720
487003
|
return result;
|
|
486721
487004
|
}
|
|
486722
|
-
const fileHistorySessionsDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) =>
|
|
487005
|
+
const fileHistorySessionsDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => join159(fileHistoryStorageDir, dirent.name));
|
|
486723
487006
|
await Promise.all(fileHistorySessionsDirs.map(async (fileHistorySessionDir) => {
|
|
486724
487007
|
try {
|
|
486725
487008
|
const stats2 = await fsImpl.stat(fileHistorySessionDir);
|
|
@@ -486746,14 +487029,14 @@ async function cleanupOldSessionEnvDirs() {
|
|
|
486746
487029
|
const fsImpl = getFsImplementation();
|
|
486747
487030
|
try {
|
|
486748
487031
|
const configDir = getClaudeConfigHomeDir();
|
|
486749
|
-
const sessionEnvBaseDir =
|
|
487032
|
+
const sessionEnvBaseDir = join159(configDir, "session-env");
|
|
486750
487033
|
let dirents;
|
|
486751
487034
|
try {
|
|
486752
487035
|
dirents = await fsImpl.readdir(sessionEnvBaseDir);
|
|
486753
487036
|
} catch {
|
|
486754
487037
|
return result;
|
|
486755
487038
|
}
|
|
486756
|
-
const sessionEnvDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) =>
|
|
487039
|
+
const sessionEnvDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => join159(sessionEnvBaseDir, dirent.name));
|
|
486757
487040
|
for (const sessionEnvDir of sessionEnvDirs) {
|
|
486758
487041
|
try {
|
|
486759
487042
|
const stats2 = await fsImpl.stat(sessionEnvDir);
|
|
@@ -486775,7 +487058,7 @@ async function cleanupOldDebugLogs() {
|
|
|
486775
487058
|
const cutoffDate = getCutoffDate();
|
|
486776
487059
|
const result = { messages: 0, errors: 0 };
|
|
486777
487060
|
const fsImpl = getFsImplementation();
|
|
486778
|
-
const debugDir =
|
|
487061
|
+
const debugDir = join159(getClaudeConfigHomeDir(), "debug");
|
|
486779
487062
|
let dirents;
|
|
486780
487063
|
try {
|
|
486781
487064
|
dirents = await fsImpl.readdir(debugDir);
|
|
@@ -486787,7 +487070,7 @@ async function cleanupOldDebugLogs() {
|
|
|
486787
487070
|
continue;
|
|
486788
487071
|
}
|
|
486789
487072
|
try {
|
|
486790
|
-
if (await unlinkIfOld(
|
|
487073
|
+
if (await unlinkIfOld(join159(debugDir, dirent.name), cutoffDate, fsImpl)) {
|
|
486791
487074
|
result.messages++;
|
|
486792
487075
|
}
|
|
486793
487076
|
} catch {
|
|
@@ -486797,7 +487080,7 @@ async function cleanupOldDebugLogs() {
|
|
|
486797
487080
|
return result;
|
|
486798
487081
|
}
|
|
486799
487082
|
async function cleanupNpmCacheForAnthropicPackages() {
|
|
486800
|
-
const markerPath =
|
|
487083
|
+
const markerPath = join159(getClaudeConfigHomeDir(), ".npm-cache-cleanup");
|
|
486801
487084
|
try {
|
|
486802
487085
|
const stat55 = await fs5.stat(markerPath);
|
|
486803
487086
|
if (Date.now() - stat55.mtimeMs < ONE_DAY_MS) {
|
|
@@ -486812,7 +487095,7 @@ async function cleanupNpmCacheForAnthropicPackages() {
|
|
|
486812
487095
|
return;
|
|
486813
487096
|
}
|
|
486814
487097
|
logForDebugging("npm cache cleanup: starting");
|
|
486815
|
-
const npmCachePath =
|
|
487098
|
+
const npmCachePath = join159(homedir36(), ".npm", "_cacache");
|
|
486816
487099
|
const NPM_CACHE_RETENTION_COUNT = 5;
|
|
486817
487100
|
const startTime = Date.now();
|
|
486818
487101
|
try {
|
|
@@ -486867,7 +487150,7 @@ async function cleanupNpmCacheForAnthropicPackages() {
|
|
|
486867
487150
|
}
|
|
486868
487151
|
}
|
|
486869
487152
|
async function cleanupOldVersionsThrottled() {
|
|
486870
|
-
const markerPath =
|
|
487153
|
+
const markerPath = join159(getClaudeConfigHomeDir(), ".version-cleanup");
|
|
486871
487154
|
try {
|
|
486872
487155
|
const stat55 = await fs5.stat(markerPath);
|
|
486873
487156
|
if (Date.now() - stat55.mtimeMs < ONE_DAY_MS) {
|
|
@@ -490097,7 +490380,7 @@ __export(exports_asciicast, {
|
|
|
490097
490380
|
_resetRecordingStateForTesting: () => _resetRecordingStateForTesting
|
|
490098
490381
|
});
|
|
490099
490382
|
import { appendFile as appendFile6, rename as rename10 } from "fs/promises";
|
|
490100
|
-
import { basename as basename58, dirname as
|
|
490383
|
+
import { basename as basename58, dirname as dirname58, join as join161 } from "path";
|
|
490101
490384
|
function getRecordFilePath() {
|
|
490102
490385
|
if (recordingState.filePath !== null) {
|
|
490103
490386
|
return recordingState.filePath;
|
|
@@ -490108,10 +490391,10 @@ function getRecordFilePath() {
|
|
|
490108
490391
|
if (!isEnvTruthy(process.env.CLAUDE_CODE_TERMINAL_RECORDING)) {
|
|
490109
490392
|
return null;
|
|
490110
490393
|
}
|
|
490111
|
-
const projectsDir =
|
|
490112
|
-
const projectDir =
|
|
490394
|
+
const projectsDir = join161(getClaudeConfigHomeDir(), "projects");
|
|
490395
|
+
const projectDir = join161(projectsDir, sanitizePath2(getOriginalCwd()));
|
|
490113
490396
|
recordingState.timestamp = Date.now();
|
|
490114
|
-
recordingState.filePath =
|
|
490397
|
+
recordingState.filePath = join161(projectDir, `${getSessionId()}-${recordingState.timestamp}.cast`);
|
|
490115
490398
|
return recordingState.filePath;
|
|
490116
490399
|
}
|
|
490117
490400
|
function _resetRecordingStateForTesting() {
|
|
@@ -490120,13 +490403,13 @@ function _resetRecordingStateForTesting() {
|
|
|
490120
490403
|
}
|
|
490121
490404
|
function getSessionRecordingPaths() {
|
|
490122
490405
|
const sessionId = getSessionId();
|
|
490123
|
-
const projectsDir =
|
|
490124
|
-
const projectDir =
|
|
490406
|
+
const projectsDir = join161(getClaudeConfigHomeDir(), "projects");
|
|
490407
|
+
const projectDir = join161(projectsDir, sanitizePath2(getOriginalCwd()));
|
|
490125
490408
|
try {
|
|
490126
490409
|
const entries = getFsImplementation().readdirSync(projectDir);
|
|
490127
490410
|
const names = typeof entries[0] === "string" ? entries : entries.map((e) => e.name);
|
|
490128
490411
|
const files2 = names.filter((f) => f.startsWith(sessionId) && f.endsWith(".cast")).sort();
|
|
490129
|
-
return files2.map((f) =>
|
|
490412
|
+
return files2.map((f) => join161(projectDir, f));
|
|
490130
490413
|
} catch {
|
|
490131
490414
|
return [];
|
|
490132
490415
|
}
|
|
@@ -490136,9 +490419,9 @@ async function renameRecordingForSession() {
|
|
|
490136
490419
|
if (!oldPath || recordingState.timestamp === 0) {
|
|
490137
490420
|
return;
|
|
490138
490421
|
}
|
|
490139
|
-
const projectsDir =
|
|
490140
|
-
const projectDir =
|
|
490141
|
-
const newPath =
|
|
490422
|
+
const projectsDir = join161(getClaudeConfigHomeDir(), "projects");
|
|
490423
|
+
const projectDir = join161(projectsDir, sanitizePath2(getOriginalCwd()));
|
|
490424
|
+
const newPath = join161(projectDir, `${getSessionId()}-${recordingState.timestamp}.cast`);
|
|
490142
490425
|
if (oldPath === newPath) {
|
|
490143
490426
|
return;
|
|
490144
490427
|
}
|
|
@@ -490179,7 +490462,7 @@ function installAsciicastRecorder() {
|
|
|
490179
490462
|
}
|
|
490180
490463
|
});
|
|
490181
490464
|
try {
|
|
490182
|
-
getFsImplementation().mkdirSync(
|
|
490465
|
+
getFsImplementation().mkdirSync(dirname58(filePath));
|
|
490183
490466
|
} catch {}
|
|
490184
490467
|
getFsImplementation().appendFileSync(filePath, header + `
|
|
490185
490468
|
`, { mode: 384 });
|
|
@@ -490248,7 +490531,7 @@ var init_asciicast = __esm(() => {
|
|
|
490248
490531
|
});
|
|
490249
490532
|
|
|
490250
490533
|
// src/utils/sessionRestore.ts
|
|
490251
|
-
import { dirname as
|
|
490534
|
+
import { dirname as dirname59 } from "path";
|
|
490252
490535
|
function extractTodosFromTranscript(messages) {
|
|
490253
490536
|
for (let i2 = messages.length - 1;i2 >= 0; i2--) {
|
|
490254
490537
|
const msg = messages[i2];
|
|
@@ -490373,7 +490656,7 @@ async function processResumedConversation(result, opts, context8) {
|
|
|
490373
490656
|
if (!opts.forkSession) {
|
|
490374
490657
|
const sid = opts.sessionIdOverride ?? result.sessionId;
|
|
490375
490658
|
if (sid) {
|
|
490376
|
-
switchSession(asSessionId(sid), opts.transcriptPath ?
|
|
490659
|
+
switchSession(asSessionId(sid), opts.transcriptPath ? dirname59(opts.transcriptPath) : null);
|
|
490377
490660
|
await renameRecordingForSession();
|
|
490378
490661
|
await resetSessionFilePointer();
|
|
490379
490662
|
restoreCostStateForSession(sid);
|
|
@@ -491720,7 +492003,7 @@ var init_useDynamicConfig = __esm(() => {
|
|
|
491720
492003
|
});
|
|
491721
492004
|
|
|
491722
492005
|
// src/components/FeedbackSurvey/submitTranscriptShare.ts
|
|
491723
|
-
import { readFile as
|
|
492006
|
+
import { readFile as readFile69, stat as stat55 } from "fs/promises";
|
|
491724
492007
|
async function submitTranscriptShare(messages, trigger, appearanceId) {
|
|
491725
492008
|
try {
|
|
491726
492009
|
logForDebugging("Collecting transcript for sharing", { level: "info" });
|
|
@@ -491732,14 +492015,14 @@ async function submitTranscriptShare(messages, trigger, appearanceId) {
|
|
|
491732
492015
|
const transcriptPath = getTranscriptPath();
|
|
491733
492016
|
const { size } = await stat55(transcriptPath);
|
|
491734
492017
|
if (size <= MAX_TRANSCRIPT_READ_BYTES) {
|
|
491735
|
-
rawTranscriptJsonl = await
|
|
492018
|
+
rawTranscriptJsonl = await readFile69(transcriptPath, "utf-8");
|
|
491736
492019
|
} else {
|
|
491737
492020
|
logForDebugging(`Skipping raw transcript read: file too large (${size} bytes)`, { level: "warn" });
|
|
491738
492021
|
}
|
|
491739
492022
|
} catch {}
|
|
491740
492023
|
const data = {
|
|
491741
492024
|
trigger,
|
|
491742
|
-
version: "2.
|
|
492025
|
+
version: "2.3.1",
|
|
491743
492026
|
platform: process.platform,
|
|
491744
492027
|
transcript,
|
|
491745
492028
|
subagentTranscripts: Object.keys(subagentTranscripts).length > 0 ? subagentTranscripts : undefined,
|
|
@@ -493015,7 +493298,7 @@ var init_useAwaySummary = __esm(() => {
|
|
|
493015
493298
|
});
|
|
493016
493299
|
|
|
493017
493300
|
// src/utils/plugins/officialMarketplaceStartupCheck.ts
|
|
493018
|
-
import { join as
|
|
493301
|
+
import { join as join162 } from "path";
|
|
493019
493302
|
function isOfficialMarketplaceAutoInstallDisabled() {
|
|
493020
493303
|
return isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL);
|
|
493021
493304
|
}
|
|
@@ -493098,7 +493381,7 @@ async function checkAndInstallOfficialMarketplace() {
|
|
|
493098
493381
|
return { installed: false, skipped: true, reason: "policy_blocked" };
|
|
493099
493382
|
}
|
|
493100
493383
|
const cacheDir = getMarketplacesCacheDir();
|
|
493101
|
-
const installLocation =
|
|
493384
|
+
const installLocation = join162(cacheDir, OFFICIAL_MARKETPLACE_NAME);
|
|
493102
493385
|
const gcsSha = await fetchOfficialMarketplaceFromGcs(installLocation, cacheDir);
|
|
493103
493386
|
if (gcsSha !== null) {
|
|
493104
493387
|
const known = await loadKnownMarketplacesConfig();
|
|
@@ -493354,7 +493637,7 @@ var init_tipHistory = __esm(() => {
|
|
|
493354
493637
|
|
|
493355
493638
|
// src/utils/desktopDeepLink.ts
|
|
493356
493639
|
import { readdir as readdir39 } from "fs/promises";
|
|
493357
|
-
import { join as
|
|
493640
|
+
import { join as join163 } from "path";
|
|
493358
493641
|
function isDevMode() {
|
|
493359
493642
|
if (true) {
|
|
493360
493643
|
return true;
|
|
@@ -493417,7 +493700,7 @@ async function getDesktopVersion() {
|
|
|
493417
493700
|
if (!localAppData) {
|
|
493418
493701
|
return null;
|
|
493419
493702
|
}
|
|
493420
|
-
const installDir =
|
|
493703
|
+
const installDir = join163(localAppData, "AnthropicClaude");
|
|
493421
493704
|
try {
|
|
493422
493705
|
const entries = await readdir39(installDir);
|
|
493423
493706
|
const versions = entries.filter((e) => e.startsWith("app-")).map((e) => e.slice(4)).filter((v2) => import_semver14.coerce(v2) !== null).sort((a, b3) => {
|
|
@@ -496449,7 +496732,7 @@ var init_usePluginRecommendationBase = __esm(() => {
|
|
|
496449
496732
|
});
|
|
496450
496733
|
|
|
496451
496734
|
// src/hooks/useLspPluginRecommendation.tsx
|
|
496452
|
-
import { extname as extname16, join as
|
|
496735
|
+
import { extname as extname16, join as join164 } from "path";
|
|
496453
496736
|
function useLspPluginRecommendation() {
|
|
496454
496737
|
const $2 = c3(12);
|
|
496455
496738
|
const trackedFiles = useAppState(_temp201);
|
|
@@ -496534,7 +496817,7 @@ function useLspPluginRecommendation() {
|
|
|
496534
496817
|
case "yes": {
|
|
496535
496818
|
installPluginAndNotify(pluginId, pluginName, "lsp-plugin", addNotification, async (pluginData) => {
|
|
496536
496819
|
logForDebugging(`[useLspPluginRecommendation] Installing plugin: ${pluginId}`);
|
|
496537
|
-
const localSourcePath = typeof pluginData.entry.source === "string" ?
|
|
496820
|
+
const localSourcePath = typeof pluginData.entry.source === "string" ? join164(pluginData.marketplaceInstallLocation, pluginData.entry.source) : undefined;
|
|
496538
496821
|
await cacheAndRegisterPlugin(pluginId, pluginData.entry, "user", undefined, localSourcePath);
|
|
496539
496822
|
const settings = getSettingsForSource("userSettings");
|
|
496540
496823
|
updateSettingsForSource("userSettings", {
|
|
@@ -499366,9 +499649,9 @@ var exports_REPL = {};
|
|
|
499366
499649
|
__export(exports_REPL, {
|
|
499367
499650
|
REPL: () => REPL
|
|
499368
499651
|
});
|
|
499369
|
-
import { dirname as
|
|
499652
|
+
import { dirname as dirname60, join as join165 } from "path";
|
|
499370
499653
|
import { tmpdir as tmpdir11 } from "os";
|
|
499371
|
-
import { writeFile as
|
|
499654
|
+
import { writeFile as writeFile64 } from "fs/promises";
|
|
499372
499655
|
import { randomUUID as randomUUID47 } from "crypto";
|
|
499373
499656
|
function TranscriptModeFooter(t0) {
|
|
499374
499657
|
const $2 = c3(9);
|
|
@@ -500304,7 +500587,7 @@ function REPL({
|
|
|
500304
500587
|
const targetSessionCosts = getStoredSessionCosts(sessionId);
|
|
500305
500588
|
saveCurrentSessionCosts();
|
|
500306
500589
|
resetCostState();
|
|
500307
|
-
switchSession(asSessionId(sessionId), log2.fullPath ?
|
|
500590
|
+
switchSession(asSessionId(sessionId), log2.fullPath ? dirname60(log2.fullPath) : null);
|
|
500308
500591
|
const {
|
|
500309
500592
|
renameRecordingForSession: renameRecordingForSession2
|
|
500310
500593
|
} = await Promise.resolve().then(() => (init_asciicast(), exports_asciicast));
|
|
@@ -501936,8 +502219,8 @@ Note: ctrl + z now suspends localclawd, ctrl + _ undoes input.
|
|
|
501936
502219
|
const w2 = Math.max(80, (process.stdout.columns ?? 80) - 6);
|
|
501937
502220
|
const raw = await renderMessagesToPlainText(deferredMessages, tools, w2);
|
|
501938
502221
|
const text = raw.replace(/[ \t]+$/gm, "");
|
|
501939
|
-
const path17 =
|
|
501940
|
-
await
|
|
502222
|
+
const path17 = join165(tmpdir11(), `cc-transcript-${Date.now()}.txt`);
|
|
502223
|
+
await writeFile64(path17, text);
|
|
501941
502224
|
const opened = openFileInExternalEditor(path17);
|
|
501942
502225
|
setStatus(opened ? `opening ${path17}` : `wrote ${path17} · no $VISUAL/$EDITOR set`);
|
|
501943
502226
|
} catch (e) {
|
|
@@ -503600,7 +503883,7 @@ var exports_TrustDialog = {};
|
|
|
503600
503883
|
__export(exports_TrustDialog, {
|
|
503601
503884
|
TrustDialog: () => TrustDialog
|
|
503602
503885
|
});
|
|
503603
|
-
import { homedir as
|
|
503886
|
+
import { homedir as homedir37 } from "os";
|
|
503604
503887
|
function TrustDialog({ onDone }) {
|
|
503605
503888
|
const [focusIdx, setFocusIdx] = import_react307.useState(0);
|
|
503606
503889
|
const doneRef = import_react307.useRef(false);
|
|
@@ -503618,7 +503901,7 @@ function TrustDialog({ onDone }) {
|
|
|
503618
503901
|
gracefulShutdownSync(1);
|
|
503619
503902
|
} else {
|
|
503620
503903
|
try {
|
|
503621
|
-
if (
|
|
503904
|
+
if (homedir37() !== getCwd()) {
|
|
503622
503905
|
try {
|
|
503623
503906
|
saveCurrentProjectConfig((c5) => ({ ...c5, hasTrustDialogAccepted: true }));
|
|
503624
503907
|
} catch {}
|
|
@@ -504947,7 +505230,7 @@ var exports_ResumeConversation = {};
|
|
|
504947
505230
|
__export(exports_ResumeConversation, {
|
|
504948
505231
|
ResumeConversation: () => ResumeConversation
|
|
504949
505232
|
});
|
|
504950
|
-
import { dirname as
|
|
505233
|
+
import { dirname as dirname61 } from "path";
|
|
504951
505234
|
function parsePrIdentifier(value) {
|
|
504952
505235
|
const directNumber = parseInt(value, 10);
|
|
504953
505236
|
if (!isNaN(directNumber) && directNumber > 0) {
|
|
@@ -505079,7 +505362,7 @@ function ResumeConversation({
|
|
|
505079
505362
|
}
|
|
505080
505363
|
if (false) {}
|
|
505081
505364
|
if (result_3.sessionId && !forkSession) {
|
|
505082
|
-
switchSession(asSessionId(result_3.sessionId), log_0.fullPath ?
|
|
505365
|
+
switchSession(asSessionId(result_3.sessionId), log_0.fullPath ? dirname61(log_0.fullPath) : null);
|
|
505083
505366
|
await renameRecordingForSession();
|
|
505084
505367
|
await resetSessionFilePointer();
|
|
505085
505368
|
restoreCostStateForSession(result_3.sessionId);
|
|
@@ -508663,12 +508946,12 @@ var init_createDirectConnectSession = __esm(() => {
|
|
|
508663
508946
|
});
|
|
508664
508947
|
|
|
508665
508948
|
// src/utils/errorLogSink.ts
|
|
508666
|
-
import { dirname as
|
|
508949
|
+
import { dirname as dirname62, join as join166 } from "path";
|
|
508667
508950
|
function getErrorsPath() {
|
|
508668
|
-
return
|
|
508951
|
+
return join166(CACHE_PATHS.errors(), DATE + ".jsonl");
|
|
508669
508952
|
}
|
|
508670
508953
|
function getMCPLogsPath(serverName) {
|
|
508671
|
-
return
|
|
508954
|
+
return join166(CACHE_PATHS.mcpLogs(serverName), DATE + ".jsonl");
|
|
508672
508955
|
}
|
|
508673
508956
|
function createJsonlWriter(options) {
|
|
508674
508957
|
const writer = createBufferedWriter(options);
|
|
@@ -508684,7 +508967,7 @@ function createJsonlWriter(options) {
|
|
|
508684
508967
|
function getLogWriter(path17) {
|
|
508685
508968
|
let writer = logWriters.get(path17);
|
|
508686
508969
|
if (!writer) {
|
|
508687
|
-
const dir =
|
|
508970
|
+
const dir = dirname62(path17);
|
|
508688
508971
|
writer = createJsonlWriter({
|
|
508689
508972
|
writeFn: (content) => {
|
|
508690
508973
|
try {
|
|
@@ -508712,7 +508995,7 @@ function appendToLog(path17, message) {
|
|
|
508712
508995
|
cwd: getFsImplementation().cwd(),
|
|
508713
508996
|
userType: process.env.USER_TYPE,
|
|
508714
508997
|
sessionId: getSessionId(),
|
|
508715
|
-
version: "2.
|
|
508998
|
+
version: "2.3.1"
|
|
508716
508999
|
};
|
|
508717
509000
|
getLogWriter(path17).write(messageWithTimestamp);
|
|
508718
509001
|
}
|
|
@@ -508812,8 +509095,8 @@ var init_sinks = __esm(() => {
|
|
|
508812
509095
|
|
|
508813
509096
|
// src/utils/iTermBackup.ts
|
|
508814
509097
|
import { copyFile as copyFile11, stat as stat57 } from "fs/promises";
|
|
508815
|
-
import { homedir as
|
|
508816
|
-
import { join as
|
|
509098
|
+
import { homedir as homedir38 } from "os";
|
|
509099
|
+
import { join as join167 } from "path";
|
|
508817
509100
|
function markITerm2SetupComplete() {
|
|
508818
509101
|
saveGlobalConfig((current) => ({
|
|
508819
509102
|
...current,
|
|
@@ -508828,7 +509111,7 @@ function getIterm2RecoveryInfo() {
|
|
|
508828
509111
|
};
|
|
508829
509112
|
}
|
|
508830
509113
|
function getITerm2PlistPath() {
|
|
508831
|
-
return
|
|
509114
|
+
return join167(homedir38(), "Library", "Preferences", "com.googlecode.iterm2.plist");
|
|
508832
509115
|
}
|
|
508833
509116
|
async function checkAndRestoreITerm2Backup() {
|
|
508834
509117
|
const { inProgress, backupPath } = getIterm2RecoveryInfo();
|
|
@@ -512204,8 +512487,8 @@ var init_idleTimeout = __esm(() => {
|
|
|
512204
512487
|
|
|
512205
512488
|
// src/bridge/inboundAttachments.ts
|
|
512206
512489
|
import { randomUUID as randomUUID50 } from "crypto";
|
|
512207
|
-
import { mkdir as
|
|
512208
|
-
import { basename as basename59, join as
|
|
512490
|
+
import { mkdir as mkdir62, writeFile as writeFile65 } from "fs/promises";
|
|
512491
|
+
import { basename as basename59, join as join168 } from "path";
|
|
512209
512492
|
import { z as z95 } from "zod/v4";
|
|
512210
512493
|
function debug3(msg) {
|
|
512211
512494
|
logForDebugging(`[bridge:inbound-attach] ${msg}`);
|
|
@@ -512222,7 +512505,7 @@ function sanitizeFileName(name) {
|
|
|
512222
512505
|
return base || "attachment";
|
|
512223
512506
|
}
|
|
512224
512507
|
function uploadsDir() {
|
|
512225
|
-
return
|
|
512508
|
+
return join168(getClaudeConfigHomeDir(), "uploads", getSessionId());
|
|
512226
512509
|
}
|
|
512227
512510
|
async function resolveOne(att) {
|
|
512228
512511
|
const token = getBridgeAccessToken();
|
|
@@ -512251,10 +512534,10 @@ async function resolveOne(att) {
|
|
|
512251
512534
|
const safeName = sanitizeFileName(att.file_name);
|
|
512252
512535
|
const prefix = (att.file_uuid.slice(0, 8) || randomUUID50().slice(0, 8)).replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
512253
512536
|
const dir = uploadsDir();
|
|
512254
|
-
const outPath =
|
|
512537
|
+
const outPath = join168(dir, `${prefix}-${safeName}`);
|
|
512255
512538
|
try {
|
|
512256
|
-
await
|
|
512257
|
-
await
|
|
512539
|
+
await mkdir62(dir, { recursive: true });
|
|
512540
|
+
await writeFile65(outPath, data);
|
|
512258
512541
|
} catch (e) {
|
|
512259
512542
|
debug3(`write ${outPath} failed: ${e}`);
|
|
512260
512543
|
return;
|
|
@@ -512349,11 +512632,11 @@ var init_sessionUrl = __esm(() => {
|
|
|
512349
512632
|
});
|
|
512350
512633
|
|
|
512351
512634
|
// src/utils/plugins/zipCacheAdapters.ts
|
|
512352
|
-
import { readFile as
|
|
512353
|
-
import { join as
|
|
512635
|
+
import { readFile as readFile70 } from "fs/promises";
|
|
512636
|
+
import { join as join169 } from "path";
|
|
512354
512637
|
async function readZipCacheKnownMarketplaces() {
|
|
512355
512638
|
try {
|
|
512356
|
-
const content = await
|
|
512639
|
+
const content = await readFile70(getZipCacheKnownMarketplacesPath(), "utf-8");
|
|
512357
512640
|
const parsed = KnownMarketplacesFileSchema().safeParse(jsonParse(content));
|
|
512358
512641
|
if (!parsed.success) {
|
|
512359
512642
|
logForDebugging(`Invalid known_marketplaces.json in zip cache: ${parsed.error.message}`, { level: "error" });
|
|
@@ -512375,18 +512658,18 @@ async function saveMarketplaceJsonToZipCache(marketplaceName, installLocation) {
|
|
|
512375
512658
|
const content = await readMarketplaceJsonContent(installLocation);
|
|
512376
512659
|
if (content !== null) {
|
|
512377
512660
|
const relPath = getMarketplaceJsonRelativePath(marketplaceName);
|
|
512378
|
-
await atomicWriteToZipCache(
|
|
512661
|
+
await atomicWriteToZipCache(join169(zipCachePath, relPath), content);
|
|
512379
512662
|
}
|
|
512380
512663
|
}
|
|
512381
512664
|
async function readMarketplaceJsonContent(dir) {
|
|
512382
512665
|
const candidates = [
|
|
512383
|
-
|
|
512384
|
-
|
|
512666
|
+
join169(dir, ".claude-plugin", "marketplace.json"),
|
|
512667
|
+
join169(dir, "marketplace.json"),
|
|
512385
512668
|
dir
|
|
512386
512669
|
];
|
|
512387
512670
|
for (const candidate of candidates) {
|
|
512388
512671
|
try {
|
|
512389
|
-
return await
|
|
512672
|
+
return await readFile70(candidate, "utf-8");
|
|
512390
512673
|
} catch {}
|
|
512391
512674
|
}
|
|
512392
512675
|
return null;
|
|
@@ -512511,8 +512794,8 @@ async function getEnvLessBridgeConfig() {
|
|
|
512511
512794
|
}
|
|
512512
512795
|
async function checkEnvLessBridgeMinVersion() {
|
|
512513
512796
|
const cfg = await getEnvLessBridgeConfig();
|
|
512514
|
-
if (cfg.min_version && lt("2.
|
|
512515
|
-
return `Your version of localclawd (${"2.
|
|
512797
|
+
if (cfg.min_version && lt("2.3.1", cfg.min_version)) {
|
|
512798
|
+
return `Your version of localclawd (${"2.3.1"}) is too old for Remote Control.
|
|
512516
512799
|
Version ${cfg.min_version} or higher is required. Run \`localclawd update\` to update.`;
|
|
512517
512800
|
}
|
|
512518
512801
|
return null;
|
|
@@ -512837,17 +513120,17 @@ __export(exports_bridgePointer, {
|
|
|
512837
513120
|
clearBridgePointer: () => clearBridgePointer,
|
|
512838
513121
|
BRIDGE_POINTER_TTL_MS: () => BRIDGE_POINTER_TTL_MS
|
|
512839
513122
|
});
|
|
512840
|
-
import { mkdir as
|
|
512841
|
-
import { dirname as
|
|
513123
|
+
import { mkdir as mkdir63, readFile as readFile71, stat as stat58, unlink as unlink25, writeFile as writeFile66 } from "fs/promises";
|
|
513124
|
+
import { dirname as dirname63, join as join170 } from "path";
|
|
512842
513125
|
import { z as z97 } from "zod/v4";
|
|
512843
513126
|
function getBridgePointerPath(dir) {
|
|
512844
|
-
return
|
|
513127
|
+
return join170(getProjectsDir(), sanitizePath2(dir), "bridge-pointer.json");
|
|
512845
513128
|
}
|
|
512846
513129
|
async function writeBridgePointer(dir, pointer) {
|
|
512847
513130
|
const path17 = getBridgePointerPath(dir);
|
|
512848
513131
|
try {
|
|
512849
|
-
await
|
|
512850
|
-
await
|
|
513132
|
+
await mkdir63(dirname63(path17), { recursive: true });
|
|
513133
|
+
await writeFile66(path17, jsonStringify(pointer), "utf8");
|
|
512851
513134
|
logForDebugging(`[bridge:pointer] wrote ${path17}`);
|
|
512852
513135
|
} catch (err2) {
|
|
512853
513136
|
logForDebugging(`[bridge:pointer] write failed: ${err2}`, { level: "warn" });
|
|
@@ -512859,7 +513142,7 @@ async function readBridgePointer(dir) {
|
|
|
512859
513142
|
let mtimeMs;
|
|
512860
513143
|
try {
|
|
512861
513144
|
mtimeMs = (await stat58(path17)).mtimeMs;
|
|
512862
|
-
raw = await
|
|
513145
|
+
raw = await readFile71(path17, "utf8");
|
|
512863
513146
|
} catch {
|
|
512864
513147
|
return null;
|
|
512865
513148
|
}
|
|
@@ -512984,7 +513267,7 @@ async function initBridgeCore(params) {
|
|
|
512984
513267
|
const rawApi = createBridgeApiClient({
|
|
512985
513268
|
baseUrl,
|
|
512986
513269
|
getAccessToken,
|
|
512987
|
-
runnerVersion: "2.
|
|
513270
|
+
runnerVersion: "2.3.1",
|
|
512988
513271
|
onDebug: logForDebugging,
|
|
512989
513272
|
onAuth401,
|
|
512990
513273
|
getTrustedDeviceToken
|
|
@@ -514845,8 +515128,8 @@ __export(exports_print, {
|
|
|
514845
515128
|
createCanUseToolWithPermissionPrompt: () => createCanUseToolWithPermissionPrompt,
|
|
514846
515129
|
canBatchWith: () => canBatchWith
|
|
514847
515130
|
});
|
|
514848
|
-
import { readFile as
|
|
514849
|
-
import { dirname as
|
|
515131
|
+
import { readFile as readFile72, stat as stat59 } from "fs/promises";
|
|
515132
|
+
import { dirname as dirname64 } from "path";
|
|
514850
515133
|
import { cwd as cwd2 } from "process";
|
|
514851
515134
|
import { randomUUID as randomUUID53 } from "crypto";
|
|
514852
515135
|
function trackReceivedMessageUuid(uuid2) {
|
|
@@ -516195,7 +516478,7 @@ ${m2.text}
|
|
|
516195
516478
|
const normalizedPath = expandPath(message.request.path);
|
|
516196
516479
|
const diskMtime = Math.floor((await stat59(normalizedPath)).mtimeMs);
|
|
516197
516480
|
if (diskMtime <= message.request.mtime) {
|
|
516198
|
-
const raw = await
|
|
516481
|
+
const raw = await readFile72(normalizedPath, "utf-8");
|
|
516199
516482
|
const content = (raw.charCodeAt(0) === 65279 ? raw.slice(1) : raw).replaceAll(`\r
|
|
516200
516483
|
`, `
|
|
516201
516484
|
`);
|
|
@@ -517281,7 +517564,7 @@ async function loadInitialMessages(setAppState, options) {
|
|
|
517281
517564
|
if (false) {}
|
|
517282
517565
|
if (!options.forkSession) {
|
|
517283
517566
|
if (result.sessionId) {
|
|
517284
|
-
switchSession(asSessionId(result.sessionId), result.fullPath ?
|
|
517567
|
+
switchSession(asSessionId(result.sessionId), result.fullPath ? dirname64(result.fullPath) : null);
|
|
517285
517568
|
if (persistSession) {
|
|
517286
517569
|
await resetSessionFilePointer();
|
|
517287
517570
|
}
|
|
@@ -517379,7 +517662,7 @@ async function loadInitialMessages(setAppState, options) {
|
|
|
517379
517662
|
}
|
|
517380
517663
|
if (false) {}
|
|
517381
517664
|
if (!options.forkSession && result.sessionId) {
|
|
517382
|
-
switchSession(asSessionId(result.sessionId), result.fullPath ?
|
|
517665
|
+
switchSession(asSessionId(result.sessionId), result.fullPath ? dirname64(result.fullPath) : null);
|
|
517383
517666
|
if (persistSession) {
|
|
517384
517667
|
await resetSessionFilePointer();
|
|
517385
517668
|
}
|
|
@@ -518703,7 +518986,7 @@ async function startMCPServer(cwd3, debug4, verbose) {
|
|
|
518703
518986
|
setCwd(cwd3);
|
|
518704
518987
|
const server = new Server({
|
|
518705
518988
|
name: "claude/tengu",
|
|
518706
|
-
version: "2.
|
|
518989
|
+
version: "2.3.1"
|
|
518707
518990
|
}, {
|
|
518708
518991
|
capabilities: {
|
|
518709
518992
|
tools: {}
|
|
@@ -518833,16 +519116,16 @@ __export(exports_appDesktop, {
|
|
|
518833
519116
|
readClaudeDesktopMcpServers: () => readClaudeDesktopMcpServers,
|
|
518834
519117
|
getClaudeDesktopConfigPath: () => getClaudeDesktopConfigPath
|
|
518835
519118
|
});
|
|
518836
|
-
import { readdir as readdir40, readFile as
|
|
518837
|
-
import { homedir as
|
|
518838
|
-
import { join as
|
|
519119
|
+
import { readdir as readdir40, readFile as readFile73, stat as stat60 } from "fs/promises";
|
|
519120
|
+
import { homedir as homedir39 } from "os";
|
|
519121
|
+
import { join as join171 } from "path";
|
|
518839
519122
|
async function getClaudeDesktopConfigPath() {
|
|
518840
519123
|
const platform3 = getPlatform();
|
|
518841
519124
|
if (!SUPPORTED_PLATFORMS.includes(platform3)) {
|
|
518842
519125
|
throw new Error(`Unsupported platform: ${platform3} - desktop app integration only works on macOS and WSL.`);
|
|
518843
519126
|
}
|
|
518844
519127
|
if (platform3 === "macos") {
|
|
518845
|
-
return
|
|
519128
|
+
return join171(homedir39(), "Library", "Application Support", "Claude", "claude_desktop_config.json");
|
|
518846
519129
|
}
|
|
518847
519130
|
const windowsHome = process.env.USERPROFILE ? process.env.USERPROFILE.replace(/\\/g, "/") : null;
|
|
518848
519131
|
if (windowsHome) {
|
|
@@ -518861,7 +519144,7 @@ async function getClaudeDesktopConfigPath() {
|
|
|
518861
519144
|
if (user.name === "Public" || user.name === "Default" || user.name === "Default User" || user.name === "All Users") {
|
|
518862
519145
|
continue;
|
|
518863
519146
|
}
|
|
518864
|
-
const potentialConfigPath =
|
|
519147
|
+
const potentialConfigPath = join171(usersDir, user.name, "AppData", "Roaming", "Claude", "claude_desktop_config.json");
|
|
518865
519148
|
try {
|
|
518866
519149
|
await stat60(potentialConfigPath);
|
|
518867
519150
|
return potentialConfigPath;
|
|
@@ -518881,7 +519164,7 @@ async function readClaudeDesktopMcpServers() {
|
|
|
518881
519164
|
const configPath = await getClaudeDesktopConfigPath();
|
|
518882
519165
|
let configContent;
|
|
518883
519166
|
try {
|
|
518884
|
-
configContent = await
|
|
519167
|
+
configContent = await readFile73(configPath, { encoding: "utf8" });
|
|
518885
519168
|
} catch (e) {
|
|
518886
519169
|
const code = getErrnoCode(e);
|
|
518887
519170
|
if (code === "ENOENT") {
|
|
@@ -519256,7 +519539,7 @@ __export(exports_plugins, {
|
|
|
519256
519539
|
VALID_UPDATE_SCOPES: () => VALID_UPDATE_SCOPES,
|
|
519257
519540
|
VALID_INSTALLABLE_SCOPES: () => VALID_INSTALLABLE_SCOPES
|
|
519258
519541
|
});
|
|
519259
|
-
import { basename as basename60, dirname as
|
|
519542
|
+
import { basename as basename60, dirname as dirname65 } from "path";
|
|
519260
519543
|
function handleMarketplaceError(error5, action2) {
|
|
519261
519544
|
logError(error5);
|
|
519262
519545
|
cliError(`${figures_default.cross} Failed to ${action2}: ${errorMessage(error5)}`);
|
|
@@ -519289,9 +519572,9 @@ async function pluginValidateHandler(manifestPath, options) {
|
|
|
519289
519572
|
printValidationResult(result);
|
|
519290
519573
|
let contentResults = [];
|
|
519291
519574
|
if (result.fileType === "plugin") {
|
|
519292
|
-
const manifestDir =
|
|
519575
|
+
const manifestDir = dirname65(result.filePath);
|
|
519293
519576
|
if (basename60(manifestDir) === ".claude-plugin") {
|
|
519294
|
-
contentResults = await validatePluginContents(
|
|
519577
|
+
contentResults = await validatePluginContents(dirname65(manifestDir));
|
|
519295
519578
|
for (const r of contentResults) {
|
|
519296
519579
|
console.log(`Validating ${r.fileType}: ${r.filePath}
|
|
519297
519580
|
`);
|
|
@@ -519784,7 +520067,7 @@ function WelcomeLogo() {
|
|
|
519784
520067
|
dimColor: true,
|
|
519785
520068
|
children: [
|
|
519786
520069
|
"v",
|
|
519787
|
-
"2.
|
|
520070
|
+
"2.3.1"
|
|
519788
520071
|
]
|
|
519789
520072
|
}, undefined, true, undefined, this)
|
|
519790
520073
|
]
|
|
@@ -519975,7 +520258,7 @@ __export(exports_update, {
|
|
|
519975
520258
|
});
|
|
519976
520259
|
async function update() {
|
|
519977
520260
|
logEvent("tengu_update_check", {});
|
|
519978
|
-
writeToStdout(`Current version: ${"2.
|
|
520261
|
+
writeToStdout(`Current version: ${"2.3.1"}
|
|
519979
520262
|
`);
|
|
519980
520263
|
const channel = getInitialSettings()?.autoUpdatesChannel ?? "latest";
|
|
519981
520264
|
writeToStdout(`Checking for updates to ${channel} version...
|
|
@@ -520050,8 +520333,8 @@ async function update() {
|
|
|
520050
520333
|
writeToStdout(`localclawd is managed by Homebrew.
|
|
520051
520334
|
`);
|
|
520052
520335
|
const latest = await getLatestVersion(channel);
|
|
520053
|
-
if (latest && !gte("2.
|
|
520054
|
-
writeToStdout(`Update available: ${"2.
|
|
520336
|
+
if (latest && !gte("2.3.1", latest)) {
|
|
520337
|
+
writeToStdout(`Update available: ${"2.3.1"} → ${latest}
|
|
520055
520338
|
`);
|
|
520056
520339
|
writeToStdout(`
|
|
520057
520340
|
`);
|
|
@@ -520067,8 +520350,8 @@ async function update() {
|
|
|
520067
520350
|
writeToStdout(`localclawd is managed by winget.
|
|
520068
520351
|
`);
|
|
520069
520352
|
const latest = await getLatestVersion(channel);
|
|
520070
|
-
if (latest && !gte("2.
|
|
520071
|
-
writeToStdout(`Update available: ${"2.
|
|
520353
|
+
if (latest && !gte("2.3.1", latest)) {
|
|
520354
|
+
writeToStdout(`Update available: ${"2.3.1"} → ${latest}
|
|
520072
520355
|
`);
|
|
520073
520356
|
writeToStdout(`
|
|
520074
520357
|
`);
|
|
@@ -520082,8 +520365,8 @@ async function update() {
|
|
|
520082
520365
|
writeToStdout(`localclawd is managed by apk.
|
|
520083
520366
|
`);
|
|
520084
520367
|
const latest = await getLatestVersion(channel);
|
|
520085
|
-
if (latest && !gte("2.
|
|
520086
|
-
writeToStdout(`Update available: ${"2.
|
|
520368
|
+
if (latest && !gte("2.3.1", latest)) {
|
|
520369
|
+
writeToStdout(`Update available: ${"2.3.1"} → ${latest}
|
|
520087
520370
|
`);
|
|
520088
520371
|
writeToStdout(`
|
|
520089
520372
|
`);
|
|
@@ -520148,11 +520431,11 @@ async function update() {
|
|
|
520148
520431
|
`);
|
|
520149
520432
|
await gracefulShutdown(1);
|
|
520150
520433
|
}
|
|
520151
|
-
if (result.latestVersion === "2.
|
|
520152
|
-
writeToStdout(source_default.green(`localclawd is up to date (${"2.
|
|
520434
|
+
if (result.latestVersion === "2.3.1") {
|
|
520435
|
+
writeToStdout(source_default.green(`localclawd is up to date (${"2.3.1"})`) + `
|
|
520153
520436
|
`);
|
|
520154
520437
|
} else {
|
|
520155
|
-
writeToStdout(source_default.green(`Successfully updated from ${"2.
|
|
520438
|
+
writeToStdout(source_default.green(`Successfully updated from ${"2.3.1"} to version ${result.latestVersion}`) + `
|
|
520156
520439
|
`);
|
|
520157
520440
|
await regenerateCompletionCache();
|
|
520158
520441
|
}
|
|
@@ -520212,12 +520495,12 @@ async function update() {
|
|
|
520212
520495
|
`);
|
|
520213
520496
|
await gracefulShutdown(1);
|
|
520214
520497
|
}
|
|
520215
|
-
if (latestVersion === "2.
|
|
520216
|
-
writeToStdout(source_default.green(`localclawd is up to date (${"2.
|
|
520498
|
+
if (latestVersion === "2.3.1") {
|
|
520499
|
+
writeToStdout(source_default.green(`localclawd is up to date (${"2.3.1"})`) + `
|
|
520217
520500
|
`);
|
|
520218
520501
|
await gracefulShutdown(0);
|
|
520219
520502
|
}
|
|
520220
|
-
writeToStdout(`New version available: ${latestVersion} (current: ${"2.
|
|
520503
|
+
writeToStdout(`New version available: ${latestVersion} (current: ${"2.3.1"})
|
|
520221
520504
|
`);
|
|
520222
520505
|
writeToStdout(`Installing update...
|
|
520223
520506
|
`);
|
|
@@ -520262,7 +520545,7 @@ async function update() {
|
|
|
520262
520545
|
logForDebugging(`update: Installation status: ${status2}`);
|
|
520263
520546
|
switch (status2) {
|
|
520264
520547
|
case "success":
|
|
520265
|
-
writeToStdout(source_default.green(`Successfully updated from ${"2.
|
|
520548
|
+
writeToStdout(source_default.green(`Successfully updated from ${"2.3.1"} to version ${latestVersion}`) + `
|
|
520266
520549
|
`);
|
|
520267
520550
|
await regenerateCompletionCache();
|
|
520268
520551
|
break;
|
|
@@ -521504,7 +521787,7 @@ Run with --debug for more details.
|
|
|
521504
521787
|
}
|
|
521505
521788
|
}
|
|
521506
521789
|
logForDiagnosticsNoPII("info", "started", {
|
|
521507
|
-
version: "2.
|
|
521790
|
+
version: "2.3.1",
|
|
521508
521791
|
is_native_binary: isInBundledMode()
|
|
521509
521792
|
});
|
|
521510
521793
|
registerCleanup(async () => {
|
|
@@ -522288,7 +522571,7 @@ Usage: localclawd --remote "your task description"`, () => gracefulShutdown(1));
|
|
|
522288
522571
|
pendingHookMessages
|
|
522289
522572
|
}, renderAndRun);
|
|
522290
522573
|
}
|
|
522291
|
-
}).version("2.
|
|
522574
|
+
}).version("2.3.1 (localclawd)", "-v, --version", "Output the version number");
|
|
522292
522575
|
program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
|
|
522293
522576
|
program2.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.");
|
|
522294
522577
|
if (canUserConfigureAdvisor()) {
|
|
@@ -522802,7 +523085,7 @@ if (false) {}
|
|
|
522802
523085
|
async function main2() {
|
|
522803
523086
|
const args = process.argv.slice(2);
|
|
522804
523087
|
if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
|
|
522805
|
-
console.log(`${"2.
|
|
523088
|
+
console.log(`${"2.3.1"} (localclawd)`);
|
|
522806
523089
|
return;
|
|
522807
523090
|
}
|
|
522808
523091
|
const {
|
|
@@ -522877,11 +523160,11 @@ localclawd: unhandled error (continuing) — ${msg}
|
|
|
522877
523160
|
`);
|
|
522878
523161
|
try {
|
|
522879
523162
|
const { appendFileSync: appendFileSync4, mkdirSync: mkdirSync6 } = __require("fs");
|
|
522880
|
-
const { homedir:
|
|
522881
|
-
const { join:
|
|
522882
|
-
const dir =
|
|
523163
|
+
const { homedir: homedir40 } = __require("os");
|
|
523164
|
+
const { join: join172 } = __require("path");
|
|
523165
|
+
const dir = join172(homedir40(), ".claude");
|
|
522883
523166
|
mkdirSync6(dir, { recursive: true });
|
|
522884
|
-
appendFileSync4(
|
|
523167
|
+
appendFileSync4(join172(dir, "crash.log"), `[${new Date().toISOString()}] unhandledRejection: ${msg}
|
|
522885
523168
|
`);
|
|
522886
523169
|
} catch {}
|
|
522887
523170
|
});
|
|
@@ -522893,4 +523176,4 @@ localclawd crashed: ${msg}
|
|
|
522893
523176
|
process.exit(1);
|
|
522894
523177
|
});
|
|
522895
523178
|
|
|
522896
|
-
//# debugId=
|
|
523179
|
+
//# debugId=33D2CC954FB1725C64756E2164756E21
|