@cnwenf/occ 2.1.298 → 2.1.300
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.js +766 -334
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
globalThis.MACRO={"VERSION":"2.1.
|
|
2
|
+
globalThis.MACRO={"VERSION":"2.1.300","BINARY_NAME":"occ","BUILD_TIME":"2026-08-13T23:37:42.199Z","FEEDBACK_CHANNEL":"","ISSUES_EXPLAINER":"","NATIVE_PACKAGE_URL":"","PACKAGE_URL":"@cnwenf/occ","VERSION_CHANGELOG":""};
|
|
3
3
|
// @bun
|
|
4
4
|
var __create = Object.create;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -162601,7 +162601,7 @@ var init_prompt2 = __esm(() => {
|
|
|
162601
162601
|
});
|
|
162602
162602
|
|
|
162603
162603
|
// src/tools/FileEditTool/constants.ts
|
|
162604
|
-
var FILE_EDIT_TOOL_NAME = "Edit", CLAUDE_FOLDER_PERMISSION_PATTERN = "/.claude/**", GLOBAL_CLAUDE_FOLDER_PERMISSION_PATTERN = "~/.claude/**"
|
|
162604
|
+
var FILE_EDIT_TOOL_NAME = "Edit", CLAUDE_FOLDER_PERMISSION_PATTERN = "/.claude/**", GLOBAL_CLAUDE_FOLDER_PERMISSION_PATTERN = "~/.claude/**";
|
|
162605
162605
|
|
|
162606
162606
|
// src/utils/pdfUtils.ts
|
|
162607
162607
|
function parsePDFPageRange(pages) {
|
|
@@ -189468,14 +189468,23 @@ function getCLISyspromptPrefix(options) {
|
|
|
189468
189468
|
}
|
|
189469
189469
|
return DEFAULT_PREFIX;
|
|
189470
189470
|
}
|
|
189471
|
-
function
|
|
189472
|
-
|
|
189471
|
+
function isPlainAnthropicApiBaseUrl() {
|
|
189472
|
+
const baseUrl = process.env.ANTHROPIC_BASE_URL;
|
|
189473
|
+
if (!baseUrl) {
|
|
189474
|
+
return true;
|
|
189475
|
+
}
|
|
189476
|
+
try {
|
|
189477
|
+
return ["api.anthropic.com"].includes(new URL(baseUrl).host);
|
|
189478
|
+
} catch {
|
|
189473
189479
|
return false;
|
|
189474
189480
|
}
|
|
189475
|
-
return getFeatureValue_CACHED_MAY_BE_STALE("tengu_attribution_header", true);
|
|
189476
189481
|
}
|
|
189477
|
-
function getAttributionHeader(fingerprint) {
|
|
189478
|
-
|
|
189482
|
+
function getAttributionHeader(fingerprint, opts) {
|
|
189483
|
+
const envOptOutBypassed = opts?.ignoreEnvOptOut === true && getAPIProvider() === "firstParty" && isPlainAnthropicApiBaseUrl() && !process.env.ANTHROPIC_UNIX_SOCKET;
|
|
189484
|
+
if (!envOptOutBypassed && isEnvDefinedFalsy(process.env.CLAUDE_CODE_ATTRIBUTION_HEADER)) {
|
|
189485
|
+
return "";
|
|
189486
|
+
}
|
|
189487
|
+
if (!getFeatureValue_CACHED_MAY_BE_STALE("tengu_attribution_header", true)) {
|
|
189479
189488
|
return "";
|
|
189480
189489
|
}
|
|
189481
189490
|
const version5 = `${MACRO.VERSION}.${fingerprint}`;
|
|
@@ -263679,13 +263688,6 @@ function checkEditWouldApply(fileContent, oldString, replaceAll2) {
|
|
|
263679
263688
|
}
|
|
263680
263689
|
return "applies";
|
|
263681
263690
|
}
|
|
263682
|
-
function isStaleReadRecoverable(filePath, toolUseContext) {
|
|
263683
|
-
const tools = toolUseContext.options.tools ?? [];
|
|
263684
|
-
const hasReadTool = tools.some((tool) => tool.name === FILE_READ_TOOL_NAME);
|
|
263685
|
-
const appState = toolUseContext.getAppState();
|
|
263686
|
-
const denyReadRule = matchingRuleForInput(filePath, appState.toolPermissionContext, "read", "deny");
|
|
263687
|
-
return hasReadTool && denyReadRule === null;
|
|
263688
|
-
}
|
|
263689
263691
|
function preserveQuoteStyle(oldString, actualOldString, newString) {
|
|
263690
263692
|
if (oldString === actualOldString) {
|
|
263691
263693
|
return newString;
|
|
@@ -263993,8 +263995,6 @@ var init_utils8 = __esm(() => {
|
|
|
263993
263995
|
init_diff2();
|
|
263994
263996
|
init_errors();
|
|
263995
263997
|
init_file();
|
|
263996
|
-
init_filesystem();
|
|
263997
|
-
init_prompt3();
|
|
263998
263998
|
DESANITIZATIONS = {
|
|
263999
263999
|
"<fnr>": "<function_results>",
|
|
264000
264000
|
"<n>": "<name>",
|
|
@@ -367482,6 +367482,7 @@ var init_types10 = __esm(() => {
|
|
|
367482
367482
|
structuredPatch: exports_external.array(hunkSchema()).describe("Diff patch showing the changes"),
|
|
367483
367483
|
userModified: exports_external.boolean().describe("Whether the user modified the proposed changes"),
|
|
367484
367484
|
replaceAll: exports_external.boolean().describe("Whether all occurrences were replaced"),
|
|
367485
|
+
staleRecovered: exports_external.boolean().optional().describe("True when the file changed on disk since the last read but the edit still applied cleanly (2.1.228 stale recovery)"),
|
|
367485
367486
|
gitDiff: gitDiffSchema().optional()
|
|
367486
367487
|
}));
|
|
367487
367488
|
});
|
|
@@ -372717,6 +372718,183 @@ var init_perforce = __esm(() => {
|
|
|
372717
372718
|
init_envUtils();
|
|
372718
372719
|
});
|
|
372719
372720
|
|
|
372721
|
+
// src/utils/permissions/fileStateGuard.ts
|
|
372722
|
+
import { extname as extname12 } from "path";
|
|
372723
|
+
function stripBracket1m(model) {
|
|
372724
|
+
return model.replace(/\[1m\]$/i, "");
|
|
372725
|
+
}
|
|
372726
|
+
function isOldModel(model) {
|
|
372727
|
+
const stripped = stripBracket1m(model);
|
|
372728
|
+
const guardName = CANONICAL_TO_GUARD_NAME[stripped] ?? stripped;
|
|
372729
|
+
return OLD_GUARD_MODELS.has(guardName);
|
|
372730
|
+
}
|
|
372731
|
+
function getModelBucket(model) {
|
|
372732
|
+
const bucket = stripBracket1m(model).replace(/^claude-/, "").replaceAll("-", "_");
|
|
372733
|
+
return /^[a-z0-9_]{1,40}$/.test(bucket) ? bucket : "nonconforming";
|
|
372734
|
+
}
|
|
372735
|
+
function getGuardModel(context4) {
|
|
372736
|
+
return getCanonicalName(context4.options.mainLoopModel);
|
|
372737
|
+
}
|
|
372738
|
+
function isNotebookPathForGuard(fullFilePath) {
|
|
372739
|
+
return extname12(fullFilePath.replace(/[. ]+$/, "")).toLowerCase() === ".ipynb";
|
|
372740
|
+
}
|
|
372741
|
+
function isCoveredByReadDenyRule(fullFilePath, toolPermissionContext) {
|
|
372742
|
+
const bareReadDenied = getDenyRules(toolPermissionContext).some((rule) => !RUNTIME_NARROWING_RULE_SOURCES.has(rule.source) && rule.ruleValue.ruleContent === undefined && rule.ruleValue.toolName === FILE_READ_TOOL_NAME);
|
|
372743
|
+
if (bareReadDenied) {
|
|
372744
|
+
return true;
|
|
372745
|
+
}
|
|
372746
|
+
if (getRuleByContentsForToolName(toolPermissionContext, FILE_READ_TOOL_NAME, "deny").size === 0) {
|
|
372747
|
+
return false;
|
|
372748
|
+
}
|
|
372749
|
+
return getPathsForPermissionCheck(fullFilePath).some((pathToCheck) => matchingRuleForInput(pathToCheck, toolPermissionContext, "read", "deny") !== null);
|
|
372750
|
+
}
|
|
372751
|
+
function isReadToolUnavailableForGuard(writingToolName, context4) {
|
|
372752
|
+
const tools = context4.options.tools ?? [];
|
|
372753
|
+
return tools.some((tool) => toolMatchesName(tool, writingToolName)) && !tools.some((tool) => toolMatchesName(tool, FILE_READ_TOOL_NAME)) && !tools.some((tool) => toolMatchesName(tool, REPL_TOOL_NAME));
|
|
372754
|
+
}
|
|
372755
|
+
function isReadAutoAllowedForPath(fullFilePath, toolPermissionContext) {
|
|
372756
|
+
if (getDenyRuleForTool(toolPermissionContext, READ_PROBE) !== null || getAskRuleForTool(toolPermissionContext, READ_PROBE) !== null) {
|
|
372757
|
+
return false;
|
|
372758
|
+
}
|
|
372759
|
+
const decision = checkReadPermissionForTool(READ_PROBE, { file_path: fullFilePath }, toolPermissionContext);
|
|
372760
|
+
if (decision.behavior === "allow") {
|
|
372761
|
+
return true;
|
|
372762
|
+
}
|
|
372763
|
+
if (decision.behavior !== "ask") {
|
|
372764
|
+
return false;
|
|
372765
|
+
}
|
|
372766
|
+
if (toolPermissionContext.mode !== "bypassPermissions") {
|
|
372767
|
+
return false;
|
|
372768
|
+
}
|
|
372769
|
+
const reason = decision.decisionReason;
|
|
372770
|
+
return !(reason?.type === "rule" && reason.rule.ruleBehavior === "ask");
|
|
372771
|
+
}
|
|
372772
|
+
function wouldReadBeAutoAllowed(writingToolName, fullFilePath, context4, toolPermissionContext) {
|
|
372773
|
+
return !isReadToolUnavailableForGuard(writingToolName, context4) && isReadAutoAllowedForPath(fullFilePath, toolPermissionContext);
|
|
372774
|
+
}
|
|
372775
|
+
function isFullReadOfFileState(state3) {
|
|
372776
|
+
if ((state3.offset ?? 1) > 1 || state3.isPartialView) {
|
|
372777
|
+
return false;
|
|
372778
|
+
}
|
|
372779
|
+
if (state3.limit === undefined) {
|
|
372780
|
+
return true;
|
|
372781
|
+
}
|
|
372782
|
+
return state3.content !== "" && countCharInString(state3.content, `
|
|
372783
|
+
`) + 1 < state3.limit;
|
|
372784
|
+
}
|
|
372785
|
+
function stripBom(content) {
|
|
372786
|
+
return content.charCodeAt(0) === 65279 ? content.slice(1) : content;
|
|
372787
|
+
}
|
|
372788
|
+
function normalizeForComparison(content) {
|
|
372789
|
+
return stripBom(content).replaceAll(`\r
|
|
372790
|
+
`, `
|
|
372791
|
+
`);
|
|
372792
|
+
}
|
|
372793
|
+
function fileStateMatchesDisk(state3, diskContent) {
|
|
372794
|
+
return state3.content === diskContent;
|
|
372795
|
+
}
|
|
372796
|
+
function fileStateMatchesNormalized(state3, rawContent2) {
|
|
372797
|
+
return fileStateMatchesDisk(state3, normalizeForComparison(rawContent2));
|
|
372798
|
+
}
|
|
372799
|
+
function editWouldApplyToTelemetry(result) {
|
|
372800
|
+
switch (result) {
|
|
372801
|
+
case "no_match":
|
|
372802
|
+
return "errorCode8";
|
|
372803
|
+
case "ambiguous":
|
|
372804
|
+
return "errorCode9";
|
|
372805
|
+
case "applies":
|
|
372806
|
+
return "success";
|
|
372807
|
+
}
|
|
372808
|
+
}
|
|
372809
|
+
function assertWriteFileStateFresh(args) {
|
|
372810
|
+
const { fullFilePath, diskContent, lastRead, model, readNotAutoAllowed } = args;
|
|
372811
|
+
if (!lastRead || lastRead.isPartialView) {
|
|
372812
|
+
if (!lastRead && !isNotebookPathForGuard(fullFilePath) && !isOldModel(model) && !readNotAutoAllowed()) {
|
|
372813
|
+
return;
|
|
372814
|
+
}
|
|
372815
|
+
throw new FileStateError(FILE_NOT_READ_MESSAGE);
|
|
372816
|
+
}
|
|
372817
|
+
if (!(getFileModificationTime(fullFilePath) > lastRead.timestamp)) {
|
|
372818
|
+
return;
|
|
372819
|
+
}
|
|
372820
|
+
if (isFullReadOfFileState(lastRead) && fileStateMatchesDisk(lastRead, stripBom(diskContent))) {
|
|
372821
|
+
return;
|
|
372822
|
+
}
|
|
372823
|
+
throw new FileStateError(FILE_MODIFIED_SINCE_READ_CALL_MESSAGE);
|
|
372824
|
+
}
|
|
372825
|
+
function checkEditFileStateAtCall(args) {
|
|
372826
|
+
const {
|
|
372827
|
+
absoluteFilePath,
|
|
372828
|
+
fileContents,
|
|
372829
|
+
lastRead,
|
|
372830
|
+
oldString,
|
|
372831
|
+
replaceAll: replaceAll2,
|
|
372832
|
+
model,
|
|
372833
|
+
readNotAutoAllowed
|
|
372834
|
+
} = args;
|
|
372835
|
+
if (!lastRead) {
|
|
372836
|
+
if (!isOldModel(model) && !readNotAutoAllowed()) {
|
|
372837
|
+
return false;
|
|
372838
|
+
}
|
|
372839
|
+
throw new FileStateError(FILE_NOT_READ_MESSAGE);
|
|
372840
|
+
}
|
|
372841
|
+
if (getFileModificationTime(absoluteFilePath) <= lastRead.timestamp) {
|
|
372842
|
+
return false;
|
|
372843
|
+
}
|
|
372844
|
+
if (isFullReadOfFileState(lastRead) && fileStateMatchesDisk(lastRead, stripBom(fileContents))) {
|
|
372845
|
+
return false;
|
|
372846
|
+
}
|
|
372847
|
+
if (checkEditWouldApply(fileContents, oldString, replaceAll2) === "applies" && !readNotAutoAllowed()) {
|
|
372848
|
+
return true;
|
|
372849
|
+
}
|
|
372850
|
+
throw new FileStateError(FILE_MODIFIED_SINCE_READ_CALL_MESSAGE);
|
|
372851
|
+
}
|
|
372852
|
+
var FILE_NOT_READ_MESSAGE = "File has not been read yet. Read it first before writing to it.", FILE_MODIFIED_SINCE_READ_VALIDATION_MESSAGE = "File has been modified since read, either by the user or by a linter. Read it again before attempting to write it.", FILE_MODIFIED_SINCE_READ_CALL_MESSAGE = "File content has changed since it was last read. This commonly happens when a linter or formatter run via Bash rewrites the file. Call Read on this file to refresh, then retry the edit.", READ_DENY_EDIT_MESSAGE = "File is covered by a Read deny rule in your permission settings and cannot be edited.", READ_DENY_WRITE_MESSAGE = "File is covered by a Read deny rule in your permission settings and cannot be written.", FILE_STATE_CURRENT_NOTE = " (file state is current in your context \u2014 no need to Read it back)", FileStateError, OLD_GUARD_MODELS, CANONICAL_TO_GUARD_NAME, RUNTIME_NARROWING_RULE_SOURCES, READ_PROBE;
|
|
372853
|
+
var init_fileStateGuard = __esm(() => {
|
|
372854
|
+
init_Tool();
|
|
372855
|
+
init_prompt3();
|
|
372856
|
+
init_constants9();
|
|
372857
|
+
init_utils8();
|
|
372858
|
+
init_file();
|
|
372859
|
+
init_fsOperations();
|
|
372860
|
+
init_model();
|
|
372861
|
+
init_stringUtils();
|
|
372862
|
+
init_filesystem();
|
|
372863
|
+
init_permissions2();
|
|
372864
|
+
FileStateError = class FileStateError extends Error {
|
|
372865
|
+
constructor(message) {
|
|
372866
|
+
super(message);
|
|
372867
|
+
this.name = "FileStateError";
|
|
372868
|
+
}
|
|
372869
|
+
};
|
|
372870
|
+
OLD_GUARD_MODELS = new Set([
|
|
372871
|
+
"claude-opus-4-6",
|
|
372872
|
+
"claude-haiku-4-5",
|
|
372873
|
+
"claude-opus-4-5",
|
|
372874
|
+
"claude-opus-4-1",
|
|
372875
|
+
"claude-opus-4-0",
|
|
372876
|
+
"claude-sonnet-4-5",
|
|
372877
|
+
"claude-sonnet-4-0",
|
|
372878
|
+
"claude-3-7-sonnet",
|
|
372879
|
+
"claude-3-5-sonnet",
|
|
372880
|
+
"claude-3-5-haiku"
|
|
372881
|
+
]);
|
|
372882
|
+
CANONICAL_TO_GUARD_NAME = {
|
|
372883
|
+
"claude-opus-4": "claude-opus-4-0",
|
|
372884
|
+
"claude-sonnet-4": "claude-sonnet-4-0"
|
|
372885
|
+
};
|
|
372886
|
+
RUNTIME_NARROWING_RULE_SOURCES = new Set([
|
|
372887
|
+
"toolsNarrowing",
|
|
372888
|
+
"cliArg",
|
|
372889
|
+
"command"
|
|
372890
|
+
]);
|
|
372891
|
+
READ_PROBE = {
|
|
372892
|
+
name: FILE_READ_TOOL_NAME,
|
|
372893
|
+
mcpInfo: undefined,
|
|
372894
|
+
getPath: (input) => String(input.file_path)
|
|
372895
|
+
};
|
|
372896
|
+
});
|
|
372897
|
+
|
|
372720
372898
|
// src/tools/FileWriteTool/UI.tsx
|
|
372721
372899
|
import { isAbsolute as isAbsolute15, relative as relative13, resolve as resolve29 } from "path";
|
|
372722
372900
|
function countLines(content) {
|
|
@@ -373181,12 +373359,11 @@ var init_UI3 = __esm(() => {
|
|
|
373181
373359
|
});
|
|
373182
373360
|
|
|
373183
373361
|
// src/tools/FileWriteTool/FileWriteTool.ts
|
|
373184
|
-
import { dirname as dirname32, sep as sep20 } from "path";
|
|
373362
|
+
import { basename as basename18, dirname as dirname32, isAbsolute as isAbsolute16, sep as sep20 } from "path";
|
|
373185
373363
|
var inputSchema5, outputSchema5, FileWriteTool;
|
|
373186
373364
|
var init_FileWriteTool = __esm(() => {
|
|
373187
373365
|
init_analytics();
|
|
373188
373366
|
init_v4();
|
|
373189
|
-
init_growthbook();
|
|
373190
373367
|
init_diagnosticTracking();
|
|
373191
373368
|
init_LSPDiagnosticRegistry();
|
|
373192
373369
|
init_manager3();
|
|
@@ -373208,6 +373385,7 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373208
373385
|
init_log3();
|
|
373209
373386
|
init_path2();
|
|
373210
373387
|
init_perforce();
|
|
373388
|
+
init_fileStateGuard();
|
|
373211
373389
|
init_filesystem();
|
|
373212
373390
|
init_shellRuleMatching();
|
|
373213
373391
|
init_types10();
|
|
@@ -373277,12 +373455,22 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373277
373455
|
},
|
|
373278
373456
|
async validateInput({ file_path, content }, toolUseContext) {
|
|
373279
373457
|
const fullFilePath = expandPath(file_path);
|
|
373458
|
+
const toolPermissionContext = toolUseContext.getAppState().toolPermissionContext;
|
|
373459
|
+
if (toolUseContext.agentId && /^(REPORT|SUMMARY|FINDINGS|ANALYSIS).*\.md$/i.test(basename18(fullFilePath))) {
|
|
373460
|
+
logEvent2("tengu_subagent_md_report_blocked", {
|
|
373461
|
+
contentBytes: Buffer.byteLength(content)
|
|
373462
|
+
});
|
|
373463
|
+
return {
|
|
373464
|
+
result: false,
|
|
373465
|
+
message: "Subagents should return findings as text, not write report files. Include this content in your final response instead.",
|
|
373466
|
+
errorCode: 5
|
|
373467
|
+
};
|
|
373468
|
+
}
|
|
373280
373469
|
const secretError = checkTeamMemSecrets(fullFilePath, content);
|
|
373281
373470
|
if (secretError) {
|
|
373282
373471
|
return { result: false, message: secretError, errorCode: 0 };
|
|
373283
373472
|
}
|
|
373284
|
-
const
|
|
373285
|
-
const denyRule = matchingRuleForInput(fullFilePath, appState.toolPermissionContext, "edit", "deny");
|
|
373473
|
+
const denyRule = matchingRuleForInput(fullFilePath, toolPermissionContext, "edit", "deny");
|
|
373286
373474
|
if (denyRule !== null) {
|
|
373287
373475
|
return {
|
|
373288
373476
|
result: false,
|
|
@@ -373290,6 +373478,13 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373290
373478
|
errorCode: 1
|
|
373291
373479
|
};
|
|
373292
373480
|
}
|
|
373481
|
+
if (isCoveredByReadDenyRule(fullFilePath, toolPermissionContext)) {
|
|
373482
|
+
return {
|
|
373483
|
+
result: false,
|
|
373484
|
+
message: READ_DENY_WRITE_MESSAGE,
|
|
373485
|
+
errorCode: 13
|
|
373486
|
+
};
|
|
373487
|
+
}
|
|
373293
373488
|
if (fullFilePath.startsWith("\\\\") || fullFilePath.startsWith("//")) {
|
|
373294
373489
|
return { result: true };
|
|
373295
373490
|
}
|
|
@@ -373302,9 +373497,8 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373302
373497
|
if (perforceError) {
|
|
373303
373498
|
return {
|
|
373304
373499
|
result: false,
|
|
373305
|
-
behavior: "ask",
|
|
373306
373500
|
message: perforceError,
|
|
373307
|
-
errorCode:
|
|
373501
|
+
errorCode: 6
|
|
373308
373502
|
};
|
|
373309
373503
|
}
|
|
373310
373504
|
} catch (e4) {
|
|
@@ -373313,38 +373507,60 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373313
373507
|
}
|
|
373314
373508
|
throw e4;
|
|
373315
373509
|
}
|
|
373316
|
-
const
|
|
373317
|
-
if (!
|
|
373318
|
-
|
|
373319
|
-
|
|
373320
|
-
|
|
373321
|
-
|
|
373322
|
-
|
|
373510
|
+
const lastRead = toolUseContext.readFileState.get(fullFilePath);
|
|
373511
|
+
if (!lastRead || lastRead.isPartialView) {
|
|
373512
|
+
const model = getGuardModel(toolUseContext);
|
|
373513
|
+
const guardSkipped = !lastRead && !isNotebookPathForGuard(fullFilePath) && !isOldModel(model) && wouldReadBeAutoAllowed(FILE_WRITE_TOOL_NAME, fullFilePath, toolUseContext, toolPermissionContext);
|
|
373514
|
+
logEvent2("tengu_write_tool_not_read_hypothetical", {
|
|
373515
|
+
wouldHaveResult: lastRead && Math.floor(fileMtimeMs) > lastRead.timestamp ? "errorCode3" : "success",
|
|
373516
|
+
isPartialView: lastRead?.isPartialView === true,
|
|
373517
|
+
isFilePathAbsolute: isAbsolute16(file_path),
|
|
373518
|
+
guardSkipped,
|
|
373519
|
+
modelBucket: getModelBucket(model)
|
|
373520
|
+
});
|
|
373521
|
+
if (!guardSkipped) {
|
|
373522
|
+
return {
|
|
373523
|
+
result: false,
|
|
373524
|
+
message: FILE_NOT_READ_MESSAGE,
|
|
373525
|
+
errorCode: 2
|
|
373526
|
+
};
|
|
373527
|
+
}
|
|
373528
|
+
return { result: true };
|
|
373323
373529
|
}
|
|
373324
|
-
|
|
373325
|
-
|
|
373326
|
-
|
|
373327
|
-
|
|
373328
|
-
|
|
373329
|
-
|
|
373330
|
-
|
|
373530
|
+
if (Math.floor(fileMtimeMs) > lastRead.timestamp) {
|
|
373531
|
+
let matchesDisk = false;
|
|
373532
|
+
if (isFullReadOfFileState(lastRead)) {
|
|
373533
|
+
const diskBytes = await fs17.readFileBytes(fullFilePath);
|
|
373534
|
+
matchesDisk = fileStateMatchesNormalized(lastRead, diskBytes.toString("utf8"));
|
|
373535
|
+
}
|
|
373536
|
+
if (!matchesDisk) {
|
|
373537
|
+
return {
|
|
373538
|
+
result: false,
|
|
373539
|
+
message: FILE_MODIFIED_SINCE_READ_VALIDATION_MESSAGE,
|
|
373540
|
+
errorCode: 3
|
|
373541
|
+
};
|
|
373542
|
+
}
|
|
373331
373543
|
}
|
|
373332
373544
|
return { result: true };
|
|
373333
373545
|
},
|
|
373334
|
-
async call({ file_path, content },
|
|
373546
|
+
async call({ file_path, content }, context4, _2, parentMessage) {
|
|
373547
|
+
const { readFileState, updateFileHistoryState, dynamicSkillDirTriggers } = context4;
|
|
373335
373548
|
const fullFilePath = expandPath(file_path);
|
|
373336
373549
|
const dir = dirname32(fullFilePath);
|
|
373550
|
+
const toolPermissionContext = context4.getAppState().toolPermissionContext;
|
|
373551
|
+
if (isCoveredByReadDenyRule(fullFilePath, toolPermissionContext)) {
|
|
373552
|
+
throw new FileStateError(READ_DENY_WRITE_MESSAGE);
|
|
373553
|
+
}
|
|
373337
373554
|
const cwd2 = getCwd();
|
|
373338
373555
|
const newSkillDirs = await discoverSkillDirsForPaths([fullFilePath], cwd2);
|
|
373339
373556
|
if (newSkillDirs.length > 0) {
|
|
373340
|
-
for (const
|
|
373341
|
-
dynamicSkillDirTriggers?.add(
|
|
373557
|
+
for (const discoveredDir of newSkillDirs) {
|
|
373558
|
+
dynamicSkillDirTriggers?.add(discoveredDir);
|
|
373342
373559
|
}
|
|
373343
373560
|
addSkillDirectories(newSkillDirs).catch(() => {});
|
|
373344
373561
|
}
|
|
373345
373562
|
activateConditionalSkillsForPaths([fullFilePath], cwd2);
|
|
373346
373563
|
await diagnosticTracker.beforeFileEdited(fullFilePath);
|
|
373347
|
-
await getFsImplementation().mkdir(dir);
|
|
373348
373564
|
if (fileHistoryEnabled()) {
|
|
373349
373565
|
await fileHistoryTrackEdit(updateFileHistoryState, fullFilePath, parentMessage.uuid);
|
|
373350
373566
|
}
|
|
@@ -373359,18 +373575,16 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373359
373575
|
}
|
|
373360
373576
|
}
|
|
373361
373577
|
if (meta3 !== null) {
|
|
373362
|
-
|
|
373363
|
-
|
|
373364
|
-
|
|
373365
|
-
|
|
373366
|
-
|
|
373367
|
-
|
|
373368
|
-
|
|
373369
|
-
}
|
|
373578
|
+
assertWriteFileStateFresh({
|
|
373579
|
+
fullFilePath,
|
|
373580
|
+
diskContent: meta3.content,
|
|
373581
|
+
lastRead: readFileState.get(fullFilePath),
|
|
373582
|
+
model: getGuardModel(context4),
|
|
373583
|
+
readNotAutoAllowed: () => !wouldReadBeAutoAllowed(FILE_WRITE_TOOL_NAME, fullFilePath, context4, toolPermissionContext)
|
|
373584
|
+
});
|
|
373370
373585
|
}
|
|
373371
|
-
|
|
373372
|
-
|
|
373373
|
-
writeTextContent(fullFilePath, content, enc, "LF");
|
|
373586
|
+
await getFsImplementation().mkdir(dir);
|
|
373587
|
+
writeTextContent(fullFilePath, content, meta3?.encoding ?? "utf8", "LF");
|
|
373374
373588
|
const lspManager = getLspServerManager();
|
|
373375
373589
|
if (lspManager) {
|
|
373376
373590
|
clearDeliveredDiagnosticsForFile(`file://${fullFilePath}`);
|
|
@@ -373383,9 +373597,10 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373383
373597
|
logError2(err2);
|
|
373384
373598
|
});
|
|
373385
373599
|
}
|
|
373600
|
+
const oldContent = meta3?.content ?? null;
|
|
373386
373601
|
notifyVscodeFileUpdated(fullFilePath, oldContent, content);
|
|
373387
373602
|
readFileState.set(fullFilePath, {
|
|
373388
|
-
content,
|
|
373603
|
+
content: normalizeForComparison(content),
|
|
373389
373604
|
timestamp: getFileModificationTime(fullFilePath),
|
|
373390
373605
|
offset: undefined,
|
|
373391
373606
|
limit: undefined
|
|
@@ -373394,7 +373609,7 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373394
373609
|
logEvent2("tengu_write_claudemd", {});
|
|
373395
373610
|
}
|
|
373396
373611
|
let gitDiff;
|
|
373397
|
-
if (isEnvTruthy(process.env.CLAUDE_CODE_REMOTE)
|
|
373612
|
+
if (isEnvTruthy(process.env.CLAUDE_CODE_REMOTE)) {
|
|
373398
373613
|
const startTime2 = Date.now();
|
|
373399
373614
|
const diff2 = await fetchSingleFileGitDiff(fullFilePath);
|
|
373400
373615
|
if (diff2)
|
|
@@ -373405,6 +373620,7 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373405
373620
|
hasDiff: !!diff2
|
|
373406
373621
|
});
|
|
373407
373622
|
}
|
|
373623
|
+
const userModified = context4.userModified ?? false;
|
|
373408
373624
|
if (oldContent) {
|
|
373409
373625
|
const patch = getPatchForDisplay({
|
|
373410
373626
|
filePath: file_path,
|
|
@@ -373423,6 +373639,7 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373423
373639
|
content,
|
|
373424
373640
|
structuredPatch: patch,
|
|
373425
373641
|
originalFile: oldContent,
|
|
373642
|
+
userModified,
|
|
373426
373643
|
...gitDiff && { gitDiff }
|
|
373427
373644
|
};
|
|
373428
373645
|
countLinesChanged(patch);
|
|
@@ -373442,6 +373659,7 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373442
373659
|
content,
|
|
373443
373660
|
structuredPatch: [],
|
|
373444
373661
|
originalFile: null,
|
|
373662
|
+
userModified,
|
|
373445
373663
|
...gitDiff && { gitDiff }
|
|
373446
373664
|
};
|
|
373447
373665
|
countLinesChanged([], content);
|
|
@@ -373455,19 +373673,21 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373455
373673
|
data
|
|
373456
373674
|
};
|
|
373457
373675
|
},
|
|
373458
|
-
mapToolResultToToolResultBlockParam({ filePath, type }, toolUseID) {
|
|
373676
|
+
mapToolResultToToolResultBlockParam({ filePath, type, userModified }, toolUseID) {
|
|
373677
|
+
const modifiedNote = userModified ? " The user modified your proposed content before accepting it." : "";
|
|
373678
|
+
const stateNote = userModified ? "" : FILE_STATE_CURRENT_NOTE;
|
|
373459
373679
|
switch (type) {
|
|
373460
373680
|
case "create":
|
|
373461
373681
|
return {
|
|
373462
373682
|
tool_use_id: toolUseID,
|
|
373463
373683
|
type: "tool_result",
|
|
373464
|
-
content: `File created successfully at: ${filePath}`
|
|
373684
|
+
content: `File created successfully at: ${filePath}${modifiedNote}${stateNote}`
|
|
373465
373685
|
};
|
|
373466
373686
|
case "update":
|
|
373467
373687
|
return {
|
|
373468
373688
|
tool_use_id: toolUseID,
|
|
373469
373689
|
type: "tool_result",
|
|
373470
|
-
content: `The file ${filePath} has been updated successfully
|
|
373690
|
+
content: `The file ${filePath} has been updated successfully.${modifiedNote}${stateNote}`
|
|
373471
373691
|
};
|
|
373472
373692
|
}
|
|
373473
373693
|
}
|
|
@@ -373475,7 +373695,7 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373475
373695
|
});
|
|
373476
373696
|
|
|
373477
373697
|
// src/utils/plugins/orphanedPluginFilter.ts
|
|
373478
|
-
import { dirname as dirname33, isAbsolute as
|
|
373698
|
+
import { dirname as dirname33, isAbsolute as isAbsolute17, join as join73, normalize as normalize11, relative as relative14, sep as sep21 } from "path";
|
|
373479
373699
|
async function getGlobExclusionsForPluginCache(searchPath) {
|
|
373480
373700
|
const cachePath = normalize11(join73(getPluginsDirectory(), "cache"));
|
|
373481
373701
|
if (searchPath && !pathsOverlap(searchPath, cachePath)) {
|
|
@@ -373496,7 +373716,7 @@ async function getGlobExclusionsForPluginCache(searchPath) {
|
|
|
373496
373716
|
], cachePath, new AbortController().signal);
|
|
373497
373717
|
cachedExclusions = markers.map((markerPath) => {
|
|
373498
373718
|
const versionDir = dirname33(markerPath);
|
|
373499
|
-
const rel =
|
|
373719
|
+
const rel = isAbsolute17(versionDir) ? relative14(cachePath, versionDir) : versionDir;
|
|
373500
373720
|
const posixRelative = rel.replace(/\\/g, "/");
|
|
373501
373721
|
return `!**/${posixRelative}/**`;
|
|
373502
373722
|
});
|
|
@@ -373525,13 +373745,13 @@ var init_orphanedPluginFilter = __esm(() => {
|
|
|
373525
373745
|
});
|
|
373526
373746
|
|
|
373527
373747
|
// src/utils/glob.ts
|
|
373528
|
-
import { basename as
|
|
373748
|
+
import { basename as basename19, dirname as dirname34, isAbsolute as isAbsolute18, join as join74, sep as sep22 } from "path";
|
|
373529
373749
|
function extractGlobBaseDirectory(pattern) {
|
|
373530
373750
|
const globChars = /[*?[{]/;
|
|
373531
373751
|
const match = pattern.match(globChars);
|
|
373532
373752
|
if (!match || match.index === undefined) {
|
|
373533
373753
|
const dir = dirname34(pattern);
|
|
373534
|
-
const file2 =
|
|
373754
|
+
const file2 = basename19(pattern);
|
|
373535
373755
|
return { baseDir: dir, relativePattern: file2 };
|
|
373536
373756
|
}
|
|
373537
373757
|
const staticPrefix = pattern.slice(0, match.index);
|
|
@@ -373552,7 +373772,7 @@ function extractGlobBaseDirectory(pattern) {
|
|
|
373552
373772
|
async function glob(filePattern, cwd2, { limit, offset }, abortSignal, toolPermissionContext) {
|
|
373553
373773
|
let searchDir = cwd2;
|
|
373554
373774
|
let searchPattern = filePattern;
|
|
373555
|
-
if (
|
|
373775
|
+
if (isAbsolute18(filePattern)) {
|
|
373556
373776
|
const { baseDir, relativePattern } = extractGlobBaseDirectory(filePattern);
|
|
373557
373777
|
if (baseDir) {
|
|
373558
373778
|
searchDir = baseDir;
|
|
@@ -373577,7 +373797,7 @@ async function glob(filePattern, cwd2, { limit, offset }, abortSignal, toolPermi
|
|
|
373577
373797
|
args.push("--glob", exclusion);
|
|
373578
373798
|
}
|
|
373579
373799
|
const allPaths = await ripGrep(args, searchDir, abortSignal);
|
|
373580
|
-
const absolutePaths = allPaths.map((p4) =>
|
|
373800
|
+
const absolutePaths = allPaths.map((p4) => isAbsolute18(p4) ? p4 : join74(searchDir, p4));
|
|
373581
373801
|
const truncated = absolutePaths.length > offset + limit;
|
|
373582
373802
|
const files2 = absolutePaths.slice(offset, offset + limit);
|
|
373583
373803
|
return { files: files2, truncated };
|
|
@@ -379099,13 +379319,13 @@ var init_sedValidation = __esm(() => {
|
|
|
379099
379319
|
|
|
379100
379320
|
// src/tools/BashTool/pathValidation.ts
|
|
379101
379321
|
import { homedir as homedir22 } from "os";
|
|
379102
|
-
import { isAbsolute as
|
|
379322
|
+
import { isAbsolute as isAbsolute19, resolve as resolve30 } from "path";
|
|
379103
379323
|
function checkDangerousRemovalPaths(command4, args, cwd2) {
|
|
379104
379324
|
const extractor = PATH_EXTRACTORS[command4];
|
|
379105
379325
|
const paths2 = extractor(args);
|
|
379106
379326
|
for (const path21 of paths2) {
|
|
379107
379327
|
const cleanPath = expandTilde(path21.replace(/^['"]|['"]$/g, ""));
|
|
379108
|
-
const absolutePath =
|
|
379328
|
+
const absolutePath = isAbsolute19(cleanPath) ? cleanPath : resolve30(cwd2, cleanPath);
|
|
379109
379329
|
if (isDangerousRemovalPath(absolutePath)) {
|
|
379110
379330
|
return {
|
|
379111
379331
|
behavior: "ask",
|
|
@@ -383553,11 +383773,11 @@ var init_modeValidation = __esm(() => {
|
|
|
383553
383773
|
});
|
|
383554
383774
|
|
|
383555
383775
|
// src/tools/BashTool/worktreeGitRedirectGuard.ts
|
|
383556
|
-
import { resolve as resolve31, isAbsolute as
|
|
383776
|
+
import { resolve as resolve31, isAbsolute as isAbsolute20, sep as sep24, basename as basename20 } from "path";
|
|
383557
383777
|
function isGitToken(tok) {
|
|
383558
383778
|
if (!tok)
|
|
383559
383779
|
return false;
|
|
383560
|
-
return GIT_NAME_RE.test(
|
|
383780
|
+
return GIT_NAME_RE.test(basename20(tok));
|
|
383561
383781
|
}
|
|
383562
383782
|
function isGlobTarget(path21) {
|
|
383563
383783
|
return GLOB_CHARS.some((c9) => path21.includes(c9));
|
|
@@ -383566,7 +383786,7 @@ function isDynamicTarget(path21) {
|
|
|
383566
383786
|
return path21.includes("$") || path21.includes("`") || path21.includes("$(") || path21.startsWith("~");
|
|
383567
383787
|
}
|
|
383568
383788
|
function isWithinWorktree(target, agentWorktree, cwd2) {
|
|
383569
|
-
const resolved =
|
|
383789
|
+
const resolved = isAbsolute20(target) ? target : resolve31(cwd2, target);
|
|
383570
383790
|
const worktree = resolve31(agentWorktree);
|
|
383571
383791
|
return resolved === worktree || resolved.startsWith(worktree + sep24);
|
|
383572
383792
|
}
|
|
@@ -383622,25 +383842,25 @@ function isRedirectConfigKey(key2) {
|
|
|
383622
383842
|
function findShellEscapeIdx(argv) {
|
|
383623
383843
|
if (argv.length === 0)
|
|
383624
383844
|
return -1;
|
|
383625
|
-
const first =
|
|
383845
|
+
const first = basename20(argv[0] ?? "").toLowerCase();
|
|
383626
383846
|
if (SHELL_INTERPRETERS.has(first))
|
|
383627
383847
|
return 0;
|
|
383628
383848
|
if (COMMAND_WRAPPERS.has(first)) {
|
|
383629
|
-
return argv.findIndex((o5, i6) => i6 > 0 && SHELL_INTERPRETERS.has(
|
|
383849
|
+
return argv.findIndex((o5, i6) => i6 > 0 && SHELL_INTERPRETERS.has(basename20(o5 ?? "").toLowerCase()));
|
|
383630
383850
|
}
|
|
383631
383851
|
return -1;
|
|
383632
383852
|
}
|
|
383633
383853
|
function checkShellWrapperObfuscation(argv, ctx = EMPTY_CTX) {
|
|
383634
383854
|
if (argv.length === 0)
|
|
383635
383855
|
return null;
|
|
383636
|
-
const t4 = argv.some((o5) => GIT_NAME_RE.test(
|
|
383637
|
-
if (t4 && argv.some((o5) => STDIN_FEED_WRAPPERS.has(
|
|
383856
|
+
const t4 = argv.some((o5) => GIT_NAME_RE.test(basename20(o5)));
|
|
383857
|
+
if (t4 && argv.some((o5) => STDIN_FEED_WRAPPERS.has(basename20(o5).toLowerCase()))) {
|
|
383638
383858
|
return {
|
|
383639
383859
|
mechanism: "xargs/parallel",
|
|
383640
383860
|
reason: "feeds git its arguments from stdin at runtime (xargs/parallel), so the repository it targets cannot be verified"
|
|
383641
383861
|
};
|
|
383642
383862
|
}
|
|
383643
|
-
const hasFind = argv.some((o5) =>
|
|
383863
|
+
const hasFind = argv.some((o5) => basename20(o5).toLowerCase() === "find");
|
|
383644
383864
|
if (t4 && hasFind && argv.some((o5) => FIND_PERMATCH_FLAGS.has(o5))) {
|
|
383645
383865
|
return {
|
|
383646
383866
|
mechanism: "find -execdir/-okdir",
|
|
@@ -383653,7 +383873,7 @@ function checkShellWrapperObfuscation(argv, ctx = EMPTY_CTX) {
|
|
|
383653
383873
|
const hasCFlag = rest.includes("-c");
|
|
383654
383874
|
const hasScriptfile = rest.some((a5) => a5.length > 0 && !a5.startsWith("-"));
|
|
383655
383875
|
if (hasCFlag || hasScriptfile) {
|
|
383656
|
-
const name3 =
|
|
383876
|
+
const name3 = basename20(argv[shellIdx]);
|
|
383657
383877
|
return {
|
|
383658
383878
|
mechanism: `${name3} -c`,
|
|
383659
383879
|
reason: `runs a string through ${name3} -c, which can't be verified to stay inside the worktree; run the command directly instead`
|
|
@@ -383661,7 +383881,7 @@ function checkShellWrapperObfuscation(argv, ctx = EMPTY_CTX) {
|
|
|
383661
383881
|
}
|
|
383662
383882
|
const stdinFed = ctx.stdinFromPipe || ctx.stdinFeedOp !== null;
|
|
383663
383883
|
if (stdinFed) {
|
|
383664
|
-
const name3 =
|
|
383884
|
+
const name3 = basename20(argv[shellIdx]);
|
|
383665
383885
|
const source = ctx.stdinFromPipe ? "pipe" : stdinSourceLabel(ctx.stdinFeedOp);
|
|
383666
383886
|
return {
|
|
383667
383887
|
mechanism: `${name3} (stdin: ${source})`,
|
|
@@ -383669,7 +383889,7 @@ function checkShellWrapperObfuscation(argv, ctx = EMPTY_CTX) {
|
|
|
383669
383889
|
};
|
|
383670
383890
|
}
|
|
383671
383891
|
}
|
|
383672
|
-
const head =
|
|
383892
|
+
const head = basename20(argv[0] ?? "").toLowerCase();
|
|
383673
383893
|
if ((head === "su" || head === "runuser") && argv.includes("-c")) {
|
|
383674
383894
|
return {
|
|
383675
383895
|
mechanism: `${head} -c`,
|
|
@@ -383677,11 +383897,11 @@ function checkShellWrapperObfuscation(argv, ctx = EMPTY_CTX) {
|
|
|
383677
383897
|
};
|
|
383678
383898
|
}
|
|
383679
383899
|
const n5 = argv.find((o5, i6) => {
|
|
383680
|
-
const b5 =
|
|
383900
|
+
const b5 = basename20(o5).toLowerCase();
|
|
383681
383901
|
return b5 === "." ? i6 === 0 : SHELL_BUILTIN_WRAPPERS.has(b5);
|
|
383682
383902
|
});
|
|
383683
383903
|
if (n5 !== undefined && argv.filter((i6) => i6 !== n5).length > 0) {
|
|
383684
|
-
const name3 =
|
|
383904
|
+
const name3 = basename20(n5);
|
|
383685
383905
|
return {
|
|
383686
383906
|
mechanism: name3,
|
|
383687
383907
|
reason: `runs a string through ${name3}, which can't be verified to stay inside the worktree; run the command directly instead`
|
|
@@ -383709,11 +383929,11 @@ function checkWorktreeGitRedirect(command4, agentWorktree, cwd2) {
|
|
|
383709
383929
|
return ozgBlock;
|
|
383710
383930
|
if (hasGitAtOrAfter[f4]) {
|
|
383711
383931
|
const builtinIdx = argv.findIndex((o5, i6) => {
|
|
383712
|
-
const b5 =
|
|
383932
|
+
const b5 = basename20(o5).toLowerCase();
|
|
383713
383933
|
return b5 === "." ? i6 === 0 : SHELL_BUILTIN_WRAPPERS.has(b5);
|
|
383714
383934
|
});
|
|
383715
383935
|
if (builtinIdx !== -1) {
|
|
383716
|
-
const name3 =
|
|
383936
|
+
const name3 = basename20(argv[builtinIdx]);
|
|
383717
383937
|
return {
|
|
383718
383938
|
mechanism: name3,
|
|
383719
383939
|
reason: `runs ${name3} before a git command, whose string payload can't be verified to leave the worktree alone`
|
|
@@ -383899,18 +384119,18 @@ var init_worktreeGitRedirectGuard = __esm(() => {
|
|
|
383899
384119
|
|
|
383900
384120
|
// src/tools/BashTool/bashPermissions.ts
|
|
383901
384121
|
import { homedir as homedir23 } from "os";
|
|
383902
|
-
import { isAbsolute as
|
|
384122
|
+
import { isAbsolute as isAbsolute21, resolve as resolve32, sep as sep25 } from "path";
|
|
383903
384123
|
function isBuildToolConfigTarget(target) {
|
|
383904
384124
|
const stripped = target.replace(/^['"]|['"]$/g, "");
|
|
383905
384125
|
const expanded = stripped.startsWith("~/") ? homedir23() + stripped.slice(1) : stripped;
|
|
383906
|
-
const
|
|
383907
|
-
return BUILD_TOOL_CONFIG_FILES.has(
|
|
384126
|
+
const basename21 = expanded.split("/").pop() ?? expanded;
|
|
384127
|
+
return BUILD_TOOL_CONFIG_FILES.has(basename21);
|
|
383908
384128
|
}
|
|
383909
384129
|
function isShellStartupFileTarget(target) {
|
|
383910
384130
|
const stripped = target.replace(/^['"]|['"]$/g, "");
|
|
383911
384131
|
const expanded = stripped.startsWith("~/") ? homedir23() + stripped.slice(1) : stripped;
|
|
383912
|
-
const
|
|
383913
|
-
if (SHELL_STARTUP_FILES.has(
|
|
384132
|
+
const basename21 = expanded.split("/").pop() ?? expanded;
|
|
384133
|
+
if (SHELL_STARTUP_FILES.has(basename21)) {
|
|
383914
384134
|
return true;
|
|
383915
384135
|
}
|
|
383916
384136
|
if (/(?:^|\/)\.config\/git(?:\/|$)/.test(expanded)) {
|
|
@@ -383985,10 +384205,10 @@ function isPathOutsideWorkingDir(filePath, cwd2, toolPermissionContext) {
|
|
|
383985
384205
|
if (expanded.includes("$") || expanded.startsWith("~")) {
|
|
383986
384206
|
return true;
|
|
383987
384207
|
}
|
|
383988
|
-
const abs =
|
|
384208
|
+
const abs = isAbsolute21(expanded) ? expanded : resolve32(cwd2, expanded);
|
|
383989
384209
|
const workingDirs = [cwd2];
|
|
383990
384210
|
for (const dir of toolPermissionContext.additionalWorkingDirectories.keys()) {
|
|
383991
|
-
workingDirs.push(
|
|
384211
|
+
workingDirs.push(isAbsolute21(dir) ? dir : resolve32(cwd2, dir));
|
|
383992
384212
|
}
|
|
383993
384213
|
const normalizedAbs = abs.replace(/\/+$/, "") || "/";
|
|
383994
384214
|
return !workingDirs.some((d4) => {
|
|
@@ -389241,7 +389461,7 @@ async function sideQuery(opts) {
|
|
|
389241
389461
|
}
|
|
389242
389462
|
const messageText = extractFirstUserMessageText(messages);
|
|
389243
389463
|
const fingerprint = computeFingerprint(messageText, MACRO.VERSION);
|
|
389244
|
-
const attributionHeader = getAttributionHeader(fingerprint);
|
|
389464
|
+
const attributionHeader = getAttributionHeader(fingerprint, opts.forceAttributionHeader ? { ignoreEnvOptOut: true } : undefined);
|
|
389245
389465
|
const systemBlocks = [
|
|
389246
389466
|
attributionHeader ? { type: "text", text: attributionHeader } : null,
|
|
389247
389467
|
...skipSystemPromptPrefix ? [] : [
|
|
@@ -390107,6 +390327,7 @@ async function classifyYoloActionXml(prefixMessages, systemPrompt, userPrompt, u
|
|
|
390107
390327
|
max_tokens: (mode === "fast" ? 256 : 64) + thinkingPadding,
|
|
390108
390328
|
system: systemBlocks,
|
|
390109
390329
|
skipSystemPromptPrefix: true,
|
|
390330
|
+
forceAttributionHeader: true,
|
|
390110
390331
|
temperature: 0,
|
|
390111
390332
|
thinking: disableThinking,
|
|
390112
390333
|
messages: [
|
|
@@ -390187,6 +390408,7 @@ async function classifyYoloActionXml(prefixMessages, systemPrompt, userPrompt, u
|
|
|
390187
390408
|
max_tokens: 4096 + thinkingPadding,
|
|
390188
390409
|
system: systemBlocks,
|
|
390189
390410
|
skipSystemPromptPrefix: true,
|
|
390411
|
+
forceAttributionHeader: true,
|
|
390190
390412
|
temperature: 0,
|
|
390191
390413
|
thinking: disableThinking,
|
|
390192
390414
|
messages: [
|
|
@@ -390383,6 +390605,7 @@ async function classifyYoloAction(messages, action2, tools, context4, signal) {
|
|
|
390383
390605
|
}
|
|
390384
390606
|
],
|
|
390385
390607
|
skipSystemPromptPrefix: true,
|
|
390608
|
+
forceAttributionHeader: true,
|
|
390386
390609
|
temperature: 0,
|
|
390387
390610
|
thinking: disableThinking,
|
|
390388
390611
|
messages: [
|
|
@@ -415517,12 +415740,12 @@ var require_fetch = __commonJS((exports, module) => {
|
|
|
415517
415740
|
// node_modules/.bun/@protobufjs+path@1.1.2/node_modules/@protobufjs/path/index.js
|
|
415518
415741
|
var require_path = __commonJS((exports) => {
|
|
415519
415742
|
var path21 = exports;
|
|
415520
|
-
var
|
|
415743
|
+
var isAbsolute22 = path21.isAbsolute = function isAbsolute23(path22) {
|
|
415521
415744
|
return /^(?:\/|\w+:)/.test(path22);
|
|
415522
415745
|
};
|
|
415523
415746
|
var normalize12 = path21.normalize = function normalize13(path22) {
|
|
415524
415747
|
path22 = path22.replace(/\\/g, "/").replace(/\/{2,}/g, "/");
|
|
415525
|
-
var parts = path22.split("/"), absolute =
|
|
415748
|
+
var parts = path22.split("/"), absolute = isAbsolute22(path22), prefix = "";
|
|
415526
415749
|
if (absolute)
|
|
415527
415750
|
prefix = parts.shift() + "/";
|
|
415528
415751
|
for (var i6 = 0;i6 < parts.length; ) {
|
|
@@ -415543,7 +415766,7 @@ var require_path = __commonJS((exports) => {
|
|
|
415543
415766
|
path21.resolve = function resolve34(originPath, includePath, alreadyNormalized) {
|
|
415544
415767
|
if (!alreadyNormalized)
|
|
415545
415768
|
includePath = normalize12(includePath);
|
|
415546
|
-
if (
|
|
415769
|
+
if (isAbsolute22(includePath))
|
|
415547
415770
|
return includePath;
|
|
415548
415771
|
if (!alreadyNormalized)
|
|
415549
415772
|
originPath = normalize12(originPath);
|
|
@@ -435436,7 +435659,7 @@ var init_download = __esm(() => {
|
|
|
435436
435659
|
});
|
|
435437
435660
|
|
|
435438
435661
|
// src/utils/nativeInstaller/pidLock.ts
|
|
435439
|
-
import { basename as
|
|
435662
|
+
import { basename as basename21, join as join92 } from "path";
|
|
435440
435663
|
function isPidBasedLockingEnabled() {
|
|
435441
435664
|
const envVar = process.env.ENABLE_PID_BASED_VERSION_LOCKING;
|
|
435442
435665
|
if (isEnvTruthy(envVar)) {
|
|
@@ -435536,7 +435759,7 @@ function writeLockFile(lockFilePath, content) {
|
|
|
435536
435759
|
}
|
|
435537
435760
|
async function tryAcquireLock(versionPath, lockFilePath) {
|
|
435538
435761
|
const fs17 = getFsImplementation();
|
|
435539
|
-
const versionName =
|
|
435762
|
+
const versionName = basename21(versionPath);
|
|
435540
435763
|
if (isLockActive(lockFilePath)) {
|
|
435541
435764
|
const existingContent = readLockContent(lockFilePath);
|
|
435542
435765
|
logForDebugging(`Cannot acquire lock for ${versionName} - held by PID ${existingContent?.pid}`);
|
|
@@ -435686,7 +435909,7 @@ import {
|
|
|
435686
435909
|
writeFile as writeFile23
|
|
435687
435910
|
} from "fs/promises";
|
|
435688
435911
|
import { homedir as homedir27 } from "os";
|
|
435689
|
-
import { basename as
|
|
435912
|
+
import { basename as basename22, delimiter as delimiter3, dirname as dirname39, join as join93, resolve as resolve35 } from "path";
|
|
435690
435913
|
function getPlatform3() {
|
|
435691
435914
|
const os9 = env4.platform;
|
|
435692
435915
|
const arch2 = process.arch === "x64" ? "x64" : process.arch === "arm64" ? "arm64" : null;
|
|
@@ -436283,7 +436506,7 @@ async function getVersionFromSymlink(symlinkPath) {
|
|
|
436283
436506
|
return null;
|
|
436284
436507
|
}
|
|
436285
436508
|
function getLockFilePathFromVersionPath(dirs, versionPath) {
|
|
436286
|
-
const versionName =
|
|
436509
|
+
const versionName = basename22(versionPath);
|
|
436287
436510
|
return join93(dirs.locks, `${versionName}.lock`);
|
|
436288
436511
|
}
|
|
436289
436512
|
async function lockCurrentVersion() {
|
|
@@ -445674,7 +445897,7 @@ var init_osc52ClipboardRead = __esm(() => {
|
|
|
445674
445897
|
import { randomBytes as randomBytes9 } from "crypto";
|
|
445675
445898
|
import { homedir as homedir28, tmpdir as tmpdir8 } from "os";
|
|
445676
445899
|
import { writeFileSync as writeFileSync9 } from "fs";
|
|
445677
|
-
import { basename as
|
|
445900
|
+
import { basename as basename23, extname as extname13, isAbsolute as isAbsolute22, join as join94 } from "path";
|
|
445678
445901
|
function getClipboardCommands() {
|
|
445679
445902
|
const platform5 = process.platform;
|
|
445680
445903
|
const baseTmpDir = process.env.CLAUDE_CODE_TMPDIR || (platform5 === "win32" ? process.env.TEMP || "C:\\Temp" : "/tmp");
|
|
@@ -445935,11 +446158,11 @@ async function tryReadImageFromPath(text2) {
|
|
|
445935
446158
|
const imagePath = cleanedPath;
|
|
445936
446159
|
let imageBuffer;
|
|
445937
446160
|
try {
|
|
445938
|
-
if (
|
|
446161
|
+
if (isAbsolute22(imagePath)) {
|
|
445939
446162
|
imageBuffer = getFsImplementation().readFileBytesSync(imagePath);
|
|
445940
446163
|
} else {
|
|
445941
446164
|
const clipboardPath = await getImagePathFromClipboard();
|
|
445942
|
-
if (clipboardPath && imagePath ===
|
|
446165
|
+
if (clipboardPath && imagePath === basename23(clipboardPath)) {
|
|
445943
446166
|
imageBuffer = getFsImplementation().readFileBytesSync(clipboardPath);
|
|
445944
446167
|
}
|
|
445945
446168
|
}
|
|
@@ -445958,7 +446181,7 @@ async function tryReadImageFromPath(text2) {
|
|
|
445958
446181
|
const sharp2 = await getImageProcessor();
|
|
445959
446182
|
imageBuffer = await sharp2(imageBuffer).png().toBuffer();
|
|
445960
446183
|
}
|
|
445961
|
-
const ext =
|
|
446184
|
+
const ext = extname13(imagePath).slice(1).toLowerCase() || "png";
|
|
445962
446185
|
const resized = await maybeResizeAndDownsampleImageBuffer(imageBuffer, imageBuffer.length, ext);
|
|
445963
446186
|
const base64Image = resized.buffer.toString("base64");
|
|
445964
446187
|
const mediaType = detectImageFormatFromBase64(base64Image);
|
|
@@ -448967,7 +449190,10 @@ var init_prompt15 = __esm(() => {
|
|
|
448967
449190
|
});
|
|
448968
449191
|
|
|
448969
449192
|
// src/tools/FileEditTool/FileEditTool.ts
|
|
448970
|
-
import { dirname as dirname40, isAbsolute as
|
|
449193
|
+
import { dirname as dirname40, isAbsolute as isAbsolute23, sep as sep27 } from "path";
|
|
449194
|
+
function hasUnicodeEscapesOrNonAscii(value) {
|
|
449195
|
+
return UNICODE_ESCAPE_PATTERN.test(value) || NON_ASCII_PATTERN2.test(value);
|
|
449196
|
+
}
|
|
448971
449197
|
function readFileForEdit(absoluteFilePath) {
|
|
448972
449198
|
try {
|
|
448973
449199
|
const meta3 = readFileSyncWithMetadata(absoluteFilePath);
|
|
@@ -448989,10 +449215,9 @@ function readFileForEdit(absoluteFilePath) {
|
|
|
448989
449215
|
throw e4;
|
|
448990
449216
|
}
|
|
448991
449217
|
}
|
|
448992
|
-
var MAX_EDIT_FILE_SIZE, FileEditTool;
|
|
449218
|
+
var UNICODE_ESCAPE_PATTERN, NON_ASCII_PATTERN2, MAX_EDIT_FILE_SIZE, FileEditTool;
|
|
448993
449219
|
var init_FileEditTool = __esm(() => {
|
|
448994
449220
|
init_analytics();
|
|
448995
|
-
init_growthbook();
|
|
448996
449221
|
init_diagnosticTracking();
|
|
448997
449222
|
init_LSPDiagnosticRegistry();
|
|
448998
449223
|
init_manager3();
|
|
@@ -449016,12 +449241,15 @@ var init_FileEditTool = __esm(() => {
|
|
|
449016
449241
|
init_path2();
|
|
449017
449242
|
init_perforce();
|
|
449018
449243
|
init_filesystem();
|
|
449244
|
+
init_fileStateGuard();
|
|
449019
449245
|
init_shellRuleMatching();
|
|
449020
449246
|
init_validateEditTool();
|
|
449021
449247
|
init_prompt15();
|
|
449022
449248
|
init_types10();
|
|
449023
449249
|
init_UI2();
|
|
449024
449250
|
init_utils8();
|
|
449251
|
+
UNICODE_ESCAPE_PATTERN = /\\u[0-9a-fA-F]{4}/;
|
|
449252
|
+
NON_ASCII_PATTERN2 = /[\u0080-\uffff]/;
|
|
449025
449253
|
MAX_EDIT_FILE_SIZE = 1024 * 1024 * 1024;
|
|
449026
449254
|
FileEditTool = buildTool({
|
|
449027
449255
|
name: FILE_EDIT_TOOL_NAME,
|
|
@@ -449093,6 +449321,14 @@ var init_FileEditTool = __esm(() => {
|
|
|
449093
449321
|
errorCode: 2
|
|
449094
449322
|
};
|
|
449095
449323
|
}
|
|
449324
|
+
if (isCoveredByReadDenyRule(fullFilePath, appState.toolPermissionContext)) {
|
|
449325
|
+
return {
|
|
449326
|
+
result: false,
|
|
449327
|
+
behavior: "ask",
|
|
449328
|
+
message: READ_DENY_EDIT_MESSAGE,
|
|
449329
|
+
errorCode: 13
|
|
449330
|
+
};
|
|
449331
|
+
}
|
|
449096
449332
|
if (fullFilePath.startsWith("\\\\") || fullFilePath.startsWith("//")) {
|
|
449097
449333
|
return { result: true };
|
|
449098
449334
|
}
|
|
@@ -449125,9 +449361,7 @@ var init_FileEditTool = __esm(() => {
|
|
|
449125
449361
|
try {
|
|
449126
449362
|
const fileBuffer = await fs17.readFileBytes(fullFilePath);
|
|
449127
449363
|
const encoding = fileBuffer.length >= 2 && fileBuffer[0] === 255 && fileBuffer[1] === 254 ? "utf16le" : "utf8";
|
|
449128
|
-
fileContent = fileBuffer.toString(encoding)
|
|
449129
|
-
`, `
|
|
449130
|
-
`);
|
|
449364
|
+
fileContent = normalizeForComparison(fileBuffer.toString(encoding));
|
|
449131
449365
|
} catch (e4) {
|
|
449132
449366
|
if (isENOENT(e4)) {
|
|
449133
449367
|
fileContent = null;
|
|
@@ -449175,34 +449409,45 @@ var init_FileEditTool = __esm(() => {
|
|
|
449175
449409
|
errorCode: 5
|
|
449176
449410
|
};
|
|
449177
449411
|
}
|
|
449178
|
-
const
|
|
449179
|
-
|
|
449180
|
-
|
|
449181
|
-
|
|
449182
|
-
|
|
449183
|
-
|
|
449184
|
-
|
|
449185
|
-
|
|
449186
|
-
|
|
449187
|
-
|
|
449188
|
-
|
|
449412
|
+
const lastRead = toolUseContext.readFileState.get(fullFilePath);
|
|
449413
|
+
const toolPermissionContext = appState.toolPermissionContext;
|
|
449414
|
+
if (!lastRead || lastRead.isPartialView) {
|
|
449415
|
+
const model = getGuardModel(toolUseContext);
|
|
449416
|
+
const guardSkipped = !isOldModel(model) && wouldReadBeAutoAllowed(FILE_EDIT_TOOL_NAME, fullFilePath, toolUseContext, toolPermissionContext);
|
|
449417
|
+
logEvent2("tengu_edit_tool_not_read_hypothetical", {
|
|
449418
|
+
wouldHaveResult: editWouldApplyToTelemetry(checkEditWouldApply(fileContent, old_string, replace_all)),
|
|
449419
|
+
isPartialView: lastRead?.isPartialView === true,
|
|
449420
|
+
isFilePathAbsolute: String(isAbsolute23(file_path)),
|
|
449421
|
+
guardSkipped,
|
|
449422
|
+
modelBucket: getModelBucket(model)
|
|
449423
|
+
});
|
|
449424
|
+
if (!guardSkipped) {
|
|
449425
|
+
return {
|
|
449426
|
+
result: false,
|
|
449427
|
+
behavior: "ask",
|
|
449428
|
+
message: FILE_NOT_READ_MESSAGE,
|
|
449429
|
+
meta: {
|
|
449430
|
+
isFilePathAbsolute: String(isAbsolute23(file_path))
|
|
449431
|
+
},
|
|
449432
|
+
errorCode: 6
|
|
449433
|
+
};
|
|
449434
|
+
}
|
|
449189
449435
|
}
|
|
449190
|
-
if (
|
|
449436
|
+
if (lastRead) {
|
|
449191
449437
|
const lastWriteTime = getFileModificationTime(fullFilePath);
|
|
449192
|
-
if (lastWriteTime >
|
|
449193
|
-
|
|
449194
|
-
|
|
449195
|
-
const
|
|
449196
|
-
const recovered = wouldApply === "applies" && isStaleReadRecoverable(fullFilePath, toolUseContext);
|
|
449438
|
+
if (lastWriteTime > lastRead.timestamp) {
|
|
449439
|
+
if (!(isFullReadOfFileState(lastRead) && fileStateMatchesDisk(lastRead, fileContent))) {
|
|
449440
|
+
const wouldApply = checkEditWouldApply(fileContent, old_string, replace_all);
|
|
449441
|
+
const recovered = wouldApply === "applies" && wouldReadBeAutoAllowed(FILE_EDIT_TOOL_NAME, fullFilePath, toolUseContext, toolPermissionContext);
|
|
449197
449442
|
logEvent2("tengu_edit_tool_stale_read", {
|
|
449198
|
-
wouldHaveResult: wouldApply,
|
|
449443
|
+
wouldHaveResult: editWouldApplyToTelemetry(wouldApply),
|
|
449199
449444
|
recovered
|
|
449200
449445
|
});
|
|
449201
449446
|
if (!recovered) {
|
|
449202
449447
|
return {
|
|
449203
449448
|
result: false,
|
|
449204
449449
|
behavior: "ask",
|
|
449205
|
-
message:
|
|
449450
|
+
message: FILE_MODIFIED_SINCE_READ_VALIDATION_MESSAGE,
|
|
449206
449451
|
errorCode: 7
|
|
449207
449452
|
};
|
|
449208
449453
|
}
|
|
@@ -449212,13 +449457,15 @@ var init_FileEditTool = __esm(() => {
|
|
|
449212
449457
|
const file2 = fileContent;
|
|
449213
449458
|
const actualOldString = findActualString(file2, old_string);
|
|
449214
449459
|
if (!actualOldString) {
|
|
449460
|
+
const escapeNote = hasUnicodeEscapesOrNonAscii(old_string) ? `
|
|
449461
|
+
(note: Edit also tried swapping \\uXXXX escapes and their characters; neither form matched, so the mismatch is likely elsewhere in old_string. Re-read the file and copy the exact surrounding text.)` : "";
|
|
449215
449462
|
return {
|
|
449216
449463
|
result: false,
|
|
449217
449464
|
behavior: "ask",
|
|
449218
449465
|
message: `String to replace not found in file.
|
|
449219
|
-
String: ${old_string}`,
|
|
449466
|
+
String: ${old_string}${escapeNote}`,
|
|
449220
449467
|
meta: {
|
|
449221
|
-
isFilePathAbsolute: String(
|
|
449468
|
+
isFilePathAbsolute: String(isAbsolute23(file_path))
|
|
449222
449469
|
},
|
|
449223
449470
|
errorCode: 8
|
|
449224
449471
|
};
|
|
@@ -449231,7 +449478,7 @@ String: ${old_string}`,
|
|
|
449231
449478
|
message: `Found ${matches} matches of the string to replace, but replace_all is false. To replace all occurrences, set replace_all to true. To replace only one occurrence, please provide more context to uniquely identify the instance.
|
|
449232
449479
|
String: ${old_string}`,
|
|
449233
449480
|
meta: {
|
|
449234
|
-
isFilePathAbsolute: String(
|
|
449481
|
+
isFilePathAbsolute: String(isAbsolute23(file_path)),
|
|
449235
449482
|
actualOldString
|
|
449236
449483
|
},
|
|
449237
449484
|
errorCode: 9
|
|
@@ -449271,6 +449518,10 @@ String: ${old_string}`,
|
|
|
449271
449518
|
const { file_path, old_string, new_string, replace_all = false } = input;
|
|
449272
449519
|
const fs17 = getFsImplementation();
|
|
449273
449520
|
const absoluteFilePath = expandPath(file_path);
|
|
449521
|
+
const toolPermissionContext = toolUseContext.getAppState().toolPermissionContext;
|
|
449522
|
+
if (isCoveredByReadDenyRule(absoluteFilePath, toolPermissionContext)) {
|
|
449523
|
+
throw new FileStateError(READ_DENY_EDIT_MESSAGE);
|
|
449524
|
+
}
|
|
449274
449525
|
const cwd2 = getCwd();
|
|
449275
449526
|
if (!isEnvTruthy(process.env.CLAUDE_CODE_SIMPLE)) {
|
|
449276
449527
|
const newSkillDirs = await discoverSkillDirsForPaths([absoluteFilePath], cwd2);
|
|
@@ -449283,7 +449534,6 @@ String: ${old_string}`,
|
|
|
449283
449534
|
activateConditionalSkillsForPaths([absoluteFilePath], cwd2);
|
|
449284
449535
|
}
|
|
449285
449536
|
await diagnosticTracker.beforeFileEdited(absoluteFilePath);
|
|
449286
|
-
await fs17.mkdir(dirname40(absoluteFilePath));
|
|
449287
449537
|
if (fileHistoryEnabled()) {
|
|
449288
449538
|
await fileHistoryTrackEdit(updateFileHistoryState, absoluteFilePath, parentMessage.uuid);
|
|
449289
449539
|
}
|
|
@@ -449293,25 +449543,15 @@ String: ${old_string}`,
|
|
|
449293
449543
|
encoding,
|
|
449294
449544
|
lineEndings: endings
|
|
449295
449545
|
} = readFileForEdit(absoluteFilePath);
|
|
449296
|
-
|
|
449297
|
-
|
|
449298
|
-
|
|
449299
|
-
|
|
449300
|
-
|
|
449301
|
-
|
|
449302
|
-
|
|
449303
|
-
|
|
449304
|
-
|
|
449305
|
-
logEvent2("tengu_edit_tool_stale_read", {
|
|
449306
|
-
wouldHaveResult: wouldApply,
|
|
449307
|
-
recovered
|
|
449308
|
-
});
|
|
449309
|
-
if (!recovered) {
|
|
449310
|
-
throw new Error(FILE_UNEXPECTEDLY_MODIFIED_ERROR);
|
|
449311
|
-
}
|
|
449312
|
-
}
|
|
449313
|
-
}
|
|
449314
|
-
}
|
|
449546
|
+
const staleRecovered = fileExists && checkEditFileStateAtCall({
|
|
449547
|
+
absoluteFilePath,
|
|
449548
|
+
fileContents: originalFileContents,
|
|
449549
|
+
lastRead: readFileState.get(absoluteFilePath),
|
|
449550
|
+
oldString: old_string,
|
|
449551
|
+
replaceAll: replace_all,
|
|
449552
|
+
model: getGuardModel(toolUseContext),
|
|
449553
|
+
readNotAutoAllowed: () => !wouldReadBeAutoAllowed(FILE_EDIT_TOOL_NAME, absoluteFilePath, toolUseContext, toolPermissionContext)
|
|
449554
|
+
});
|
|
449315
449555
|
const actualOldString = findActualString(originalFileContents, old_string) || old_string;
|
|
449316
449556
|
const actualNewString = preserveQuoteStyle(old_string, actualOldString, new_string);
|
|
449317
449557
|
const { patch, updatedFile } = getPatchForEdit({
|
|
@@ -449321,6 +449561,7 @@ String: ${old_string}`,
|
|
|
449321
449561
|
newString: actualNewString,
|
|
449322
449562
|
replaceAll: replace_all
|
|
449323
449563
|
});
|
|
449564
|
+
await fs17.mkdir(dirname40(absoluteFilePath));
|
|
449324
449565
|
writeTextContent(absoluteFilePath, updatedFile, encoding, endings);
|
|
449325
449566
|
const lspManager = getLspServerManager();
|
|
449326
449567
|
if (lspManager) {
|
|
@@ -449336,7 +449577,7 @@ String: ${old_string}`,
|
|
|
449336
449577
|
}
|
|
449337
449578
|
notifyVscodeFileUpdated(absoluteFilePath, originalFileContents, updatedFile);
|
|
449338
449579
|
readFileState.set(absoluteFilePath, {
|
|
449339
|
-
content: updatedFile,
|
|
449580
|
+
content: stripBom(updatedFile),
|
|
449340
449581
|
timestamp: getFileModificationTime(absoluteFilePath),
|
|
449341
449582
|
offset: undefined,
|
|
449342
449583
|
limit: undefined
|
|
@@ -449356,7 +449597,7 @@ String: ${old_string}`,
|
|
|
449356
449597
|
replaceAll: replace_all
|
|
449357
449598
|
});
|
|
449358
449599
|
let gitDiff;
|
|
449359
|
-
if (isEnvTruthy(process.env.CLAUDE_CODE_REMOTE)
|
|
449600
|
+
if (isEnvTruthy(process.env.CLAUDE_CODE_REMOTE)) {
|
|
449360
449601
|
const startTime2 = Date.now();
|
|
449361
449602
|
const diff2 = await fetchSingleFileGitDiff(absoluteFilePath);
|
|
449362
449603
|
if (diff2)
|
|
@@ -449375,6 +449616,7 @@ String: ${old_string}`,
|
|
|
449375
449616
|
structuredPatch: patch,
|
|
449376
449617
|
userModified: userModified ?? false,
|
|
449377
449618
|
replaceAll: replace_all,
|
|
449619
|
+
...staleRecovered && { staleRecovered: true },
|
|
449378
449620
|
...gitDiff && { gitDiff }
|
|
449379
449621
|
};
|
|
449380
449622
|
return {
|
|
@@ -449382,19 +449624,20 @@ String: ${old_string}`,
|
|
|
449382
449624
|
};
|
|
449383
449625
|
},
|
|
449384
449626
|
mapToolResultToToolResultBlockParam(data, toolUseID) {
|
|
449385
|
-
const { filePath, userModified, replaceAll: replaceAll2 } = data;
|
|
449627
|
+
const { filePath, userModified, replaceAll: replaceAll2, staleRecovered } = data;
|
|
449386
449628
|
const modifiedNote = userModified ? ". The user modified your proposed changes before accepting them. " : "";
|
|
449629
|
+
const trailingNote = staleRecovered ? " (note: the file had been modified on disk since you last read it \u2014 the edit applied cleanly, but the file contains other changes not in your context. Read it before edits that depend on surrounding context.)" : userModified ? "" : FILE_STATE_CURRENT_NOTE;
|
|
449387
449630
|
if (replaceAll2) {
|
|
449388
449631
|
return {
|
|
449389
449632
|
tool_use_id: toolUseID,
|
|
449390
449633
|
type: "tool_result",
|
|
449391
|
-
content: `The file ${filePath} has been updated${modifiedNote}. All occurrences were successfully replaced
|
|
449634
|
+
content: `The file ${filePath} has been updated${modifiedNote}. All occurrences were successfully replaced.${trailingNote}`
|
|
449392
449635
|
};
|
|
449393
449636
|
}
|
|
449394
449637
|
return {
|
|
449395
449638
|
tool_use_id: toolUseID,
|
|
449396
449639
|
type: "tool_result",
|
|
449397
|
-
content: `The file ${filePath} has been updated successfully${modifiedNote}
|
|
449640
|
+
content: `The file ${filePath} has been updated successfully${modifiedNote}.${trailingNote}`
|
|
449398
449641
|
};
|
|
449399
449642
|
}
|
|
449400
449643
|
});
|
|
@@ -449652,7 +449895,7 @@ var init_UI7 = __esm(() => {
|
|
|
449652
449895
|
});
|
|
449653
449896
|
|
|
449654
449897
|
// src/tools/NotebookEditTool/NotebookEditTool.ts
|
|
449655
|
-
import { extname as
|
|
449898
|
+
import { extname as extname14, isAbsolute as isAbsolute24, resolve as resolve36 } from "path";
|
|
449656
449899
|
var inputSchema10, outputSchema10, NotebookEditTool;
|
|
449657
449900
|
var init_NotebookEditTool = __esm(() => {
|
|
449658
449901
|
init_featureFlags();
|
|
@@ -449768,11 +450011,11 @@ var init_NotebookEditTool = __esm(() => {
|
|
|
449768
450011
|
renderToolUseErrorMessage: renderToolUseErrorMessage7,
|
|
449769
450012
|
renderToolResultMessage: renderToolResultMessage6,
|
|
449770
450013
|
async validateInput({ notebook_path, cell_type, cell_id, edit_mode = "replace" }, toolUseContext) {
|
|
449771
|
-
const fullPath =
|
|
450014
|
+
const fullPath = isAbsolute24(notebook_path) ? notebook_path : resolve36(getCwd(), notebook_path);
|
|
449772
450015
|
if (fullPath.startsWith("\\\\") || fullPath.startsWith("//")) {
|
|
449773
450016
|
return { result: true };
|
|
449774
450017
|
}
|
|
449775
|
-
if (
|
|
450018
|
+
if (extname14(fullPath) !== ".ipynb") {
|
|
449776
450019
|
return {
|
|
449777
450020
|
result: false,
|
|
449778
450021
|
message: "File must be a Jupyter notebook (.ipynb file). For editing other file types, use the FileEdit tool.",
|
|
@@ -449879,7 +450122,7 @@ var init_NotebookEditTool = __esm(() => {
|
|
|
449879
450122
|
cell_type,
|
|
449880
450123
|
edit_mode: originalEditMode
|
|
449881
450124
|
}, { readFileState, updateFileHistoryState }, _2, parentMessage) {
|
|
449882
|
-
const fullPath =
|
|
450125
|
+
const fullPath = isAbsolute24(notebook_path) ? notebook_path : resolve36(getCwd(), notebook_path);
|
|
449883
450126
|
if (fileHistoryEnabled()) {
|
|
449884
450127
|
await fileHistoryTrackEdit(updateFileHistoryState, fullPath, parentMessage.uuid);
|
|
449885
450128
|
}
|
|
@@ -459659,11 +459902,27 @@ var init_bypassPermissionsKillswitch = __esm(() => {
|
|
|
459659
459902
|
// src/commands/login/login.tsx
|
|
459660
459903
|
var exports_login = {};
|
|
459661
459904
|
__export(exports_login, {
|
|
459905
|
+
getLoginStartingMessage: () => getLoginStartingMessage,
|
|
459662
459906
|
call: () => call2,
|
|
459907
|
+
buildLoginDoneMessage: () => buildLoginDoneMessage,
|
|
459663
459908
|
Login: () => Login
|
|
459664
459909
|
});
|
|
459910
|
+
function getLoginStartingMessage() {
|
|
459911
|
+
return process.env.CLAUDE_CODE_OAUTH_TOKEN ? `Warning: CLAUDE_CODE_OAUTH_TOKEN is set in your environment. This session will switch to your new credentials after logging in, ${ENV_TOKEN_OVERRIDE_WARNING_TAIL}` : undefined;
|
|
459912
|
+
}
|
|
459913
|
+
function buildLoginDoneMessage(success2, opts) {
|
|
459914
|
+
if (!success2)
|
|
459915
|
+
return "Login interrupted";
|
|
459916
|
+
const base2 = opts.bridgeDisconnected ? `Login successful. ${REMOTE_CONTROL_DISCONNECTED_NOTE}` : "Login successful";
|
|
459917
|
+
return opts.envTokenWasSet && !opts.gatewayActive ? `${base2}
|
|
459918
|
+
|
|
459919
|
+
${ENV_TOKEN_OVERRIDE_DONE_NOTE}` : base2;
|
|
459920
|
+
}
|
|
459665
459921
|
async function call2(onDone, context6) {
|
|
459922
|
+
const startingMessage = getLoginStartingMessage();
|
|
459923
|
+
const envTokenWasSet = startingMessage !== undefined;
|
|
459666
459924
|
return /* @__PURE__ */ jsx_runtime84.jsx(Login, {
|
|
459925
|
+
startingMessage,
|
|
459667
459926
|
onDone: async (success2) => {
|
|
459668
459927
|
context6.onChangeAPIKey();
|
|
459669
459928
|
context6.setMessages(stripSignatureBlocks);
|
|
@@ -459687,7 +459946,11 @@ async function call2(onDone, context6) {
|
|
|
459687
459946
|
authVersion: prev.authVersion + 1
|
|
459688
459947
|
}));
|
|
459689
459948
|
}
|
|
459690
|
-
onDone(success2
|
|
459949
|
+
onDone(buildLoginDoneMessage(success2, {
|
|
459950
|
+
bridgeDisconnected: false,
|
|
459951
|
+
envTokenWasSet,
|
|
459952
|
+
gatewayActive: getAPIProvider() === "gateway"
|
|
459953
|
+
}));
|
|
459691
459954
|
}
|
|
459692
459955
|
});
|
|
459693
459956
|
}
|
|
@@ -459755,7 +460018,7 @@ function _temp14(exitState) {
|
|
|
459755
460018
|
description: "cancel"
|
|
459756
460019
|
});
|
|
459757
460020
|
}
|
|
459758
|
-
var import_compiler_runtime71, jsx_runtime84;
|
|
460021
|
+
var import_compiler_runtime71, jsx_runtime84, ENV_TOKEN_OVERRIDE_WARNING_TAIL = "but if that variable is set in your shell profile or a Claude Code settings file, new `claude` sessions will keep using the old token until you remove it there.", ENV_TOKEN_OVERRIDE_DONE_NOTE, REMOTE_CONTROL_DISCONNECTED_NOTE = "Remote Control disconnected.";
|
|
459759
460022
|
var init_login = __esm(() => {
|
|
459760
460023
|
init_featureFlags();
|
|
459761
460024
|
init_state();
|
|
@@ -459769,10 +460032,12 @@ var init_login = __esm(() => {
|
|
|
459769
460032
|
init_policyLimits();
|
|
459770
460033
|
init_remoteManagedSettings();
|
|
459771
460034
|
init_messages3();
|
|
460035
|
+
init_providers();
|
|
459772
460036
|
init_bypassPermissionsKillswitch();
|
|
459773
460037
|
init_user();
|
|
459774
460038
|
import_compiler_runtime71 = __toESM(require_compiler_runtime(), 1);
|
|
459775
460039
|
jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
|
|
460040
|
+
ENV_TOKEN_OVERRIDE_DONE_NOTE = `Note: CLAUDE_CODE_OAUTH_TOKEN was set in your environment when /login started. This session will use your new credentials, ${ENV_TOKEN_OVERRIDE_WARNING_TAIL}`;
|
|
459776
460041
|
});
|
|
459777
460042
|
|
|
459778
460043
|
// src/utils/teleport/api.ts
|
|
@@ -464769,7 +465034,7 @@ var init_UserImageMessage = __esm(() => {
|
|
|
464769
465034
|
});
|
|
464770
465035
|
|
|
464771
465036
|
// src/components/messages/AttachmentMessage.tsx
|
|
464772
|
-
import { basename as
|
|
465037
|
+
import { basename as basename24, sep as sep28 } from "path";
|
|
464773
465038
|
function AttachmentMessage({
|
|
464774
465039
|
attachment,
|
|
464775
465040
|
addMargin,
|
|
@@ -465025,7 +465290,7 @@ function AttachmentMessage({
|
|
|
465025
465290
|
dimColor: true,
|
|
465026
465291
|
children: /* @__PURE__ */ jsx_runtime111.jsx(FilePathLink, {
|
|
465027
465292
|
filePath: m5.path,
|
|
465028
|
-
children:
|
|
465293
|
+
children: basename24(m5.path)
|
|
465029
465294
|
})
|
|
465030
465295
|
})
|
|
465031
465296
|
}),
|
|
@@ -465932,7 +466197,7 @@ var init_teamMemCollapsed = __esm(() => {
|
|
|
465932
466197
|
});
|
|
465933
466198
|
|
|
465934
466199
|
// src/components/messages/CollapsedReadSearchContent.tsx
|
|
465935
|
-
import { basename as
|
|
466200
|
+
import { basename as basename25 } from "path";
|
|
465936
466201
|
function VerboseToolUse(t0) {
|
|
465937
466202
|
const $3 = import_compiler_runtime98.c(24);
|
|
465938
466203
|
const {
|
|
@@ -466193,7 +466458,7 @@ function CollapsedReadSearchContent({
|
|
|
466193
466458
|
children: [
|
|
466194
466459
|
" \u23BF ",
|
|
466195
466460
|
"Recalled ",
|
|
466196
|
-
|
|
466461
|
+
basename25(m5.path)
|
|
466197
466462
|
]
|
|
466198
466463
|
}),
|
|
466199
466464
|
/* @__PURE__ */ jsx_runtime116.jsx(ThemedBox_default, {
|
|
@@ -466936,7 +467201,7 @@ function teamMemSavedPart(message) {
|
|
|
466936
467201
|
}
|
|
466937
467202
|
|
|
466938
467203
|
// src/components/messages/SystemTextMessage.tsx
|
|
466939
|
-
import { basename as
|
|
467204
|
+
import { basename as basename26 } from "path";
|
|
466940
467205
|
function SystemTextMessage(t0) {
|
|
466941
467206
|
const $3 = import_compiler_runtime101.c(51);
|
|
466942
467207
|
const {
|
|
@@ -467861,7 +468126,7 @@ function MemoryFileRow(t0) {
|
|
|
467861
468126
|
const t4 = !hover;
|
|
467862
468127
|
let t5;
|
|
467863
468128
|
if ($3[4] !== path21) {
|
|
467864
|
-
t5 =
|
|
468129
|
+
t5 = basename26(path21);
|
|
467865
468130
|
$3[4] = path21;
|
|
467866
468131
|
$3[5] = t5;
|
|
467867
468132
|
} else {
|
|
@@ -541639,7 +541904,7 @@ var require_util13 = __commonJS((exports) => {
|
|
|
541639
541904
|
}
|
|
541640
541905
|
path22 = url3.path;
|
|
541641
541906
|
}
|
|
541642
|
-
var
|
|
541907
|
+
var isAbsolute25 = exports.isAbsolute(path22);
|
|
541643
541908
|
var parts = path22.split(/\/+/);
|
|
541644
541909
|
for (var part, up = 0, i6 = parts.length - 1;i6 >= 0; i6--) {
|
|
541645
541910
|
part = parts[i6];
|
|
@@ -541659,7 +541924,7 @@ var require_util13 = __commonJS((exports) => {
|
|
|
541659
541924
|
}
|
|
541660
541925
|
path22 = parts.join("/");
|
|
541661
541926
|
if (path22 === "") {
|
|
541662
|
-
path22 =
|
|
541927
|
+
path22 = isAbsolute25 ? "/" : ".";
|
|
541663
541928
|
}
|
|
541664
541929
|
if (url3) {
|
|
541665
541930
|
url3.path = path22;
|
|
@@ -566514,7 +566779,7 @@ import { notStrictEqual, strictEqual } from "assert";
|
|
|
566514
566779
|
import { inspect as inspect5 } from "util";
|
|
566515
566780
|
import { readFileSync as readFileSync24 } from "fs";
|
|
566516
566781
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
566517
|
-
import { basename as
|
|
566782
|
+
import { basename as basename28, dirname as dirname44, extname as extname15, relative as relative19, resolve as resolve41 } from "path";
|
|
566518
566783
|
var REQUIRE_ERROR = "require is not supported by ESM", REQUIRE_DIRECTORY_ERROR = "loading a directory of commands is not supported yet for ESM", __dirname4, mainFilename, esm_default5;
|
|
566519
566784
|
var init_esm26 = __esm(() => {
|
|
566520
566785
|
init_cliui();
|
|
@@ -566546,9 +566811,9 @@ var init_esm26 = __esm(() => {
|
|
|
566546
566811
|
mainFilename: mainFilename || process.cwd(),
|
|
566547
566812
|
Parser: lib_default,
|
|
566548
566813
|
path: {
|
|
566549
|
-
basename:
|
|
566814
|
+
basename: basename28,
|
|
566550
566815
|
dirname: dirname44,
|
|
566551
|
-
extname:
|
|
566816
|
+
extname: extname15,
|
|
566552
566817
|
relative: relative19,
|
|
566553
566818
|
resolve: resolve41
|
|
566554
566819
|
},
|
|
@@ -572082,7 +572347,7 @@ var init_WebBrowserTool = __esm(() => {
|
|
|
572082
572347
|
|
|
572083
572348
|
// src/utils/listSessionsImpl.ts
|
|
572084
572349
|
import { readdir as readdir20, stat as stat32 } from "fs/promises";
|
|
572085
|
-
import { basename as
|
|
572350
|
+
import { basename as basename29, join as join104 } from "path";
|
|
572086
572351
|
async function listCandidates(projectDir, doStat, projectPath) {
|
|
572087
572352
|
let names;
|
|
572088
572353
|
try {
|
|
@@ -572811,9 +573076,9 @@ __export(exports_upload, {
|
|
|
572811
573076
|
});
|
|
572812
573077
|
import { randomUUID as randomUUID21 } from "crypto";
|
|
572813
573078
|
import { readFile as readFile37 } from "fs/promises";
|
|
572814
|
-
import { basename as
|
|
573079
|
+
import { basename as basename30, extname as extname16 } from "path";
|
|
572815
573080
|
function guessMimeType(filename) {
|
|
572816
|
-
const ext =
|
|
573081
|
+
const ext = extname16(filename).toLowerCase();
|
|
572817
573082
|
return MIME_BY_EXT[ext] ?? "application/octet-stream";
|
|
572818
573083
|
}
|
|
572819
573084
|
function debug8(msg) {
|
|
@@ -572844,7 +573109,7 @@ async function uploadBriefAttachment(fullPath, size, ctx) {
|
|
|
572844
573109
|
}
|
|
572845
573110
|
const baseUrl = getBridgeBaseUrl2();
|
|
572846
573111
|
const url3 = `${baseUrl}/api/oauth/file_upload`;
|
|
572847
|
-
const filename =
|
|
573112
|
+
const filename = basename30(fullPath);
|
|
572848
573113
|
const mimeType = guessMimeType(filename);
|
|
572849
573114
|
const boundary = `----FormBoundary${randomUUID21()}`;
|
|
572850
573115
|
const body = Buffer.concat([
|
|
@@ -578420,7 +578685,7 @@ var init_UI21 = __esm(() => {
|
|
|
578420
578685
|
|
|
578421
578686
|
// src/tools/EnterWorktreeTool/EnterWorktreeTool.ts
|
|
578422
578687
|
import { realpath as realpath13 } from "fs/promises";
|
|
578423
|
-
import { basename as
|
|
578688
|
+
import { basename as basename31, resolve as resolve42, sep as sep31 } from "path";
|
|
578424
578689
|
async function listRegisteredWorktreePaths(gitRoot) {
|
|
578425
578690
|
const result = await execFileNoThrowWithCwd(gitExe(), ["worktree", "list", "--porcelain"], { cwd: gitRoot });
|
|
578426
578691
|
if (result.code !== 0) {
|
|
@@ -578468,7 +578733,7 @@ async function enterExistingWorktree(worktreePathInput) {
|
|
|
578468
578733
|
const session = {
|
|
578469
578734
|
originalCwd,
|
|
578470
578735
|
worktreePath: realResolved,
|
|
578471
|
-
worktreeName:
|
|
578736
|
+
worktreeName: basename31(realResolved),
|
|
578472
578737
|
worktreeBranch,
|
|
578473
578738
|
sessionId: getSessionId()
|
|
578474
578739
|
};
|
|
@@ -583688,7 +583953,7 @@ __export(exports_scriptLoader, {
|
|
|
583688
583953
|
WorkflowScriptError: () => WorkflowScriptError
|
|
583689
583954
|
});
|
|
583690
583955
|
import { readFileSync as readFileSync26 } from "fs";
|
|
583691
|
-
import { isAbsolute as
|
|
583956
|
+
import { isAbsolute as isAbsolute26, resolve as resolve43 } from "path";
|
|
583692
583957
|
import vm from "vm";
|
|
583693
583958
|
function validateScriptPath(scriptPath) {
|
|
583694
583959
|
if (!scriptPath || typeof scriptPath !== "string") {
|
|
@@ -583697,7 +583962,7 @@ function validateScriptPath(scriptPath) {
|
|
|
583697
583962
|
if (/^\\\\/.test(scriptPath)) {
|
|
583698
583963
|
throw new WorkflowScriptError(`UNC paths are not allowed for workflow scriptPath: ${scriptPath}`);
|
|
583699
583964
|
}
|
|
583700
|
-
const resolved =
|
|
583965
|
+
const resolved = isAbsolute26(scriptPath) ? scriptPath : resolve43(scriptPath);
|
|
583701
583966
|
return resolved;
|
|
583702
583967
|
}
|
|
583703
583968
|
function findMetaEnd(source2, openBraceIndex) {
|
|
@@ -583869,6 +584134,142 @@ var init_errors11 = __esm(() => {
|
|
|
583869
584134
|
};
|
|
583870
584135
|
});
|
|
583871
584136
|
|
|
584137
|
+
// src/tools/WorkflowTool/prefixStagger.ts
|
|
584138
|
+
function createWarmingEntry() {
|
|
584139
|
+
let release;
|
|
584140
|
+
const ready = new Promise((resolve44) => {
|
|
584141
|
+
release = resolve44;
|
|
584142
|
+
});
|
|
584143
|
+
return { state: "warming", ready, release: () => release?.() };
|
|
584144
|
+
}
|
|
584145
|
+
function sleepWithAbort(ms, signal) {
|
|
584146
|
+
return new Promise((resolve44) => {
|
|
584147
|
+
if (signal?.aborted) {
|
|
584148
|
+
resolve44();
|
|
584149
|
+
return;
|
|
584150
|
+
}
|
|
584151
|
+
const onAbort = () => {
|
|
584152
|
+
clearTimeout(timer2);
|
|
584153
|
+
resolve44();
|
|
584154
|
+
};
|
|
584155
|
+
const timer2 = setTimeout(() => {
|
|
584156
|
+
signal?.removeEventListener("abort", onAbort);
|
|
584157
|
+
resolve44();
|
|
584158
|
+
}, ms);
|
|
584159
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
584160
|
+
});
|
|
584161
|
+
}
|
|
584162
|
+
function raceReadyWithTimeout(ready, timeoutMs, signal) {
|
|
584163
|
+
if (signal?.aborted)
|
|
584164
|
+
return Promise.resolve();
|
|
584165
|
+
const controller = new AbortController;
|
|
584166
|
+
const onAbort = () => controller.abort();
|
|
584167
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
584168
|
+
return Promise.race([ready, sleepWithAbort(timeoutMs, controller.signal)]).finally(() => {
|
|
584169
|
+
controller.abort();
|
|
584170
|
+
signal?.removeEventListener("abort", onAbort);
|
|
584171
|
+
});
|
|
584172
|
+
}
|
|
584173
|
+
|
|
584174
|
+
class WorkflowPrefixStaggerGate {
|
|
584175
|
+
now;
|
|
584176
|
+
entries = new Map;
|
|
584177
|
+
constructor(now2 = Date.now) {
|
|
584178
|
+
this.now = now2;
|
|
584179
|
+
}
|
|
584180
|
+
async enter(key3, opts) {
|
|
584181
|
+
const now2 = this.now();
|
|
584182
|
+
for (const [k5, entry] of this.entries) {
|
|
584183
|
+
if (entry.state === "warm" && entry.until <= now2) {
|
|
584184
|
+
this.entries.delete(k5);
|
|
584185
|
+
}
|
|
584186
|
+
}
|
|
584187
|
+
const existing = this.entries.get(key3);
|
|
584188
|
+
let warming;
|
|
584189
|
+
let waitedMs = 0;
|
|
584190
|
+
if (existing === undefined) {
|
|
584191
|
+
warming = createWarmingEntry();
|
|
584192
|
+
this.entries.set(key3, warming);
|
|
584193
|
+
} else if (existing.state === "warming" && opts.capMs > 0) {
|
|
584194
|
+
const start = this.now();
|
|
584195
|
+
await raceReadyWithTimeout(existing.ready, opts.capMs, opts.signal);
|
|
584196
|
+
waitedMs = Math.max(0, this.now() - start);
|
|
584197
|
+
}
|
|
584198
|
+
let respondedFired = false;
|
|
584199
|
+
return {
|
|
584200
|
+
leader: warming !== undefined,
|
|
584201
|
+
waitedMs,
|
|
584202
|
+
responded: () => {
|
|
584203
|
+
respondedFired = true;
|
|
584204
|
+
this.markWarm(key3);
|
|
584205
|
+
},
|
|
584206
|
+
done: () => {
|
|
584207
|
+
if (respondedFired || warming === undefined)
|
|
584208
|
+
return;
|
|
584209
|
+
if (this.entries.get(key3) === warming && warming.state === "warming") {
|
|
584210
|
+
this.entries.delete(key3);
|
|
584211
|
+
warming.release();
|
|
584212
|
+
}
|
|
584213
|
+
}
|
|
584214
|
+
};
|
|
584215
|
+
}
|
|
584216
|
+
stateOf(key3) {
|
|
584217
|
+
const entry = this.entries.get(key3);
|
|
584218
|
+
if (entry === undefined)
|
|
584219
|
+
return "cold";
|
|
584220
|
+
if (entry.state === "warm") {
|
|
584221
|
+
return entry.until > this.now() ? "warm" : "cold";
|
|
584222
|
+
}
|
|
584223
|
+
return "warming";
|
|
584224
|
+
}
|
|
584225
|
+
clear() {
|
|
584226
|
+
for (const entry of this.entries.values()) {
|
|
584227
|
+
if (entry.state === "warming")
|
|
584228
|
+
entry.release();
|
|
584229
|
+
}
|
|
584230
|
+
this.entries.clear();
|
|
584231
|
+
}
|
|
584232
|
+
markWarm(key3) {
|
|
584233
|
+
const existing = this.entries.get(key3);
|
|
584234
|
+
this.entries.set(key3, {
|
|
584235
|
+
state: "warm",
|
|
584236
|
+
until: this.now() + WORKFLOW_PREFIX_WARM_TTL_MS
|
|
584237
|
+
});
|
|
584238
|
+
if (existing?.state === "warming")
|
|
584239
|
+
existing.release();
|
|
584240
|
+
}
|
|
584241
|
+
}
|
|
584242
|
+
function getWorkflowPrefixStaggerGate() {
|
|
584243
|
+
return singleton ??= new WorkflowPrefixStaggerGate;
|
|
584244
|
+
}
|
|
584245
|
+
function getWorkflowPrefixStaggerCapMs(env7 = process.env) {
|
|
584246
|
+
if (isEnvTruthy(env7.DISABLE_PROMPT_CACHING)) {
|
|
584247
|
+
return 0;
|
|
584248
|
+
}
|
|
584249
|
+
const raw = env7.CLAUDE_CODE_WORKFLOW_PREFIX_STAGGER_MS;
|
|
584250
|
+
if (raw !== undefined && raw !== "") {
|
|
584251
|
+
const parsed = Number.parseInt(raw, 10);
|
|
584252
|
+
if (Number.isFinite(parsed) && parsed >= 0)
|
|
584253
|
+
return parsed;
|
|
584254
|
+
}
|
|
584255
|
+
return WORKFLOW_PREFIX_STAGGER_DEFAULT_MS;
|
|
584256
|
+
}
|
|
584257
|
+
function buildWorkflowPrefixKey(parts) {
|
|
584258
|
+
return [
|
|
584259
|
+
parts.model ?? "",
|
|
584260
|
+
String(parts.effort ?? ""),
|
|
584261
|
+
parts.agentType,
|
|
584262
|
+
parts.toolNames,
|
|
584263
|
+
parts.schemaJson,
|
|
584264
|
+
parts.cwd
|
|
584265
|
+
].join(`
|
|
584266
|
+
`);
|
|
584267
|
+
}
|
|
584268
|
+
var WORKFLOW_PREFIX_WARM_TTL_MS = 270000, WORKFLOW_PREFIX_STAGGER_DEFAULT_MS = 5000, singleton;
|
|
584269
|
+
var init_prefixStagger = __esm(() => {
|
|
584270
|
+
init_envUtils();
|
|
584271
|
+
});
|
|
584272
|
+
|
|
583872
584273
|
// src/tools/WorkflowTool/primitives.ts
|
|
583873
584274
|
function workflowAgentTelemetryAttributes(runId, workflowName) {
|
|
583874
584275
|
return {
|
|
@@ -584060,10 +584461,29 @@ You MUST call the ${SYNTHETIC_OUTPUT_TOOL_NAME} tool exactly once at the end of
|
|
|
584060
584461
|
})
|
|
584061
584462
|
];
|
|
584062
584463
|
let agentTokens = 0;
|
|
584063
|
-
const onQueryProgress = () => {};
|
|
584064
584464
|
const agentId = createAgentId("wf");
|
|
584065
584465
|
const agentShortId = agentId.slice(0, 16);
|
|
584066
584466
|
const agentLabel = opts.label ?? prompt.slice(0, 80);
|
|
584467
|
+
const agentStartTime = Date.now();
|
|
584468
|
+
const agentModel = opts.model ?? getMainLoopModel();
|
|
584469
|
+
const prefixKey = buildWorkflowPrefixKey({
|
|
584470
|
+
model: agentModel,
|
|
584471
|
+
effort: opts.effort,
|
|
584472
|
+
agentType: agentDef.agentType,
|
|
584473
|
+
toolNames: ctx.availableTools.map((t4) => t4.name).join(","),
|
|
584474
|
+
schemaJson: opts.schema ? JSON.stringify(opts.schema) : "",
|
|
584475
|
+
cwd: worktreePath ?? getCwd()
|
|
584476
|
+
});
|
|
584477
|
+
const staggerHandle = await getWorkflowPrefixStaggerGate().enter(prefixKey, {
|
|
584478
|
+
capMs: getWorkflowPrefixStaggerCapMs(),
|
|
584479
|
+
signal: ctx.abortController.signal
|
|
584480
|
+
});
|
|
584481
|
+
if (staggerHandle.waitedMs > 0) {
|
|
584482
|
+
logForDebugging(`workflow agent [${agentLabel}] held ${staggerHandle.waitedMs}ms for a same-prefix sibling's first response (prompt-cache warm-up)`);
|
|
584483
|
+
}
|
|
584484
|
+
const onQueryProgress = () => {
|
|
584485
|
+
staggerHandle.responded();
|
|
584486
|
+
};
|
|
584067
584487
|
const gen = runAgent({
|
|
584068
584488
|
agentDefinition: agentDef,
|
|
584069
584489
|
promptMessages,
|
|
@@ -584082,8 +584502,6 @@ You MUST call the ${SYNTHETIC_OUTPUT_TOOL_NAME} tool exactly once at the end of
|
|
|
584082
584502
|
onQueryProgress,
|
|
584083
584503
|
override: { agentId }
|
|
584084
584504
|
});
|
|
584085
|
-
const agentStartTime = Date.now();
|
|
584086
|
-
const agentModel = opts.model ?? getMainLoopModel();
|
|
584087
584505
|
logEvent2("tengu_workflow_agent_started", {
|
|
584088
584506
|
...workflowAgentTelemetryAttributes(ctx.runId, ctx.workflowName),
|
|
584089
584507
|
agent_id: agentShortId,
|
|
@@ -584130,6 +584548,8 @@ You MUST call the ${SYNTHETIC_OUTPUT_TOOL_NAME} tool exactly once at the end of
|
|
|
584130
584548
|
elapsedMs: Math.max(0, Date.now() - agentStartTime)
|
|
584131
584549
|
});
|
|
584132
584550
|
throw e4;
|
|
584551
|
+
} finally {
|
|
584552
|
+
staggerHandle.done();
|
|
584133
584553
|
}
|
|
584134
584554
|
agentTokens = extractTokenUsage(messages);
|
|
584135
584555
|
ctx.counters.spentTokens += agentTokens;
|
|
@@ -584386,7 +584806,10 @@ var init_primitives = __esm(() => {
|
|
|
584386
584806
|
init_SyntheticOutputTool();
|
|
584387
584807
|
init_errors11();
|
|
584388
584808
|
init_journal();
|
|
584809
|
+
init_prefixStagger();
|
|
584389
584810
|
init_model();
|
|
584811
|
+
init_cwd2();
|
|
584812
|
+
init_debug();
|
|
584390
584813
|
});
|
|
584391
584814
|
|
|
584392
584815
|
// src/utils/effort/workflowDiscovery.ts
|
|
@@ -585474,8 +585897,8 @@ function extractBaseCommand2(segment2) {
|
|
|
585474
585897
|
const stripped = segment2.trim().replace(/^[&.]\s+/, "");
|
|
585475
585898
|
const firstToken = stripped.split(/\s+/)[0] || "";
|
|
585476
585899
|
const unquoted = firstToken.replace(/^["']|["']$/g, "");
|
|
585477
|
-
const
|
|
585478
|
-
return
|
|
585900
|
+
const basename32 = unquoted.split(/[\\/]/).pop() || unquoted;
|
|
585901
|
+
return basename32.toLowerCase().replace(/\.exe$/, "");
|
|
585479
585902
|
}
|
|
585480
585903
|
function heuristicallyExtractBaseCommand2(command5) {
|
|
585481
585904
|
const segments = command5.split(/[;|]/).filter((s4) => s4.trim());
|
|
@@ -586420,11 +586843,11 @@ var init_parser6 = __esm(() => {
|
|
|
586420
586843
|
});
|
|
586421
586844
|
|
|
586422
586845
|
// src/tools/PowerShellTool/gitSafety.ts
|
|
586423
|
-
import { basename as
|
|
586846
|
+
import { basename as basename32, posix as posix7, resolve as resolve44, sep as sep33 } from "path";
|
|
586424
586847
|
function resolveCwdReentry(normalized) {
|
|
586425
586848
|
if (!normalized.startsWith("../"))
|
|
586426
586849
|
return normalized;
|
|
586427
|
-
const cwdBase =
|
|
586850
|
+
const cwdBase = basename32(getCwd()).toLowerCase();
|
|
586428
586851
|
if (!cwdBase)
|
|
586429
586852
|
return normalized;
|
|
586430
586853
|
const prefix = "../" + cwdBase + "/";
|
|
@@ -587738,7 +588161,7 @@ var init_modeValidation2 = __esm(() => {
|
|
|
587738
588161
|
|
|
587739
588162
|
// src/tools/PowerShellTool/pathValidation.ts
|
|
587740
588163
|
import { homedir as homedir32 } from "os";
|
|
587741
|
-
import { isAbsolute as
|
|
588164
|
+
import { isAbsolute as isAbsolute27, resolve as resolve45 } from "path";
|
|
587742
588165
|
function matchesParam(paramLower, paramList) {
|
|
587743
588166
|
for (const p4 of paramList) {
|
|
587744
588167
|
if (p4 === paramLower || paramLower.length > 1 && p4.startsWith(paramLower)) {
|
|
@@ -587846,7 +588269,7 @@ function checkDenyRuleForGuessedPath(strippedPath, cwd2, toolPermissionContext,
|
|
|
587846
588269
|
if (!strippedPath || strippedPath.includes("\x00"))
|
|
587847
588270
|
return null;
|
|
587848
588271
|
const tildeExpanded = expandTilde2(strippedPath);
|
|
587849
|
-
const abs =
|
|
588272
|
+
const abs = isAbsolute27(tildeExpanded) ? tildeExpanded : resolve45(cwd2, tildeExpanded);
|
|
587850
588273
|
const { resolvedPath } = safeResolvePath(getFsImplementation(), abs);
|
|
587851
588274
|
const permissionType = operationType === "read" ? "read" : "edit";
|
|
587852
588275
|
const denyRule = matchingRuleForInput(resolvedPath, toolPermissionContext, permissionType, "deny");
|
|
@@ -587936,7 +588359,7 @@ function validatePath2(filePath, cwd2, toolPermissionContext, operationType) {
|
|
|
587936
588359
|
};
|
|
587937
588360
|
}
|
|
587938
588361
|
if (containsPathTraversal(normalizedPath)) {
|
|
587939
|
-
const absolutePath2 =
|
|
588362
|
+
const absolutePath2 = isAbsolute27(normalizedPath) ? normalizedPath : resolve45(cwd2, normalizedPath);
|
|
587940
588363
|
const { resolvedPath: resolvedPath3, isCanonical: isCanonical2 } = safeResolvePath(getFsImplementation(), absolutePath2);
|
|
587941
588364
|
const result2 = isPathAllowed2(resolvedPath3, toolPermissionContext, operationType, isCanonical2 ? [resolvedPath3] : undefined);
|
|
587942
588365
|
return {
|
|
@@ -587946,7 +588369,7 @@ function validatePath2(filePath, cwd2, toolPermissionContext, operationType) {
|
|
|
587946
588369
|
};
|
|
587947
588370
|
}
|
|
587948
588371
|
const basePath = getGlobBaseDirectory2(normalizedPath);
|
|
587949
|
-
const absoluteBasePath =
|
|
588372
|
+
const absoluteBasePath = isAbsolute27(basePath) ? basePath : resolve45(cwd2, basePath);
|
|
587950
588373
|
const { resolvedPath: resolvedPath2 } = safeResolvePath(getFsImplementation(), absoluteBasePath);
|
|
587951
588374
|
const permissionType = operationType === "read" ? "read" : "edit";
|
|
587952
588375
|
const denyRule = matchingRuleForInput(resolvedPath2, toolPermissionContext, permissionType, "deny");
|
|
@@ -587966,7 +588389,7 @@ function validatePath2(filePath, cwd2, toolPermissionContext, operationType) {
|
|
|
587966
588389
|
}
|
|
587967
588390
|
};
|
|
587968
588391
|
}
|
|
587969
|
-
const absolutePath =
|
|
588392
|
+
const absolutePath = isAbsolute27(normalizedPath) ? normalizedPath : resolve45(cwd2, normalizedPath);
|
|
587970
588393
|
const { resolvedPath, isCanonical } = safeResolvePath(getFsImplementation(), absolutePath);
|
|
587971
588394
|
const result = isPathAllowed2(resolvedPath, toolPermissionContext, operationType, isCanonical ? [resolvedPath] : undefined);
|
|
587972
588395
|
return {
|
|
@@ -594416,11 +594839,11 @@ var init_memoryTypes = __esm(() => {
|
|
|
594416
594839
|
|
|
594417
594840
|
// src/memdir/memoryScan.ts
|
|
594418
594841
|
import { readdir as readdir22 } from "fs/promises";
|
|
594419
|
-
import { basename as
|
|
594842
|
+
import { basename as basename33, join as join111 } from "path";
|
|
594420
594843
|
async function scanMemoryFiles(memoryDir, signal) {
|
|
594421
594844
|
try {
|
|
594422
594845
|
const entries = await readdir22(memoryDir, { recursive: true });
|
|
594423
|
-
const mdFiles = entries.filter((f4) => f4.endsWith(".md") &&
|
|
594846
|
+
const mdFiles = entries.filter((f4) => f4.endsWith(".md") && basename33(f4) !== "MEMORY.md");
|
|
594424
594847
|
const headerResults = await Promise.allSettled(mdFiles.map(async (relativePath) => {
|
|
594425
594848
|
const filePath = join111(memoryDir, relativePath);
|
|
594426
594849
|
const { content, mtimeMs } = await readFileInRange(filePath, 0, FRONTMATTER_MAX_LINES, undefined, signal);
|
|
@@ -594571,7 +594994,7 @@ __export(exports_extractMemories, {
|
|
|
594571
594994
|
drainPendingExtraction: () => drainPendingExtraction,
|
|
594572
594995
|
createAutoMemCanUseTool: () => createAutoMemCanUseTool
|
|
594573
594996
|
});
|
|
594574
|
-
import { basename as
|
|
594997
|
+
import { basename as basename34 } from "path";
|
|
594575
594998
|
function isModelVisibleMessage(message) {
|
|
594576
594999
|
return message.type === "user" || message.type === "assistant";
|
|
594577
595000
|
}
|
|
@@ -594753,7 +595176,7 @@ function initExtractMemories() {
|
|
|
594753
595176
|
} else {
|
|
594754
595177
|
logForDebugging("[extractMemories] no memories saved this run");
|
|
594755
595178
|
}
|
|
594756
|
-
const memoryPaths = writtenPaths.filter((p4) =>
|
|
595179
|
+
const memoryPaths = writtenPaths.filter((p4) => basename34(p4) !== ENTRYPOINT_NAME);
|
|
594757
595180
|
const teamCount = feature("TEAMMEM") ? count2(memoryPaths, teamMemPaths5.isTeamMemPath) : 0;
|
|
594758
595181
|
logEvent2("tengu_extract_memories_extraction", {
|
|
594759
595182
|
input_tokens: result.totalUsage.input_tokens,
|
|
@@ -599296,7 +599719,7 @@ var init_queryHelpers = __esm(() => {
|
|
|
599296
599719
|
import { randomUUID as randomUUID27 } from "crypto";
|
|
599297
599720
|
import { rm as rm7 } from "fs";
|
|
599298
599721
|
import { appendFile as appendFile5, copyFile as copyFile7, mkdir as mkdir34 } from "fs/promises";
|
|
599299
|
-
import { dirname as dirname47, isAbsolute as
|
|
599722
|
+
import { dirname as dirname47, isAbsolute as isAbsolute28, join as join114, relative as relative22 } from "path";
|
|
599300
599723
|
function safeRemoveOverlay(overlayPath) {
|
|
599301
599724
|
rm7(overlayPath, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }, () => {});
|
|
599302
599725
|
}
|
|
@@ -599548,7 +599971,7 @@ async function startSpeculation(suggestionText, context7, setAppState, isPipelin
|
|
|
599548
599971
|
const filePath = input2[pathKey2];
|
|
599549
599972
|
if (filePath) {
|
|
599550
599973
|
const rel = relative22(cwd2, filePath);
|
|
599551
|
-
if (
|
|
599974
|
+
if (isAbsolute28(rel) || rel.startsWith("..")) {
|
|
599552
599975
|
if (isWriteTool) {
|
|
599553
599976
|
logForDebugging(`[Speculation] Denied ${tool.name}: path outside cwd: ${filePath}`);
|
|
599554
599977
|
return denySpeculation("Write outside cwd not allowed during speculation", "speculation_write_outside_root");
|
|
@@ -606608,9 +607031,9 @@ var builders = null;
|
|
|
606608
607031
|
import { createHash as createHash26 } from "crypto";
|
|
606609
607032
|
import { realpath as realpath14 } from "fs/promises";
|
|
606610
607033
|
import {
|
|
606611
|
-
basename as
|
|
607034
|
+
basename as basename35,
|
|
606612
607035
|
dirname as dirname50,
|
|
606613
|
-
isAbsolute as
|
|
607036
|
+
isAbsolute as isAbsolute29,
|
|
606614
607037
|
join as join117,
|
|
606615
607038
|
sep as pathSep,
|
|
606616
607039
|
relative as relative24
|
|
@@ -606928,7 +607351,7 @@ async function loadSkillsFromSkillsDir(basePath, source2) {
|
|
|
606928
607351
|
return results.filter((r4) => r4 !== null);
|
|
606929
607352
|
}
|
|
606930
607353
|
function isSkillFile(filePath) {
|
|
606931
|
-
return /^skill\.md$/i.test(
|
|
607354
|
+
return /^skill\.md$/i.test(basename35(filePath));
|
|
606932
607355
|
}
|
|
606933
607356
|
function transformSkillFiles(files2) {
|
|
606934
607357
|
const filesByDir = new Map;
|
|
@@ -606944,7 +607367,7 @@ function transformSkillFiles(files2) {
|
|
|
606944
607367
|
if (skillFiles.length > 0) {
|
|
606945
607368
|
const skillFile = skillFiles[0];
|
|
606946
607369
|
if (skillFiles.length > 1) {
|
|
606947
|
-
logForDebugging(`Multiple skill files found in ${dir}, using ${
|
|
607370
|
+
logForDebugging(`Multiple skill files found in ${dir}, using ${basename35(skillFile.filePath)}`);
|
|
606948
607371
|
}
|
|
606949
607372
|
result.push(skillFile);
|
|
606950
607373
|
} else {
|
|
@@ -606964,12 +607387,12 @@ function buildNamespace(targetDir, baseDir) {
|
|
|
606964
607387
|
function getSkillCommandName(filePath, baseDir) {
|
|
606965
607388
|
const skillDirectory = dirname50(filePath);
|
|
606966
607389
|
const parentOfSkillDir = dirname50(skillDirectory);
|
|
606967
|
-
const commandBaseName =
|
|
607390
|
+
const commandBaseName = basename35(skillDirectory);
|
|
606968
607391
|
const namespace = buildNamespace(parentOfSkillDir, baseDir);
|
|
606969
607392
|
return namespace ? `${namespace}:${commandBaseName}` : commandBaseName;
|
|
606970
607393
|
}
|
|
606971
607394
|
function getRegularCommandName(filePath, baseDir) {
|
|
606972
|
-
const fileName =
|
|
607395
|
+
const fileName = basename35(filePath);
|
|
606973
607396
|
const fileDirectory = dirname50(filePath);
|
|
606974
607397
|
const commandBaseName = fileName.replace(/\.md$/, "");
|
|
606975
607398
|
const namespace = buildNamespace(fileDirectory, baseDir);
|
|
@@ -607121,8 +607544,8 @@ function activateConditionalSkillsForPaths(filePaths, cwd2) {
|
|
|
607121
607544
|
}
|
|
607122
607545
|
const skillIgnore = import_ignore4.default().add(filterValidIgnorePatterns(skill.paths, "skill_paths"));
|
|
607123
607546
|
for (const filePath of filePaths) {
|
|
607124
|
-
const relativePath =
|
|
607125
|
-
if (!relativePath || relativePath.startsWith("..") ||
|
|
607547
|
+
const relativePath = isAbsolute29(filePath) ? relative24(cwd2, filePath) : filePath;
|
|
607548
|
+
if (!relativePath || relativePath.startsWith("..") || isAbsolute29(relativePath)) {
|
|
607126
607549
|
continue;
|
|
607127
607550
|
}
|
|
607128
607551
|
if (skillIgnore.ignores(relativePath)) {
|
|
@@ -607456,9 +607879,9 @@ Important:
|
|
|
607456
607879
|
});
|
|
607457
607880
|
|
|
607458
607881
|
// src/utils/plugins/loadPluginCommands.ts
|
|
607459
|
-
import { basename as
|
|
607882
|
+
import { basename as basename36, dirname as dirname51, join as join118 } from "path";
|
|
607460
607883
|
function isSkillFile2(filePath) {
|
|
607461
|
-
return /^skill\.md$/i.test(
|
|
607884
|
+
return /^skill\.md$/i.test(basename36(filePath));
|
|
607462
607885
|
}
|
|
607463
607886
|
function pluginSkillUserFacingName(commandName, _displayName) {
|
|
607464
607887
|
return commandName;
|
|
@@ -607468,13 +607891,13 @@ function getCommandNameFromFile(filePath, baseDir, pluginName) {
|
|
|
607468
607891
|
if (isSkill) {
|
|
607469
607892
|
const skillDirectory = dirname51(filePath);
|
|
607470
607893
|
const parentOfSkillDir = dirname51(skillDirectory);
|
|
607471
|
-
const commandBaseName =
|
|
607894
|
+
const commandBaseName = basename36(skillDirectory);
|
|
607472
607895
|
const relativePath = parentOfSkillDir.startsWith(baseDir) ? parentOfSkillDir.slice(baseDir.length).replace(/^\//, "") : "";
|
|
607473
607896
|
const namespace = relativePath ? relativePath.split("/").join(":") : "";
|
|
607474
607897
|
return namespace ? `${pluginName}:${namespace}:${commandBaseName}` : `${pluginName}:${commandBaseName}`;
|
|
607475
607898
|
} else {
|
|
607476
607899
|
const fileDirectory = dirname51(filePath);
|
|
607477
|
-
const commandBaseName =
|
|
607900
|
+
const commandBaseName = basename36(filePath).replace(/\.md$/, "");
|
|
607478
607901
|
const relativePath = fileDirectory.startsWith(baseDir) ? fileDirectory.slice(baseDir.length).replace(/^\//, "") : "";
|
|
607479
607902
|
const namespace = relativePath ? relativePath.split("/").join(":") : "";
|
|
607480
607903
|
return namespace ? `${pluginName}:${namespace}:${commandBaseName}` : `${pluginName}:${commandBaseName}`;
|
|
@@ -607511,7 +607934,7 @@ function transformPluginSkillFiles(files2) {
|
|
|
607511
607934
|
if (skillFiles.length > 0) {
|
|
607512
607935
|
const skillFile = skillFiles[0];
|
|
607513
607936
|
if (skillFiles.length > 1) {
|
|
607514
|
-
logForDebugging(`Multiple skill files found in ${dir}, using ${
|
|
607937
|
+
logForDebugging(`Multiple skill files found in ${dir}, using ${basename36(skillFile.filePath)}`);
|
|
607515
607938
|
}
|
|
607516
607939
|
result.push(skillFile);
|
|
607517
607940
|
} else {
|
|
@@ -607662,7 +608085,7 @@ async function loadSkillsFromDirectory(skillsPath, pluginName, sourceName, plugi
|
|
|
607662
608085
|
}
|
|
607663
608086
|
try {
|
|
607664
608087
|
const { frontmatter, content: markdownContent } = parseFrontmatter(directSkillContent, directSkillPath);
|
|
607665
|
-
const skillName = `${pluginName}:${
|
|
608088
|
+
const skillName = `${pluginName}:${basename36(skillsPath)}`;
|
|
607666
608089
|
const file2 = {
|
|
607667
608090
|
filePath: directSkillPath,
|
|
607668
608091
|
baseDir: dirname51(directSkillPath),
|
|
@@ -607808,7 +608231,7 @@ var init_loadPluginCommands = __esm(() => {
|
|
|
607808
608231
|
}
|
|
607809
608232
|
}
|
|
607810
608233
|
if (!commandName) {
|
|
607811
|
-
commandName = `${plugin.name}:${
|
|
608234
|
+
commandName = `${plugin.name}:${basename36(commandPath).replace(/\.md$/, "")}`;
|
|
607812
608235
|
}
|
|
607813
608236
|
const finalFrontmatter = metadataOverride ? {
|
|
607814
608237
|
...frontmatter,
|
|
@@ -607952,7 +608375,7 @@ import {
|
|
|
607952
608375
|
writeFile as writeFile36
|
|
607953
608376
|
} from "fs/promises";
|
|
607954
608377
|
import { tmpdir as tmpdir12 } from "os";
|
|
607955
|
-
import { basename as
|
|
608378
|
+
import { basename as basename37, dirname as dirname52, join as join119 } from "path";
|
|
607956
608379
|
function isPluginZipCacheEnabled() {
|
|
607957
608380
|
return isEnvTruthy(process.env.CLAUDE_CODE_PLUGIN_USE_ZIP_CACHE);
|
|
607958
608381
|
}
|
|
@@ -608017,7 +608440,7 @@ async function cleanupSessionPluginCache() {
|
|
|
608017
608440
|
async function atomicWriteToZipCache(targetPath, data) {
|
|
608018
608441
|
const dir = dirname52(targetPath);
|
|
608019
608442
|
await getFsImplementation().mkdir(dir);
|
|
608020
|
-
const tmpName = `.${
|
|
608443
|
+
const tmpName = `.${basename37(targetPath)}.tmp.${randomBytes10(4).toString("hex")}`;
|
|
608021
608444
|
const tmpPath = join119(dir, tmpName);
|
|
608022
608445
|
try {
|
|
608023
608446
|
if (typeof data === "string") {
|
|
@@ -608723,7 +609146,7 @@ var init_officialMarketplaceGcs = __esm(() => {
|
|
|
608723
609146
|
|
|
608724
609147
|
// src/utils/plugins/marketplaceManager.ts
|
|
608725
609148
|
import { writeFile as writeFile39 } from "fs/promises";
|
|
608726
|
-
import { basename as
|
|
609149
|
+
import { basename as basename38, dirname as dirname54, isAbsolute as isAbsolute30, join as join122, resolve as resolve50, sep as sep36 } from "path";
|
|
608727
609150
|
function getKnownMarketplacesFile() {
|
|
608728
609151
|
return join122(getPluginsDirectory(), "known_marketplaces.json");
|
|
608729
609152
|
}
|
|
@@ -609308,7 +609731,7 @@ Technical details: ${error52.message}`);
|
|
|
609308
609731
|
});
|
|
609309
609732
|
}
|
|
609310
609733
|
function getCachePathForSource(source2) {
|
|
609311
|
-
const tempName = source2.source === "github" ? source2.repo.replace("/", "-") : source2.source === "npm" ? source2.package.replace("@", "").replace("/", "-") : source2.source === "file" ?
|
|
609734
|
+
const tempName = source2.source === "github" ? source2.repo.replace("/", "-") : source2.source === "npm" ? source2.package.replace("@", "").replace("/", "-") : source2.source === "file" ? basename38(source2.path).replace(".json", "") : source2.source === "directory" ? basename38(source2.path) : "temp_" + Date.now();
|
|
609312
609735
|
return tempName;
|
|
609313
609736
|
}
|
|
609314
609737
|
async function parseFileWithSchema(filePath, schema) {
|
|
@@ -609481,7 +609904,7 @@ Technical details: ${errorMsg}`);
|
|
|
609481
609904
|
}
|
|
609482
609905
|
async function addMarketplaceSource(source2, onProgress) {
|
|
609483
609906
|
let resolvedSource = source2;
|
|
609484
|
-
if (isLocalMarketplaceSource(source2) && !
|
|
609907
|
+
if (isLocalMarketplaceSource(source2) && !isAbsolute30(source2.path)) {
|
|
609485
609908
|
resolvedSource = { ...source2, path: resolve50(source2.path) };
|
|
609486
609909
|
}
|
|
609487
609910
|
if (!isSourceAllowedByPolicy(resolvedSource)) {
|
|
@@ -609894,7 +610317,7 @@ var init_marketplaceManager = __esm(() => {
|
|
|
609894
610317
|
if (!entry) {
|
|
609895
610318
|
throw new Error(`Marketplace '${name3}' not found in configuration. Available marketplaces: ${Object.keys(config7).join(", ")}`);
|
|
609896
610319
|
}
|
|
609897
|
-
if (isLocalMarketplaceSource(entry.source) && !
|
|
610320
|
+
if (isLocalMarketplaceSource(entry.source) && !isAbsolute30(entry.source.path)) {
|
|
609898
610321
|
throw new Error(`Marketplace "${name3}" has a relative source path (${entry.source.path}) ` + `in known_marketplaces.json \u2014 this is stale state from an older ` + `OCC version. Run 'occ marketplace remove ${name3}' and ` + `re-add it from the original project directory.`);
|
|
609899
610322
|
}
|
|
609900
610323
|
try {
|
|
@@ -610744,7 +611167,7 @@ import {
|
|
|
610744
611167
|
stat as stat38,
|
|
610745
611168
|
symlink as symlink3
|
|
610746
611169
|
} from "fs/promises";
|
|
610747
|
-
import { basename as
|
|
611170
|
+
import { basename as basename39, dirname as dirname57, join as join125, relative as relative25, resolve as resolve52, sep as sep38 } from "path";
|
|
610748
611171
|
function getPluginCachePath() {
|
|
610749
611172
|
return join125(getPluginsDirectory(), "cache");
|
|
610750
611173
|
}
|
|
@@ -612109,7 +612532,7 @@ async function loadSessionOnlyPlugins(sessionPluginPaths) {
|
|
|
612109
612532
|
});
|
|
612110
612533
|
continue;
|
|
612111
612534
|
}
|
|
612112
|
-
const dirName =
|
|
612535
|
+
const dirName = basename39(resolvedPath);
|
|
612113
612536
|
const { plugin, errors: pluginErrors } = await createPluginFromPath(resolvedPath, `${dirName}@inline`, true, dirName);
|
|
612114
612537
|
plugin.source = `${plugin.name}@inline`;
|
|
612115
612538
|
plugin.repository = `${plugin.name}@inline`;
|
|
@@ -612284,7 +612707,7 @@ var init_pluginLoader = __esm(() => {
|
|
|
612284
612707
|
});
|
|
612285
612708
|
|
|
612286
612709
|
// src/utils/plugins/loadPluginOutputStyles.ts
|
|
612287
|
-
import { basename as
|
|
612710
|
+
import { basename as basename40 } from "path";
|
|
612288
612711
|
async function loadOutputStylesFromDirectory(outputStylesPath, pluginName, loadedPaths) {
|
|
612289
612712
|
const styles5 = [];
|
|
612290
612713
|
await walkPluginMarkdown(outputStylesPath, async (fullPath) => {
|
|
@@ -612302,7 +612725,7 @@ async function loadOutputStyleFromFile(filePath, pluginName, loadedPaths) {
|
|
|
612302
612725
|
try {
|
|
612303
612726
|
const content = await fs24.readFile(filePath, { encoding: "utf-8" });
|
|
612304
612727
|
const { frontmatter, content: markdownContent } = parseFrontmatter(content, filePath);
|
|
612305
|
-
const fileName =
|
|
612728
|
+
const fileName = basename40(filePath, ".md");
|
|
612306
612729
|
const baseStyleName = frontmatter.name || fileName;
|
|
612307
612730
|
const name3 = `${pluginName}:${baseStyleName}`;
|
|
612308
612731
|
const description = coerceDescriptionToString(frontmatter.description, name3) ?? extractDescriptionFromMarkdown(markdownContent, `Output style from ${pluginName} plugin`);
|
|
@@ -612383,7 +612806,7 @@ var init_loadPluginOutputStyles = __esm(() => {
|
|
|
612383
612806
|
});
|
|
612384
612807
|
|
|
612385
612808
|
// src/outputStyles/loadOutputStylesDir.ts
|
|
612386
|
-
import { basename as
|
|
612809
|
+
import { basename as basename41 } from "path";
|
|
612387
612810
|
var getOutputStyleDirStyles;
|
|
612388
612811
|
var init_loadOutputStylesDir = __esm(() => {
|
|
612389
612812
|
init_memoize();
|
|
@@ -612397,7 +612820,7 @@ var init_loadOutputStylesDir = __esm(() => {
|
|
|
612397
612820
|
const markdownFiles = await loadMarkdownFilesForSubdir("output-styles", cwd2);
|
|
612398
612821
|
const styles5 = markdownFiles.map(({ filePath, frontmatter, content, source: source2 }) => {
|
|
612399
612822
|
try {
|
|
612400
|
-
const fileName =
|
|
612823
|
+
const fileName = basename41(filePath);
|
|
612401
612824
|
const styleName = fileName.replace(/\.md$/, "");
|
|
612402
612825
|
const name3 = frontmatter["name"] || styleName;
|
|
612403
612826
|
const description = coerceDescriptionToString(frontmatter["description"], styleName) ?? extractDescriptionFromMarkdown(content, `Custom ${styleName} output style`);
|
|
@@ -616589,7 +617012,7 @@ function getMcpAutoBackgroundMs(tool, {
|
|
|
616589
617012
|
function isPipeNonInteractiveModeDefault() {
|
|
616590
617013
|
return isPipeNonInteractiveMode();
|
|
616591
617014
|
}
|
|
616592
|
-
function
|
|
617015
|
+
function sleepWithAbort2(ms, signal) {
|
|
616593
617016
|
return new Promise((resolve53) => {
|
|
616594
617017
|
if (signal.aborted) {
|
|
616595
617018
|
resolve53("timeout");
|
|
@@ -616631,7 +617054,7 @@ async function callMcpToolWithAutoBackground({
|
|
|
616631
617054
|
while (true) {
|
|
616632
617055
|
const winner = await Promise.race([
|
|
616633
617056
|
settledPromise,
|
|
616634
|
-
|
|
617057
|
+
sleepWithAbort2(autoBackgroundMs, raceController.signal)
|
|
616635
617058
|
]);
|
|
616636
617059
|
if (winner === "settled" || parentAbortController.signal.aborted) {
|
|
616637
617060
|
raceController.abort();
|
|
@@ -637884,7 +638307,7 @@ var init_renderPlaceholder = __esm(() => {
|
|
|
637884
638307
|
});
|
|
637885
638308
|
|
|
637886
638309
|
// src/hooks/usePasteHandler.ts
|
|
637887
|
-
import { basename as
|
|
638310
|
+
import { basename as basename42 } from "path";
|
|
637888
638311
|
function usePasteHandler({
|
|
637889
638312
|
onPaste,
|
|
637890
638313
|
onInput,
|
|
@@ -637946,7 +638369,7 @@ function usePasteHandler({
|
|
|
637946
638369
|
const validImages = results.filter((r4) => r4 !== null);
|
|
637947
638370
|
if (validImages.length > 0) {
|
|
637948
638371
|
for (const imageData of validImages) {
|
|
637949
|
-
const filename =
|
|
638372
|
+
const filename = basename42(imageData.path);
|
|
637950
638373
|
onImagePaste2(imageData.base64, imageData.mediaType, filename, imageData.dimensions, imageData.path);
|
|
637951
638374
|
}
|
|
637952
638375
|
const nonImageLines = lines2.filter((line) => !isImageFilePath(line));
|
|
@@ -638555,7 +638978,7 @@ var init_TextInput = __esm(() => {
|
|
|
638555
638978
|
});
|
|
638556
638979
|
|
|
638557
638980
|
// src/utils/suggestions/directoryCompletion.ts
|
|
638558
|
-
import { basename as
|
|
638981
|
+
import { basename as basename43, dirname as dirname61, join as join134, sep as sep39 } from "path";
|
|
638559
638982
|
function parsePartialPath(partialPath, basePath) {
|
|
638560
638983
|
if (!partialPath) {
|
|
638561
638984
|
const directory2 = basePath || getCwd();
|
|
@@ -638566,7 +638989,7 @@ function parsePartialPath(partialPath, basePath) {
|
|
|
638566
638989
|
return { directory: resolved, prefix: "" };
|
|
638567
638990
|
}
|
|
638568
638991
|
const directory = dirname61(resolved);
|
|
638569
|
-
const prefix =
|
|
638992
|
+
const prefix = basename43(partialPath);
|
|
638570
638993
|
return { directory, prefix };
|
|
638571
638994
|
}
|
|
638572
638995
|
async function scanDirectory(dirPath) {
|
|
@@ -657535,12 +657958,12 @@ import {
|
|
|
657535
657958
|
spawn as spawn14,
|
|
657536
657959
|
spawnSync as spawnSync10
|
|
657537
657960
|
} from "child_process";
|
|
657538
|
-
import { basename as
|
|
657961
|
+
import { basename as basename44 } from "path";
|
|
657539
657962
|
function isCommandAvailable3(command7) {
|
|
657540
657963
|
return !!whichSync(command7);
|
|
657541
657964
|
}
|
|
657542
657965
|
function classifyGuiEditor(editor) {
|
|
657543
|
-
const base2 =
|
|
657966
|
+
const base2 = basename44(editor.split(" ")[0] ?? "");
|
|
657544
657967
|
return GUI_EDITORS.find((g5) => base2.includes(g5));
|
|
657545
657968
|
}
|
|
657546
657969
|
function guiGotoArgv(guiFamily, filePath, line) {
|
|
@@ -657577,7 +658000,7 @@ function openFileInExternalEditor(filePath, line) {
|
|
|
657577
658000
|
const inkInstance = instances_default.get(process.stdout);
|
|
657578
658001
|
if (!inkInstance)
|
|
657579
658002
|
return false;
|
|
657580
|
-
const useGotoLine = line && PLUS_N_EDITORS.test(
|
|
658003
|
+
const useGotoLine = line && PLUS_N_EDITORS.test(basename44(base2));
|
|
657581
658004
|
inkInstance.enterAlternateScreen();
|
|
657582
658005
|
try {
|
|
657583
658006
|
const syncOpts = { stdio: "inherit" };
|
|
@@ -665172,7 +665595,7 @@ var clearSkillIndexCache = () => {};
|
|
|
665172
665595
|
var init_localSearch = () => {};
|
|
665173
665596
|
|
|
665174
665597
|
// src/services/mcp/useManageMCPConnections.ts
|
|
665175
|
-
import { basename as
|
|
665598
|
+
import { basename as basename45 } from "path";
|
|
665176
665599
|
function getErrorKey(error52) {
|
|
665177
665600
|
const plugin = "plugin" in error52 ? error52.plugin : "no-plugin";
|
|
665178
665601
|
return `${error52.type}:${error52.source}:${plugin}`;
|
|
@@ -665655,7 +666078,7 @@ function useManageMCPConnections(dynamicMcpConfig, isStrictMcpConfig = false) {
|
|
|
665655
666078
|
else if (serverConfig.scope === "claudeai")
|
|
665656
666079
|
counts.claudeai++;
|
|
665657
666080
|
if (process.env.USER_TYPE === "ant" && !isMcpServerDisabled(name3) && (serverConfig.type === undefined || serverConfig.type === "stdio") && "command" in serverConfig) {
|
|
665658
|
-
stdioCommands.push(
|
|
666081
|
+
stdioCommands.push(basename45(serverConfig.command));
|
|
665659
666082
|
}
|
|
665660
666083
|
}
|
|
665661
666084
|
logEvent2("tengu_mcp_servers", {
|
|
@@ -711951,7 +712374,7 @@ var init_advisor2 = __esm(() => {
|
|
|
711951
712374
|
// src/skills/bundledSkills.ts
|
|
711952
712375
|
import { constants as fsConstants7 } from "fs";
|
|
711953
712376
|
import { mkdir as mkdir49, open as open14 } from "fs/promises";
|
|
711954
|
-
import { dirname as dirname68, isAbsolute as
|
|
712377
|
+
import { dirname as dirname68, isAbsolute as isAbsolute31, join as join158, normalize as normalize16, sep as pathSep2 } from "path";
|
|
711955
712378
|
function registerBundledSkill(definition) {
|
|
711956
712379
|
const { files: files3 } = definition;
|
|
711957
712380
|
let skillRoot;
|
|
@@ -712040,7 +712463,7 @@ async function safeWriteFile(p4, content) {
|
|
|
712040
712463
|
}
|
|
712041
712464
|
function resolveSkillFilePath(baseDir, relPath) {
|
|
712042
712465
|
const normalized = normalize16(relPath);
|
|
712043
|
-
if (
|
|
712466
|
+
if (isAbsolute31(normalized) || normalized.split(pathSep2).includes("..") || normalized.split("/").includes("..")) {
|
|
712044
712467
|
throw new Error(`bundled skill file path escapes skill dir: ${relPath}`);
|
|
712045
712468
|
}
|
|
712046
712469
|
return join158(baseDir, normalized);
|
|
@@ -715518,12 +715941,12 @@ var init_remoteControlServer2 = __esm(() => {
|
|
|
715518
715941
|
});
|
|
715519
715942
|
|
|
715520
715943
|
// src/services/voiceKeyterms.ts
|
|
715521
|
-
import { basename as
|
|
715944
|
+
import { basename as basename48 } from "path";
|
|
715522
715945
|
function splitIdentifier(name3) {
|
|
715523
715946
|
return name3.replace(/([a-z])([A-Z])/g, "$1 $2").split(/[-_./\s]+/).map((w4) => w4.trim()).filter((w4) => w4.length > 2 && w4.length <= 20);
|
|
715524
715947
|
}
|
|
715525
715948
|
function fileNameWords(filePath) {
|
|
715526
|
-
const stem =
|
|
715949
|
+
const stem = basename48(filePath).replace(/\.[^.]+$/, "");
|
|
715527
715950
|
return splitIdentifier(stem);
|
|
715528
715951
|
}
|
|
715529
715952
|
async function getVoiceKeyterms(recentFiles) {
|
|
@@ -715531,7 +715954,7 @@ async function getVoiceKeyterms(recentFiles) {
|
|
|
715531
715954
|
try {
|
|
715532
715955
|
const projectRoot = getProjectRoot();
|
|
715533
715956
|
if (projectRoot) {
|
|
715534
|
-
const name3 =
|
|
715957
|
+
const name3 = basename48(projectRoot);
|
|
715535
715958
|
if (name3.length > 2 && name3.length <= 50) {
|
|
715536
715959
|
terms.add(name3);
|
|
715537
715960
|
}
|
|
@@ -717595,7 +718018,7 @@ import {
|
|
|
717595
718018
|
writeFile as writeFile54
|
|
717596
718019
|
} from "fs/promises";
|
|
717597
718020
|
import { tmpdir as tmpdir14 } from "os";
|
|
717598
|
-
import { extname as
|
|
718021
|
+
import { extname as extname18, join as join160 } from "path";
|
|
717599
718022
|
function getAnalysisModel() {
|
|
717600
718023
|
return getDefaultOpusModel();
|
|
717601
718024
|
}
|
|
@@ -717612,7 +718035,7 @@ function getSessionMetaDir() {
|
|
|
717612
718035
|
return join160(getDataDir(), "session-meta");
|
|
717613
718036
|
}
|
|
717614
718037
|
function getLanguageFromPath(filePath) {
|
|
717615
|
-
const ext =
|
|
718038
|
+
const ext = extname18(filePath).toLowerCase();
|
|
717616
718039
|
return EXTENSION_TO_LANGUAGE[ext] || null;
|
|
717617
718040
|
}
|
|
717618
718041
|
function extractToolStats(log3) {
|
|
@@ -720410,7 +720833,7 @@ import {
|
|
|
720410
720833
|
unlink as unlink26,
|
|
720411
720834
|
writeFile as writeFile55
|
|
720412
720835
|
} from "fs/promises";
|
|
720413
|
-
import { basename as
|
|
720836
|
+
import { basename as basename49, dirname as dirname72, join as join161 } from "path";
|
|
720414
720837
|
function resetTranscriptWriteWarnings() {
|
|
720415
720838
|
transcriptWriteFailureWarned = false;
|
|
720416
720839
|
sessionSavingOffWarned = false;
|
|
@@ -722961,7 +723384,7 @@ async function getSessionFilesWithMtime(projectDir) {
|
|
|
722961
723384
|
for (const dirent of dirents) {
|
|
722962
723385
|
if (!dirent.isFile() || !dirent.name.endsWith(".jsonl"))
|
|
722963
723386
|
continue;
|
|
722964
|
-
const sessionId = validateUuid2(
|
|
723387
|
+
const sessionId = validateUuid2(basename49(dirent.name, ".jsonl"));
|
|
722965
723388
|
if (!sessionId)
|
|
722966
723389
|
continue;
|
|
722967
723390
|
candidates.push({ sessionId, filePath: join161(projectDir, dirent.name) });
|
|
@@ -723470,7 +723893,7 @@ var init_teamMemPrompts = __esm(() => {
|
|
|
723470
723893
|
});
|
|
723471
723894
|
|
|
723472
723895
|
// src/memdir/memdir.ts
|
|
723473
|
-
import { basename as
|
|
723896
|
+
import { basename as basename50, join as join162, resolve as resolve58 } from "path";
|
|
723474
723897
|
function stripNonLoadedContent(raw) {
|
|
723475
723898
|
const withoutFrontmatter = raw.replace(FRONTMATTER_REGEX, "");
|
|
723476
723899
|
if (!withoutFrontmatter.includes("<!--")) {
|
|
@@ -723566,7 +723989,7 @@ function getMemoryIndexOverCapMessage(params) {
|
|
|
723566
723989
|
async function checkMemoryEntrypointOverCap(filePath) {
|
|
723567
723990
|
if (!isAutoMemoryEnabled())
|
|
723568
723991
|
return null;
|
|
723569
|
-
const isAutoMemIndex = resolve58(filePath) === resolve58(getAutoMemEntrypoint()) ||
|
|
723992
|
+
const isAutoMemIndex = resolve58(filePath) === resolve58(getAutoMemEntrypoint()) || basename50(filePath) === ENTRYPOINT_NAME && isAutoMemPath(filePath);
|
|
723570
723993
|
if (!isAutoMemIndex)
|
|
723571
723994
|
return null;
|
|
723572
723995
|
const fs25 = getFsImplementation();
|
|
@@ -726567,7 +726990,7 @@ __export(exports_hooks2, {
|
|
|
726567
726990
|
createBaseHookInput: () => createBaseHookInput,
|
|
726568
726991
|
PRE_TOOL_USE_HOOK_TIMEOUT_MESSAGE: () => PRE_TOOL_USE_HOOK_TIMEOUT_MESSAGE
|
|
726569
726992
|
});
|
|
726570
|
-
import { basename as
|
|
726993
|
+
import { basename as basename51 } from "path";
|
|
726571
726994
|
import { spawn as spawn15 } from "child_process";
|
|
726572
726995
|
import { randomUUID as randomUUID41 } from "crypto";
|
|
726573
726996
|
function isPerHookCallbackTimeout(abortSignalAborted, parentSignalAborted) {
|
|
@@ -727527,7 +727950,7 @@ async function getMatchingHooks(appState, sessionId, hookEvent, hookInput, tools
|
|
|
727527
727950
|
matchQuery = hookInput.load_reason;
|
|
727528
727951
|
break;
|
|
727529
727952
|
case "FileChanged":
|
|
727530
|
-
matchQuery =
|
|
727953
|
+
matchQuery = basename51(hookInput.file_path);
|
|
727531
727954
|
break;
|
|
727532
727955
|
case "UserPromptExpansion":
|
|
727533
727956
|
matchQuery = hookInput.command_name;
|
|
@@ -729877,7 +730300,7 @@ import {
|
|
|
729877
730300
|
utimes as utimes2
|
|
729878
730301
|
} from "fs/promises";
|
|
729879
730302
|
import { existsSync as existsSync26, readFileSync as readFileSync34, statSync as statSync20 } from "fs";
|
|
729880
|
-
import { basename as
|
|
730303
|
+
import { basename as basename52, dirname as dirname73, join as join166 } from "path";
|
|
729881
730304
|
function validateWorktreeSlug(slug) {
|
|
729882
730305
|
if (slug.length > MAX_WORKTREE_SLUG_LENGTH) {
|
|
729883
730306
|
throw new Error(`Invalid worktree name: must be ${MAX_WORKTREE_SLUG_LENGTH} characters or fewer (got ${slug.length})`);
|
|
@@ -729944,7 +730367,7 @@ function restoreWorktreeSession(session2) {
|
|
|
729944
730367
|
currentWorktreeSession = session2;
|
|
729945
730368
|
}
|
|
729946
730369
|
function generateTmuxSessionName(repoPath, branch2) {
|
|
729947
|
-
const repoName =
|
|
730370
|
+
const repoName = basename52(repoPath);
|
|
729948
730371
|
const combined = `${repoName}_${branch2}`;
|
|
729949
730372
|
return combined.replace(/[/.]/g, "_");
|
|
729950
730373
|
}
|
|
@@ -730527,7 +730950,7 @@ async function execIntoTmuxWorktree(args) {
|
|
|
730527
730950
|
error: `Error: ${errorMessage(error52)}`
|
|
730528
730951
|
};
|
|
730529
730952
|
}
|
|
730530
|
-
repoName =
|
|
730953
|
+
repoName = basename52(findCanonicalGitRoot(getCwd()) ?? getCwd());
|
|
730531
730954
|
console.log(`Using worktree via hook: ${worktreeDir}`);
|
|
730532
730955
|
} else {
|
|
730533
730956
|
const repoRoot = findCanonicalGitRoot(getCwd());
|
|
@@ -730537,7 +730960,7 @@ async function execIntoTmuxWorktree(args) {
|
|
|
730537
730960
|
error: "Error: --worktree requires a git repository"
|
|
730538
730961
|
};
|
|
730539
730962
|
}
|
|
730540
|
-
repoName =
|
|
730963
|
+
repoName = basename52(repoRoot);
|
|
730541
730964
|
worktreeDir = worktreePathFor(repoRoot, worktreeName);
|
|
730542
730965
|
try {
|
|
730543
730966
|
const result = await getOrCreateWorktree(repoRoot, worktreeName, prNumber !== null ? { prNumber } : undefined);
|
|
@@ -732834,7 +733257,7 @@ __export(exports_bridgeMain, {
|
|
|
732834
733257
|
});
|
|
732835
733258
|
import { randomUUID as randomUUID42 } from "crypto";
|
|
732836
733259
|
import { hostname as hostname4, tmpdir as tmpdir17 } from "os";
|
|
732837
|
-
import { basename as
|
|
733260
|
+
import { basename as basename53, join as join171, resolve as resolve59 } from "path";
|
|
732838
733261
|
async function isMultiSessionSpawnEnabled() {
|
|
732839
733262
|
return checkGate_CACHED_OR_BLOCKING("tengu_ccr_bridge_multi_session");
|
|
732840
733263
|
}
|
|
@@ -734171,7 +734594,7 @@ The session may still be resumable \u2014 try running the same command again.`);
|
|
|
734171
734594
|
const logger30 = createBridgeLogger({ verbose });
|
|
734172
734595
|
const { parseGitHubRepository: parseGitHubRepository2 } = await Promise.resolve().then(() => (init_detectRepository(), exports_detectRepository));
|
|
734173
734596
|
const ownerRepo = gitRepoUrl ? parseGitHubRepository2(gitRepoUrl) : null;
|
|
734174
|
-
const repoName = ownerRepo ? ownerRepo.split("/").pop() :
|
|
734597
|
+
const repoName = ownerRepo ? ownerRepo.split("/").pop() : basename53(dir);
|
|
734175
734598
|
logger30.setRepoInfo(repoName, branch2);
|
|
734176
734599
|
const toggleAvailable = spawnMode !== "single-session" && worktreeAvailable;
|
|
734177
734600
|
if (toggleAvailable) {
|
|
@@ -743463,7 +743886,7 @@ __export(exports_inboundAttachments, {
|
|
|
743463
743886
|
});
|
|
743464
743887
|
import { randomUUID as randomUUID47 } from "crypto";
|
|
743465
743888
|
import { mkdir as mkdir58, writeFile as writeFile58 } from "fs/promises";
|
|
743466
|
-
import { basename as
|
|
743889
|
+
import { basename as basename54, join as join174 } from "path";
|
|
743467
743890
|
function debug9(msg) {
|
|
743468
743891
|
logForDebugging(`[bridge:inbound-attach] ${msg}`);
|
|
743469
743892
|
}
|
|
@@ -743475,7 +743898,7 @@ function extractInboundAttachments(msg) {
|
|
|
743475
743898
|
return parsed.success ? parsed.data : [];
|
|
743476
743899
|
}
|
|
743477
743900
|
function sanitizeFileName(name3) {
|
|
743478
|
-
const base2 =
|
|
743901
|
+
const base2 = basename54(name3).replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
743479
743902
|
return base2 || "attachment";
|
|
743480
743903
|
}
|
|
743481
743904
|
function uploadsDir() {
|
|
@@ -750178,7 +750601,7 @@ var init_FileEditToolDiff = __esm(() => {
|
|
|
750178
750601
|
|
|
750179
750602
|
// src/hooks/useDiffInIDE.ts
|
|
750180
750603
|
import { randomUUID as randomUUID49 } from "crypto";
|
|
750181
|
-
import { basename as
|
|
750604
|
+
import { basename as basename56 } from "path";
|
|
750182
750605
|
function useDiffInIDE({
|
|
750183
750606
|
onChange,
|
|
750184
750607
|
toolUseContext,
|
|
@@ -750189,7 +750612,7 @@ function useDiffInIDE({
|
|
|
750189
750612
|
const isUnmounted = import_react209.useRef(false);
|
|
750190
750613
|
const [hasError, setHasError] = import_react209.useState(false);
|
|
750191
750614
|
const sha = import_react209.useMemo(() => randomUUID49().slice(0, 6), []);
|
|
750192
|
-
const tabName = import_react209.useMemo(() => `\u273B [Claude Code] ${
|
|
750615
|
+
const tabName = import_react209.useMemo(() => `\u273B [Claude Code] ${basename56(filePath)} (${sha}) \u29C9`, [filePath, sha]);
|
|
750193
750616
|
const shouldShowDiffInIDE = hasAccessToIDEExtensionDiffFeature(toolUseContext.options.mcpClients) && getGlobalConfig().diffTool === "auto" && !filePath.endsWith(".ipynb");
|
|
750194
750617
|
const ideName = getConnectedIdeName(toolUseContext.options.mcpClients) ?? "IDE";
|
|
750195
750618
|
async function showDiff() {
|
|
@@ -750371,7 +750794,7 @@ var init_useDiffInIDE = __esm(() => {
|
|
|
750371
750794
|
});
|
|
750372
750795
|
|
|
750373
750796
|
// src/components/ShowInIDEPrompt.tsx
|
|
750374
|
-
import { basename as
|
|
750797
|
+
import { basename as basename57, relative as relative32 } from "path";
|
|
750375
750798
|
function ShowInIDEPrompt(t0) {
|
|
750376
750799
|
const $4 = import_compiler_runtime272.c(36);
|
|
750377
750800
|
const {
|
|
@@ -750428,7 +750851,7 @@ function ShowInIDEPrompt(t0) {
|
|
|
750428
750851
|
}
|
|
750429
750852
|
let t4;
|
|
750430
750853
|
if ($4[5] !== filePath) {
|
|
750431
|
-
t4 =
|
|
750854
|
+
t4 = basename57(filePath);
|
|
750432
750855
|
$4[5] = filePath;
|
|
750433
750856
|
$4[6] = t4;
|
|
750434
750857
|
} else {
|
|
@@ -750589,7 +751012,7 @@ var init_ShowInIDEPrompt = __esm(() => {
|
|
|
750589
751012
|
|
|
750590
751013
|
// src/components/permissions/FilePermissionDialog/permissionOptions.tsx
|
|
750591
751014
|
import { homedir as homedir46 } from "os";
|
|
750592
|
-
import { basename as
|
|
751015
|
+
import { basename as basename58, join as join175, sep as sep47 } from "path";
|
|
750593
751016
|
function isInClaudeFolder(filePath) {
|
|
750594
751017
|
const absolutePath = expandPath(filePath);
|
|
750595
751018
|
const claudeFolderPath = expandPath(`${getOriginalCwd()}/.claude`);
|
|
@@ -750671,7 +751094,7 @@ function getFilePermissionOptions({
|
|
|
750671
751094
|
}
|
|
750672
751095
|
} else {
|
|
750673
751096
|
const dirPath = getDirectoryForPath(filePath);
|
|
750674
|
-
const dirName =
|
|
751097
|
+
const dirName = basename58(dirPath) || "this directory";
|
|
750675
751098
|
if (operationType === "read") {
|
|
750676
751099
|
sessionLabel = /* @__PURE__ */ jsx_runtime379.jsxs(ThemedText, {
|
|
750677
751100
|
children: [
|
|
@@ -751170,7 +751593,7 @@ var init_FilePermissionDialog = __esm(() => {
|
|
|
751170
751593
|
});
|
|
751171
751594
|
|
|
751172
751595
|
// src/components/permissions/SedEditPermissionRequest/SedEditPermissionRequest.tsx
|
|
751173
|
-
import { basename as
|
|
751596
|
+
import { basename as basename59, relative as relative34 } from "path";
|
|
751174
751597
|
function SedEditPermissionRequest(t0) {
|
|
751175
751598
|
const $4 = import_compiler_runtime273.c(9);
|
|
751176
751599
|
let props;
|
|
@@ -751346,7 +751769,7 @@ function SedEditPermissionRequestInner(t0) {
|
|
|
751346
751769
|
}
|
|
751347
751770
|
let t10;
|
|
751348
751771
|
if ($4[16] !== filePath) {
|
|
751349
|
-
t10 =
|
|
751772
|
+
t10 = basename59(filePath);
|
|
751350
751773
|
$4[16] = filePath;
|
|
751351
751774
|
$4[17] = t10;
|
|
751352
751775
|
} else {
|
|
@@ -751558,7 +751981,7 @@ var init_useShellPermissionFeedback = __esm(() => {
|
|
|
751558
751981
|
});
|
|
751559
751982
|
|
|
751560
751983
|
// src/components/permissions/shellPermissionHelpers.tsx
|
|
751561
|
-
import { basename as
|
|
751984
|
+
import { basename as basename60, sep as sep48 } from "path";
|
|
751562
751985
|
function commandListDisplay(commands7) {
|
|
751563
751986
|
switch (commands7.length) {
|
|
751564
751987
|
case 0:
|
|
@@ -751609,7 +752032,7 @@ function commandListDisplayTruncated(commands7) {
|
|
|
751609
752032
|
function formatPathList(paths2) {
|
|
751610
752033
|
if (paths2.length === 0)
|
|
751611
752034
|
return "";
|
|
751612
|
-
const names = paths2.map((p4) =>
|
|
752035
|
+
const names = paths2.map((p4) => basename60(p4) || p4);
|
|
751613
752036
|
if (names.length === 1) {
|
|
751614
752037
|
return /* @__PURE__ */ jsx_runtime382.jsxs(ThemedText, {
|
|
751615
752038
|
children: [
|
|
@@ -751675,7 +752098,7 @@ function generateShellSuggestionsLabel(suggestions, shellToolName, commandTransf
|
|
|
751675
752098
|
if (hasReadPaths && !hasDirectories && !hasCommands) {
|
|
751676
752099
|
if (readPaths.length === 1) {
|
|
751677
752100
|
const firstPath = readPaths[0];
|
|
751678
|
-
const dirName =
|
|
752101
|
+
const dirName = basename60(firstPath) || firstPath;
|
|
751679
752102
|
return /* @__PURE__ */ jsx_runtime382.jsxs(ThemedText, {
|
|
751680
752103
|
children: [
|
|
751681
752104
|
"Yes, allow reading from ",
|
|
@@ -751699,7 +752122,7 @@ function generateShellSuggestionsLabel(suggestions, shellToolName, commandTransf
|
|
|
751699
752122
|
if (hasDirectories && !hasReadPaths && !hasCommands) {
|
|
751700
752123
|
if (directories.length === 1) {
|
|
751701
752124
|
const firstDir = directories[0];
|
|
751702
|
-
const dirName =
|
|
752125
|
+
const dirName = basename60(firstDir) || firstDir;
|
|
751703
752126
|
return /* @__PURE__ */ jsx_runtime382.jsxs(ThemedText, {
|
|
751704
752127
|
children: [
|
|
751705
752128
|
"Yes, and always allow access to ",
|
|
@@ -754123,7 +754546,7 @@ function createSingleEditDiffConfig(filePath, oldString, newString, replaceAll2)
|
|
|
754123
754546
|
}
|
|
754124
754547
|
|
|
754125
754548
|
// src/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.tsx
|
|
754126
|
-
import { basename as
|
|
754549
|
+
import { basename as basename61, relative as relative35 } from "path";
|
|
754127
754550
|
function FileEditPermissionRequest(props) {
|
|
754128
754551
|
const $4 = import_compiler_runtime278.c(51);
|
|
754129
754552
|
const parseInput = _temp176;
|
|
@@ -754166,7 +754589,7 @@ function FileEditPermissionRequest(props) {
|
|
|
754166
754589
|
t32 = " ";
|
|
754167
754590
|
T0 = ThemedText;
|
|
754168
754591
|
t0 = true;
|
|
754169
|
-
t1 =
|
|
754592
|
+
t1 = basename61(file_path);
|
|
754170
754593
|
$4[0] = props.onDone;
|
|
754171
754594
|
$4[1] = props.onReject;
|
|
754172
754595
|
$4[2] = props.toolUseConfirm;
|
|
@@ -754593,7 +755016,7 @@ var init_FileWriteToolDiff = __esm(() => {
|
|
|
754593
755016
|
});
|
|
754594
755017
|
|
|
754595
755018
|
// src/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.tsx
|
|
754596
|
-
import { basename as
|
|
755019
|
+
import { basename as basename62, relative as relative36 } from "path";
|
|
754597
755020
|
function FileWritePermissionRequest(props) {
|
|
754598
755021
|
const $4 = import_compiler_runtime281.c(30);
|
|
754599
755022
|
const parseInput = _temp179;
|
|
@@ -754660,7 +755083,7 @@ function FileWritePermissionRequest(props) {
|
|
|
754660
755083
|
}
|
|
754661
755084
|
let t9;
|
|
754662
755085
|
if ($4[7] !== file_path) {
|
|
754663
|
-
t9 =
|
|
755086
|
+
t9 = basename62(file_path);
|
|
754664
755087
|
$4[7] = file_path;
|
|
754665
755088
|
$4[8] = t9;
|
|
754666
755089
|
} else {
|
|
@@ -755065,7 +755488,7 @@ var init_NotebookEditToolDiff = __esm(() => {
|
|
|
755065
755488
|
});
|
|
755066
755489
|
|
|
755067
755490
|
// src/components/permissions/NotebookEditPermissionRequest/NotebookEditPermissionRequest.tsx
|
|
755068
|
-
import { basename as
|
|
755491
|
+
import { basename as basename63 } from "path";
|
|
755069
755492
|
function NotebookEditPermissionRequest(props) {
|
|
755070
755493
|
const $4 = import_compiler_runtime283.c(52);
|
|
755071
755494
|
const parseInput = _temp181;
|
|
@@ -755109,7 +755532,7 @@ function NotebookEditPermissionRequest(props) {
|
|
|
755109
755532
|
t4 = " ";
|
|
755110
755533
|
T0 = ThemedText;
|
|
755111
755534
|
t0 = true;
|
|
755112
|
-
t1 =
|
|
755535
|
+
t1 = basename63(notebook_path);
|
|
755113
755536
|
$4[0] = props.onDone;
|
|
755114
755537
|
$4[1] = props.onReject;
|
|
755115
755538
|
$4[2] = props.toolUseConfirm;
|
|
@@ -760660,7 +761083,7 @@ var init_AutoUpdaterWrapper = __esm(() => {
|
|
|
760660
761083
|
});
|
|
760661
761084
|
|
|
760662
761085
|
// src/components/IdeStatusIndicator.tsx
|
|
760663
|
-
import { basename as
|
|
761086
|
+
import { basename as basename64 } from "path";
|
|
760664
761087
|
function IdeStatusIndicator(t0) {
|
|
760665
761088
|
const $4 = import_compiler_runtime293.c(7);
|
|
760666
761089
|
const {
|
|
@@ -760700,7 +761123,7 @@ function IdeStatusIndicator(t0) {
|
|
|
760700
761123
|
if (ideSelection.filePath) {
|
|
760701
761124
|
let t1;
|
|
760702
761125
|
if ($4[3] !== ideSelection.filePath) {
|
|
760703
|
-
t1 =
|
|
761126
|
+
t1 = basename64(ideSelection.filePath);
|
|
760704
761127
|
$4[3] = ideSelection.filePath;
|
|
760705
761128
|
$4[4] = t1;
|
|
760706
761129
|
} else {
|
|
@@ -764109,7 +764532,7 @@ var init_slackChannelSuggestions = __esm(() => {
|
|
|
764109
764532
|
});
|
|
764110
764533
|
|
|
764111
764534
|
// src/hooks/unifiedSuggestions.ts
|
|
764112
|
-
import { basename as
|
|
764535
|
+
import { basename as basename65 } from "path";
|
|
764113
764536
|
function createSuggestionFromSource(source2) {
|
|
764114
764537
|
switch (source2.type) {
|
|
764115
764538
|
case "file":
|
|
@@ -764171,7 +764594,7 @@ async function generateUnifiedSuggestions(query2, mcpResources, agents2, showOnE
|
|
|
764171
764594
|
displayText: suggestion.displayText,
|
|
764172
764595
|
description: suggestion.description,
|
|
764173
764596
|
path: suggestion.displayText,
|
|
764174
|
-
filename:
|
|
764597
|
+
filename: basename65(suggestion.displayText),
|
|
764175
764598
|
score: suggestion.metadata?.score
|
|
764176
764599
|
}));
|
|
764177
764600
|
const mcpSources = Object.values(mcpResources).flat().map((resource) => ({
|
|
@@ -765438,9 +765861,15 @@ var init_keyword = __esm(() => {
|
|
|
765438
765861
|
// src/components/AutoModeOptInDialog.tsx
|
|
765439
765862
|
var exports_AutoModeOptInDialog = {};
|
|
765440
765863
|
__export(exports_AutoModeOptInDialog, {
|
|
765864
|
+
getAutoModeDescription: () => getAutoModeDescription,
|
|
765441
765865
|
AutoModeOptInDialog: () => AutoModeOptInDialog,
|
|
765866
|
+
AUTO_MODE_DESCRIPTION_WITHOUT_COST_SENTENCE: () => AUTO_MODE_DESCRIPTION_WITHOUT_COST_SENTENCE,
|
|
765442
765867
|
AUTO_MODE_DESCRIPTION: () => AUTO_MODE_DESCRIPTION
|
|
765443
765868
|
});
|
|
765869
|
+
function getAutoModeDescription() {
|
|
765870
|
+
const subscriptionType = getSubscriptionType();
|
|
765871
|
+
return subscriptionType === "pro" || subscriptionType === "max" || subscriptionType === "team" ? AUTO_MODE_DESCRIPTION_WITHOUT_COST_SENTENCE : AUTO_MODE_DESCRIPTION;
|
|
765872
|
+
}
|
|
765444
765873
|
function AutoModeOptInDialog(t0) {
|
|
765445
765874
|
const $4 = import_compiler_runtime298.c(18);
|
|
765446
765875
|
const {
|
|
@@ -765459,45 +765888,44 @@ function AutoModeOptInDialog(t0) {
|
|
|
765459
765888
|
let t22;
|
|
765460
765889
|
if ($4[1] !== onAccept || $4[2] !== onDecline) {
|
|
765461
765890
|
t22 = function onChange2(value) {
|
|
765462
|
-
|
|
765463
|
-
|
|
765464
|
-
|
|
765465
|
-
|
|
765466
|
-
|
|
765467
|
-
|
|
765468
|
-
|
|
765469
|
-
|
|
765470
|
-
|
|
765471
|
-
|
|
765472
|
-
|
|
765473
|
-
|
|
765474
|
-
|
|
765891
|
+
switch (value) {
|
|
765892
|
+
case "accept": {
|
|
765893
|
+
logEvent2("tengu_auto_mode_opt_in_dialog_accept", {});
|
|
765894
|
+
updateSettingsForSource("userSettings", {
|
|
765895
|
+
skipAutoPermissionPrompt: true,
|
|
765896
|
+
autoModeOptInDismissed: hasAutoModeOptInDismissed() ? false : undefined
|
|
765897
|
+
});
|
|
765898
|
+
onAccept();
|
|
765899
|
+
break;
|
|
765900
|
+
}
|
|
765901
|
+
case "accept-default": {
|
|
765902
|
+
logEvent2("tengu_auto_mode_opt_in_dialog_accept_default", {});
|
|
765903
|
+
updateSettingsForSource("userSettings", {
|
|
765904
|
+
skipAutoPermissionPrompt: true,
|
|
765905
|
+
permissions: {
|
|
765906
|
+
defaultMode: "auto"
|
|
765907
|
+
},
|
|
765908
|
+
autoModeOptInDismissed: hasAutoModeOptInDismissed() ? false : undefined
|
|
765909
|
+
});
|
|
765910
|
+
onAccept();
|
|
765911
|
+
break;
|
|
765912
|
+
}
|
|
765913
|
+
case "decline": {
|
|
765914
|
+
logEvent2("tengu_auto_mode_opt_in_dialog_decline", {});
|
|
765915
|
+
onDecline("go-back");
|
|
765916
|
+
break;
|
|
765917
|
+
}
|
|
765918
|
+
case "decline-dont-ask": {
|
|
765919
|
+
logEvent2("tengu_auto_mode_opt_in_dialog_decline_dont_ask", {});
|
|
765920
|
+
if (!hasAutoModeOptInDismissed()) {
|
|
765475
765921
|
updateSettingsForSource("userSettings", {
|
|
765476
|
-
|
|
765477
|
-
permissions: {
|
|
765478
|
-
defaultMode: "auto"
|
|
765479
|
-
},
|
|
765480
|
-
autoModeOptInDismissed: hasAutoModeOptInDismissed() ? false : undefined
|
|
765922
|
+
autoModeOptInDismissed: true
|
|
765481
765923
|
});
|
|
765482
|
-
onAccept();
|
|
765483
|
-
break bb3;
|
|
765484
|
-
}
|
|
765485
|
-
case "decline": {
|
|
765486
|
-
logEvent2("tengu_auto_mode_opt_in_dialog_decline", {});
|
|
765487
|
-
onDecline("go-back");
|
|
765488
|
-
break bb3;
|
|
765489
|
-
}
|
|
765490
|
-
case "decline-dont-ask": {
|
|
765491
|
-
logEvent2("tengu_auto_mode_opt_in_dialog_decline_dont_ask", {});
|
|
765492
|
-
if (!hasAutoModeOptInDismissed()) {
|
|
765493
|
-
updateSettingsForSource("userSettings", {
|
|
765494
|
-
autoModeOptInDismissed: true
|
|
765495
|
-
});
|
|
765496
|
-
}
|
|
765497
|
-
onDecline("dont-ask");
|
|
765498
|
-
break bb3;
|
|
765499
765924
|
}
|
|
765925
|
+
onDecline("dont-ask");
|
|
765926
|
+
break;
|
|
765500
765927
|
}
|
|
765928
|
+
}
|
|
765501
765929
|
};
|
|
765502
765930
|
$4[1] = onAccept;
|
|
765503
765931
|
$4[2] = onDecline;
|
|
@@ -765513,7 +765941,7 @@ function AutoModeOptInDialog(t0) {
|
|
|
765513
765941
|
gap: 1,
|
|
765514
765942
|
children: [
|
|
765515
765943
|
/* @__PURE__ */ jsx_runtime417.jsx(ThemedText, {
|
|
765516
|
-
children:
|
|
765944
|
+
children: getAutoModeDescription()
|
|
765517
765945
|
}),
|
|
765518
765946
|
/* @__PURE__ */ jsx_runtime417.jsx(Link, {
|
|
765519
765947
|
url: "https://code.claude.com/docs/en/security"
|
|
@@ -765603,9 +766031,10 @@ function AutoModeOptInDialog(t0) {
|
|
|
765603
766031
|
function _temp189() {
|
|
765604
766032
|
logEvent2("tengu_auto_mode_opt_in_dialog_shown", {});
|
|
765605
766033
|
}
|
|
765606
|
-
var import_compiler_runtime298, import_react241, jsx_runtime417,
|
|
766034
|
+
var import_compiler_runtime298, import_react241, jsx_runtime417, AUTO_MODE_BASE_DESCRIPTION = "Auto mode lets Claude handle permission prompts automatically \u2014 Claude checks each tool call for risky actions and prompt injection before executing. Actions Claude identifies as safe are executed, while actions Claude identifies as risky are blocked and Claude may try a different approach. Ideal for long-running tasks.", AUTO_MODE_COST_SENTENCE = "Sessions are slightly more expensive.", AUTO_MODE_SAFETY_SENTENCE = "Claude can make mistakes that allow harmful commands to run, it's recommended to only use in isolated environments. Shift+Tab to change mode.", AUTO_MODE_DESCRIPTION, AUTO_MODE_DESCRIPTION_WITHOUT_COST_SENTENCE;
|
|
765607
766035
|
var init_AutoModeOptInDialog = __esm(() => {
|
|
765608
766036
|
init_analytics();
|
|
766037
|
+
init_auth6();
|
|
765609
766038
|
init_ink2();
|
|
765610
766039
|
init_settings2();
|
|
765611
766040
|
init_CustomSelect();
|
|
@@ -765613,10 +766042,12 @@ var init_AutoModeOptInDialog = __esm(() => {
|
|
|
765613
766042
|
import_compiler_runtime298 = __toESM(require_compiler_runtime(), 1);
|
|
765614
766043
|
import_react241 = __toESM(require_react(), 1);
|
|
765615
766044
|
jsx_runtime417 = __toESM(require_jsx_runtime(), 1);
|
|
766045
|
+
AUTO_MODE_DESCRIPTION = `${AUTO_MODE_BASE_DESCRIPTION} ${AUTO_MODE_COST_SENTENCE} ${AUTO_MODE_SAFETY_SENTENCE}`;
|
|
766046
|
+
AUTO_MODE_DESCRIPTION_WITHOUT_COST_SENTENCE = `${AUTO_MODE_BASE_DESCRIPTION} ${AUTO_MODE_SAFETY_SENTENCE}`;
|
|
765616
766047
|
});
|
|
765617
766048
|
|
|
765618
766049
|
// src/components/BridgeDialog.tsx
|
|
765619
|
-
import { basename as
|
|
766050
|
+
import { basename as basename66 } from "path";
|
|
765620
766051
|
function BridgeDialog(t0) {
|
|
765621
766052
|
const $4 = import_compiler_runtime299.c(87);
|
|
765622
766053
|
const {
|
|
@@ -765639,7 +766070,7 @@ function BridgeDialog(t0) {
|
|
|
765639
766070
|
const [branchName, setBranchName] = import_react242.useState("");
|
|
765640
766071
|
let t1;
|
|
765641
766072
|
if ($4[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
765642
|
-
t1 =
|
|
766073
|
+
t1 = basename66(getOriginalCwd());
|
|
765643
766074
|
$4[0] = t1;
|
|
765644
766075
|
} else {
|
|
765645
766076
|
t1 = $4[0];
|
|
@@ -779114,7 +779545,7 @@ var require_polyfill = __commonJS((exports, module) => {
|
|
|
779114
779545
|
} = __require("fs/promises");
|
|
779115
779546
|
var {
|
|
779116
779547
|
dirname: dirname77,
|
|
779117
|
-
isAbsolute:
|
|
779548
|
+
isAbsolute: isAbsolute32,
|
|
779118
779549
|
join: join176,
|
|
779119
779550
|
parse: parse16,
|
|
779120
779551
|
resolve: resolve61,
|
|
@@ -779372,7 +779803,7 @@ var require_polyfill = __commonJS((exports, module) => {
|
|
|
779372
779803
|
}
|
|
779373
779804
|
async function onLink(destStat, src, dest) {
|
|
779374
779805
|
let resolvedSrc = await readlink4(src);
|
|
779375
|
-
if (!
|
|
779806
|
+
if (!isAbsolute32(resolvedSrc)) {
|
|
779376
779807
|
resolvedSrc = resolve61(dirname77(src), resolvedSrc);
|
|
779377
779808
|
}
|
|
779378
779809
|
if (!destStat) {
|
|
@@ -779387,7 +779818,7 @@ var require_polyfill = __commonJS((exports, module) => {
|
|
|
779387
779818
|
}
|
|
779388
779819
|
throw err2;
|
|
779389
779820
|
}
|
|
779390
|
-
if (!
|
|
779821
|
+
if (!isAbsolute32(resolvedDest)) {
|
|
779391
779822
|
resolvedDest = resolve61(dirname77(dest), resolvedDest);
|
|
779392
779823
|
}
|
|
779393
779824
|
if (isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
@@ -779483,7 +779914,7 @@ var require_readdir_scoped = __commonJS((exports, module) => {
|
|
|
779483
779914
|
|
|
779484
779915
|
// node_modules/.bun/@npmcli+fs@5.0.0/node_modules/@npmcli/fs/lib/move-file.js
|
|
779485
779916
|
var require_move_file = __commonJS((exports, module) => {
|
|
779486
|
-
var { dirname: dirname77, join: join176, resolve: resolve61, relative: relative39, isAbsolute:
|
|
779917
|
+
var { dirname: dirname77, join: join176, resolve: resolve61, relative: relative39, isAbsolute: isAbsolute32 } = __require("path");
|
|
779487
779918
|
var fs25 = __require("fs/promises");
|
|
779488
779919
|
var pathExists2 = async (path42) => {
|
|
779489
779920
|
try {
|
|
@@ -779525,7 +779956,7 @@ var require_move_file = __commonJS((exports, module) => {
|
|
|
779525
779956
|
if (root3) {
|
|
779526
779957
|
await Promise.all(symlinks.map(async ({ source: symSource, destination: symDestination }) => {
|
|
779527
779958
|
let target = await fs25.readlink(symSource);
|
|
779528
|
-
if (
|
|
779959
|
+
if (isAbsolute32(target)) {
|
|
779529
779960
|
target = resolve61(symDestination, relative39(symSource, target));
|
|
779530
779961
|
}
|
|
779531
779962
|
let targetStat = "file";
|
|
@@ -789570,7 +790001,7 @@ __export(exports_asciicast, {
|
|
|
789570
790001
|
_resetRecordingStateForTesting: () => _resetRecordingStateForTesting
|
|
789571
790002
|
});
|
|
789572
790003
|
import { appendFile as appendFile8, rename as rename11 } from "fs/promises";
|
|
789573
|
-
import { basename as
|
|
790004
|
+
import { basename as basename67, dirname as dirname78, join as join179 } from "path";
|
|
789574
790005
|
function getRecordFilePath() {
|
|
789575
790006
|
if (recordingState.filePath !== null) {
|
|
789576
790007
|
return recordingState.filePath;
|
|
@@ -789616,8 +790047,8 @@ async function renameRecordingForSession() {
|
|
|
789616
790047
|
return;
|
|
789617
790048
|
}
|
|
789618
790049
|
await recorder?.flush();
|
|
789619
|
-
const oldName =
|
|
789620
|
-
const newName =
|
|
790050
|
+
const oldName = basename67(oldPath);
|
|
790051
|
+
const newName = basename67(newPath);
|
|
789621
790052
|
try {
|
|
789622
790053
|
await rename11(oldPath, newPath);
|
|
789623
790054
|
recordingState.filePath = newPath;
|
|
@@ -795441,7 +795872,7 @@ var init_binaryCheck = __esm(() => {
|
|
|
795441
795872
|
});
|
|
795442
795873
|
|
|
795443
795874
|
// src/utils/plugins/lspRecommendation.ts
|
|
795444
|
-
import { extname as
|
|
795875
|
+
import { extname as extname19 } from "path";
|
|
795445
795876
|
function isOfficialMarketplace(name3) {
|
|
795446
795877
|
return ALLOWED_OFFICIAL_MARKETPLACE_NAMES.has(name3.toLowerCase());
|
|
795447
795878
|
}
|
|
@@ -795531,7 +795962,7 @@ async function getMatchingLspPlugins(filePath) {
|
|
|
795531
795962
|
logForDebugging("[lspRecommendation] Recommendations are disabled");
|
|
795532
795963
|
return [];
|
|
795533
795964
|
}
|
|
795534
|
-
const ext =
|
|
795965
|
+
const ext = extname19(filePath).toLowerCase();
|
|
795535
795966
|
if (!ext) {
|
|
795536
795967
|
logForDebugging("[lspRecommendation] No file extension found");
|
|
795537
795968
|
return [];
|
|
@@ -795724,7 +796155,7 @@ var init_usePluginRecommendationBase = __esm(() => {
|
|
|
795724
796155
|
});
|
|
795725
796156
|
|
|
795726
796157
|
// src/hooks/useLspPluginRecommendation.tsx
|
|
795727
|
-
import { extname as
|
|
796158
|
+
import { extname as extname20, join as join181 } from "path";
|
|
795728
796159
|
function useLspPluginRecommendation() {
|
|
795729
796160
|
const $4 = import_compiler_runtime332.c(12);
|
|
795730
796161
|
const trackedFiles = useAppState(_temp254);
|
|
@@ -795770,7 +796201,7 @@ function useLspPluginRecommendation() {
|
|
|
795770
796201
|
pluginId: match.pluginId,
|
|
795771
796202
|
pluginName: match.pluginName,
|
|
795772
796203
|
pluginDescription: match.description,
|
|
795773
|
-
fileExtension:
|
|
796204
|
+
fileExtension: extname20(filePath),
|
|
795774
796205
|
shownAt: Date.now()
|
|
795775
796206
|
};
|
|
795776
796207
|
}
|
|
@@ -796513,7 +796944,7 @@ var init_usePluginAutoupdateNotification = __esm(() => {
|
|
|
796513
796944
|
});
|
|
796514
796945
|
|
|
796515
796946
|
// src/utils/plugins/reconciler.ts
|
|
796516
|
-
import { isAbsolute as
|
|
796947
|
+
import { isAbsolute as isAbsolute32, resolve as resolve62 } from "path";
|
|
796517
796948
|
function diffMarketplaces(declared, materialized, opts) {
|
|
796518
796949
|
const missing = [];
|
|
796519
796950
|
const sourceChanged = [];
|
|
@@ -796621,7 +797052,7 @@ async function reconcileMarketplaces(opts) {
|
|
|
796621
797052
|
return { installed, updated, failed, upToDate: diff2.upToDate, skipped };
|
|
796622
797053
|
}
|
|
796623
797054
|
function normalizeSource(source2, projectRoot) {
|
|
796624
|
-
if ((source2.source === "directory" || source2.source === "file") && !
|
|
797055
|
+
if ((source2.source === "directory" || source2.source === "file") && !isAbsolute32(source2.path)) {
|
|
796625
797056
|
const base2 = projectRoot ?? getOriginalCwd();
|
|
796626
797057
|
const canonicalRoot = findCanonicalGitRoot(base2);
|
|
796627
797058
|
return {
|
|
@@ -801331,7 +801762,7 @@ function REPL({
|
|
|
801331
801762
|
autoPermissionsNotificationCount: prevCount + 1
|
|
801332
801763
|
};
|
|
801333
801764
|
});
|
|
801334
|
-
setMessages2((prev) => [...prev, createSystemMessage(
|
|
801765
|
+
setMessages2((prev) => [...prev, createSystemMessage(getAutoModeDescription(), "warning")]);
|
|
801335
801766
|
}, 800, safeYoloMessageShownRef, setMessages);
|
|
801336
801767
|
return () => clearTimeout(timer2);
|
|
801337
801768
|
}
|
|
@@ -804311,7 +804742,7 @@ var init_REPL = __esm(() => {
|
|
|
804311
804742
|
HISTORY_STUB = {
|
|
804312
804743
|
maybeLoadOlder: (_4) => {}
|
|
804313
804744
|
};
|
|
804314
|
-
TITLE_ANIMATION_FRAMES = ["\
|
|
804745
|
+
TITLE_ANIMATION_FRAMES = ["\u25D0", "\u25D1"];
|
|
804315
804746
|
});
|
|
804316
804747
|
|
|
804317
804748
|
// src/replLauncher.tsx
|
|
@@ -814002,7 +814433,7 @@ var init_parseConnectUrl = () => {};
|
|
|
814002
814433
|
|
|
814003
814434
|
// src/utils/deepLink/terminalLauncher.ts
|
|
814004
814435
|
import { spawn as spawn19 } from "child_process";
|
|
814005
|
-
import { basename as
|
|
814436
|
+
import { basename as basename68 } from "path";
|
|
814006
814437
|
async function detectMacosTerminal() {
|
|
814007
814438
|
const stored = getGlobalConfig().deepLinkTerminal;
|
|
814008
814439
|
if (stored) {
|
|
@@ -814038,7 +814469,7 @@ async function detectLinuxTerminal() {
|
|
|
814038
814469
|
if (termEnv) {
|
|
814039
814470
|
const resolved = await which(termEnv);
|
|
814040
814471
|
if (resolved) {
|
|
814041
|
-
return { name:
|
|
814472
|
+
return { name: basename68(termEnv), command: resolved };
|
|
814042
814473
|
}
|
|
814043
814474
|
}
|
|
814044
814475
|
const xte = await which("x-terminal-emulator");
|
|
@@ -821481,7 +821912,7 @@ __export(exports_plugins, {
|
|
|
821481
821912
|
VALID_UPDATE_SCOPES: () => VALID_UPDATE_SCOPES,
|
|
821482
821913
|
VALID_INSTALLABLE_SCOPES: () => VALID_INSTALLABLE_SCOPES
|
|
821483
821914
|
});
|
|
821484
|
-
import { basename as
|
|
821915
|
+
import { basename as basename69, dirname as dirname85 } from "path";
|
|
821485
821916
|
function handleMarketplaceError(error52, action2) {
|
|
821486
821917
|
logError2(error52);
|
|
821487
821918
|
cliError(`${figures_default.cross} Failed to ${action2}: ${errorMessage(error52)}`);
|
|
@@ -821515,7 +821946,7 @@ async function pluginValidateHandler(manifestPath, options) {
|
|
|
821515
821946
|
let contentResults = [];
|
|
821516
821947
|
if (result.fileType === "plugin") {
|
|
821517
821948
|
const manifestDir = dirname85(result.filePath);
|
|
821518
|
-
if (
|
|
821949
|
+
if (basename69(manifestDir) === ".claude-plugin") {
|
|
821519
821950
|
contentResults = await validatePluginContents(dirname85(manifestDir));
|
|
821520
821951
|
for (const r4 of contentResults) {
|
|
821521
821952
|
console.log(`Validating ${r4.fileType}: ${r4.filePath}
|
|
@@ -823009,6 +823440,7 @@ async function autoModeCritiqueHandler(options) {
|
|
|
823009
823440
|
model,
|
|
823010
823441
|
system: CRITIQUE_SYSTEM_PROMPT,
|
|
823011
823442
|
skipSystemPromptPrefix: true,
|
|
823443
|
+
forceAttributionHeader: true,
|
|
823012
823444
|
max_tokens: 4096,
|
|
823013
823445
|
messages: [
|
|
823014
823446
|
{
|