@cnwenf/occ 2.1.297 → 2.1.299
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 +564 -325
- 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.299","BINARY_NAME":"occ","BUILD_TIME":"2026-08-12T20:49:17.819Z","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) {
|
|
@@ -263679,13 +263679,6 @@ function checkEditWouldApply(fileContent, oldString, replaceAll2) {
|
|
|
263679
263679
|
}
|
|
263680
263680
|
return "applies";
|
|
263681
263681
|
}
|
|
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
263682
|
function preserveQuoteStyle(oldString, actualOldString, newString) {
|
|
263690
263683
|
if (oldString === actualOldString) {
|
|
263691
263684
|
return newString;
|
|
@@ -263993,8 +263986,6 @@ var init_utils8 = __esm(() => {
|
|
|
263993
263986
|
init_diff2();
|
|
263994
263987
|
init_errors();
|
|
263995
263988
|
init_file();
|
|
263996
|
-
init_filesystem();
|
|
263997
|
-
init_prompt3();
|
|
263998
263989
|
DESANITIZATIONS = {
|
|
263999
263990
|
"<fnr>": "<function_results>",
|
|
264000
263991
|
"<n>": "<name>",
|
|
@@ -367482,6 +367473,7 @@ var init_types10 = __esm(() => {
|
|
|
367482
367473
|
structuredPatch: exports_external.array(hunkSchema()).describe("Diff patch showing the changes"),
|
|
367483
367474
|
userModified: exports_external.boolean().describe("Whether the user modified the proposed changes"),
|
|
367484
367475
|
replaceAll: exports_external.boolean().describe("Whether all occurrences were replaced"),
|
|
367476
|
+
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
367477
|
gitDiff: gitDiffSchema().optional()
|
|
367486
367478
|
}));
|
|
367487
367479
|
});
|
|
@@ -372717,6 +372709,183 @@ var init_perforce = __esm(() => {
|
|
|
372717
372709
|
init_envUtils();
|
|
372718
372710
|
});
|
|
372719
372711
|
|
|
372712
|
+
// src/utils/permissions/fileStateGuard.ts
|
|
372713
|
+
import { extname as extname12 } from "path";
|
|
372714
|
+
function stripBracket1m(model) {
|
|
372715
|
+
return model.replace(/\[1m\]$/i, "");
|
|
372716
|
+
}
|
|
372717
|
+
function isOldModel(model) {
|
|
372718
|
+
const stripped = stripBracket1m(model);
|
|
372719
|
+
const guardName = CANONICAL_TO_GUARD_NAME[stripped] ?? stripped;
|
|
372720
|
+
return OLD_GUARD_MODELS.has(guardName);
|
|
372721
|
+
}
|
|
372722
|
+
function getModelBucket(model) {
|
|
372723
|
+
const bucket = stripBracket1m(model).replace(/^claude-/, "").replaceAll("-", "_");
|
|
372724
|
+
return /^[a-z0-9_]{1,40}$/.test(bucket) ? bucket : "nonconforming";
|
|
372725
|
+
}
|
|
372726
|
+
function getGuardModel(context4) {
|
|
372727
|
+
return getCanonicalName(context4.options.mainLoopModel);
|
|
372728
|
+
}
|
|
372729
|
+
function isNotebookPathForGuard(fullFilePath) {
|
|
372730
|
+
return extname12(fullFilePath.replace(/[. ]+$/, "")).toLowerCase() === ".ipynb";
|
|
372731
|
+
}
|
|
372732
|
+
function isCoveredByReadDenyRule(fullFilePath, toolPermissionContext) {
|
|
372733
|
+
const bareReadDenied = getDenyRules(toolPermissionContext).some((rule) => !RUNTIME_NARROWING_RULE_SOURCES.has(rule.source) && rule.ruleValue.ruleContent === undefined && rule.ruleValue.toolName === FILE_READ_TOOL_NAME);
|
|
372734
|
+
if (bareReadDenied) {
|
|
372735
|
+
return true;
|
|
372736
|
+
}
|
|
372737
|
+
if (getRuleByContentsForToolName(toolPermissionContext, FILE_READ_TOOL_NAME, "deny").size === 0) {
|
|
372738
|
+
return false;
|
|
372739
|
+
}
|
|
372740
|
+
return getPathsForPermissionCheck(fullFilePath).some((pathToCheck) => matchingRuleForInput(pathToCheck, toolPermissionContext, "read", "deny") !== null);
|
|
372741
|
+
}
|
|
372742
|
+
function isReadToolUnavailableForGuard(writingToolName, context4) {
|
|
372743
|
+
const tools = context4.options.tools ?? [];
|
|
372744
|
+
return tools.some((tool) => toolMatchesName(tool, writingToolName)) && !tools.some((tool) => toolMatchesName(tool, FILE_READ_TOOL_NAME)) && !tools.some((tool) => toolMatchesName(tool, REPL_TOOL_NAME));
|
|
372745
|
+
}
|
|
372746
|
+
function isReadAutoAllowedForPath(fullFilePath, toolPermissionContext) {
|
|
372747
|
+
if (getDenyRuleForTool(toolPermissionContext, READ_PROBE) !== null || getAskRuleForTool(toolPermissionContext, READ_PROBE) !== null) {
|
|
372748
|
+
return false;
|
|
372749
|
+
}
|
|
372750
|
+
const decision = checkReadPermissionForTool(READ_PROBE, { file_path: fullFilePath }, toolPermissionContext);
|
|
372751
|
+
if (decision.behavior === "allow") {
|
|
372752
|
+
return true;
|
|
372753
|
+
}
|
|
372754
|
+
if (decision.behavior !== "ask") {
|
|
372755
|
+
return false;
|
|
372756
|
+
}
|
|
372757
|
+
if (toolPermissionContext.mode !== "bypassPermissions") {
|
|
372758
|
+
return false;
|
|
372759
|
+
}
|
|
372760
|
+
const reason = decision.decisionReason;
|
|
372761
|
+
return !(reason?.type === "rule" && reason.rule.ruleBehavior === "ask");
|
|
372762
|
+
}
|
|
372763
|
+
function wouldReadBeAutoAllowed(writingToolName, fullFilePath, context4, toolPermissionContext) {
|
|
372764
|
+
return !isReadToolUnavailableForGuard(writingToolName, context4) && isReadAutoAllowedForPath(fullFilePath, toolPermissionContext);
|
|
372765
|
+
}
|
|
372766
|
+
function isFullReadOfFileState(state3) {
|
|
372767
|
+
if ((state3.offset ?? 1) > 1 || state3.isPartialView) {
|
|
372768
|
+
return false;
|
|
372769
|
+
}
|
|
372770
|
+
if (state3.limit === undefined) {
|
|
372771
|
+
return true;
|
|
372772
|
+
}
|
|
372773
|
+
return state3.content !== "" && countCharInString(state3.content, `
|
|
372774
|
+
`) + 1 < state3.limit;
|
|
372775
|
+
}
|
|
372776
|
+
function stripBom(content) {
|
|
372777
|
+
return content.charCodeAt(0) === 65279 ? content.slice(1) : content;
|
|
372778
|
+
}
|
|
372779
|
+
function normalizeForComparison(content) {
|
|
372780
|
+
return stripBom(content).replaceAll(`\r
|
|
372781
|
+
`, `
|
|
372782
|
+
`);
|
|
372783
|
+
}
|
|
372784
|
+
function fileStateMatchesDisk(state3, diskContent) {
|
|
372785
|
+
return state3.content === diskContent;
|
|
372786
|
+
}
|
|
372787
|
+
function fileStateMatchesNormalized(state3, rawContent2) {
|
|
372788
|
+
return fileStateMatchesDisk(state3, normalizeForComparison(rawContent2));
|
|
372789
|
+
}
|
|
372790
|
+
function editWouldApplyToTelemetry(result) {
|
|
372791
|
+
switch (result) {
|
|
372792
|
+
case "no_match":
|
|
372793
|
+
return "errorCode8";
|
|
372794
|
+
case "ambiguous":
|
|
372795
|
+
return "errorCode9";
|
|
372796
|
+
case "applies":
|
|
372797
|
+
return "success";
|
|
372798
|
+
}
|
|
372799
|
+
}
|
|
372800
|
+
function assertWriteFileStateFresh(args) {
|
|
372801
|
+
const { fullFilePath, diskContent, lastRead, model, readNotAutoAllowed } = args;
|
|
372802
|
+
if (!lastRead || lastRead.isPartialView) {
|
|
372803
|
+
if (!lastRead && !isNotebookPathForGuard(fullFilePath) && !isOldModel(model) && !readNotAutoAllowed()) {
|
|
372804
|
+
return;
|
|
372805
|
+
}
|
|
372806
|
+
throw new FileStateError(FILE_NOT_READ_MESSAGE);
|
|
372807
|
+
}
|
|
372808
|
+
if (!(getFileModificationTime(fullFilePath) > lastRead.timestamp)) {
|
|
372809
|
+
return;
|
|
372810
|
+
}
|
|
372811
|
+
if (isFullReadOfFileState(lastRead) && fileStateMatchesDisk(lastRead, stripBom(diskContent))) {
|
|
372812
|
+
return;
|
|
372813
|
+
}
|
|
372814
|
+
throw new FileStateError(FILE_MODIFIED_SINCE_READ_CALL_MESSAGE);
|
|
372815
|
+
}
|
|
372816
|
+
function checkEditFileStateAtCall(args) {
|
|
372817
|
+
const {
|
|
372818
|
+
absoluteFilePath,
|
|
372819
|
+
fileContents,
|
|
372820
|
+
lastRead,
|
|
372821
|
+
oldString,
|
|
372822
|
+
replaceAll: replaceAll2,
|
|
372823
|
+
model,
|
|
372824
|
+
readNotAutoAllowed
|
|
372825
|
+
} = args;
|
|
372826
|
+
if (!lastRead) {
|
|
372827
|
+
if (!isOldModel(model) && !readNotAutoAllowed()) {
|
|
372828
|
+
return false;
|
|
372829
|
+
}
|
|
372830
|
+
throw new FileStateError(FILE_NOT_READ_MESSAGE);
|
|
372831
|
+
}
|
|
372832
|
+
if (getFileModificationTime(absoluteFilePath) <= lastRead.timestamp) {
|
|
372833
|
+
return false;
|
|
372834
|
+
}
|
|
372835
|
+
if (isFullReadOfFileState(lastRead) && fileStateMatchesDisk(lastRead, stripBom(fileContents))) {
|
|
372836
|
+
return false;
|
|
372837
|
+
}
|
|
372838
|
+
if (checkEditWouldApply(fileContents, oldString, replaceAll2) === "applies" && !readNotAutoAllowed()) {
|
|
372839
|
+
return true;
|
|
372840
|
+
}
|
|
372841
|
+
throw new FileStateError(FILE_MODIFIED_SINCE_READ_CALL_MESSAGE);
|
|
372842
|
+
}
|
|
372843
|
+
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;
|
|
372844
|
+
var init_fileStateGuard = __esm(() => {
|
|
372845
|
+
init_Tool();
|
|
372846
|
+
init_prompt3();
|
|
372847
|
+
init_constants9();
|
|
372848
|
+
init_utils8();
|
|
372849
|
+
init_file();
|
|
372850
|
+
init_fsOperations();
|
|
372851
|
+
init_model();
|
|
372852
|
+
init_stringUtils();
|
|
372853
|
+
init_filesystem();
|
|
372854
|
+
init_permissions2();
|
|
372855
|
+
FileStateError = class FileStateError extends Error {
|
|
372856
|
+
constructor(message) {
|
|
372857
|
+
super(message);
|
|
372858
|
+
this.name = "FileStateError";
|
|
372859
|
+
}
|
|
372860
|
+
};
|
|
372861
|
+
OLD_GUARD_MODELS = new Set([
|
|
372862
|
+
"claude-opus-4-6",
|
|
372863
|
+
"claude-haiku-4-5",
|
|
372864
|
+
"claude-opus-4-5",
|
|
372865
|
+
"claude-opus-4-1",
|
|
372866
|
+
"claude-opus-4-0",
|
|
372867
|
+
"claude-sonnet-4-5",
|
|
372868
|
+
"claude-sonnet-4-0",
|
|
372869
|
+
"claude-3-7-sonnet",
|
|
372870
|
+
"claude-3-5-sonnet",
|
|
372871
|
+
"claude-3-5-haiku"
|
|
372872
|
+
]);
|
|
372873
|
+
CANONICAL_TO_GUARD_NAME = {
|
|
372874
|
+
"claude-opus-4": "claude-opus-4-0",
|
|
372875
|
+
"claude-sonnet-4": "claude-sonnet-4-0"
|
|
372876
|
+
};
|
|
372877
|
+
RUNTIME_NARROWING_RULE_SOURCES = new Set([
|
|
372878
|
+
"toolsNarrowing",
|
|
372879
|
+
"cliArg",
|
|
372880
|
+
"command"
|
|
372881
|
+
]);
|
|
372882
|
+
READ_PROBE = {
|
|
372883
|
+
name: FILE_READ_TOOL_NAME,
|
|
372884
|
+
mcpInfo: undefined,
|
|
372885
|
+
getPath: (input) => String(input.file_path)
|
|
372886
|
+
};
|
|
372887
|
+
});
|
|
372888
|
+
|
|
372720
372889
|
// src/tools/FileWriteTool/UI.tsx
|
|
372721
372890
|
import { isAbsolute as isAbsolute15, relative as relative13, resolve as resolve29 } from "path";
|
|
372722
372891
|
function countLines(content) {
|
|
@@ -373181,12 +373350,11 @@ var init_UI3 = __esm(() => {
|
|
|
373181
373350
|
});
|
|
373182
373351
|
|
|
373183
373352
|
// src/tools/FileWriteTool/FileWriteTool.ts
|
|
373184
|
-
import { dirname as dirname32, sep as sep20 } from "path";
|
|
373353
|
+
import { basename as basename18, dirname as dirname32, isAbsolute as isAbsolute16, sep as sep20 } from "path";
|
|
373185
373354
|
var inputSchema5, outputSchema5, FileWriteTool;
|
|
373186
373355
|
var init_FileWriteTool = __esm(() => {
|
|
373187
373356
|
init_analytics();
|
|
373188
373357
|
init_v4();
|
|
373189
|
-
init_growthbook();
|
|
373190
373358
|
init_diagnosticTracking();
|
|
373191
373359
|
init_LSPDiagnosticRegistry();
|
|
373192
373360
|
init_manager3();
|
|
@@ -373208,6 +373376,7 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373208
373376
|
init_log3();
|
|
373209
373377
|
init_path2();
|
|
373210
373378
|
init_perforce();
|
|
373379
|
+
init_fileStateGuard();
|
|
373211
373380
|
init_filesystem();
|
|
373212
373381
|
init_shellRuleMatching();
|
|
373213
373382
|
init_types10();
|
|
@@ -373277,12 +373446,22 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373277
373446
|
},
|
|
373278
373447
|
async validateInput({ file_path, content }, toolUseContext) {
|
|
373279
373448
|
const fullFilePath = expandPath(file_path);
|
|
373449
|
+
const toolPermissionContext = toolUseContext.getAppState().toolPermissionContext;
|
|
373450
|
+
if (toolUseContext.agentId && /^(REPORT|SUMMARY|FINDINGS|ANALYSIS).*\.md$/i.test(basename18(fullFilePath))) {
|
|
373451
|
+
logEvent2("tengu_subagent_md_report_blocked", {
|
|
373452
|
+
contentBytes: Buffer.byteLength(content)
|
|
373453
|
+
});
|
|
373454
|
+
return {
|
|
373455
|
+
result: false,
|
|
373456
|
+
message: "Subagents should return findings as text, not write report files. Include this content in your final response instead.",
|
|
373457
|
+
errorCode: 5
|
|
373458
|
+
};
|
|
373459
|
+
}
|
|
373280
373460
|
const secretError = checkTeamMemSecrets(fullFilePath, content);
|
|
373281
373461
|
if (secretError) {
|
|
373282
373462
|
return { result: false, message: secretError, errorCode: 0 };
|
|
373283
373463
|
}
|
|
373284
|
-
const
|
|
373285
|
-
const denyRule = matchingRuleForInput(fullFilePath, appState.toolPermissionContext, "edit", "deny");
|
|
373464
|
+
const denyRule = matchingRuleForInput(fullFilePath, toolPermissionContext, "edit", "deny");
|
|
373286
373465
|
if (denyRule !== null) {
|
|
373287
373466
|
return {
|
|
373288
373467
|
result: false,
|
|
@@ -373290,6 +373469,13 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373290
373469
|
errorCode: 1
|
|
373291
373470
|
};
|
|
373292
373471
|
}
|
|
373472
|
+
if (isCoveredByReadDenyRule(fullFilePath, toolPermissionContext)) {
|
|
373473
|
+
return {
|
|
373474
|
+
result: false,
|
|
373475
|
+
message: READ_DENY_WRITE_MESSAGE,
|
|
373476
|
+
errorCode: 13
|
|
373477
|
+
};
|
|
373478
|
+
}
|
|
373293
373479
|
if (fullFilePath.startsWith("\\\\") || fullFilePath.startsWith("//")) {
|
|
373294
373480
|
return { result: true };
|
|
373295
373481
|
}
|
|
@@ -373302,9 +373488,8 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373302
373488
|
if (perforceError) {
|
|
373303
373489
|
return {
|
|
373304
373490
|
result: false,
|
|
373305
|
-
behavior: "ask",
|
|
373306
373491
|
message: perforceError,
|
|
373307
|
-
errorCode:
|
|
373492
|
+
errorCode: 6
|
|
373308
373493
|
};
|
|
373309
373494
|
}
|
|
373310
373495
|
} catch (e4) {
|
|
@@ -373313,38 +373498,60 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373313
373498
|
}
|
|
373314
373499
|
throw e4;
|
|
373315
373500
|
}
|
|
373316
|
-
const
|
|
373317
|
-
if (!
|
|
373318
|
-
|
|
373319
|
-
|
|
373320
|
-
|
|
373321
|
-
|
|
373322
|
-
|
|
373501
|
+
const lastRead = toolUseContext.readFileState.get(fullFilePath);
|
|
373502
|
+
if (!lastRead || lastRead.isPartialView) {
|
|
373503
|
+
const model = getGuardModel(toolUseContext);
|
|
373504
|
+
const guardSkipped = !lastRead && !isNotebookPathForGuard(fullFilePath) && !isOldModel(model) && wouldReadBeAutoAllowed(FILE_WRITE_TOOL_NAME, fullFilePath, toolUseContext, toolPermissionContext);
|
|
373505
|
+
logEvent2("tengu_write_tool_not_read_hypothetical", {
|
|
373506
|
+
wouldHaveResult: lastRead && Math.floor(fileMtimeMs) > lastRead.timestamp ? "errorCode3" : "success",
|
|
373507
|
+
isPartialView: lastRead?.isPartialView === true,
|
|
373508
|
+
isFilePathAbsolute: isAbsolute16(file_path),
|
|
373509
|
+
guardSkipped,
|
|
373510
|
+
modelBucket: getModelBucket(model)
|
|
373511
|
+
});
|
|
373512
|
+
if (!guardSkipped) {
|
|
373513
|
+
return {
|
|
373514
|
+
result: false,
|
|
373515
|
+
message: FILE_NOT_READ_MESSAGE,
|
|
373516
|
+
errorCode: 2
|
|
373517
|
+
};
|
|
373518
|
+
}
|
|
373519
|
+
return { result: true };
|
|
373323
373520
|
}
|
|
373324
|
-
|
|
373325
|
-
|
|
373326
|
-
|
|
373327
|
-
|
|
373328
|
-
|
|
373329
|
-
|
|
373330
|
-
|
|
373521
|
+
if (Math.floor(fileMtimeMs) > lastRead.timestamp) {
|
|
373522
|
+
let matchesDisk = false;
|
|
373523
|
+
if (isFullReadOfFileState(lastRead)) {
|
|
373524
|
+
const diskBytes = await fs17.readFileBytes(fullFilePath);
|
|
373525
|
+
matchesDisk = fileStateMatchesNormalized(lastRead, diskBytes.toString("utf8"));
|
|
373526
|
+
}
|
|
373527
|
+
if (!matchesDisk) {
|
|
373528
|
+
return {
|
|
373529
|
+
result: false,
|
|
373530
|
+
message: FILE_MODIFIED_SINCE_READ_VALIDATION_MESSAGE,
|
|
373531
|
+
errorCode: 3
|
|
373532
|
+
};
|
|
373533
|
+
}
|
|
373331
373534
|
}
|
|
373332
373535
|
return { result: true };
|
|
373333
373536
|
},
|
|
373334
|
-
async call({ file_path, content },
|
|
373537
|
+
async call({ file_path, content }, context4, _2, parentMessage) {
|
|
373538
|
+
const { readFileState, updateFileHistoryState, dynamicSkillDirTriggers } = context4;
|
|
373335
373539
|
const fullFilePath = expandPath(file_path);
|
|
373336
373540
|
const dir = dirname32(fullFilePath);
|
|
373541
|
+
const toolPermissionContext = context4.getAppState().toolPermissionContext;
|
|
373542
|
+
if (isCoveredByReadDenyRule(fullFilePath, toolPermissionContext)) {
|
|
373543
|
+
throw new FileStateError(READ_DENY_WRITE_MESSAGE);
|
|
373544
|
+
}
|
|
373337
373545
|
const cwd2 = getCwd();
|
|
373338
373546
|
const newSkillDirs = await discoverSkillDirsForPaths([fullFilePath], cwd2);
|
|
373339
373547
|
if (newSkillDirs.length > 0) {
|
|
373340
|
-
for (const
|
|
373341
|
-
dynamicSkillDirTriggers?.add(
|
|
373548
|
+
for (const discoveredDir of newSkillDirs) {
|
|
373549
|
+
dynamicSkillDirTriggers?.add(discoveredDir);
|
|
373342
373550
|
}
|
|
373343
373551
|
addSkillDirectories(newSkillDirs).catch(() => {});
|
|
373344
373552
|
}
|
|
373345
373553
|
activateConditionalSkillsForPaths([fullFilePath], cwd2);
|
|
373346
373554
|
await diagnosticTracker.beforeFileEdited(fullFilePath);
|
|
373347
|
-
await getFsImplementation().mkdir(dir);
|
|
373348
373555
|
if (fileHistoryEnabled()) {
|
|
373349
373556
|
await fileHistoryTrackEdit(updateFileHistoryState, fullFilePath, parentMessage.uuid);
|
|
373350
373557
|
}
|
|
@@ -373359,18 +373566,16 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373359
373566
|
}
|
|
373360
373567
|
}
|
|
373361
373568
|
if (meta3 !== null) {
|
|
373362
|
-
|
|
373363
|
-
|
|
373364
|
-
|
|
373365
|
-
|
|
373366
|
-
|
|
373367
|
-
|
|
373368
|
-
|
|
373369
|
-
}
|
|
373569
|
+
assertWriteFileStateFresh({
|
|
373570
|
+
fullFilePath,
|
|
373571
|
+
diskContent: meta3.content,
|
|
373572
|
+
lastRead: readFileState.get(fullFilePath),
|
|
373573
|
+
model: getGuardModel(context4),
|
|
373574
|
+
readNotAutoAllowed: () => !wouldReadBeAutoAllowed(FILE_WRITE_TOOL_NAME, fullFilePath, context4, toolPermissionContext)
|
|
373575
|
+
});
|
|
373370
373576
|
}
|
|
373371
|
-
|
|
373372
|
-
|
|
373373
|
-
writeTextContent(fullFilePath, content, enc, "LF");
|
|
373577
|
+
await getFsImplementation().mkdir(dir);
|
|
373578
|
+
writeTextContent(fullFilePath, content, meta3?.encoding ?? "utf8", "LF");
|
|
373374
373579
|
const lspManager = getLspServerManager();
|
|
373375
373580
|
if (lspManager) {
|
|
373376
373581
|
clearDeliveredDiagnosticsForFile(`file://${fullFilePath}`);
|
|
@@ -373383,9 +373588,10 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373383
373588
|
logError2(err2);
|
|
373384
373589
|
});
|
|
373385
373590
|
}
|
|
373591
|
+
const oldContent = meta3?.content ?? null;
|
|
373386
373592
|
notifyVscodeFileUpdated(fullFilePath, oldContent, content);
|
|
373387
373593
|
readFileState.set(fullFilePath, {
|
|
373388
|
-
content,
|
|
373594
|
+
content: normalizeForComparison(content),
|
|
373389
373595
|
timestamp: getFileModificationTime(fullFilePath),
|
|
373390
373596
|
offset: undefined,
|
|
373391
373597
|
limit: undefined
|
|
@@ -373394,7 +373600,7 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373394
373600
|
logEvent2("tengu_write_claudemd", {});
|
|
373395
373601
|
}
|
|
373396
373602
|
let gitDiff;
|
|
373397
|
-
if (isEnvTruthy(process.env.CLAUDE_CODE_REMOTE)
|
|
373603
|
+
if (isEnvTruthy(process.env.CLAUDE_CODE_REMOTE)) {
|
|
373398
373604
|
const startTime2 = Date.now();
|
|
373399
373605
|
const diff2 = await fetchSingleFileGitDiff(fullFilePath);
|
|
373400
373606
|
if (diff2)
|
|
@@ -373405,6 +373611,7 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373405
373611
|
hasDiff: !!diff2
|
|
373406
373612
|
});
|
|
373407
373613
|
}
|
|
373614
|
+
const userModified = context4.userModified ?? false;
|
|
373408
373615
|
if (oldContent) {
|
|
373409
373616
|
const patch = getPatchForDisplay({
|
|
373410
373617
|
filePath: file_path,
|
|
@@ -373423,6 +373630,7 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373423
373630
|
content,
|
|
373424
373631
|
structuredPatch: patch,
|
|
373425
373632
|
originalFile: oldContent,
|
|
373633
|
+
userModified,
|
|
373426
373634
|
...gitDiff && { gitDiff }
|
|
373427
373635
|
};
|
|
373428
373636
|
countLinesChanged(patch);
|
|
@@ -373442,6 +373650,7 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373442
373650
|
content,
|
|
373443
373651
|
structuredPatch: [],
|
|
373444
373652
|
originalFile: null,
|
|
373653
|
+
userModified,
|
|
373445
373654
|
...gitDiff && { gitDiff }
|
|
373446
373655
|
};
|
|
373447
373656
|
countLinesChanged([], content);
|
|
@@ -373455,19 +373664,21 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373455
373664
|
data
|
|
373456
373665
|
};
|
|
373457
373666
|
},
|
|
373458
|
-
mapToolResultToToolResultBlockParam({ filePath, type }, toolUseID) {
|
|
373667
|
+
mapToolResultToToolResultBlockParam({ filePath, type, userModified }, toolUseID) {
|
|
373668
|
+
const modifiedNote = userModified ? " The user modified your proposed content before accepting it." : "";
|
|
373669
|
+
const stateNote = userModified ? "" : FILE_STATE_CURRENT_NOTE;
|
|
373459
373670
|
switch (type) {
|
|
373460
373671
|
case "create":
|
|
373461
373672
|
return {
|
|
373462
373673
|
tool_use_id: toolUseID,
|
|
373463
373674
|
type: "tool_result",
|
|
373464
|
-
content: `File created successfully at: ${filePath}`
|
|
373675
|
+
content: `File created successfully at: ${filePath}${modifiedNote}${stateNote}`
|
|
373465
373676
|
};
|
|
373466
373677
|
case "update":
|
|
373467
373678
|
return {
|
|
373468
373679
|
tool_use_id: toolUseID,
|
|
373469
373680
|
type: "tool_result",
|
|
373470
|
-
content: `The file ${filePath} has been updated successfully
|
|
373681
|
+
content: `The file ${filePath} has been updated successfully.${modifiedNote}${stateNote}`
|
|
373471
373682
|
};
|
|
373472
373683
|
}
|
|
373473
373684
|
}
|
|
@@ -373475,7 +373686,7 @@ var init_FileWriteTool = __esm(() => {
|
|
|
373475
373686
|
});
|
|
373476
373687
|
|
|
373477
373688
|
// src/utils/plugins/orphanedPluginFilter.ts
|
|
373478
|
-
import { dirname as dirname33, isAbsolute as
|
|
373689
|
+
import { dirname as dirname33, isAbsolute as isAbsolute17, join as join73, normalize as normalize11, relative as relative14, sep as sep21 } from "path";
|
|
373479
373690
|
async function getGlobExclusionsForPluginCache(searchPath) {
|
|
373480
373691
|
const cachePath = normalize11(join73(getPluginsDirectory(), "cache"));
|
|
373481
373692
|
if (searchPath && !pathsOverlap(searchPath, cachePath)) {
|
|
@@ -373496,7 +373707,7 @@ async function getGlobExclusionsForPluginCache(searchPath) {
|
|
|
373496
373707
|
], cachePath, new AbortController().signal);
|
|
373497
373708
|
cachedExclusions = markers.map((markerPath) => {
|
|
373498
373709
|
const versionDir = dirname33(markerPath);
|
|
373499
|
-
const rel =
|
|
373710
|
+
const rel = isAbsolute17(versionDir) ? relative14(cachePath, versionDir) : versionDir;
|
|
373500
373711
|
const posixRelative = rel.replace(/\\/g, "/");
|
|
373501
373712
|
return `!**/${posixRelative}/**`;
|
|
373502
373713
|
});
|
|
@@ -373525,13 +373736,13 @@ var init_orphanedPluginFilter = __esm(() => {
|
|
|
373525
373736
|
});
|
|
373526
373737
|
|
|
373527
373738
|
// src/utils/glob.ts
|
|
373528
|
-
import { basename as
|
|
373739
|
+
import { basename as basename19, dirname as dirname34, isAbsolute as isAbsolute18, join as join74, sep as sep22 } from "path";
|
|
373529
373740
|
function extractGlobBaseDirectory(pattern) {
|
|
373530
373741
|
const globChars = /[*?[{]/;
|
|
373531
373742
|
const match = pattern.match(globChars);
|
|
373532
373743
|
if (!match || match.index === undefined) {
|
|
373533
373744
|
const dir = dirname34(pattern);
|
|
373534
|
-
const file2 =
|
|
373745
|
+
const file2 = basename19(pattern);
|
|
373535
373746
|
return { baseDir: dir, relativePattern: file2 };
|
|
373536
373747
|
}
|
|
373537
373748
|
const staticPrefix = pattern.slice(0, match.index);
|
|
@@ -373552,7 +373763,7 @@ function extractGlobBaseDirectory(pattern) {
|
|
|
373552
373763
|
async function glob(filePattern, cwd2, { limit, offset }, abortSignal, toolPermissionContext) {
|
|
373553
373764
|
let searchDir = cwd2;
|
|
373554
373765
|
let searchPattern = filePattern;
|
|
373555
|
-
if (
|
|
373766
|
+
if (isAbsolute18(filePattern)) {
|
|
373556
373767
|
const { baseDir, relativePattern } = extractGlobBaseDirectory(filePattern);
|
|
373557
373768
|
if (baseDir) {
|
|
373558
373769
|
searchDir = baseDir;
|
|
@@ -373577,7 +373788,7 @@ async function glob(filePattern, cwd2, { limit, offset }, abortSignal, toolPermi
|
|
|
373577
373788
|
args.push("--glob", exclusion);
|
|
373578
373789
|
}
|
|
373579
373790
|
const allPaths = await ripGrep(args, searchDir, abortSignal);
|
|
373580
|
-
const absolutePaths = allPaths.map((p4) =>
|
|
373791
|
+
const absolutePaths = allPaths.map((p4) => isAbsolute18(p4) ? p4 : join74(searchDir, p4));
|
|
373581
373792
|
const truncated = absolutePaths.length > offset + limit;
|
|
373582
373793
|
const files2 = absolutePaths.slice(offset, offset + limit);
|
|
373583
373794
|
return { files: files2, truncated };
|
|
@@ -379099,13 +379310,13 @@ var init_sedValidation = __esm(() => {
|
|
|
379099
379310
|
|
|
379100
379311
|
// src/tools/BashTool/pathValidation.ts
|
|
379101
379312
|
import { homedir as homedir22 } from "os";
|
|
379102
|
-
import { isAbsolute as
|
|
379313
|
+
import { isAbsolute as isAbsolute19, resolve as resolve30 } from "path";
|
|
379103
379314
|
function checkDangerousRemovalPaths(command4, args, cwd2) {
|
|
379104
379315
|
const extractor = PATH_EXTRACTORS[command4];
|
|
379105
379316
|
const paths2 = extractor(args);
|
|
379106
379317
|
for (const path21 of paths2) {
|
|
379107
379318
|
const cleanPath = expandTilde(path21.replace(/^['"]|['"]$/g, ""));
|
|
379108
|
-
const absolutePath =
|
|
379319
|
+
const absolutePath = isAbsolute19(cleanPath) ? cleanPath : resolve30(cwd2, cleanPath);
|
|
379109
379320
|
if (isDangerousRemovalPath(absolutePath)) {
|
|
379110
379321
|
return {
|
|
379111
379322
|
behavior: "ask",
|
|
@@ -383553,11 +383764,11 @@ var init_modeValidation = __esm(() => {
|
|
|
383553
383764
|
});
|
|
383554
383765
|
|
|
383555
383766
|
// src/tools/BashTool/worktreeGitRedirectGuard.ts
|
|
383556
|
-
import { resolve as resolve31, isAbsolute as
|
|
383767
|
+
import { resolve as resolve31, isAbsolute as isAbsolute20, sep as sep24, basename as basename20 } from "path";
|
|
383557
383768
|
function isGitToken(tok) {
|
|
383558
383769
|
if (!tok)
|
|
383559
383770
|
return false;
|
|
383560
|
-
return GIT_NAME_RE.test(
|
|
383771
|
+
return GIT_NAME_RE.test(basename20(tok));
|
|
383561
383772
|
}
|
|
383562
383773
|
function isGlobTarget(path21) {
|
|
383563
383774
|
return GLOB_CHARS.some((c9) => path21.includes(c9));
|
|
@@ -383566,7 +383777,7 @@ function isDynamicTarget(path21) {
|
|
|
383566
383777
|
return path21.includes("$") || path21.includes("`") || path21.includes("$(") || path21.startsWith("~");
|
|
383567
383778
|
}
|
|
383568
383779
|
function isWithinWorktree(target, agentWorktree, cwd2) {
|
|
383569
|
-
const resolved =
|
|
383780
|
+
const resolved = isAbsolute20(target) ? target : resolve31(cwd2, target);
|
|
383570
383781
|
const worktree = resolve31(agentWorktree);
|
|
383571
383782
|
return resolved === worktree || resolved.startsWith(worktree + sep24);
|
|
383572
383783
|
}
|
|
@@ -383622,25 +383833,25 @@ function isRedirectConfigKey(key2) {
|
|
|
383622
383833
|
function findShellEscapeIdx(argv) {
|
|
383623
383834
|
if (argv.length === 0)
|
|
383624
383835
|
return -1;
|
|
383625
|
-
const first =
|
|
383836
|
+
const first = basename20(argv[0] ?? "").toLowerCase();
|
|
383626
383837
|
if (SHELL_INTERPRETERS.has(first))
|
|
383627
383838
|
return 0;
|
|
383628
383839
|
if (COMMAND_WRAPPERS.has(first)) {
|
|
383629
|
-
return argv.findIndex((o5, i6) => i6 > 0 && SHELL_INTERPRETERS.has(
|
|
383840
|
+
return argv.findIndex((o5, i6) => i6 > 0 && SHELL_INTERPRETERS.has(basename20(o5 ?? "").toLowerCase()));
|
|
383630
383841
|
}
|
|
383631
383842
|
return -1;
|
|
383632
383843
|
}
|
|
383633
383844
|
function checkShellWrapperObfuscation(argv, ctx = EMPTY_CTX) {
|
|
383634
383845
|
if (argv.length === 0)
|
|
383635
383846
|
return null;
|
|
383636
|
-
const t4 = argv.some((o5) => GIT_NAME_RE.test(
|
|
383637
|
-
if (t4 && argv.some((o5) => STDIN_FEED_WRAPPERS.has(
|
|
383847
|
+
const t4 = argv.some((o5) => GIT_NAME_RE.test(basename20(o5)));
|
|
383848
|
+
if (t4 && argv.some((o5) => STDIN_FEED_WRAPPERS.has(basename20(o5).toLowerCase()))) {
|
|
383638
383849
|
return {
|
|
383639
383850
|
mechanism: "xargs/parallel",
|
|
383640
383851
|
reason: "feeds git its arguments from stdin at runtime (xargs/parallel), so the repository it targets cannot be verified"
|
|
383641
383852
|
};
|
|
383642
383853
|
}
|
|
383643
|
-
const hasFind = argv.some((o5) =>
|
|
383854
|
+
const hasFind = argv.some((o5) => basename20(o5).toLowerCase() === "find");
|
|
383644
383855
|
if (t4 && hasFind && argv.some((o5) => FIND_PERMATCH_FLAGS.has(o5))) {
|
|
383645
383856
|
return {
|
|
383646
383857
|
mechanism: "find -execdir/-okdir",
|
|
@@ -383653,7 +383864,7 @@ function checkShellWrapperObfuscation(argv, ctx = EMPTY_CTX) {
|
|
|
383653
383864
|
const hasCFlag = rest.includes("-c");
|
|
383654
383865
|
const hasScriptfile = rest.some((a5) => a5.length > 0 && !a5.startsWith("-"));
|
|
383655
383866
|
if (hasCFlag || hasScriptfile) {
|
|
383656
|
-
const name3 =
|
|
383867
|
+
const name3 = basename20(argv[shellIdx]);
|
|
383657
383868
|
return {
|
|
383658
383869
|
mechanism: `${name3} -c`,
|
|
383659
383870
|
reason: `runs a string through ${name3} -c, which can't be verified to stay inside the worktree; run the command directly instead`
|
|
@@ -383661,7 +383872,7 @@ function checkShellWrapperObfuscation(argv, ctx = EMPTY_CTX) {
|
|
|
383661
383872
|
}
|
|
383662
383873
|
const stdinFed = ctx.stdinFromPipe || ctx.stdinFeedOp !== null;
|
|
383663
383874
|
if (stdinFed) {
|
|
383664
|
-
const name3 =
|
|
383875
|
+
const name3 = basename20(argv[shellIdx]);
|
|
383665
383876
|
const source = ctx.stdinFromPipe ? "pipe" : stdinSourceLabel(ctx.stdinFeedOp);
|
|
383666
383877
|
return {
|
|
383667
383878
|
mechanism: `${name3} (stdin: ${source})`,
|
|
@@ -383669,7 +383880,7 @@ function checkShellWrapperObfuscation(argv, ctx = EMPTY_CTX) {
|
|
|
383669
383880
|
};
|
|
383670
383881
|
}
|
|
383671
383882
|
}
|
|
383672
|
-
const head =
|
|
383883
|
+
const head = basename20(argv[0] ?? "").toLowerCase();
|
|
383673
383884
|
if ((head === "su" || head === "runuser") && argv.includes("-c")) {
|
|
383674
383885
|
return {
|
|
383675
383886
|
mechanism: `${head} -c`,
|
|
@@ -383677,11 +383888,11 @@ function checkShellWrapperObfuscation(argv, ctx = EMPTY_CTX) {
|
|
|
383677
383888
|
};
|
|
383678
383889
|
}
|
|
383679
383890
|
const n5 = argv.find((o5, i6) => {
|
|
383680
|
-
const b5 =
|
|
383891
|
+
const b5 = basename20(o5).toLowerCase();
|
|
383681
383892
|
return b5 === "." ? i6 === 0 : SHELL_BUILTIN_WRAPPERS.has(b5);
|
|
383682
383893
|
});
|
|
383683
383894
|
if (n5 !== undefined && argv.filter((i6) => i6 !== n5).length > 0) {
|
|
383684
|
-
const name3 =
|
|
383895
|
+
const name3 = basename20(n5);
|
|
383685
383896
|
return {
|
|
383686
383897
|
mechanism: name3,
|
|
383687
383898
|
reason: `runs a string through ${name3}, which can't be verified to stay inside the worktree; run the command directly instead`
|
|
@@ -383709,11 +383920,11 @@ function checkWorktreeGitRedirect(command4, agentWorktree, cwd2) {
|
|
|
383709
383920
|
return ozgBlock;
|
|
383710
383921
|
if (hasGitAtOrAfter[f4]) {
|
|
383711
383922
|
const builtinIdx = argv.findIndex((o5, i6) => {
|
|
383712
|
-
const b5 =
|
|
383923
|
+
const b5 = basename20(o5).toLowerCase();
|
|
383713
383924
|
return b5 === "." ? i6 === 0 : SHELL_BUILTIN_WRAPPERS.has(b5);
|
|
383714
383925
|
});
|
|
383715
383926
|
if (builtinIdx !== -1) {
|
|
383716
|
-
const name3 =
|
|
383927
|
+
const name3 = basename20(argv[builtinIdx]);
|
|
383717
383928
|
return {
|
|
383718
383929
|
mechanism: name3,
|
|
383719
383930
|
reason: `runs ${name3} before a git command, whose string payload can't be verified to leave the worktree alone`
|
|
@@ -383899,18 +384110,18 @@ var init_worktreeGitRedirectGuard = __esm(() => {
|
|
|
383899
384110
|
|
|
383900
384111
|
// src/tools/BashTool/bashPermissions.ts
|
|
383901
384112
|
import { homedir as homedir23 } from "os";
|
|
383902
|
-
import { isAbsolute as
|
|
384113
|
+
import { isAbsolute as isAbsolute21, resolve as resolve32, sep as sep25 } from "path";
|
|
383903
384114
|
function isBuildToolConfigTarget(target) {
|
|
383904
384115
|
const stripped = target.replace(/^['"]|['"]$/g, "");
|
|
383905
384116
|
const expanded = stripped.startsWith("~/") ? homedir23() + stripped.slice(1) : stripped;
|
|
383906
|
-
const
|
|
383907
|
-
return BUILD_TOOL_CONFIG_FILES.has(
|
|
384117
|
+
const basename21 = expanded.split("/").pop() ?? expanded;
|
|
384118
|
+
return BUILD_TOOL_CONFIG_FILES.has(basename21);
|
|
383908
384119
|
}
|
|
383909
384120
|
function isShellStartupFileTarget(target) {
|
|
383910
384121
|
const stripped = target.replace(/^['"]|['"]$/g, "");
|
|
383911
384122
|
const expanded = stripped.startsWith("~/") ? homedir23() + stripped.slice(1) : stripped;
|
|
383912
|
-
const
|
|
383913
|
-
if (SHELL_STARTUP_FILES.has(
|
|
384123
|
+
const basename21 = expanded.split("/").pop() ?? expanded;
|
|
384124
|
+
if (SHELL_STARTUP_FILES.has(basename21)) {
|
|
383914
384125
|
return true;
|
|
383915
384126
|
}
|
|
383916
384127
|
if (/(?:^|\/)\.config\/git(?:\/|$)/.test(expanded)) {
|
|
@@ -383985,10 +384196,10 @@ function isPathOutsideWorkingDir(filePath, cwd2, toolPermissionContext) {
|
|
|
383985
384196
|
if (expanded.includes("$") || expanded.startsWith("~")) {
|
|
383986
384197
|
return true;
|
|
383987
384198
|
}
|
|
383988
|
-
const abs =
|
|
384199
|
+
const abs = isAbsolute21(expanded) ? expanded : resolve32(cwd2, expanded);
|
|
383989
384200
|
const workingDirs = [cwd2];
|
|
383990
384201
|
for (const dir of toolPermissionContext.additionalWorkingDirectories.keys()) {
|
|
383991
|
-
workingDirs.push(
|
|
384202
|
+
workingDirs.push(isAbsolute21(dir) ? dir : resolve32(cwd2, dir));
|
|
383992
384203
|
}
|
|
383993
384204
|
const normalizedAbs = abs.replace(/\/+$/, "") || "/";
|
|
383994
384205
|
return !workingDirs.some((d4) => {
|
|
@@ -415517,12 +415728,12 @@ var require_fetch = __commonJS((exports, module) => {
|
|
|
415517
415728
|
// node_modules/.bun/@protobufjs+path@1.1.2/node_modules/@protobufjs/path/index.js
|
|
415518
415729
|
var require_path = __commonJS((exports) => {
|
|
415519
415730
|
var path21 = exports;
|
|
415520
|
-
var
|
|
415731
|
+
var isAbsolute22 = path21.isAbsolute = function isAbsolute23(path22) {
|
|
415521
415732
|
return /^(?:\/|\w+:)/.test(path22);
|
|
415522
415733
|
};
|
|
415523
415734
|
var normalize12 = path21.normalize = function normalize13(path22) {
|
|
415524
415735
|
path22 = path22.replace(/\\/g, "/").replace(/\/{2,}/g, "/");
|
|
415525
|
-
var parts = path22.split("/"), absolute =
|
|
415736
|
+
var parts = path22.split("/"), absolute = isAbsolute22(path22), prefix = "";
|
|
415526
415737
|
if (absolute)
|
|
415527
415738
|
prefix = parts.shift() + "/";
|
|
415528
415739
|
for (var i6 = 0;i6 < parts.length; ) {
|
|
@@ -415543,7 +415754,7 @@ var require_path = __commonJS((exports) => {
|
|
|
415543
415754
|
path21.resolve = function resolve34(originPath, includePath, alreadyNormalized) {
|
|
415544
415755
|
if (!alreadyNormalized)
|
|
415545
415756
|
includePath = normalize12(includePath);
|
|
415546
|
-
if (
|
|
415757
|
+
if (isAbsolute22(includePath))
|
|
415547
415758
|
return includePath;
|
|
415548
415759
|
if (!alreadyNormalized)
|
|
415549
415760
|
originPath = normalize12(originPath);
|
|
@@ -435436,7 +435647,7 @@ var init_download = __esm(() => {
|
|
|
435436
435647
|
});
|
|
435437
435648
|
|
|
435438
435649
|
// src/utils/nativeInstaller/pidLock.ts
|
|
435439
|
-
import { basename as
|
|
435650
|
+
import { basename as basename21, join as join92 } from "path";
|
|
435440
435651
|
function isPidBasedLockingEnabled() {
|
|
435441
435652
|
const envVar = process.env.ENABLE_PID_BASED_VERSION_LOCKING;
|
|
435442
435653
|
if (isEnvTruthy(envVar)) {
|
|
@@ -435536,7 +435747,7 @@ function writeLockFile(lockFilePath, content) {
|
|
|
435536
435747
|
}
|
|
435537
435748
|
async function tryAcquireLock(versionPath, lockFilePath) {
|
|
435538
435749
|
const fs17 = getFsImplementation();
|
|
435539
|
-
const versionName =
|
|
435750
|
+
const versionName = basename21(versionPath);
|
|
435540
435751
|
if (isLockActive(lockFilePath)) {
|
|
435541
435752
|
const existingContent = readLockContent(lockFilePath);
|
|
435542
435753
|
logForDebugging(`Cannot acquire lock for ${versionName} - held by PID ${existingContent?.pid}`);
|
|
@@ -435686,7 +435897,7 @@ import {
|
|
|
435686
435897
|
writeFile as writeFile23
|
|
435687
435898
|
} from "fs/promises";
|
|
435688
435899
|
import { homedir as homedir27 } from "os";
|
|
435689
|
-
import { basename as
|
|
435900
|
+
import { basename as basename22, delimiter as delimiter3, dirname as dirname39, join as join93, resolve as resolve35 } from "path";
|
|
435690
435901
|
function getPlatform3() {
|
|
435691
435902
|
const os9 = env4.platform;
|
|
435692
435903
|
const arch2 = process.arch === "x64" ? "x64" : process.arch === "arm64" ? "arm64" : null;
|
|
@@ -436283,7 +436494,7 @@ async function getVersionFromSymlink(symlinkPath) {
|
|
|
436283
436494
|
return null;
|
|
436284
436495
|
}
|
|
436285
436496
|
function getLockFilePathFromVersionPath(dirs, versionPath) {
|
|
436286
|
-
const versionName =
|
|
436497
|
+
const versionName = basename22(versionPath);
|
|
436287
436498
|
return join93(dirs.locks, `${versionName}.lock`);
|
|
436288
436499
|
}
|
|
436289
436500
|
async function lockCurrentVersion() {
|
|
@@ -445674,7 +445885,7 @@ var init_osc52ClipboardRead = __esm(() => {
|
|
|
445674
445885
|
import { randomBytes as randomBytes9 } from "crypto";
|
|
445675
445886
|
import { homedir as homedir28, tmpdir as tmpdir8 } from "os";
|
|
445676
445887
|
import { writeFileSync as writeFileSync9 } from "fs";
|
|
445677
|
-
import { basename as
|
|
445888
|
+
import { basename as basename23, extname as extname13, isAbsolute as isAbsolute22, join as join94 } from "path";
|
|
445678
445889
|
function getClipboardCommands() {
|
|
445679
445890
|
const platform5 = process.platform;
|
|
445680
445891
|
const baseTmpDir = process.env.CLAUDE_CODE_TMPDIR || (platform5 === "win32" ? process.env.TEMP || "C:\\Temp" : "/tmp");
|
|
@@ -445935,11 +446146,11 @@ async function tryReadImageFromPath(text2) {
|
|
|
445935
446146
|
const imagePath = cleanedPath;
|
|
445936
446147
|
let imageBuffer;
|
|
445937
446148
|
try {
|
|
445938
|
-
if (
|
|
446149
|
+
if (isAbsolute22(imagePath)) {
|
|
445939
446150
|
imageBuffer = getFsImplementation().readFileBytesSync(imagePath);
|
|
445940
446151
|
} else {
|
|
445941
446152
|
const clipboardPath = await getImagePathFromClipboard();
|
|
445942
|
-
if (clipboardPath && imagePath ===
|
|
446153
|
+
if (clipboardPath && imagePath === basename23(clipboardPath)) {
|
|
445943
446154
|
imageBuffer = getFsImplementation().readFileBytesSync(clipboardPath);
|
|
445944
446155
|
}
|
|
445945
446156
|
}
|
|
@@ -445958,7 +446169,7 @@ async function tryReadImageFromPath(text2) {
|
|
|
445958
446169
|
const sharp2 = await getImageProcessor();
|
|
445959
446170
|
imageBuffer = await sharp2(imageBuffer).png().toBuffer();
|
|
445960
446171
|
}
|
|
445961
|
-
const ext =
|
|
446172
|
+
const ext = extname13(imagePath).slice(1).toLowerCase() || "png";
|
|
445962
446173
|
const resized = await maybeResizeAndDownsampleImageBuffer(imageBuffer, imageBuffer.length, ext);
|
|
445963
446174
|
const base64Image = resized.buffer.toString("base64");
|
|
445964
446175
|
const mediaType = detectImageFormatFromBase64(base64Image);
|
|
@@ -448967,7 +449178,10 @@ var init_prompt15 = __esm(() => {
|
|
|
448967
449178
|
});
|
|
448968
449179
|
|
|
448969
449180
|
// src/tools/FileEditTool/FileEditTool.ts
|
|
448970
|
-
import { dirname as dirname40, isAbsolute as
|
|
449181
|
+
import { dirname as dirname40, isAbsolute as isAbsolute23, sep as sep27 } from "path";
|
|
449182
|
+
function hasUnicodeEscapesOrNonAscii(value) {
|
|
449183
|
+
return UNICODE_ESCAPE_PATTERN.test(value) || NON_ASCII_PATTERN2.test(value);
|
|
449184
|
+
}
|
|
448971
449185
|
function readFileForEdit(absoluteFilePath) {
|
|
448972
449186
|
try {
|
|
448973
449187
|
const meta3 = readFileSyncWithMetadata(absoluteFilePath);
|
|
@@ -448989,10 +449203,9 @@ function readFileForEdit(absoluteFilePath) {
|
|
|
448989
449203
|
throw e4;
|
|
448990
449204
|
}
|
|
448991
449205
|
}
|
|
448992
|
-
var MAX_EDIT_FILE_SIZE, FileEditTool;
|
|
449206
|
+
var UNICODE_ESCAPE_PATTERN, NON_ASCII_PATTERN2, MAX_EDIT_FILE_SIZE, FileEditTool;
|
|
448993
449207
|
var init_FileEditTool = __esm(() => {
|
|
448994
449208
|
init_analytics();
|
|
448995
|
-
init_growthbook();
|
|
448996
449209
|
init_diagnosticTracking();
|
|
448997
449210
|
init_LSPDiagnosticRegistry();
|
|
448998
449211
|
init_manager3();
|
|
@@ -449016,12 +449229,15 @@ var init_FileEditTool = __esm(() => {
|
|
|
449016
449229
|
init_path2();
|
|
449017
449230
|
init_perforce();
|
|
449018
449231
|
init_filesystem();
|
|
449232
|
+
init_fileStateGuard();
|
|
449019
449233
|
init_shellRuleMatching();
|
|
449020
449234
|
init_validateEditTool();
|
|
449021
449235
|
init_prompt15();
|
|
449022
449236
|
init_types10();
|
|
449023
449237
|
init_UI2();
|
|
449024
449238
|
init_utils8();
|
|
449239
|
+
UNICODE_ESCAPE_PATTERN = /\\u[0-9a-fA-F]{4}/;
|
|
449240
|
+
NON_ASCII_PATTERN2 = /[\u0080-\uffff]/;
|
|
449025
449241
|
MAX_EDIT_FILE_SIZE = 1024 * 1024 * 1024;
|
|
449026
449242
|
FileEditTool = buildTool({
|
|
449027
449243
|
name: FILE_EDIT_TOOL_NAME,
|
|
@@ -449093,6 +449309,14 @@ var init_FileEditTool = __esm(() => {
|
|
|
449093
449309
|
errorCode: 2
|
|
449094
449310
|
};
|
|
449095
449311
|
}
|
|
449312
|
+
if (isCoveredByReadDenyRule(fullFilePath, appState.toolPermissionContext)) {
|
|
449313
|
+
return {
|
|
449314
|
+
result: false,
|
|
449315
|
+
behavior: "ask",
|
|
449316
|
+
message: READ_DENY_EDIT_MESSAGE,
|
|
449317
|
+
errorCode: 13
|
|
449318
|
+
};
|
|
449319
|
+
}
|
|
449096
449320
|
if (fullFilePath.startsWith("\\\\") || fullFilePath.startsWith("//")) {
|
|
449097
449321
|
return { result: true };
|
|
449098
449322
|
}
|
|
@@ -449125,9 +449349,7 @@ var init_FileEditTool = __esm(() => {
|
|
|
449125
449349
|
try {
|
|
449126
449350
|
const fileBuffer = await fs17.readFileBytes(fullFilePath);
|
|
449127
449351
|
const encoding = fileBuffer.length >= 2 && fileBuffer[0] === 255 && fileBuffer[1] === 254 ? "utf16le" : "utf8";
|
|
449128
|
-
fileContent = fileBuffer.toString(encoding)
|
|
449129
|
-
`, `
|
|
449130
|
-
`);
|
|
449352
|
+
fileContent = normalizeForComparison(fileBuffer.toString(encoding));
|
|
449131
449353
|
} catch (e4) {
|
|
449132
449354
|
if (isENOENT(e4)) {
|
|
449133
449355
|
fileContent = null;
|
|
@@ -449175,34 +449397,45 @@ var init_FileEditTool = __esm(() => {
|
|
|
449175
449397
|
errorCode: 5
|
|
449176
449398
|
};
|
|
449177
449399
|
}
|
|
449178
|
-
const
|
|
449179
|
-
|
|
449180
|
-
|
|
449181
|
-
|
|
449182
|
-
|
|
449183
|
-
|
|
449184
|
-
|
|
449185
|
-
|
|
449186
|
-
|
|
449187
|
-
|
|
449188
|
-
|
|
449400
|
+
const lastRead = toolUseContext.readFileState.get(fullFilePath);
|
|
449401
|
+
const toolPermissionContext = appState.toolPermissionContext;
|
|
449402
|
+
if (!lastRead || lastRead.isPartialView) {
|
|
449403
|
+
const model = getGuardModel(toolUseContext);
|
|
449404
|
+
const guardSkipped = !isOldModel(model) && wouldReadBeAutoAllowed(FILE_EDIT_TOOL_NAME, fullFilePath, toolUseContext, toolPermissionContext);
|
|
449405
|
+
logEvent2("tengu_edit_tool_not_read_hypothetical", {
|
|
449406
|
+
wouldHaveResult: editWouldApplyToTelemetry(checkEditWouldApply(fileContent, old_string, replace_all)),
|
|
449407
|
+
isPartialView: lastRead?.isPartialView === true,
|
|
449408
|
+
isFilePathAbsolute: String(isAbsolute23(file_path)),
|
|
449409
|
+
guardSkipped,
|
|
449410
|
+
modelBucket: getModelBucket(model)
|
|
449411
|
+
});
|
|
449412
|
+
if (!guardSkipped) {
|
|
449413
|
+
return {
|
|
449414
|
+
result: false,
|
|
449415
|
+
behavior: "ask",
|
|
449416
|
+
message: FILE_NOT_READ_MESSAGE,
|
|
449417
|
+
meta: {
|
|
449418
|
+
isFilePathAbsolute: String(isAbsolute23(file_path))
|
|
449419
|
+
},
|
|
449420
|
+
errorCode: 6
|
|
449421
|
+
};
|
|
449422
|
+
}
|
|
449189
449423
|
}
|
|
449190
|
-
if (
|
|
449424
|
+
if (lastRead) {
|
|
449191
449425
|
const lastWriteTime = getFileModificationTime(fullFilePath);
|
|
449192
|
-
if (lastWriteTime >
|
|
449193
|
-
|
|
449194
|
-
|
|
449195
|
-
const
|
|
449196
|
-
const recovered = wouldApply === "applies" && isStaleReadRecoverable(fullFilePath, toolUseContext);
|
|
449426
|
+
if (lastWriteTime > lastRead.timestamp) {
|
|
449427
|
+
if (!(isFullReadOfFileState(lastRead) && fileStateMatchesDisk(lastRead, fileContent))) {
|
|
449428
|
+
const wouldApply = checkEditWouldApply(fileContent, old_string, replace_all);
|
|
449429
|
+
const recovered = wouldApply === "applies" && wouldReadBeAutoAllowed(FILE_EDIT_TOOL_NAME, fullFilePath, toolUseContext, toolPermissionContext);
|
|
449197
449430
|
logEvent2("tengu_edit_tool_stale_read", {
|
|
449198
|
-
wouldHaveResult: wouldApply,
|
|
449431
|
+
wouldHaveResult: editWouldApplyToTelemetry(wouldApply),
|
|
449199
449432
|
recovered
|
|
449200
449433
|
});
|
|
449201
449434
|
if (!recovered) {
|
|
449202
449435
|
return {
|
|
449203
449436
|
result: false,
|
|
449204
449437
|
behavior: "ask",
|
|
449205
|
-
message:
|
|
449438
|
+
message: FILE_MODIFIED_SINCE_READ_VALIDATION_MESSAGE,
|
|
449206
449439
|
errorCode: 7
|
|
449207
449440
|
};
|
|
449208
449441
|
}
|
|
@@ -449212,13 +449445,15 @@ var init_FileEditTool = __esm(() => {
|
|
|
449212
449445
|
const file2 = fileContent;
|
|
449213
449446
|
const actualOldString = findActualString(file2, old_string);
|
|
449214
449447
|
if (!actualOldString) {
|
|
449448
|
+
const escapeNote = hasUnicodeEscapesOrNonAscii(old_string) ? `
|
|
449449
|
+
(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
449450
|
return {
|
|
449216
449451
|
result: false,
|
|
449217
449452
|
behavior: "ask",
|
|
449218
449453
|
message: `String to replace not found in file.
|
|
449219
|
-
String: ${old_string}`,
|
|
449454
|
+
String: ${old_string}${escapeNote}`,
|
|
449220
449455
|
meta: {
|
|
449221
|
-
isFilePathAbsolute: String(
|
|
449456
|
+
isFilePathAbsolute: String(isAbsolute23(file_path))
|
|
449222
449457
|
},
|
|
449223
449458
|
errorCode: 8
|
|
449224
449459
|
};
|
|
@@ -449231,7 +449466,7 @@ String: ${old_string}`,
|
|
|
449231
449466
|
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
449467
|
String: ${old_string}`,
|
|
449233
449468
|
meta: {
|
|
449234
|
-
isFilePathAbsolute: String(
|
|
449469
|
+
isFilePathAbsolute: String(isAbsolute23(file_path)),
|
|
449235
449470
|
actualOldString
|
|
449236
449471
|
},
|
|
449237
449472
|
errorCode: 9
|
|
@@ -449271,6 +449506,10 @@ String: ${old_string}`,
|
|
|
449271
449506
|
const { file_path, old_string, new_string, replace_all = false } = input;
|
|
449272
449507
|
const fs17 = getFsImplementation();
|
|
449273
449508
|
const absoluteFilePath = expandPath(file_path);
|
|
449509
|
+
const toolPermissionContext = toolUseContext.getAppState().toolPermissionContext;
|
|
449510
|
+
if (isCoveredByReadDenyRule(absoluteFilePath, toolPermissionContext)) {
|
|
449511
|
+
throw new FileStateError(READ_DENY_EDIT_MESSAGE);
|
|
449512
|
+
}
|
|
449274
449513
|
const cwd2 = getCwd();
|
|
449275
449514
|
if (!isEnvTruthy(process.env.CLAUDE_CODE_SIMPLE)) {
|
|
449276
449515
|
const newSkillDirs = await discoverSkillDirsForPaths([absoluteFilePath], cwd2);
|
|
@@ -449283,7 +449522,6 @@ String: ${old_string}`,
|
|
|
449283
449522
|
activateConditionalSkillsForPaths([absoluteFilePath], cwd2);
|
|
449284
449523
|
}
|
|
449285
449524
|
await diagnosticTracker.beforeFileEdited(absoluteFilePath);
|
|
449286
|
-
await fs17.mkdir(dirname40(absoluteFilePath));
|
|
449287
449525
|
if (fileHistoryEnabled()) {
|
|
449288
449526
|
await fileHistoryTrackEdit(updateFileHistoryState, absoluteFilePath, parentMessage.uuid);
|
|
449289
449527
|
}
|
|
@@ -449293,25 +449531,15 @@ String: ${old_string}`,
|
|
|
449293
449531
|
encoding,
|
|
449294
449532
|
lineEndings: endings
|
|
449295
449533
|
} = 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
|
-
}
|
|
449534
|
+
const staleRecovered = fileExists && checkEditFileStateAtCall({
|
|
449535
|
+
absoluteFilePath,
|
|
449536
|
+
fileContents: originalFileContents,
|
|
449537
|
+
lastRead: readFileState.get(absoluteFilePath),
|
|
449538
|
+
oldString: old_string,
|
|
449539
|
+
replaceAll: replace_all,
|
|
449540
|
+
model: getGuardModel(toolUseContext),
|
|
449541
|
+
readNotAutoAllowed: () => !wouldReadBeAutoAllowed(FILE_EDIT_TOOL_NAME, absoluteFilePath, toolUseContext, toolPermissionContext)
|
|
449542
|
+
});
|
|
449315
449543
|
const actualOldString = findActualString(originalFileContents, old_string) || old_string;
|
|
449316
449544
|
const actualNewString = preserveQuoteStyle(old_string, actualOldString, new_string);
|
|
449317
449545
|
const { patch, updatedFile } = getPatchForEdit({
|
|
@@ -449321,6 +449549,7 @@ String: ${old_string}`,
|
|
|
449321
449549
|
newString: actualNewString,
|
|
449322
449550
|
replaceAll: replace_all
|
|
449323
449551
|
});
|
|
449552
|
+
await fs17.mkdir(dirname40(absoluteFilePath));
|
|
449324
449553
|
writeTextContent(absoluteFilePath, updatedFile, encoding, endings);
|
|
449325
449554
|
const lspManager = getLspServerManager();
|
|
449326
449555
|
if (lspManager) {
|
|
@@ -449336,7 +449565,7 @@ String: ${old_string}`,
|
|
|
449336
449565
|
}
|
|
449337
449566
|
notifyVscodeFileUpdated(absoluteFilePath, originalFileContents, updatedFile);
|
|
449338
449567
|
readFileState.set(absoluteFilePath, {
|
|
449339
|
-
content: updatedFile,
|
|
449568
|
+
content: stripBom(updatedFile),
|
|
449340
449569
|
timestamp: getFileModificationTime(absoluteFilePath),
|
|
449341
449570
|
offset: undefined,
|
|
449342
449571
|
limit: undefined
|
|
@@ -449356,7 +449585,7 @@ String: ${old_string}`,
|
|
|
449356
449585
|
replaceAll: replace_all
|
|
449357
449586
|
});
|
|
449358
449587
|
let gitDiff;
|
|
449359
|
-
if (isEnvTruthy(process.env.CLAUDE_CODE_REMOTE)
|
|
449588
|
+
if (isEnvTruthy(process.env.CLAUDE_CODE_REMOTE)) {
|
|
449360
449589
|
const startTime2 = Date.now();
|
|
449361
449590
|
const diff2 = await fetchSingleFileGitDiff(absoluteFilePath);
|
|
449362
449591
|
if (diff2)
|
|
@@ -449375,6 +449604,7 @@ String: ${old_string}`,
|
|
|
449375
449604
|
structuredPatch: patch,
|
|
449376
449605
|
userModified: userModified ?? false,
|
|
449377
449606
|
replaceAll: replace_all,
|
|
449607
|
+
...staleRecovered && { staleRecovered: true },
|
|
449378
449608
|
...gitDiff && { gitDiff }
|
|
449379
449609
|
};
|
|
449380
449610
|
return {
|
|
@@ -449382,19 +449612,20 @@ String: ${old_string}`,
|
|
|
449382
449612
|
};
|
|
449383
449613
|
},
|
|
449384
449614
|
mapToolResultToToolResultBlockParam(data, toolUseID) {
|
|
449385
|
-
const { filePath, userModified, replaceAll: replaceAll2 } = data;
|
|
449615
|
+
const { filePath, userModified, replaceAll: replaceAll2, staleRecovered } = data;
|
|
449386
449616
|
const modifiedNote = userModified ? ". The user modified your proposed changes before accepting them. " : "";
|
|
449617
|
+
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
449618
|
if (replaceAll2) {
|
|
449388
449619
|
return {
|
|
449389
449620
|
tool_use_id: toolUseID,
|
|
449390
449621
|
type: "tool_result",
|
|
449391
|
-
content: `The file ${filePath} has been updated${modifiedNote}. All occurrences were successfully replaced
|
|
449622
|
+
content: `The file ${filePath} has been updated${modifiedNote}. All occurrences were successfully replaced.${trailingNote}`
|
|
449392
449623
|
};
|
|
449393
449624
|
}
|
|
449394
449625
|
return {
|
|
449395
449626
|
tool_use_id: toolUseID,
|
|
449396
449627
|
type: "tool_result",
|
|
449397
|
-
content: `The file ${filePath} has been updated successfully${modifiedNote}
|
|
449628
|
+
content: `The file ${filePath} has been updated successfully${modifiedNote}.${trailingNote}`
|
|
449398
449629
|
};
|
|
449399
449630
|
}
|
|
449400
449631
|
});
|
|
@@ -449652,7 +449883,7 @@ var init_UI7 = __esm(() => {
|
|
|
449652
449883
|
});
|
|
449653
449884
|
|
|
449654
449885
|
// src/tools/NotebookEditTool/NotebookEditTool.ts
|
|
449655
|
-
import { extname as
|
|
449886
|
+
import { extname as extname14, isAbsolute as isAbsolute24, resolve as resolve36 } from "path";
|
|
449656
449887
|
var inputSchema10, outputSchema10, NotebookEditTool;
|
|
449657
449888
|
var init_NotebookEditTool = __esm(() => {
|
|
449658
449889
|
init_featureFlags();
|
|
@@ -449768,11 +449999,11 @@ var init_NotebookEditTool = __esm(() => {
|
|
|
449768
449999
|
renderToolUseErrorMessage: renderToolUseErrorMessage7,
|
|
449769
450000
|
renderToolResultMessage: renderToolResultMessage6,
|
|
449770
450001
|
async validateInput({ notebook_path, cell_type, cell_id, edit_mode = "replace" }, toolUseContext) {
|
|
449771
|
-
const fullPath =
|
|
450002
|
+
const fullPath = isAbsolute24(notebook_path) ? notebook_path : resolve36(getCwd(), notebook_path);
|
|
449772
450003
|
if (fullPath.startsWith("\\\\") || fullPath.startsWith("//")) {
|
|
449773
450004
|
return { result: true };
|
|
449774
450005
|
}
|
|
449775
|
-
if (
|
|
450006
|
+
if (extname14(fullPath) !== ".ipynb") {
|
|
449776
450007
|
return {
|
|
449777
450008
|
result: false,
|
|
449778
450009
|
message: "File must be a Jupyter notebook (.ipynb file). For editing other file types, use the FileEdit tool.",
|
|
@@ -449879,7 +450110,7 @@ var init_NotebookEditTool = __esm(() => {
|
|
|
449879
450110
|
cell_type,
|
|
449880
450111
|
edit_mode: originalEditMode
|
|
449881
450112
|
}, { readFileState, updateFileHistoryState }, _2, parentMessage) {
|
|
449882
|
-
const fullPath =
|
|
450113
|
+
const fullPath = isAbsolute24(notebook_path) ? notebook_path : resolve36(getCwd(), notebook_path);
|
|
449883
450114
|
if (fileHistoryEnabled()) {
|
|
449884
450115
|
await fileHistoryTrackEdit(updateFileHistoryState, fullPath, parentMessage.uuid);
|
|
449885
450116
|
}
|
|
@@ -464769,7 +465000,7 @@ var init_UserImageMessage = __esm(() => {
|
|
|
464769
465000
|
});
|
|
464770
465001
|
|
|
464771
465002
|
// src/components/messages/AttachmentMessage.tsx
|
|
464772
|
-
import { basename as
|
|
465003
|
+
import { basename as basename24, sep as sep28 } from "path";
|
|
464773
465004
|
function AttachmentMessage({
|
|
464774
465005
|
attachment,
|
|
464775
465006
|
addMargin,
|
|
@@ -465025,7 +465256,7 @@ function AttachmentMessage({
|
|
|
465025
465256
|
dimColor: true,
|
|
465026
465257
|
children: /* @__PURE__ */ jsx_runtime111.jsx(FilePathLink, {
|
|
465027
465258
|
filePath: m5.path,
|
|
465028
|
-
children:
|
|
465259
|
+
children: basename24(m5.path)
|
|
465029
465260
|
})
|
|
465030
465261
|
})
|
|
465031
465262
|
}),
|
|
@@ -465932,7 +466163,7 @@ var init_teamMemCollapsed = __esm(() => {
|
|
|
465932
466163
|
});
|
|
465933
466164
|
|
|
465934
466165
|
// src/components/messages/CollapsedReadSearchContent.tsx
|
|
465935
|
-
import { basename as
|
|
466166
|
+
import { basename as basename25 } from "path";
|
|
465936
466167
|
function VerboseToolUse(t0) {
|
|
465937
466168
|
const $3 = import_compiler_runtime98.c(24);
|
|
465938
466169
|
const {
|
|
@@ -466193,7 +466424,7 @@ function CollapsedReadSearchContent({
|
|
|
466193
466424
|
children: [
|
|
466194
466425
|
" \u23BF ",
|
|
466195
466426
|
"Recalled ",
|
|
466196
|
-
|
|
466427
|
+
basename25(m5.path)
|
|
466197
466428
|
]
|
|
466198
466429
|
}),
|
|
466199
466430
|
/* @__PURE__ */ jsx_runtime116.jsx(ThemedBox_default, {
|
|
@@ -466936,7 +467167,7 @@ function teamMemSavedPart(message) {
|
|
|
466936
467167
|
}
|
|
466937
467168
|
|
|
466938
467169
|
// src/components/messages/SystemTextMessage.tsx
|
|
466939
|
-
import { basename as
|
|
467170
|
+
import { basename as basename26 } from "path";
|
|
466940
467171
|
function SystemTextMessage(t0) {
|
|
466941
467172
|
const $3 = import_compiler_runtime101.c(51);
|
|
466942
467173
|
const {
|
|
@@ -467861,7 +468092,7 @@ function MemoryFileRow(t0) {
|
|
|
467861
468092
|
const t4 = !hover;
|
|
467862
468093
|
let t5;
|
|
467863
468094
|
if ($3[4] !== path21) {
|
|
467864
|
-
t5 =
|
|
468095
|
+
t5 = basename26(path21);
|
|
467865
468096
|
$3[4] = path21;
|
|
467866
468097
|
$3[5] = t5;
|
|
467867
468098
|
} else {
|
|
@@ -541639,7 +541870,7 @@ var require_util13 = __commonJS((exports) => {
|
|
|
541639
541870
|
}
|
|
541640
541871
|
path22 = url3.path;
|
|
541641
541872
|
}
|
|
541642
|
-
var
|
|
541873
|
+
var isAbsolute25 = exports.isAbsolute(path22);
|
|
541643
541874
|
var parts = path22.split(/\/+/);
|
|
541644
541875
|
for (var part, up = 0, i6 = parts.length - 1;i6 >= 0; i6--) {
|
|
541645
541876
|
part = parts[i6];
|
|
@@ -541659,7 +541890,7 @@ var require_util13 = __commonJS((exports) => {
|
|
|
541659
541890
|
}
|
|
541660
541891
|
path22 = parts.join("/");
|
|
541661
541892
|
if (path22 === "") {
|
|
541662
|
-
path22 =
|
|
541893
|
+
path22 = isAbsolute25 ? "/" : ".";
|
|
541663
541894
|
}
|
|
541664
541895
|
if (url3) {
|
|
541665
541896
|
url3.path = path22;
|
|
@@ -566514,7 +566745,7 @@ import { notStrictEqual, strictEqual } from "assert";
|
|
|
566514
566745
|
import { inspect as inspect5 } from "util";
|
|
566515
566746
|
import { readFileSync as readFileSync24 } from "fs";
|
|
566516
566747
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
566517
|
-
import { basename as
|
|
566748
|
+
import { basename as basename28, dirname as dirname44, extname as extname15, relative as relative19, resolve as resolve41 } from "path";
|
|
566518
566749
|
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
566750
|
var init_esm26 = __esm(() => {
|
|
566520
566751
|
init_cliui();
|
|
@@ -566546,9 +566777,9 @@ var init_esm26 = __esm(() => {
|
|
|
566546
566777
|
mainFilename: mainFilename || process.cwd(),
|
|
566547
566778
|
Parser: lib_default,
|
|
566548
566779
|
path: {
|
|
566549
|
-
basename:
|
|
566780
|
+
basename: basename28,
|
|
566550
566781
|
dirname: dirname44,
|
|
566551
|
-
extname:
|
|
566782
|
+
extname: extname15,
|
|
566552
566783
|
relative: relative19,
|
|
566553
566784
|
resolve: resolve41
|
|
566554
566785
|
},
|
|
@@ -572082,7 +572313,7 @@ var init_WebBrowserTool = __esm(() => {
|
|
|
572082
572313
|
|
|
572083
572314
|
// src/utils/listSessionsImpl.ts
|
|
572084
572315
|
import { readdir as readdir20, stat as stat32 } from "fs/promises";
|
|
572085
|
-
import { basename as
|
|
572316
|
+
import { basename as basename29, join as join104 } from "path";
|
|
572086
572317
|
async function listCandidates(projectDir, doStat, projectPath) {
|
|
572087
572318
|
let names;
|
|
572088
572319
|
try {
|
|
@@ -572811,9 +573042,9 @@ __export(exports_upload, {
|
|
|
572811
573042
|
});
|
|
572812
573043
|
import { randomUUID as randomUUID21 } from "crypto";
|
|
572813
573044
|
import { readFile as readFile37 } from "fs/promises";
|
|
572814
|
-
import { basename as
|
|
573045
|
+
import { basename as basename30, extname as extname16 } from "path";
|
|
572815
573046
|
function guessMimeType(filename) {
|
|
572816
|
-
const ext =
|
|
573047
|
+
const ext = extname16(filename).toLowerCase();
|
|
572817
573048
|
return MIME_BY_EXT[ext] ?? "application/octet-stream";
|
|
572818
573049
|
}
|
|
572819
573050
|
function debug8(msg) {
|
|
@@ -572844,7 +573075,7 @@ async function uploadBriefAttachment(fullPath, size, ctx) {
|
|
|
572844
573075
|
}
|
|
572845
573076
|
const baseUrl = getBridgeBaseUrl2();
|
|
572846
573077
|
const url3 = `${baseUrl}/api/oauth/file_upload`;
|
|
572847
|
-
const filename =
|
|
573078
|
+
const filename = basename30(fullPath);
|
|
572848
573079
|
const mimeType = guessMimeType(filename);
|
|
572849
573080
|
const boundary = `----FormBoundary${randomUUID21()}`;
|
|
572850
573081
|
const body = Buffer.concat([
|
|
@@ -578420,7 +578651,7 @@ var init_UI21 = __esm(() => {
|
|
|
578420
578651
|
|
|
578421
578652
|
// src/tools/EnterWorktreeTool/EnterWorktreeTool.ts
|
|
578422
578653
|
import { realpath as realpath13 } from "fs/promises";
|
|
578423
|
-
import { basename as
|
|
578654
|
+
import { basename as basename31, resolve as resolve42, sep as sep31 } from "path";
|
|
578424
578655
|
async function listRegisteredWorktreePaths(gitRoot) {
|
|
578425
578656
|
const result = await execFileNoThrowWithCwd(gitExe(), ["worktree", "list", "--porcelain"], { cwd: gitRoot });
|
|
578426
578657
|
if (result.code !== 0) {
|
|
@@ -578468,7 +578699,7 @@ async function enterExistingWorktree(worktreePathInput) {
|
|
|
578468
578699
|
const session = {
|
|
578469
578700
|
originalCwd,
|
|
578470
578701
|
worktreePath: realResolved,
|
|
578471
|
-
worktreeName:
|
|
578702
|
+
worktreeName: basename31(realResolved),
|
|
578472
578703
|
worktreeBranch,
|
|
578473
578704
|
sessionId: getSessionId()
|
|
578474
578705
|
};
|
|
@@ -583688,7 +583919,7 @@ __export(exports_scriptLoader, {
|
|
|
583688
583919
|
WorkflowScriptError: () => WorkflowScriptError
|
|
583689
583920
|
});
|
|
583690
583921
|
import { readFileSync as readFileSync26 } from "fs";
|
|
583691
|
-
import { isAbsolute as
|
|
583922
|
+
import { isAbsolute as isAbsolute26, resolve as resolve43 } from "path";
|
|
583692
583923
|
import vm from "vm";
|
|
583693
583924
|
function validateScriptPath(scriptPath) {
|
|
583694
583925
|
if (!scriptPath || typeof scriptPath !== "string") {
|
|
@@ -583697,7 +583928,7 @@ function validateScriptPath(scriptPath) {
|
|
|
583697
583928
|
if (/^\\\\/.test(scriptPath)) {
|
|
583698
583929
|
throw new WorkflowScriptError(`UNC paths are not allowed for workflow scriptPath: ${scriptPath}`);
|
|
583699
583930
|
}
|
|
583700
|
-
const resolved =
|
|
583931
|
+
const resolved = isAbsolute26(scriptPath) ? scriptPath : resolve43(scriptPath);
|
|
583701
583932
|
return resolved;
|
|
583702
583933
|
}
|
|
583703
583934
|
function findMetaEnd(source2, openBraceIndex) {
|
|
@@ -585474,8 +585705,8 @@ function extractBaseCommand2(segment2) {
|
|
|
585474
585705
|
const stripped = segment2.trim().replace(/^[&.]\s+/, "");
|
|
585475
585706
|
const firstToken = stripped.split(/\s+/)[0] || "";
|
|
585476
585707
|
const unquoted = firstToken.replace(/^["']|["']$/g, "");
|
|
585477
|
-
const
|
|
585478
|
-
return
|
|
585708
|
+
const basename32 = unquoted.split(/[\\/]/).pop() || unquoted;
|
|
585709
|
+
return basename32.toLowerCase().replace(/\.exe$/, "");
|
|
585479
585710
|
}
|
|
585480
585711
|
function heuristicallyExtractBaseCommand2(command5) {
|
|
585481
585712
|
const segments = command5.split(/[;|]/).filter((s4) => s4.trim());
|
|
@@ -586420,11 +586651,11 @@ var init_parser6 = __esm(() => {
|
|
|
586420
586651
|
});
|
|
586421
586652
|
|
|
586422
586653
|
// src/tools/PowerShellTool/gitSafety.ts
|
|
586423
|
-
import { basename as
|
|
586654
|
+
import { basename as basename32, posix as posix7, resolve as resolve44, sep as sep33 } from "path";
|
|
586424
586655
|
function resolveCwdReentry(normalized) {
|
|
586425
586656
|
if (!normalized.startsWith("../"))
|
|
586426
586657
|
return normalized;
|
|
586427
|
-
const cwdBase =
|
|
586658
|
+
const cwdBase = basename32(getCwd()).toLowerCase();
|
|
586428
586659
|
if (!cwdBase)
|
|
586429
586660
|
return normalized;
|
|
586430
586661
|
const prefix = "../" + cwdBase + "/";
|
|
@@ -587738,7 +587969,7 @@ var init_modeValidation2 = __esm(() => {
|
|
|
587738
587969
|
|
|
587739
587970
|
// src/tools/PowerShellTool/pathValidation.ts
|
|
587740
587971
|
import { homedir as homedir32 } from "os";
|
|
587741
|
-
import { isAbsolute as
|
|
587972
|
+
import { isAbsolute as isAbsolute27, resolve as resolve45 } from "path";
|
|
587742
587973
|
function matchesParam(paramLower, paramList) {
|
|
587743
587974
|
for (const p4 of paramList) {
|
|
587744
587975
|
if (p4 === paramLower || paramLower.length > 1 && p4.startsWith(paramLower)) {
|
|
@@ -587846,7 +588077,7 @@ function checkDenyRuleForGuessedPath(strippedPath, cwd2, toolPermissionContext,
|
|
|
587846
588077
|
if (!strippedPath || strippedPath.includes("\x00"))
|
|
587847
588078
|
return null;
|
|
587848
588079
|
const tildeExpanded = expandTilde2(strippedPath);
|
|
587849
|
-
const abs =
|
|
588080
|
+
const abs = isAbsolute27(tildeExpanded) ? tildeExpanded : resolve45(cwd2, tildeExpanded);
|
|
587850
588081
|
const { resolvedPath } = safeResolvePath(getFsImplementation(), abs);
|
|
587851
588082
|
const permissionType = operationType === "read" ? "read" : "edit";
|
|
587852
588083
|
const denyRule = matchingRuleForInput(resolvedPath, toolPermissionContext, permissionType, "deny");
|
|
@@ -587936,7 +588167,7 @@ function validatePath2(filePath, cwd2, toolPermissionContext, operationType) {
|
|
|
587936
588167
|
};
|
|
587937
588168
|
}
|
|
587938
588169
|
if (containsPathTraversal(normalizedPath)) {
|
|
587939
|
-
const absolutePath2 =
|
|
588170
|
+
const absolutePath2 = isAbsolute27(normalizedPath) ? normalizedPath : resolve45(cwd2, normalizedPath);
|
|
587940
588171
|
const { resolvedPath: resolvedPath3, isCanonical: isCanonical2 } = safeResolvePath(getFsImplementation(), absolutePath2);
|
|
587941
588172
|
const result2 = isPathAllowed2(resolvedPath3, toolPermissionContext, operationType, isCanonical2 ? [resolvedPath3] : undefined);
|
|
587942
588173
|
return {
|
|
@@ -587946,7 +588177,7 @@ function validatePath2(filePath, cwd2, toolPermissionContext, operationType) {
|
|
|
587946
588177
|
};
|
|
587947
588178
|
}
|
|
587948
588179
|
const basePath = getGlobBaseDirectory2(normalizedPath);
|
|
587949
|
-
const absoluteBasePath =
|
|
588180
|
+
const absoluteBasePath = isAbsolute27(basePath) ? basePath : resolve45(cwd2, basePath);
|
|
587950
588181
|
const { resolvedPath: resolvedPath2 } = safeResolvePath(getFsImplementation(), absoluteBasePath);
|
|
587951
588182
|
const permissionType = operationType === "read" ? "read" : "edit";
|
|
587952
588183
|
const denyRule = matchingRuleForInput(resolvedPath2, toolPermissionContext, permissionType, "deny");
|
|
@@ -587966,7 +588197,7 @@ function validatePath2(filePath, cwd2, toolPermissionContext, operationType) {
|
|
|
587966
588197
|
}
|
|
587967
588198
|
};
|
|
587968
588199
|
}
|
|
587969
|
-
const absolutePath =
|
|
588200
|
+
const absolutePath = isAbsolute27(normalizedPath) ? normalizedPath : resolve45(cwd2, normalizedPath);
|
|
587970
588201
|
const { resolvedPath, isCanonical } = safeResolvePath(getFsImplementation(), absolutePath);
|
|
587971
588202
|
const result = isPathAllowed2(resolvedPath, toolPermissionContext, operationType, isCanonical ? [resolvedPath] : undefined);
|
|
587972
588203
|
return {
|
|
@@ -594416,11 +594647,11 @@ var init_memoryTypes = __esm(() => {
|
|
|
594416
594647
|
|
|
594417
594648
|
// src/memdir/memoryScan.ts
|
|
594418
594649
|
import { readdir as readdir22 } from "fs/promises";
|
|
594419
|
-
import { basename as
|
|
594650
|
+
import { basename as basename33, join as join111 } from "path";
|
|
594420
594651
|
async function scanMemoryFiles(memoryDir, signal) {
|
|
594421
594652
|
try {
|
|
594422
594653
|
const entries = await readdir22(memoryDir, { recursive: true });
|
|
594423
|
-
const mdFiles = entries.filter((f4) => f4.endsWith(".md") &&
|
|
594654
|
+
const mdFiles = entries.filter((f4) => f4.endsWith(".md") && basename33(f4) !== "MEMORY.md");
|
|
594424
594655
|
const headerResults = await Promise.allSettled(mdFiles.map(async (relativePath) => {
|
|
594425
594656
|
const filePath = join111(memoryDir, relativePath);
|
|
594426
594657
|
const { content, mtimeMs } = await readFileInRange(filePath, 0, FRONTMATTER_MAX_LINES, undefined, signal);
|
|
@@ -594571,7 +594802,7 @@ __export(exports_extractMemories, {
|
|
|
594571
594802
|
drainPendingExtraction: () => drainPendingExtraction,
|
|
594572
594803
|
createAutoMemCanUseTool: () => createAutoMemCanUseTool
|
|
594573
594804
|
});
|
|
594574
|
-
import { basename as
|
|
594805
|
+
import { basename as basename34 } from "path";
|
|
594575
594806
|
function isModelVisibleMessage(message) {
|
|
594576
594807
|
return message.type === "user" || message.type === "assistant";
|
|
594577
594808
|
}
|
|
@@ -594753,7 +594984,7 @@ function initExtractMemories() {
|
|
|
594753
594984
|
} else {
|
|
594754
594985
|
logForDebugging("[extractMemories] no memories saved this run");
|
|
594755
594986
|
}
|
|
594756
|
-
const memoryPaths = writtenPaths.filter((p4) =>
|
|
594987
|
+
const memoryPaths = writtenPaths.filter((p4) => basename34(p4) !== ENTRYPOINT_NAME);
|
|
594757
594988
|
const teamCount = feature("TEAMMEM") ? count2(memoryPaths, teamMemPaths5.isTeamMemPath) : 0;
|
|
594758
594989
|
logEvent2("tengu_extract_memories_extraction", {
|
|
594759
594990
|
input_tokens: result.totalUsage.input_tokens,
|
|
@@ -599296,7 +599527,7 @@ var init_queryHelpers = __esm(() => {
|
|
|
599296
599527
|
import { randomUUID as randomUUID27 } from "crypto";
|
|
599297
599528
|
import { rm as rm7 } from "fs";
|
|
599298
599529
|
import { appendFile as appendFile5, copyFile as copyFile7, mkdir as mkdir34 } from "fs/promises";
|
|
599299
|
-
import { dirname as dirname47, isAbsolute as
|
|
599530
|
+
import { dirname as dirname47, isAbsolute as isAbsolute28, join as join114, relative as relative22 } from "path";
|
|
599300
599531
|
function safeRemoveOverlay(overlayPath) {
|
|
599301
599532
|
rm7(overlayPath, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }, () => {});
|
|
599302
599533
|
}
|
|
@@ -599548,7 +599779,7 @@ async function startSpeculation(suggestionText, context7, setAppState, isPipelin
|
|
|
599548
599779
|
const filePath = input2[pathKey2];
|
|
599549
599780
|
if (filePath) {
|
|
599550
599781
|
const rel = relative22(cwd2, filePath);
|
|
599551
|
-
if (
|
|
599782
|
+
if (isAbsolute28(rel) || rel.startsWith("..")) {
|
|
599552
599783
|
if (isWriteTool) {
|
|
599553
599784
|
logForDebugging(`[Speculation] Denied ${tool.name}: path outside cwd: ${filePath}`);
|
|
599554
599785
|
return denySpeculation("Write outside cwd not allowed during speculation", "speculation_write_outside_root");
|
|
@@ -606608,9 +606839,9 @@ var builders = null;
|
|
|
606608
606839
|
import { createHash as createHash26 } from "crypto";
|
|
606609
606840
|
import { realpath as realpath14 } from "fs/promises";
|
|
606610
606841
|
import {
|
|
606611
|
-
basename as
|
|
606842
|
+
basename as basename35,
|
|
606612
606843
|
dirname as dirname50,
|
|
606613
|
-
isAbsolute as
|
|
606844
|
+
isAbsolute as isAbsolute29,
|
|
606614
606845
|
join as join117,
|
|
606615
606846
|
sep as pathSep,
|
|
606616
606847
|
relative as relative24
|
|
@@ -606928,7 +607159,7 @@ async function loadSkillsFromSkillsDir(basePath, source2) {
|
|
|
606928
607159
|
return results.filter((r4) => r4 !== null);
|
|
606929
607160
|
}
|
|
606930
607161
|
function isSkillFile(filePath) {
|
|
606931
|
-
return /^skill\.md$/i.test(
|
|
607162
|
+
return /^skill\.md$/i.test(basename35(filePath));
|
|
606932
607163
|
}
|
|
606933
607164
|
function transformSkillFiles(files2) {
|
|
606934
607165
|
const filesByDir = new Map;
|
|
@@ -606944,7 +607175,7 @@ function transformSkillFiles(files2) {
|
|
|
606944
607175
|
if (skillFiles.length > 0) {
|
|
606945
607176
|
const skillFile = skillFiles[0];
|
|
606946
607177
|
if (skillFiles.length > 1) {
|
|
606947
|
-
logForDebugging(`Multiple skill files found in ${dir}, using ${
|
|
607178
|
+
logForDebugging(`Multiple skill files found in ${dir}, using ${basename35(skillFile.filePath)}`);
|
|
606948
607179
|
}
|
|
606949
607180
|
result.push(skillFile);
|
|
606950
607181
|
} else {
|
|
@@ -606964,12 +607195,12 @@ function buildNamespace(targetDir, baseDir) {
|
|
|
606964
607195
|
function getSkillCommandName(filePath, baseDir) {
|
|
606965
607196
|
const skillDirectory = dirname50(filePath);
|
|
606966
607197
|
const parentOfSkillDir = dirname50(skillDirectory);
|
|
606967
|
-
const commandBaseName =
|
|
607198
|
+
const commandBaseName = basename35(skillDirectory);
|
|
606968
607199
|
const namespace = buildNamespace(parentOfSkillDir, baseDir);
|
|
606969
607200
|
return namespace ? `${namespace}:${commandBaseName}` : commandBaseName;
|
|
606970
607201
|
}
|
|
606971
607202
|
function getRegularCommandName(filePath, baseDir) {
|
|
606972
|
-
const fileName =
|
|
607203
|
+
const fileName = basename35(filePath);
|
|
606973
607204
|
const fileDirectory = dirname50(filePath);
|
|
606974
607205
|
const commandBaseName = fileName.replace(/\.md$/, "");
|
|
606975
607206
|
const namespace = buildNamespace(fileDirectory, baseDir);
|
|
@@ -607121,8 +607352,8 @@ function activateConditionalSkillsForPaths(filePaths, cwd2) {
|
|
|
607121
607352
|
}
|
|
607122
607353
|
const skillIgnore = import_ignore4.default().add(filterValidIgnorePatterns(skill.paths, "skill_paths"));
|
|
607123
607354
|
for (const filePath of filePaths) {
|
|
607124
|
-
const relativePath =
|
|
607125
|
-
if (!relativePath || relativePath.startsWith("..") ||
|
|
607355
|
+
const relativePath = isAbsolute29(filePath) ? relative24(cwd2, filePath) : filePath;
|
|
607356
|
+
if (!relativePath || relativePath.startsWith("..") || isAbsolute29(relativePath)) {
|
|
607126
607357
|
continue;
|
|
607127
607358
|
}
|
|
607128
607359
|
if (skillIgnore.ignores(relativePath)) {
|
|
@@ -607456,9 +607687,9 @@ Important:
|
|
|
607456
607687
|
});
|
|
607457
607688
|
|
|
607458
607689
|
// src/utils/plugins/loadPluginCommands.ts
|
|
607459
|
-
import { basename as
|
|
607690
|
+
import { basename as basename36, dirname as dirname51, join as join118 } from "path";
|
|
607460
607691
|
function isSkillFile2(filePath) {
|
|
607461
|
-
return /^skill\.md$/i.test(
|
|
607692
|
+
return /^skill\.md$/i.test(basename36(filePath));
|
|
607462
607693
|
}
|
|
607463
607694
|
function pluginSkillUserFacingName(commandName, _displayName) {
|
|
607464
607695
|
return commandName;
|
|
@@ -607468,13 +607699,13 @@ function getCommandNameFromFile(filePath, baseDir, pluginName) {
|
|
|
607468
607699
|
if (isSkill) {
|
|
607469
607700
|
const skillDirectory = dirname51(filePath);
|
|
607470
607701
|
const parentOfSkillDir = dirname51(skillDirectory);
|
|
607471
|
-
const commandBaseName =
|
|
607702
|
+
const commandBaseName = basename36(skillDirectory);
|
|
607472
607703
|
const relativePath = parentOfSkillDir.startsWith(baseDir) ? parentOfSkillDir.slice(baseDir.length).replace(/^\//, "") : "";
|
|
607473
607704
|
const namespace = relativePath ? relativePath.split("/").join(":") : "";
|
|
607474
607705
|
return namespace ? `${pluginName}:${namespace}:${commandBaseName}` : `${pluginName}:${commandBaseName}`;
|
|
607475
607706
|
} else {
|
|
607476
607707
|
const fileDirectory = dirname51(filePath);
|
|
607477
|
-
const commandBaseName =
|
|
607708
|
+
const commandBaseName = basename36(filePath).replace(/\.md$/, "");
|
|
607478
607709
|
const relativePath = fileDirectory.startsWith(baseDir) ? fileDirectory.slice(baseDir.length).replace(/^\//, "") : "";
|
|
607479
607710
|
const namespace = relativePath ? relativePath.split("/").join(":") : "";
|
|
607480
607711
|
return namespace ? `${pluginName}:${namespace}:${commandBaseName}` : `${pluginName}:${commandBaseName}`;
|
|
@@ -607511,7 +607742,7 @@ function transformPluginSkillFiles(files2) {
|
|
|
607511
607742
|
if (skillFiles.length > 0) {
|
|
607512
607743
|
const skillFile = skillFiles[0];
|
|
607513
607744
|
if (skillFiles.length > 1) {
|
|
607514
|
-
logForDebugging(`Multiple skill files found in ${dir}, using ${
|
|
607745
|
+
logForDebugging(`Multiple skill files found in ${dir}, using ${basename36(skillFile.filePath)}`);
|
|
607515
607746
|
}
|
|
607516
607747
|
result.push(skillFile);
|
|
607517
607748
|
} else {
|
|
@@ -607662,7 +607893,7 @@ async function loadSkillsFromDirectory(skillsPath, pluginName, sourceName, plugi
|
|
|
607662
607893
|
}
|
|
607663
607894
|
try {
|
|
607664
607895
|
const { frontmatter, content: markdownContent } = parseFrontmatter(directSkillContent, directSkillPath);
|
|
607665
|
-
const skillName = `${pluginName}:${
|
|
607896
|
+
const skillName = `${pluginName}:${basename36(skillsPath)}`;
|
|
607666
607897
|
const file2 = {
|
|
607667
607898
|
filePath: directSkillPath,
|
|
607668
607899
|
baseDir: dirname51(directSkillPath),
|
|
@@ -607808,7 +608039,7 @@ var init_loadPluginCommands = __esm(() => {
|
|
|
607808
608039
|
}
|
|
607809
608040
|
}
|
|
607810
608041
|
if (!commandName) {
|
|
607811
|
-
commandName = `${plugin.name}:${
|
|
608042
|
+
commandName = `${plugin.name}:${basename36(commandPath).replace(/\.md$/, "")}`;
|
|
607812
608043
|
}
|
|
607813
608044
|
const finalFrontmatter = metadataOverride ? {
|
|
607814
608045
|
...frontmatter,
|
|
@@ -607952,7 +608183,7 @@ import {
|
|
|
607952
608183
|
writeFile as writeFile36
|
|
607953
608184
|
} from "fs/promises";
|
|
607954
608185
|
import { tmpdir as tmpdir12 } from "os";
|
|
607955
|
-
import { basename as
|
|
608186
|
+
import { basename as basename37, dirname as dirname52, join as join119 } from "path";
|
|
607956
608187
|
function isPluginZipCacheEnabled() {
|
|
607957
608188
|
return isEnvTruthy(process.env.CLAUDE_CODE_PLUGIN_USE_ZIP_CACHE);
|
|
607958
608189
|
}
|
|
@@ -608017,7 +608248,7 @@ async function cleanupSessionPluginCache() {
|
|
|
608017
608248
|
async function atomicWriteToZipCache(targetPath, data) {
|
|
608018
608249
|
const dir = dirname52(targetPath);
|
|
608019
608250
|
await getFsImplementation().mkdir(dir);
|
|
608020
|
-
const tmpName = `.${
|
|
608251
|
+
const tmpName = `.${basename37(targetPath)}.tmp.${randomBytes10(4).toString("hex")}`;
|
|
608021
608252
|
const tmpPath = join119(dir, tmpName);
|
|
608022
608253
|
try {
|
|
608023
608254
|
if (typeof data === "string") {
|
|
@@ -608723,7 +608954,7 @@ var init_officialMarketplaceGcs = __esm(() => {
|
|
|
608723
608954
|
|
|
608724
608955
|
// src/utils/plugins/marketplaceManager.ts
|
|
608725
608956
|
import { writeFile as writeFile39 } from "fs/promises";
|
|
608726
|
-
import { basename as
|
|
608957
|
+
import { basename as basename38, dirname as dirname54, isAbsolute as isAbsolute30, join as join122, resolve as resolve50, sep as sep36 } from "path";
|
|
608727
608958
|
function getKnownMarketplacesFile() {
|
|
608728
608959
|
return join122(getPluginsDirectory(), "known_marketplaces.json");
|
|
608729
608960
|
}
|
|
@@ -609308,7 +609539,7 @@ Technical details: ${error52.message}`);
|
|
|
609308
609539
|
});
|
|
609309
609540
|
}
|
|
609310
609541
|
function getCachePathForSource(source2) {
|
|
609311
|
-
const tempName = source2.source === "github" ? source2.repo.replace("/", "-") : source2.source === "npm" ? source2.package.replace("@", "").replace("/", "-") : source2.source === "file" ?
|
|
609542
|
+
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
609543
|
return tempName;
|
|
609313
609544
|
}
|
|
609314
609545
|
async function parseFileWithSchema(filePath, schema) {
|
|
@@ -609481,7 +609712,7 @@ Technical details: ${errorMsg}`);
|
|
|
609481
609712
|
}
|
|
609482
609713
|
async function addMarketplaceSource(source2, onProgress) {
|
|
609483
609714
|
let resolvedSource = source2;
|
|
609484
|
-
if (isLocalMarketplaceSource(source2) && !
|
|
609715
|
+
if (isLocalMarketplaceSource(source2) && !isAbsolute30(source2.path)) {
|
|
609485
609716
|
resolvedSource = { ...source2, path: resolve50(source2.path) };
|
|
609486
609717
|
}
|
|
609487
609718
|
if (!isSourceAllowedByPolicy(resolvedSource)) {
|
|
@@ -609894,7 +610125,7 @@ var init_marketplaceManager = __esm(() => {
|
|
|
609894
610125
|
if (!entry) {
|
|
609895
610126
|
throw new Error(`Marketplace '${name3}' not found in configuration. Available marketplaces: ${Object.keys(config7).join(", ")}`);
|
|
609896
610127
|
}
|
|
609897
|
-
if (isLocalMarketplaceSource(entry.source) && !
|
|
610128
|
+
if (isLocalMarketplaceSource(entry.source) && !isAbsolute30(entry.source.path)) {
|
|
609898
610129
|
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
610130
|
}
|
|
609900
610131
|
try {
|
|
@@ -610744,7 +610975,7 @@ import {
|
|
|
610744
610975
|
stat as stat38,
|
|
610745
610976
|
symlink as symlink3
|
|
610746
610977
|
} from "fs/promises";
|
|
610747
|
-
import { basename as
|
|
610978
|
+
import { basename as basename39, dirname as dirname57, join as join125, relative as relative25, resolve as resolve52, sep as sep38 } from "path";
|
|
610748
610979
|
function getPluginCachePath() {
|
|
610749
610980
|
return join125(getPluginsDirectory(), "cache");
|
|
610750
610981
|
}
|
|
@@ -612109,7 +612340,7 @@ async function loadSessionOnlyPlugins(sessionPluginPaths) {
|
|
|
612109
612340
|
});
|
|
612110
612341
|
continue;
|
|
612111
612342
|
}
|
|
612112
|
-
const dirName =
|
|
612343
|
+
const dirName = basename39(resolvedPath);
|
|
612113
612344
|
const { plugin, errors: pluginErrors } = await createPluginFromPath(resolvedPath, `${dirName}@inline`, true, dirName);
|
|
612114
612345
|
plugin.source = `${plugin.name}@inline`;
|
|
612115
612346
|
plugin.repository = `${plugin.name}@inline`;
|
|
@@ -612284,7 +612515,7 @@ var init_pluginLoader = __esm(() => {
|
|
|
612284
612515
|
});
|
|
612285
612516
|
|
|
612286
612517
|
// src/utils/plugins/loadPluginOutputStyles.ts
|
|
612287
|
-
import { basename as
|
|
612518
|
+
import { basename as basename40 } from "path";
|
|
612288
612519
|
async function loadOutputStylesFromDirectory(outputStylesPath, pluginName, loadedPaths) {
|
|
612289
612520
|
const styles5 = [];
|
|
612290
612521
|
await walkPluginMarkdown(outputStylesPath, async (fullPath) => {
|
|
@@ -612302,7 +612533,7 @@ async function loadOutputStyleFromFile(filePath, pluginName, loadedPaths) {
|
|
|
612302
612533
|
try {
|
|
612303
612534
|
const content = await fs24.readFile(filePath, { encoding: "utf-8" });
|
|
612304
612535
|
const { frontmatter, content: markdownContent } = parseFrontmatter(content, filePath);
|
|
612305
|
-
const fileName =
|
|
612536
|
+
const fileName = basename40(filePath, ".md");
|
|
612306
612537
|
const baseStyleName = frontmatter.name || fileName;
|
|
612307
612538
|
const name3 = `${pluginName}:${baseStyleName}`;
|
|
612308
612539
|
const description = coerceDescriptionToString(frontmatter.description, name3) ?? extractDescriptionFromMarkdown(markdownContent, `Output style from ${pluginName} plugin`);
|
|
@@ -612383,7 +612614,7 @@ var init_loadPluginOutputStyles = __esm(() => {
|
|
|
612383
612614
|
});
|
|
612384
612615
|
|
|
612385
612616
|
// src/outputStyles/loadOutputStylesDir.ts
|
|
612386
|
-
import { basename as
|
|
612617
|
+
import { basename as basename41 } from "path";
|
|
612387
612618
|
var getOutputStyleDirStyles;
|
|
612388
612619
|
var init_loadOutputStylesDir = __esm(() => {
|
|
612389
612620
|
init_memoize();
|
|
@@ -612397,7 +612628,7 @@ var init_loadOutputStylesDir = __esm(() => {
|
|
|
612397
612628
|
const markdownFiles = await loadMarkdownFilesForSubdir("output-styles", cwd2);
|
|
612398
612629
|
const styles5 = markdownFiles.map(({ filePath, frontmatter, content, source: source2 }) => {
|
|
612399
612630
|
try {
|
|
612400
|
-
const fileName =
|
|
612631
|
+
const fileName = basename41(filePath);
|
|
612401
612632
|
const styleName = fileName.replace(/\.md$/, "");
|
|
612402
612633
|
const name3 = frontmatter["name"] || styleName;
|
|
612403
612634
|
const description = coerceDescriptionToString(frontmatter["description"], styleName) ?? extractDescriptionFromMarkdown(content, `Custom ${styleName} output style`);
|
|
@@ -637884,7 +638115,7 @@ var init_renderPlaceholder = __esm(() => {
|
|
|
637884
638115
|
});
|
|
637885
638116
|
|
|
637886
638117
|
// src/hooks/usePasteHandler.ts
|
|
637887
|
-
import { basename as
|
|
638118
|
+
import { basename as basename42 } from "path";
|
|
637888
638119
|
function usePasteHandler({
|
|
637889
638120
|
onPaste,
|
|
637890
638121
|
onInput,
|
|
@@ -637946,7 +638177,7 @@ function usePasteHandler({
|
|
|
637946
638177
|
const validImages = results.filter((r4) => r4 !== null);
|
|
637947
638178
|
if (validImages.length > 0) {
|
|
637948
638179
|
for (const imageData of validImages) {
|
|
637949
|
-
const filename =
|
|
638180
|
+
const filename = basename42(imageData.path);
|
|
637950
638181
|
onImagePaste2(imageData.base64, imageData.mediaType, filename, imageData.dimensions, imageData.path);
|
|
637951
638182
|
}
|
|
637952
638183
|
const nonImageLines = lines2.filter((line) => !isImageFilePath(line));
|
|
@@ -638555,7 +638786,7 @@ var init_TextInput = __esm(() => {
|
|
|
638555
638786
|
});
|
|
638556
638787
|
|
|
638557
638788
|
// src/utils/suggestions/directoryCompletion.ts
|
|
638558
|
-
import { basename as
|
|
638789
|
+
import { basename as basename43, dirname as dirname61, join as join134, sep as sep39 } from "path";
|
|
638559
638790
|
function parsePartialPath(partialPath, basePath) {
|
|
638560
638791
|
if (!partialPath) {
|
|
638561
638792
|
const directory2 = basePath || getCwd();
|
|
@@ -638566,7 +638797,7 @@ function parsePartialPath(partialPath, basePath) {
|
|
|
638566
638797
|
return { directory: resolved, prefix: "" };
|
|
638567
638798
|
}
|
|
638568
638799
|
const directory = dirname61(resolved);
|
|
638569
|
-
const prefix =
|
|
638800
|
+
const prefix = basename43(partialPath);
|
|
638570
638801
|
return { directory, prefix };
|
|
638571
638802
|
}
|
|
638572
638803
|
async function scanDirectory(dirPath) {
|
|
@@ -657535,12 +657766,12 @@ import {
|
|
|
657535
657766
|
spawn as spawn14,
|
|
657536
657767
|
spawnSync as spawnSync10
|
|
657537
657768
|
} from "child_process";
|
|
657538
|
-
import { basename as
|
|
657769
|
+
import { basename as basename44 } from "path";
|
|
657539
657770
|
function isCommandAvailable3(command7) {
|
|
657540
657771
|
return !!whichSync(command7);
|
|
657541
657772
|
}
|
|
657542
657773
|
function classifyGuiEditor(editor) {
|
|
657543
|
-
const base2 =
|
|
657774
|
+
const base2 = basename44(editor.split(" ")[0] ?? "");
|
|
657544
657775
|
return GUI_EDITORS.find((g5) => base2.includes(g5));
|
|
657545
657776
|
}
|
|
657546
657777
|
function guiGotoArgv(guiFamily, filePath, line) {
|
|
@@ -657577,7 +657808,7 @@ function openFileInExternalEditor(filePath, line) {
|
|
|
657577
657808
|
const inkInstance = instances_default.get(process.stdout);
|
|
657578
657809
|
if (!inkInstance)
|
|
657579
657810
|
return false;
|
|
657580
|
-
const useGotoLine = line && PLUS_N_EDITORS.test(
|
|
657811
|
+
const useGotoLine = line && PLUS_N_EDITORS.test(basename44(base2));
|
|
657581
657812
|
inkInstance.enterAlternateScreen();
|
|
657582
657813
|
try {
|
|
657583
657814
|
const syncOpts = { stdio: "inherit" };
|
|
@@ -665172,7 +665403,7 @@ var clearSkillIndexCache = () => {};
|
|
|
665172
665403
|
var init_localSearch = () => {};
|
|
665173
665404
|
|
|
665174
665405
|
// src/services/mcp/useManageMCPConnections.ts
|
|
665175
|
-
import { basename as
|
|
665406
|
+
import { basename as basename45 } from "path";
|
|
665176
665407
|
function getErrorKey(error52) {
|
|
665177
665408
|
const plugin = "plugin" in error52 ? error52.plugin : "no-plugin";
|
|
665178
665409
|
return `${error52.type}:${error52.source}:${plugin}`;
|
|
@@ -665655,7 +665886,7 @@ function useManageMCPConnections(dynamicMcpConfig, isStrictMcpConfig = false) {
|
|
|
665655
665886
|
else if (serverConfig.scope === "claudeai")
|
|
665656
665887
|
counts.claudeai++;
|
|
665657
665888
|
if (process.env.USER_TYPE === "ant" && !isMcpServerDisabled(name3) && (serverConfig.type === undefined || serverConfig.type === "stdio") && "command" in serverConfig) {
|
|
665658
|
-
stdioCommands.push(
|
|
665889
|
+
stdioCommands.push(basename45(serverConfig.command));
|
|
665659
665890
|
}
|
|
665660
665891
|
}
|
|
665661
665892
|
logEvent2("tengu_mcp_servers", {
|
|
@@ -684902,12 +685133,12 @@ var init_OccMark = __esm(() => {
|
|
|
684902
685133
|
};
|
|
684903
685134
|
CHEVRON_TONES = {
|
|
684904
685135
|
dark: {
|
|
684905
|
-
base: [
|
|
684906
|
-
peak: [
|
|
685136
|
+
base: [79, 107, 184],
|
|
685137
|
+
peak: [120, 140, 217]
|
|
684907
685138
|
},
|
|
684908
685139
|
light: {
|
|
684909
|
-
base: [
|
|
684910
|
-
peak: [
|
|
685140
|
+
base: [59, 85, 196],
|
|
685141
|
+
peak: [92, 124, 250]
|
|
684911
685142
|
}
|
|
684912
685143
|
};
|
|
684913
685144
|
});
|
|
@@ -711951,7 +712182,7 @@ var init_advisor2 = __esm(() => {
|
|
|
711951
712182
|
// src/skills/bundledSkills.ts
|
|
711952
712183
|
import { constants as fsConstants7 } from "fs";
|
|
711953
712184
|
import { mkdir as mkdir49, open as open14 } from "fs/promises";
|
|
711954
|
-
import { dirname as dirname68, isAbsolute as
|
|
712185
|
+
import { dirname as dirname68, isAbsolute as isAbsolute31, join as join158, normalize as normalize16, sep as pathSep2 } from "path";
|
|
711955
712186
|
function registerBundledSkill(definition) {
|
|
711956
712187
|
const { files: files3 } = definition;
|
|
711957
712188
|
let skillRoot;
|
|
@@ -712040,7 +712271,7 @@ async function safeWriteFile(p4, content) {
|
|
|
712040
712271
|
}
|
|
712041
712272
|
function resolveSkillFilePath(baseDir, relPath) {
|
|
712042
712273
|
const normalized = normalize16(relPath);
|
|
712043
|
-
if (
|
|
712274
|
+
if (isAbsolute31(normalized) || normalized.split(pathSep2).includes("..") || normalized.split("/").includes("..")) {
|
|
712044
712275
|
throw new Error(`bundled skill file path escapes skill dir: ${relPath}`);
|
|
712045
712276
|
}
|
|
712046
712277
|
return join158(baseDir, normalized);
|
|
@@ -715518,12 +715749,12 @@ var init_remoteControlServer2 = __esm(() => {
|
|
|
715518
715749
|
});
|
|
715519
715750
|
|
|
715520
715751
|
// src/services/voiceKeyterms.ts
|
|
715521
|
-
import { basename as
|
|
715752
|
+
import { basename as basename48 } from "path";
|
|
715522
715753
|
function splitIdentifier(name3) {
|
|
715523
715754
|
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
715755
|
}
|
|
715525
715756
|
function fileNameWords(filePath) {
|
|
715526
|
-
const stem =
|
|
715757
|
+
const stem = basename48(filePath).replace(/\.[^.]+$/, "");
|
|
715527
715758
|
return splitIdentifier(stem);
|
|
715528
715759
|
}
|
|
715529
715760
|
async function getVoiceKeyterms(recentFiles) {
|
|
@@ -715531,7 +715762,7 @@ async function getVoiceKeyterms(recentFiles) {
|
|
|
715531
715762
|
try {
|
|
715532
715763
|
const projectRoot = getProjectRoot();
|
|
715533
715764
|
if (projectRoot) {
|
|
715534
|
-
const name3 =
|
|
715765
|
+
const name3 = basename48(projectRoot);
|
|
715535
715766
|
if (name3.length > 2 && name3.length <= 50) {
|
|
715536
715767
|
terms.add(name3);
|
|
715537
715768
|
}
|
|
@@ -717595,7 +717826,7 @@ import {
|
|
|
717595
717826
|
writeFile as writeFile54
|
|
717596
717827
|
} from "fs/promises";
|
|
717597
717828
|
import { tmpdir as tmpdir14 } from "os";
|
|
717598
|
-
import { extname as
|
|
717829
|
+
import { extname as extname18, join as join160 } from "path";
|
|
717599
717830
|
function getAnalysisModel() {
|
|
717600
717831
|
return getDefaultOpusModel();
|
|
717601
717832
|
}
|
|
@@ -717612,7 +717843,7 @@ function getSessionMetaDir() {
|
|
|
717612
717843
|
return join160(getDataDir(), "session-meta");
|
|
717613
717844
|
}
|
|
717614
717845
|
function getLanguageFromPath(filePath) {
|
|
717615
|
-
const ext =
|
|
717846
|
+
const ext = extname18(filePath).toLowerCase();
|
|
717616
717847
|
return EXTENSION_TO_LANGUAGE[ext] || null;
|
|
717617
717848
|
}
|
|
717618
717849
|
function extractToolStats(log3) {
|
|
@@ -720410,7 +720641,7 @@ import {
|
|
|
720410
720641
|
unlink as unlink26,
|
|
720411
720642
|
writeFile as writeFile55
|
|
720412
720643
|
} from "fs/promises";
|
|
720413
|
-
import { basename as
|
|
720644
|
+
import { basename as basename49, dirname as dirname72, join as join161 } from "path";
|
|
720414
720645
|
function resetTranscriptWriteWarnings() {
|
|
720415
720646
|
transcriptWriteFailureWarned = false;
|
|
720416
720647
|
sessionSavingOffWarned = false;
|
|
@@ -722961,7 +723192,7 @@ async function getSessionFilesWithMtime(projectDir) {
|
|
|
722961
723192
|
for (const dirent of dirents) {
|
|
722962
723193
|
if (!dirent.isFile() || !dirent.name.endsWith(".jsonl"))
|
|
722963
723194
|
continue;
|
|
722964
|
-
const sessionId = validateUuid2(
|
|
723195
|
+
const sessionId = validateUuid2(basename49(dirent.name, ".jsonl"));
|
|
722965
723196
|
if (!sessionId)
|
|
722966
723197
|
continue;
|
|
722967
723198
|
candidates.push({ sessionId, filePath: join161(projectDir, dirent.name) });
|
|
@@ -723470,7 +723701,7 @@ var init_teamMemPrompts = __esm(() => {
|
|
|
723470
723701
|
});
|
|
723471
723702
|
|
|
723472
723703
|
// src/memdir/memdir.ts
|
|
723473
|
-
import { basename as
|
|
723704
|
+
import { basename as basename50, join as join162, resolve as resolve58 } from "path";
|
|
723474
723705
|
function stripNonLoadedContent(raw) {
|
|
723475
723706
|
const withoutFrontmatter = raw.replace(FRONTMATTER_REGEX, "");
|
|
723476
723707
|
if (!withoutFrontmatter.includes("<!--")) {
|
|
@@ -723566,7 +723797,7 @@ function getMemoryIndexOverCapMessage(params) {
|
|
|
723566
723797
|
async function checkMemoryEntrypointOverCap(filePath) {
|
|
723567
723798
|
if (!isAutoMemoryEnabled())
|
|
723568
723799
|
return null;
|
|
723569
|
-
const isAutoMemIndex = resolve58(filePath) === resolve58(getAutoMemEntrypoint()) ||
|
|
723800
|
+
const isAutoMemIndex = resolve58(filePath) === resolve58(getAutoMemEntrypoint()) || basename50(filePath) === ENTRYPOINT_NAME && isAutoMemPath(filePath);
|
|
723570
723801
|
if (!isAutoMemIndex)
|
|
723571
723802
|
return null;
|
|
723572
723803
|
const fs25 = getFsImplementation();
|
|
@@ -726567,7 +726798,7 @@ __export(exports_hooks2, {
|
|
|
726567
726798
|
createBaseHookInput: () => createBaseHookInput,
|
|
726568
726799
|
PRE_TOOL_USE_HOOK_TIMEOUT_MESSAGE: () => PRE_TOOL_USE_HOOK_TIMEOUT_MESSAGE
|
|
726569
726800
|
});
|
|
726570
|
-
import { basename as
|
|
726801
|
+
import { basename as basename51 } from "path";
|
|
726571
726802
|
import { spawn as spawn15 } from "child_process";
|
|
726572
726803
|
import { randomUUID as randomUUID41 } from "crypto";
|
|
726573
726804
|
function isPerHookCallbackTimeout(abortSignalAborted, parentSignalAborted) {
|
|
@@ -727527,7 +727758,7 @@ async function getMatchingHooks(appState, sessionId, hookEvent, hookInput, tools
|
|
|
727527
727758
|
matchQuery = hookInput.load_reason;
|
|
727528
727759
|
break;
|
|
727529
727760
|
case "FileChanged":
|
|
727530
|
-
matchQuery =
|
|
727761
|
+
matchQuery = basename51(hookInput.file_path);
|
|
727531
727762
|
break;
|
|
727532
727763
|
case "UserPromptExpansion":
|
|
727533
727764
|
matchQuery = hookInput.command_name;
|
|
@@ -729877,7 +730108,7 @@ import {
|
|
|
729877
730108
|
utimes as utimes2
|
|
729878
730109
|
} from "fs/promises";
|
|
729879
730110
|
import { existsSync as existsSync26, readFileSync as readFileSync34, statSync as statSync20 } from "fs";
|
|
729880
|
-
import { basename as
|
|
730111
|
+
import { basename as basename52, dirname as dirname73, join as join166 } from "path";
|
|
729881
730112
|
function validateWorktreeSlug(slug) {
|
|
729882
730113
|
if (slug.length > MAX_WORKTREE_SLUG_LENGTH) {
|
|
729883
730114
|
throw new Error(`Invalid worktree name: must be ${MAX_WORKTREE_SLUG_LENGTH} characters or fewer (got ${slug.length})`);
|
|
@@ -729944,7 +730175,7 @@ function restoreWorktreeSession(session2) {
|
|
|
729944
730175
|
currentWorktreeSession = session2;
|
|
729945
730176
|
}
|
|
729946
730177
|
function generateTmuxSessionName(repoPath, branch2) {
|
|
729947
|
-
const repoName =
|
|
730178
|
+
const repoName = basename52(repoPath);
|
|
729948
730179
|
const combined = `${repoName}_${branch2}`;
|
|
729949
730180
|
return combined.replace(/[/.]/g, "_");
|
|
729950
730181
|
}
|
|
@@ -730527,7 +730758,7 @@ async function execIntoTmuxWorktree(args) {
|
|
|
730527
730758
|
error: `Error: ${errorMessage(error52)}`
|
|
730528
730759
|
};
|
|
730529
730760
|
}
|
|
730530
|
-
repoName =
|
|
730761
|
+
repoName = basename52(findCanonicalGitRoot(getCwd()) ?? getCwd());
|
|
730531
730762
|
console.log(`Using worktree via hook: ${worktreeDir}`);
|
|
730532
730763
|
} else {
|
|
730533
730764
|
const repoRoot = findCanonicalGitRoot(getCwd());
|
|
@@ -730537,7 +730768,7 @@ async function execIntoTmuxWorktree(args) {
|
|
|
730537
730768
|
error: "Error: --worktree requires a git repository"
|
|
730538
730769
|
};
|
|
730539
730770
|
}
|
|
730540
|
-
repoName =
|
|
730771
|
+
repoName = basename52(repoRoot);
|
|
730541
730772
|
worktreeDir = worktreePathFor(repoRoot, worktreeName);
|
|
730542
730773
|
try {
|
|
730543
730774
|
const result = await getOrCreateWorktree(repoRoot, worktreeName, prNumber !== null ? { prNumber } : undefined);
|
|
@@ -732834,7 +733065,7 @@ __export(exports_bridgeMain, {
|
|
|
732834
733065
|
});
|
|
732835
733066
|
import { randomUUID as randomUUID42 } from "crypto";
|
|
732836
733067
|
import { hostname as hostname4, tmpdir as tmpdir17 } from "os";
|
|
732837
|
-
import { basename as
|
|
733068
|
+
import { basename as basename53, join as join171, resolve as resolve59 } from "path";
|
|
732838
733069
|
async function isMultiSessionSpawnEnabled() {
|
|
732839
733070
|
return checkGate_CACHED_OR_BLOCKING("tengu_ccr_bridge_multi_session");
|
|
732840
733071
|
}
|
|
@@ -734171,7 +734402,7 @@ The session may still be resumable \u2014 try running the same command again.`);
|
|
|
734171
734402
|
const logger30 = createBridgeLogger({ verbose });
|
|
734172
734403
|
const { parseGitHubRepository: parseGitHubRepository2 } = await Promise.resolve().then(() => (init_detectRepository(), exports_detectRepository));
|
|
734173
734404
|
const ownerRepo = gitRepoUrl ? parseGitHubRepository2(gitRepoUrl) : null;
|
|
734174
|
-
const repoName = ownerRepo ? ownerRepo.split("/").pop() :
|
|
734405
|
+
const repoName = ownerRepo ? ownerRepo.split("/").pop() : basename53(dir);
|
|
734175
734406
|
logger30.setRepoInfo(repoName, branch2);
|
|
734176
734407
|
const toggleAvailable = spawnMode !== "single-session" && worktreeAvailable;
|
|
734177
734408
|
if (toggleAvailable) {
|
|
@@ -743463,7 +743694,7 @@ __export(exports_inboundAttachments, {
|
|
|
743463
743694
|
});
|
|
743464
743695
|
import { randomUUID as randomUUID47 } from "crypto";
|
|
743465
743696
|
import { mkdir as mkdir58, writeFile as writeFile58 } from "fs/promises";
|
|
743466
|
-
import { basename as
|
|
743697
|
+
import { basename as basename54, join as join174 } from "path";
|
|
743467
743698
|
function debug9(msg) {
|
|
743468
743699
|
logForDebugging(`[bridge:inbound-attach] ${msg}`);
|
|
743469
743700
|
}
|
|
@@ -743475,7 +743706,7 @@ function extractInboundAttachments(msg) {
|
|
|
743475
743706
|
return parsed.success ? parsed.data : [];
|
|
743476
743707
|
}
|
|
743477
743708
|
function sanitizeFileName(name3) {
|
|
743478
|
-
const base2 =
|
|
743709
|
+
const base2 = basename54(name3).replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
743479
743710
|
return base2 || "attachment";
|
|
743480
743711
|
}
|
|
743481
743712
|
function uploadsDir() {
|
|
@@ -750178,7 +750409,7 @@ var init_FileEditToolDiff = __esm(() => {
|
|
|
750178
750409
|
|
|
750179
750410
|
// src/hooks/useDiffInIDE.ts
|
|
750180
750411
|
import { randomUUID as randomUUID49 } from "crypto";
|
|
750181
|
-
import { basename as
|
|
750412
|
+
import { basename as basename56 } from "path";
|
|
750182
750413
|
function useDiffInIDE({
|
|
750183
750414
|
onChange,
|
|
750184
750415
|
toolUseContext,
|
|
@@ -750189,7 +750420,7 @@ function useDiffInIDE({
|
|
|
750189
750420
|
const isUnmounted = import_react209.useRef(false);
|
|
750190
750421
|
const [hasError, setHasError] = import_react209.useState(false);
|
|
750191
750422
|
const sha = import_react209.useMemo(() => randomUUID49().slice(0, 6), []);
|
|
750192
|
-
const tabName = import_react209.useMemo(() => `\u273B [Claude Code] ${
|
|
750423
|
+
const tabName = import_react209.useMemo(() => `\u273B [Claude Code] ${basename56(filePath)} (${sha}) \u29C9`, [filePath, sha]);
|
|
750193
750424
|
const shouldShowDiffInIDE = hasAccessToIDEExtensionDiffFeature(toolUseContext.options.mcpClients) && getGlobalConfig().diffTool === "auto" && !filePath.endsWith(".ipynb");
|
|
750194
750425
|
const ideName = getConnectedIdeName(toolUseContext.options.mcpClients) ?? "IDE";
|
|
750195
750426
|
async function showDiff() {
|
|
@@ -750371,7 +750602,7 @@ var init_useDiffInIDE = __esm(() => {
|
|
|
750371
750602
|
});
|
|
750372
750603
|
|
|
750373
750604
|
// src/components/ShowInIDEPrompt.tsx
|
|
750374
|
-
import { basename as
|
|
750605
|
+
import { basename as basename57, relative as relative32 } from "path";
|
|
750375
750606
|
function ShowInIDEPrompt(t0) {
|
|
750376
750607
|
const $4 = import_compiler_runtime272.c(36);
|
|
750377
750608
|
const {
|
|
@@ -750428,7 +750659,7 @@ function ShowInIDEPrompt(t0) {
|
|
|
750428
750659
|
}
|
|
750429
750660
|
let t4;
|
|
750430
750661
|
if ($4[5] !== filePath) {
|
|
750431
|
-
t4 =
|
|
750662
|
+
t4 = basename57(filePath);
|
|
750432
750663
|
$4[5] = filePath;
|
|
750433
750664
|
$4[6] = t4;
|
|
750434
750665
|
} else {
|
|
@@ -750589,7 +750820,7 @@ var init_ShowInIDEPrompt = __esm(() => {
|
|
|
750589
750820
|
|
|
750590
750821
|
// src/components/permissions/FilePermissionDialog/permissionOptions.tsx
|
|
750591
750822
|
import { homedir as homedir46 } from "os";
|
|
750592
|
-
import { basename as
|
|
750823
|
+
import { basename as basename58, join as join175, sep as sep47 } from "path";
|
|
750593
750824
|
function isInClaudeFolder(filePath) {
|
|
750594
750825
|
const absolutePath = expandPath(filePath);
|
|
750595
750826
|
const claudeFolderPath = expandPath(`${getOriginalCwd()}/.claude`);
|
|
@@ -750671,7 +750902,7 @@ function getFilePermissionOptions({
|
|
|
750671
750902
|
}
|
|
750672
750903
|
} else {
|
|
750673
750904
|
const dirPath = getDirectoryForPath(filePath);
|
|
750674
|
-
const dirName =
|
|
750905
|
+
const dirName = basename58(dirPath) || "this directory";
|
|
750675
750906
|
if (operationType === "read") {
|
|
750676
750907
|
sessionLabel = /* @__PURE__ */ jsx_runtime379.jsxs(ThemedText, {
|
|
750677
750908
|
children: [
|
|
@@ -751170,7 +751401,7 @@ var init_FilePermissionDialog = __esm(() => {
|
|
|
751170
751401
|
});
|
|
751171
751402
|
|
|
751172
751403
|
// src/components/permissions/SedEditPermissionRequest/SedEditPermissionRequest.tsx
|
|
751173
|
-
import { basename as
|
|
751404
|
+
import { basename as basename59, relative as relative34 } from "path";
|
|
751174
751405
|
function SedEditPermissionRequest(t0) {
|
|
751175
751406
|
const $4 = import_compiler_runtime273.c(9);
|
|
751176
751407
|
let props;
|
|
@@ -751346,7 +751577,7 @@ function SedEditPermissionRequestInner(t0) {
|
|
|
751346
751577
|
}
|
|
751347
751578
|
let t10;
|
|
751348
751579
|
if ($4[16] !== filePath) {
|
|
751349
|
-
t10 =
|
|
751580
|
+
t10 = basename59(filePath);
|
|
751350
751581
|
$4[16] = filePath;
|
|
751351
751582
|
$4[17] = t10;
|
|
751352
751583
|
} else {
|
|
@@ -751558,7 +751789,7 @@ var init_useShellPermissionFeedback = __esm(() => {
|
|
|
751558
751789
|
});
|
|
751559
751790
|
|
|
751560
751791
|
// src/components/permissions/shellPermissionHelpers.tsx
|
|
751561
|
-
import { basename as
|
|
751792
|
+
import { basename as basename60, sep as sep48 } from "path";
|
|
751562
751793
|
function commandListDisplay(commands7) {
|
|
751563
751794
|
switch (commands7.length) {
|
|
751564
751795
|
case 0:
|
|
@@ -751609,7 +751840,7 @@ function commandListDisplayTruncated(commands7) {
|
|
|
751609
751840
|
function formatPathList(paths2) {
|
|
751610
751841
|
if (paths2.length === 0)
|
|
751611
751842
|
return "";
|
|
751612
|
-
const names = paths2.map((p4) =>
|
|
751843
|
+
const names = paths2.map((p4) => basename60(p4) || p4);
|
|
751613
751844
|
if (names.length === 1) {
|
|
751614
751845
|
return /* @__PURE__ */ jsx_runtime382.jsxs(ThemedText, {
|
|
751615
751846
|
children: [
|
|
@@ -751675,7 +751906,7 @@ function generateShellSuggestionsLabel(suggestions, shellToolName, commandTransf
|
|
|
751675
751906
|
if (hasReadPaths && !hasDirectories && !hasCommands) {
|
|
751676
751907
|
if (readPaths.length === 1) {
|
|
751677
751908
|
const firstPath = readPaths[0];
|
|
751678
|
-
const dirName =
|
|
751909
|
+
const dirName = basename60(firstPath) || firstPath;
|
|
751679
751910
|
return /* @__PURE__ */ jsx_runtime382.jsxs(ThemedText, {
|
|
751680
751911
|
children: [
|
|
751681
751912
|
"Yes, allow reading from ",
|
|
@@ -751699,7 +751930,7 @@ function generateShellSuggestionsLabel(suggestions, shellToolName, commandTransf
|
|
|
751699
751930
|
if (hasDirectories && !hasReadPaths && !hasCommands) {
|
|
751700
751931
|
if (directories.length === 1) {
|
|
751701
751932
|
const firstDir = directories[0];
|
|
751702
|
-
const dirName =
|
|
751933
|
+
const dirName = basename60(firstDir) || firstDir;
|
|
751703
751934
|
return /* @__PURE__ */ jsx_runtime382.jsxs(ThemedText, {
|
|
751704
751935
|
children: [
|
|
751705
751936
|
"Yes, and always allow access to ",
|
|
@@ -754123,7 +754354,7 @@ function createSingleEditDiffConfig(filePath, oldString, newString, replaceAll2)
|
|
|
754123
754354
|
}
|
|
754124
754355
|
|
|
754125
754356
|
// src/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.tsx
|
|
754126
|
-
import { basename as
|
|
754357
|
+
import { basename as basename61, relative as relative35 } from "path";
|
|
754127
754358
|
function FileEditPermissionRequest(props) {
|
|
754128
754359
|
const $4 = import_compiler_runtime278.c(51);
|
|
754129
754360
|
const parseInput = _temp176;
|
|
@@ -754166,7 +754397,7 @@ function FileEditPermissionRequest(props) {
|
|
|
754166
754397
|
t32 = " ";
|
|
754167
754398
|
T0 = ThemedText;
|
|
754168
754399
|
t0 = true;
|
|
754169
|
-
t1 =
|
|
754400
|
+
t1 = basename61(file_path);
|
|
754170
754401
|
$4[0] = props.onDone;
|
|
754171
754402
|
$4[1] = props.onReject;
|
|
754172
754403
|
$4[2] = props.toolUseConfirm;
|
|
@@ -754593,7 +754824,7 @@ var init_FileWriteToolDiff = __esm(() => {
|
|
|
754593
754824
|
});
|
|
754594
754825
|
|
|
754595
754826
|
// src/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.tsx
|
|
754596
|
-
import { basename as
|
|
754827
|
+
import { basename as basename62, relative as relative36 } from "path";
|
|
754597
754828
|
function FileWritePermissionRequest(props) {
|
|
754598
754829
|
const $4 = import_compiler_runtime281.c(30);
|
|
754599
754830
|
const parseInput = _temp179;
|
|
@@ -754660,7 +754891,7 @@ function FileWritePermissionRequest(props) {
|
|
|
754660
754891
|
}
|
|
754661
754892
|
let t9;
|
|
754662
754893
|
if ($4[7] !== file_path) {
|
|
754663
|
-
t9 =
|
|
754894
|
+
t9 = basename62(file_path);
|
|
754664
754895
|
$4[7] = file_path;
|
|
754665
754896
|
$4[8] = t9;
|
|
754666
754897
|
} else {
|
|
@@ -755065,7 +755296,7 @@ var init_NotebookEditToolDiff = __esm(() => {
|
|
|
755065
755296
|
});
|
|
755066
755297
|
|
|
755067
755298
|
// src/components/permissions/NotebookEditPermissionRequest/NotebookEditPermissionRequest.tsx
|
|
755068
|
-
import { basename as
|
|
755299
|
+
import { basename as basename63 } from "path";
|
|
755069
755300
|
function NotebookEditPermissionRequest(props) {
|
|
755070
755301
|
const $4 = import_compiler_runtime283.c(52);
|
|
755071
755302
|
const parseInput = _temp181;
|
|
@@ -755109,7 +755340,7 @@ function NotebookEditPermissionRequest(props) {
|
|
|
755109
755340
|
t4 = " ";
|
|
755110
755341
|
T0 = ThemedText;
|
|
755111
755342
|
t0 = true;
|
|
755112
|
-
t1 =
|
|
755343
|
+
t1 = basename63(notebook_path);
|
|
755113
755344
|
$4[0] = props.onDone;
|
|
755114
755345
|
$4[1] = props.onReject;
|
|
755115
755346
|
$4[2] = props.toolUseConfirm;
|
|
@@ -760660,7 +760891,7 @@ var init_AutoUpdaterWrapper = __esm(() => {
|
|
|
760660
760891
|
});
|
|
760661
760892
|
|
|
760662
760893
|
// src/components/IdeStatusIndicator.tsx
|
|
760663
|
-
import { basename as
|
|
760894
|
+
import { basename as basename64 } from "path";
|
|
760664
760895
|
function IdeStatusIndicator(t0) {
|
|
760665
760896
|
const $4 = import_compiler_runtime293.c(7);
|
|
760666
760897
|
const {
|
|
@@ -760700,7 +760931,7 @@ function IdeStatusIndicator(t0) {
|
|
|
760700
760931
|
if (ideSelection.filePath) {
|
|
760701
760932
|
let t1;
|
|
760702
760933
|
if ($4[3] !== ideSelection.filePath) {
|
|
760703
|
-
t1 =
|
|
760934
|
+
t1 = basename64(ideSelection.filePath);
|
|
760704
760935
|
$4[3] = ideSelection.filePath;
|
|
760705
760936
|
$4[4] = t1;
|
|
760706
760937
|
} else {
|
|
@@ -764109,7 +764340,7 @@ var init_slackChannelSuggestions = __esm(() => {
|
|
|
764109
764340
|
});
|
|
764110
764341
|
|
|
764111
764342
|
// src/hooks/unifiedSuggestions.ts
|
|
764112
|
-
import { basename as
|
|
764343
|
+
import { basename as basename65 } from "path";
|
|
764113
764344
|
function createSuggestionFromSource(source2) {
|
|
764114
764345
|
switch (source2.type) {
|
|
764115
764346
|
case "file":
|
|
@@ -764171,7 +764402,7 @@ async function generateUnifiedSuggestions(query2, mcpResources, agents2, showOnE
|
|
|
764171
764402
|
displayText: suggestion.displayText,
|
|
764172
764403
|
description: suggestion.description,
|
|
764173
764404
|
path: suggestion.displayText,
|
|
764174
|
-
filename:
|
|
764405
|
+
filename: basename65(suggestion.displayText),
|
|
764175
764406
|
score: suggestion.metadata?.score
|
|
764176
764407
|
}));
|
|
764177
764408
|
const mcpSources = Object.values(mcpResources).flat().map((resource) => ({
|
|
@@ -765438,9 +765669,15 @@ var init_keyword = __esm(() => {
|
|
|
765438
765669
|
// src/components/AutoModeOptInDialog.tsx
|
|
765439
765670
|
var exports_AutoModeOptInDialog = {};
|
|
765440
765671
|
__export(exports_AutoModeOptInDialog, {
|
|
765672
|
+
getAutoModeDescription: () => getAutoModeDescription,
|
|
765441
765673
|
AutoModeOptInDialog: () => AutoModeOptInDialog,
|
|
765674
|
+
AUTO_MODE_DESCRIPTION_WITHOUT_COST_SENTENCE: () => AUTO_MODE_DESCRIPTION_WITHOUT_COST_SENTENCE,
|
|
765442
765675
|
AUTO_MODE_DESCRIPTION: () => AUTO_MODE_DESCRIPTION
|
|
765443
765676
|
});
|
|
765677
|
+
function getAutoModeDescription() {
|
|
765678
|
+
const subscriptionType = getSubscriptionType();
|
|
765679
|
+
return subscriptionType === "pro" || subscriptionType === "max" || subscriptionType === "team" ? AUTO_MODE_DESCRIPTION_WITHOUT_COST_SENTENCE : AUTO_MODE_DESCRIPTION;
|
|
765680
|
+
}
|
|
765444
765681
|
function AutoModeOptInDialog(t0) {
|
|
765445
765682
|
const $4 = import_compiler_runtime298.c(18);
|
|
765446
765683
|
const {
|
|
@@ -765459,45 +765696,44 @@ function AutoModeOptInDialog(t0) {
|
|
|
765459
765696
|
let t22;
|
|
765460
765697
|
if ($4[1] !== onAccept || $4[2] !== onDecline) {
|
|
765461
765698
|
t22 = function onChange2(value) {
|
|
765462
|
-
|
|
765463
|
-
|
|
765464
|
-
|
|
765465
|
-
|
|
765466
|
-
|
|
765467
|
-
|
|
765468
|
-
|
|
765469
|
-
|
|
765470
|
-
|
|
765471
|
-
|
|
765472
|
-
|
|
765473
|
-
|
|
765474
|
-
|
|
765699
|
+
switch (value) {
|
|
765700
|
+
case "accept": {
|
|
765701
|
+
logEvent2("tengu_auto_mode_opt_in_dialog_accept", {});
|
|
765702
|
+
updateSettingsForSource("userSettings", {
|
|
765703
|
+
skipAutoPermissionPrompt: true,
|
|
765704
|
+
autoModeOptInDismissed: hasAutoModeOptInDismissed() ? false : undefined
|
|
765705
|
+
});
|
|
765706
|
+
onAccept();
|
|
765707
|
+
break;
|
|
765708
|
+
}
|
|
765709
|
+
case "accept-default": {
|
|
765710
|
+
logEvent2("tengu_auto_mode_opt_in_dialog_accept_default", {});
|
|
765711
|
+
updateSettingsForSource("userSettings", {
|
|
765712
|
+
skipAutoPermissionPrompt: true,
|
|
765713
|
+
permissions: {
|
|
765714
|
+
defaultMode: "auto"
|
|
765715
|
+
},
|
|
765716
|
+
autoModeOptInDismissed: hasAutoModeOptInDismissed() ? false : undefined
|
|
765717
|
+
});
|
|
765718
|
+
onAccept();
|
|
765719
|
+
break;
|
|
765720
|
+
}
|
|
765721
|
+
case "decline": {
|
|
765722
|
+
logEvent2("tengu_auto_mode_opt_in_dialog_decline", {});
|
|
765723
|
+
onDecline("go-back");
|
|
765724
|
+
break;
|
|
765725
|
+
}
|
|
765726
|
+
case "decline-dont-ask": {
|
|
765727
|
+
logEvent2("tengu_auto_mode_opt_in_dialog_decline_dont_ask", {});
|
|
765728
|
+
if (!hasAutoModeOptInDismissed()) {
|
|
765475
765729
|
updateSettingsForSource("userSettings", {
|
|
765476
|
-
|
|
765477
|
-
permissions: {
|
|
765478
|
-
defaultMode: "auto"
|
|
765479
|
-
},
|
|
765480
|
-
autoModeOptInDismissed: hasAutoModeOptInDismissed() ? false : undefined
|
|
765730
|
+
autoModeOptInDismissed: true
|
|
765481
765731
|
});
|
|
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
765732
|
}
|
|
765733
|
+
onDecline("dont-ask");
|
|
765734
|
+
break;
|
|
765500
765735
|
}
|
|
765736
|
+
}
|
|
765501
765737
|
};
|
|
765502
765738
|
$4[1] = onAccept;
|
|
765503
765739
|
$4[2] = onDecline;
|
|
@@ -765513,7 +765749,7 @@ function AutoModeOptInDialog(t0) {
|
|
|
765513
765749
|
gap: 1,
|
|
765514
765750
|
children: [
|
|
765515
765751
|
/* @__PURE__ */ jsx_runtime417.jsx(ThemedText, {
|
|
765516
|
-
children:
|
|
765752
|
+
children: getAutoModeDescription()
|
|
765517
765753
|
}),
|
|
765518
765754
|
/* @__PURE__ */ jsx_runtime417.jsx(Link, {
|
|
765519
765755
|
url: "https://code.claude.com/docs/en/security"
|
|
@@ -765603,9 +765839,10 @@ function AutoModeOptInDialog(t0) {
|
|
|
765603
765839
|
function _temp189() {
|
|
765604
765840
|
logEvent2("tengu_auto_mode_opt_in_dialog_shown", {});
|
|
765605
765841
|
}
|
|
765606
|
-
var import_compiler_runtime298, import_react241, jsx_runtime417,
|
|
765842
|
+
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
765843
|
var init_AutoModeOptInDialog = __esm(() => {
|
|
765608
765844
|
init_analytics();
|
|
765845
|
+
init_auth6();
|
|
765609
765846
|
init_ink2();
|
|
765610
765847
|
init_settings2();
|
|
765611
765848
|
init_CustomSelect();
|
|
@@ -765613,10 +765850,12 @@ var init_AutoModeOptInDialog = __esm(() => {
|
|
|
765613
765850
|
import_compiler_runtime298 = __toESM(require_compiler_runtime(), 1);
|
|
765614
765851
|
import_react241 = __toESM(require_react(), 1);
|
|
765615
765852
|
jsx_runtime417 = __toESM(require_jsx_runtime(), 1);
|
|
765853
|
+
AUTO_MODE_DESCRIPTION = `${AUTO_MODE_BASE_DESCRIPTION} ${AUTO_MODE_COST_SENTENCE} ${AUTO_MODE_SAFETY_SENTENCE}`;
|
|
765854
|
+
AUTO_MODE_DESCRIPTION_WITHOUT_COST_SENTENCE = `${AUTO_MODE_BASE_DESCRIPTION} ${AUTO_MODE_SAFETY_SENTENCE}`;
|
|
765616
765855
|
});
|
|
765617
765856
|
|
|
765618
765857
|
// src/components/BridgeDialog.tsx
|
|
765619
|
-
import { basename as
|
|
765858
|
+
import { basename as basename66 } from "path";
|
|
765620
765859
|
function BridgeDialog(t0) {
|
|
765621
765860
|
const $4 = import_compiler_runtime299.c(87);
|
|
765622
765861
|
const {
|
|
@@ -765639,7 +765878,7 @@ function BridgeDialog(t0) {
|
|
|
765639
765878
|
const [branchName, setBranchName] = import_react242.useState("");
|
|
765640
765879
|
let t1;
|
|
765641
765880
|
if ($4[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
765642
|
-
t1 =
|
|
765881
|
+
t1 = basename66(getOriginalCwd());
|
|
765643
765882
|
$4[0] = t1;
|
|
765644
765883
|
} else {
|
|
765645
765884
|
t1 = $4[0];
|
|
@@ -779114,7 +779353,7 @@ var require_polyfill = __commonJS((exports, module) => {
|
|
|
779114
779353
|
} = __require("fs/promises");
|
|
779115
779354
|
var {
|
|
779116
779355
|
dirname: dirname77,
|
|
779117
|
-
isAbsolute:
|
|
779356
|
+
isAbsolute: isAbsolute32,
|
|
779118
779357
|
join: join176,
|
|
779119
779358
|
parse: parse16,
|
|
779120
779359
|
resolve: resolve61,
|
|
@@ -779372,7 +779611,7 @@ var require_polyfill = __commonJS((exports, module) => {
|
|
|
779372
779611
|
}
|
|
779373
779612
|
async function onLink(destStat, src, dest) {
|
|
779374
779613
|
let resolvedSrc = await readlink4(src);
|
|
779375
|
-
if (!
|
|
779614
|
+
if (!isAbsolute32(resolvedSrc)) {
|
|
779376
779615
|
resolvedSrc = resolve61(dirname77(src), resolvedSrc);
|
|
779377
779616
|
}
|
|
779378
779617
|
if (!destStat) {
|
|
@@ -779387,7 +779626,7 @@ var require_polyfill = __commonJS((exports, module) => {
|
|
|
779387
779626
|
}
|
|
779388
779627
|
throw err2;
|
|
779389
779628
|
}
|
|
779390
|
-
if (!
|
|
779629
|
+
if (!isAbsolute32(resolvedDest)) {
|
|
779391
779630
|
resolvedDest = resolve61(dirname77(dest), resolvedDest);
|
|
779392
779631
|
}
|
|
779393
779632
|
if (isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
@@ -779483,7 +779722,7 @@ var require_readdir_scoped = __commonJS((exports, module) => {
|
|
|
779483
779722
|
|
|
779484
779723
|
// node_modules/.bun/@npmcli+fs@5.0.0/node_modules/@npmcli/fs/lib/move-file.js
|
|
779485
779724
|
var require_move_file = __commonJS((exports, module) => {
|
|
779486
|
-
var { dirname: dirname77, join: join176, resolve: resolve61, relative: relative39, isAbsolute:
|
|
779725
|
+
var { dirname: dirname77, join: join176, resolve: resolve61, relative: relative39, isAbsolute: isAbsolute32 } = __require("path");
|
|
779487
779726
|
var fs25 = __require("fs/promises");
|
|
779488
779727
|
var pathExists2 = async (path42) => {
|
|
779489
779728
|
try {
|
|
@@ -779525,7 +779764,7 @@ var require_move_file = __commonJS((exports, module) => {
|
|
|
779525
779764
|
if (root3) {
|
|
779526
779765
|
await Promise.all(symlinks.map(async ({ source: symSource, destination: symDestination }) => {
|
|
779527
779766
|
let target = await fs25.readlink(symSource);
|
|
779528
|
-
if (
|
|
779767
|
+
if (isAbsolute32(target)) {
|
|
779529
779768
|
target = resolve61(symDestination, relative39(symSource, target));
|
|
779530
779769
|
}
|
|
779531
779770
|
let targetStat = "file";
|
|
@@ -789570,7 +789809,7 @@ __export(exports_asciicast, {
|
|
|
789570
789809
|
_resetRecordingStateForTesting: () => _resetRecordingStateForTesting
|
|
789571
789810
|
});
|
|
789572
789811
|
import { appendFile as appendFile8, rename as rename11 } from "fs/promises";
|
|
789573
|
-
import { basename as
|
|
789812
|
+
import { basename as basename67, dirname as dirname78, join as join179 } from "path";
|
|
789574
789813
|
function getRecordFilePath() {
|
|
789575
789814
|
if (recordingState.filePath !== null) {
|
|
789576
789815
|
return recordingState.filePath;
|
|
@@ -789616,8 +789855,8 @@ async function renameRecordingForSession() {
|
|
|
789616
789855
|
return;
|
|
789617
789856
|
}
|
|
789618
789857
|
await recorder?.flush();
|
|
789619
|
-
const oldName =
|
|
789620
|
-
const newName =
|
|
789858
|
+
const oldName = basename67(oldPath);
|
|
789859
|
+
const newName = basename67(newPath);
|
|
789621
789860
|
try {
|
|
789622
789861
|
await rename11(oldPath, newPath);
|
|
789623
789862
|
recordingState.filePath = newPath;
|
|
@@ -795441,7 +795680,7 @@ var init_binaryCheck = __esm(() => {
|
|
|
795441
795680
|
});
|
|
795442
795681
|
|
|
795443
795682
|
// src/utils/plugins/lspRecommendation.ts
|
|
795444
|
-
import { extname as
|
|
795683
|
+
import { extname as extname19 } from "path";
|
|
795445
795684
|
function isOfficialMarketplace(name3) {
|
|
795446
795685
|
return ALLOWED_OFFICIAL_MARKETPLACE_NAMES.has(name3.toLowerCase());
|
|
795447
795686
|
}
|
|
@@ -795531,7 +795770,7 @@ async function getMatchingLspPlugins(filePath) {
|
|
|
795531
795770
|
logForDebugging("[lspRecommendation] Recommendations are disabled");
|
|
795532
795771
|
return [];
|
|
795533
795772
|
}
|
|
795534
|
-
const ext =
|
|
795773
|
+
const ext = extname19(filePath).toLowerCase();
|
|
795535
795774
|
if (!ext) {
|
|
795536
795775
|
logForDebugging("[lspRecommendation] No file extension found");
|
|
795537
795776
|
return [];
|
|
@@ -795724,7 +795963,7 @@ var init_usePluginRecommendationBase = __esm(() => {
|
|
|
795724
795963
|
});
|
|
795725
795964
|
|
|
795726
795965
|
// src/hooks/useLspPluginRecommendation.tsx
|
|
795727
|
-
import { extname as
|
|
795966
|
+
import { extname as extname20, join as join181 } from "path";
|
|
795728
795967
|
function useLspPluginRecommendation() {
|
|
795729
795968
|
const $4 = import_compiler_runtime332.c(12);
|
|
795730
795969
|
const trackedFiles = useAppState(_temp254);
|
|
@@ -795770,7 +796009,7 @@ function useLspPluginRecommendation() {
|
|
|
795770
796009
|
pluginId: match.pluginId,
|
|
795771
796010
|
pluginName: match.pluginName,
|
|
795772
796011
|
pluginDescription: match.description,
|
|
795773
|
-
fileExtension:
|
|
796012
|
+
fileExtension: extname20(filePath),
|
|
795774
796013
|
shownAt: Date.now()
|
|
795775
796014
|
};
|
|
795776
796015
|
}
|
|
@@ -796513,7 +796752,7 @@ var init_usePluginAutoupdateNotification = __esm(() => {
|
|
|
796513
796752
|
});
|
|
796514
796753
|
|
|
796515
796754
|
// src/utils/plugins/reconciler.ts
|
|
796516
|
-
import { isAbsolute as
|
|
796755
|
+
import { isAbsolute as isAbsolute32, resolve as resolve62 } from "path";
|
|
796517
796756
|
function diffMarketplaces(declared, materialized, opts) {
|
|
796518
796757
|
const missing = [];
|
|
796519
796758
|
const sourceChanged = [];
|
|
@@ -796621,7 +796860,7 @@ async function reconcileMarketplaces(opts) {
|
|
|
796621
796860
|
return { installed, updated, failed, upToDate: diff2.upToDate, skipped };
|
|
796622
796861
|
}
|
|
796623
796862
|
function normalizeSource(source2, projectRoot) {
|
|
796624
|
-
if ((source2.source === "directory" || source2.source === "file") && !
|
|
796863
|
+
if ((source2.source === "directory" || source2.source === "file") && !isAbsolute32(source2.path)) {
|
|
796625
796864
|
const base2 = projectRoot ?? getOriginalCwd();
|
|
796626
796865
|
const canonicalRoot = findCanonicalGitRoot(base2);
|
|
796627
796866
|
return {
|
|
@@ -801331,7 +801570,7 @@ function REPL({
|
|
|
801331
801570
|
autoPermissionsNotificationCount: prevCount + 1
|
|
801332
801571
|
};
|
|
801333
801572
|
});
|
|
801334
|
-
setMessages2((prev) => [...prev, createSystemMessage(
|
|
801573
|
+
setMessages2((prev) => [...prev, createSystemMessage(getAutoModeDescription(), "warning")]);
|
|
801335
801574
|
}, 800, safeYoloMessageShownRef, setMessages);
|
|
801336
801575
|
return () => clearTimeout(timer2);
|
|
801337
801576
|
}
|
|
@@ -804311,7 +804550,7 @@ var init_REPL = __esm(() => {
|
|
|
804311
804550
|
HISTORY_STUB = {
|
|
804312
804551
|
maybeLoadOlder: (_4) => {}
|
|
804313
804552
|
};
|
|
804314
|
-
TITLE_ANIMATION_FRAMES = ["\
|
|
804553
|
+
TITLE_ANIMATION_FRAMES = ["\u25D0", "\u25D1"];
|
|
804315
804554
|
});
|
|
804316
804555
|
|
|
804317
804556
|
// src/replLauncher.tsx
|
|
@@ -814002,7 +814241,7 @@ var init_parseConnectUrl = () => {};
|
|
|
814002
814241
|
|
|
814003
814242
|
// src/utils/deepLink/terminalLauncher.ts
|
|
814004
814243
|
import { spawn as spawn19 } from "child_process";
|
|
814005
|
-
import { basename as
|
|
814244
|
+
import { basename as basename68 } from "path";
|
|
814006
814245
|
async function detectMacosTerminal() {
|
|
814007
814246
|
const stored = getGlobalConfig().deepLinkTerminal;
|
|
814008
814247
|
if (stored) {
|
|
@@ -814038,7 +814277,7 @@ async function detectLinuxTerminal() {
|
|
|
814038
814277
|
if (termEnv) {
|
|
814039
814278
|
const resolved = await which(termEnv);
|
|
814040
814279
|
if (resolved) {
|
|
814041
|
-
return { name:
|
|
814280
|
+
return { name: basename68(termEnv), command: resolved };
|
|
814042
814281
|
}
|
|
814043
814282
|
}
|
|
814044
814283
|
const xte = await which("x-terminal-emulator");
|
|
@@ -821481,7 +821720,7 @@ __export(exports_plugins, {
|
|
|
821481
821720
|
VALID_UPDATE_SCOPES: () => VALID_UPDATE_SCOPES,
|
|
821482
821721
|
VALID_INSTALLABLE_SCOPES: () => VALID_INSTALLABLE_SCOPES
|
|
821483
821722
|
});
|
|
821484
|
-
import { basename as
|
|
821723
|
+
import { basename as basename69, dirname as dirname85 } from "path";
|
|
821485
821724
|
function handleMarketplaceError(error52, action2) {
|
|
821486
821725
|
logError2(error52);
|
|
821487
821726
|
cliError(`${figures_default.cross} Failed to ${action2}: ${errorMessage(error52)}`);
|
|
@@ -821515,7 +821754,7 @@ async function pluginValidateHandler(manifestPath, options) {
|
|
|
821515
821754
|
let contentResults = [];
|
|
821516
821755
|
if (result.fileType === "plugin") {
|
|
821517
821756
|
const manifestDir = dirname85(result.filePath);
|
|
821518
|
-
if (
|
|
821757
|
+
if (basename69(manifestDir) === ".claude-plugin") {
|
|
821519
821758
|
contentResults = await validatePluginContents(dirname85(manifestDir));
|
|
821520
821759
|
for (const r4 of contentResults) {
|
|
821521
821760
|
console.log(`Validating ${r4.fileType}: ${r4.filePath}
|