@sourcegraph/cody-web 0.33.0 → 0.35.0
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/{agent.worker-2jv6UYtG.mjs → agent.worker-BLjjG8ds.mjs} +2063 -604
- package/dist/agent.worker.js +2 -2
- package/dist/{git-log-Sw0MOWAb.mjs → git-log-C0C2_x8P.mjs} +1 -1
- package/dist/index.js +628 -899
- package/dist/{lite-ch5VbcSy.mjs → lite-b2NFi2v9.mjs} +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{util-BcM-aRzi.mjs → util-C44wiTt8.mjs} +1 -1
- package/dist/{vscode-shim-DCfZW3km.mjs → vscode-shim-H_ThTWLs.mjs} +595 -593
- package/package.json +1 -1
|
@@ -17,9 +17,9 @@ var __privateWrapper = (obj, member, setter2, getter) => ({
|
|
|
17
17
|
return __privateGet2(obj, member, getter);
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
var _a2, _b, _c, _d, _e, _constructing, _f, _g, _max, _maxSize, _dispose, _disposeAfter, _fetchMethod, _size, _calculatedSize, _keyMap, _keyList, _valList, _next, _prev, _head, _tail, _free, _disposed, _sizes, _starts, _ttls, _hasDispose, _hasFetchMethod, _hasDisposeAfter, _LRUCache_instances, initializeTTLTracking_fn, _updateItemAge, _statusTTL, _setItemTTL, _isStale, initializeSizeTracking_fn, _removeItemSize, _addItemSize, _requireSize, indexes_fn, rindexes_fn, isValidIndex_fn, evict_fn, backgroundFetch_fn, isBackgroundFetch_fn, connect_fn2, moveToTail_fn, _h, _i, _j, _k, _l;
|
|
21
|
-
import { O as Observable,
|
|
22
|
-
import { r as requireUtil, i as inherits_browserExports, a as utilExports } from "./util-
|
|
20
|
+
var _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, partsToRegExp_fn, parseGlob_fn, _a2, _b, _c, _d, _e, _constructing, _f, _g, _max, _maxSize, _dispose, _disposeAfter, _fetchMethod, _size, _calculatedSize, _keyMap, _keyList, _valList, _next, _prev, _head, _tail, _free, _disposed, _sizes, _starts, _ttls, _hasDispose, _hasFetchMethod, _hasDisposeAfter, _LRUCache_instances, initializeTTLTracking_fn, _updateItemAge, _statusTTL, _setItemTTL, _isStale, initializeSizeTracking_fn, _removeItemSize, _addItemSize, _requireSize, indexes_fn, rindexes_fn, isValidIndex_fn, evict_fn, backgroundFetch_fn, isBackgroundFetch_fn, connect_fn2, moveToTail_fn, _h, _i, _j, _k, _l;
|
|
21
|
+
import { O as Observable, aU as unsubscribe, aV as AsyncSerialScheduler, aW as authStatus, aX as pick, aY as distinctUntilChanged$1, aZ as switchMapReplayOperation, a_ as pendingOperation, a$ as promiseFactoryToObservable, J as map$1, ac as isError$3, b0 as retry$1, b1 as logError$2, aF as firstResultFromOperation, b2 as graphqlClient, P as isDotCom, b3 as semver, b4 as debounceTime, b5 as interval, b6 as filter$3, b7 as startWith$1, b8 as switchMap$1, as as firstValueFrom$1, at as skipPendingOperation, b9 as logDebug$1, ba as isAbortError, ah as ModelTag, bb as getModelInfo, bc as CHAT_INPUT_TOKEN_BUDGET, bd as CHAT_OUTPUT_TOKEN_BUDGET, be as EXTENDED_CHAT_INPUT_TOKEN_BUDGET, bf as EXTENDED_USER_CONTEXT_TOKEN_BUDGET, bg as expand, ab as LRUCache$1, bh as TRANSIENT_REFETCH_INTERVAL_HINT, bi as createSubscriber, bj as fromVSCodeEvent, D as isEqual, bk as cenv, aD as lodashExports, bl as EXCLUDE_EVERYTHING_CONTEXT_FILTERS, bm as isFileURI, w as wrapInActiveSpan, bn as INCLUDE_EVERYTHING_CONTEXT_FILTERS, bo as onAbort, bp as addCodyClientIdentificationHeaders, bq as addTraceparent, br as addAuthHeaders, bs as fetch$2, bt as verifyResponseCode, H as combineLatest$1, bu as take$2, bv as clientCapabilities, bw as shareReplay$1, bx as tap$2, by as featureFlagProvider, ae as FeatureFlag, bz as telemetryRecorder, bA as getEnterpriseContextWindow, bB as ANSWER_TOKENS, bC as currentAuthStatusOrNotReadyYet, bD as mockAuthStatus, bE as storeLastValue, bF as resolvedConfig, bG as userProductSubscription, bH as currentAuthStatus, bI as isEnterpriseUser, bJ as ps, bK as GuardrailsMode, bL as currentResolvedConfig, aQ as PromptString, a7 as CodyIDE, bM as CORPUS_CONTEXT_ALLOCATION, bN as isCustomModel, bO as recordErrorToSpan, bP as addClientInfoParams, bQ as dependentAbortController, F as FILE_CONTEXT_MENTION_PROVIDER, S as SYMBOL_CONTEXT_MENTION_PROVIDER, R as REMOTE_REPOSITORY_PROVIDER_URI, a as REMOTE_FILE_PROVIDER_URI, b as REMOTE_DIRECTORY_PROVIDER_URI, W as WEB_PROVIDER_URI, C as ContextItemSource, bR as isS2, bS as GIT_OPENCTX_PROVIDER_URI, bT as CODE_SEARCH_PROVIDER_URI, a9 as cryptoJsExports, bU as currentOpenCtxController, m as URI, bV as MulticastSubject, bW as AsyncSerialScheduler_1, g as getDefaultExportFromCjs, bX as workspace, p as path$1, bY as vscode, bZ as Range, b_ as commands$1, b$ as window$1, c0 as Selection, U as Uri, c1 as AgentEventEmitter, c2 as MarkdownString, c3 as Disposable, c4 as TextEditorRevealType, c5 as ThemeIcon, c6 as StatusBarAlignment, c7 as readFile, c8 as env, c9 as UIKind, ca as languages$1, c as commonjsGlobal, cb as InvalidAccessTokenError, cc as _baseAssignValue, cd as eq_1, ce as isArrayLike_1, cf as isObjectLike_1, cg as _copyObject, ch as keysIn_1, ci as _cloneBufferExports, cj as _cloneTypedArray, ck as _copyArray, cl as _initCloneObject, cm as isArguments_1, cn as isArray_1, co as isBufferExports, cp as isFunction_1, cq as isObject_1, cr as isPlainObject_1, cs as isTypedArray_1, ct as _Stack, cu as identity_1, cv as _overRest, cw as _setToString, cx as _isIndex, Y as isSourcegraphToken, aC as v4, cy as CONFIG_KEY, aN as CodyAutoSuggestionMode, cz as ConfigurationTarget, cA as pathBrowserify, cB as stat, cC as extensions, cD as version$2, cE as setExtensionVersion, cF as withLatestFrom, cG as NEVER$1, cH as abortableOperation, cI as isNeedsAuthChallengeError, cJ as EMPTY$1, cK as disposableSubscription, cL as setAuthStatusObservable, cM as DOTCOM_URL, X as isAvailabilityError, cN as isInvalidAccessTokenError, cO as normalizeServerEndpointURL, cP as isEnterpriseUserDotComError, cQ as ProgressLocation, cR as AuthConfigError, cS as SourcegraphGraphQLAPIClient, cT as isExternalProviderAuthError, cU as isNetworkLikeError, cV as NeedsAuthChallengeError, cW as AvailabilityError, cX as EnterpriseUserDotComError, cY as resolveAuth, cZ as QuickPickItemKind, Q as isWorkspaceInstance, c_ as getAuthHeaders, c$ as toLightweightChatTranscript, d0 as SUPPORTED_URI_SCHEMAS, d1 as RelativePattern, d2 as _baseIsEqual, d3 as keys_1, d4 as _baseGet, d5 as _castPath, d6 as isLength_1, d7 as _toKey, d8 as _isKey, d9 as toNumber_1, da as _baseFindIndex, db as require$$0$2, dc as NetworkError, dd as isRateLimitError, V as isAuthError, de as FileType, df as dedent$1, dg as FoldingRange, dh as CancellationTokenSource, di as SymbolKind, dj as convertGitCloneURLToCodebaseName, aL as isDefined, dk as pluck, dl as toRangeData, dm as Position, dn as DefaultChatCommands, dp as pathFunctionsForURI, dq as uriParseNameAndExtension, dr as uriDirname, ds as Utils$1, dt as uriExtname, du as uriBasename, dv as DefaultEditCommands, dw as subscriptionDisposable, dx as updateGlobalTelemetryInstances, dy as TelemetryRecorderProvider, dz as telemetryRecorderProvider, dA as createGitDiff, dB as AgentWorkspaceEdit, dC as TextDocumentChangeReason, dD as omit$1, dE as getEditorInsertSpaces, dF as escapeRegExp$1, dG as TimeoutError, dH as isNetworkError, dI as displayPathWithoutWorkspaceFolderPrefix, dJ as http, dK as open, dL as defer$2, dM as merge$2, dN as ruleSearchPaths, dO as isRuleFilename, dP as parseRuleFile, dQ as languageFromFilename, f as displayLineRange, e as displayPath, dR as ruleTitle, an as isCodyProModel, dS as debounce_1, aP as isErrorLike, dT as isWindows, dU as GLOBAL_SEARCH_PROVIDER_URI, dV as mentionProvidersMetadata, dW as currentUserProductSubscription, dX as checkIfEnterpriseUser, dY as ThemeColor, dZ as QuickInputButtons, E as scanForMentionTriggerInUserTextInput, u as parseMentionQuery, L as LARGE_FILE_WARNING_LABEL, d_ as GENERAL_HELP_LABEL, a8 as CodyTaskState, d$ as CodeLens, e0 as defaultWebviewPanel, x as createExtensionAPI, y as createMessageAPIForWebview, e1 as EndOfLine, e2 as ViewColumn, e3 as Location, e4 as onDidChangeActiveTextEditor, e5 as tabGroups, e6 as workspaceTextDocuments, e7 as visibleTextEditors, e8 as onDidChangeVisibleTextEditors, e9 as fs, ea as onDidCloseTextDocument, eb as setCreateWebviewPanel, ec as getAugmentedNamespace, ed as extensionConfiguration, ee as main$1, ef as setAgent, eg as setWorkspaceDocuments, eh as setLastOpenedWorkspaceFolder, ei as onDidRegisterNewCodeActionProvider, ej as onDidUnregisterNewCodeActionProvider, ek as onDidRegisterNewCodeLensProvider, el as onDidUnregisterNewCodeLensProvider, em as setClientInfo, en as AgentWorkspaceConfiguration, eo as firstNonPendingAuthStatus, ep as workspaceFolders$1, eq as setWorkspaceFolders, er as onDidChangeWorkspaceFolders, es as onDidChangeWindowState, et as onDidOpenTextDocument, eu as onDidSaveTextDocument, ev as onDidRenameFiles, ew as packageJson, ex as progressBars, ey as CodeActionTriggerKind, ez as CodeAction, eA as UriString, eB as DiagnosticSeverity, eC as diagnostics, eD as isIntegrationTesting, eE as TESTING_TELEMETRY_EXPORTER, eF as dist, eG as completionProvider, eH as InlineCompletionTriggerKind, eI as currentAuthStatusAuthed, eJ as waitUntilComplete, eK as setExtensionConfiguration, eL as onDidChangeConfiguration, eM as onDidChangeTextDocument, eN as onDidChangeTextEditorSelection, eO as isTokenOrEndpointChange, ao as isMacOS, aq as CustomCommandType, aO as setDisplayPathEnvInfo, aI as ACCOUNT_USAGE_URL, z as debounce$1, eP as structuredPatch, eQ as dedupeWith$1, eR as AbortError, eS as createDisposables, eT as isNodeResponse, eU as getClientInfoQueryParams, eV as tracer, eW as getActiveTraceAndSpanId, eX as getClientIdentificationHeaders, eY as setJSONAcceptContentTypeHeaders, eZ as logResponseHeadersToSpan, e_ as isCustomAuthChallengeResponse, e$ as TracedError, $ as SpanStatusCode, ad as RateLimitError$1, f0 as capitalize, f1 as InlineCompletionItem, f2 as createTwoFilesPatch, f3 as vsCodeMocks, a2 as whitespace, a0 as svg, a3 as find$1, a4 as stringify$1, a5 as stringify$2, a6 as ccount, a1 as html$3, f4 as getEditorTabSize$1, f5 as metrics, f6 as _, aE as deserializeContextItem, f7 as editorStateFromPromptString, f8 as _baseGetTag, ag as isAbortErrorOrSocketHangUp, f9 as inputTextWithoutContextChipsFromPromptEditorState, ai as DeepCodyAgentID, fa as exec, s as spawn, ax as UIToolStatus, i as displayPathBasename, fb as expandToLineRange, fc as openctxController, fd as openCtxProviderMetadata, fe as CODY_PASSTHROUGH_VSCODE_OPEN_COMMAND_ID, ff as catchError$1, az as diffWithLineNum, aA as UITerminalOutputType, fg as getPlatform$1, fh as PromptMode, fi as skip$1, _ as context, fj as extractContextFromTraceparent, fk as isContextWindowLimitError, q as serializeContextItem, K as forceHydration, af as reformatBotMessageForChat, M as hydrateAfterPostMessage, fl as addMessageListenersForExtensionAPI, fm as createMessageAPIForExtension, am as View, aG as ChatHistoryType, fn as CodeActionKind, aw as pluralize, fo as assertFileURI, d as RULES_PROVIDER_URI, fp as createCodeSearchProvider, fq as ProgrammingLanguage, fr as MAX_CURRENT_FILE_TOKENS, fs as psDedent, ft as formatRuleForPrompt, fu as posixFilePaths, fv as DecorationRangeBehavior, fw as SURROUNDING_LINES, fx as diffLines, fy as CODY_SUPPORT_URL, fz as CODY_DOC_URL, fA as CODY_FEEDBACK_URL, fB as DISCORD_URL, fC as globalAgentRef, fD as VSCODE_CHANGELOG_URL, fE as SG_CHANGELOG_URL, fF as ACCOUNT_LIMITS_INFO_URL, fG as assertUnreachable, fH as promise, fI as ExtensionMode, fJ as setLogger, fK as setClientCapabilities, fL as setResolvedConfigurationObservable, fM as setClientNameVersion, fN as setOpenCtxControllerObservable, aK as isPlgEsAccessDisabled, aM as browser$4 } from "./vscode-shim-H_ThTWLs.mjs";
|
|
22
|
+
import { r as requireUtil, i as inherits_browserExports, a as utilExports } from "./util-C44wiTt8.mjs";
|
|
23
23
|
var NOTHING = Symbol.for("immer-nothing");
|
|
24
24
|
var DRAFTABLE = Symbol.for("immer-draftable");
|
|
25
25
|
var DRAFT_STATE = Symbol.for("immer-state");
|
|
@@ -674,7 +674,7 @@ var __awaiter = function(thisArg, _arguments, P, generator) {
|
|
|
674
674
|
step6((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
675
675
|
});
|
|
676
676
|
};
|
|
677
|
-
function filter$
|
|
677
|
+
function filter$2(test) {
|
|
678
678
|
return (observable) => {
|
|
679
679
|
return new Observable((observer) => {
|
|
680
680
|
const scheduler = new AsyncSerialScheduler(observer);
|
|
@@ -697,13 +697,13 @@ function filter$1(test) {
|
|
|
697
697
|
});
|
|
698
698
|
};
|
|
699
699
|
}
|
|
700
|
-
var define_process_default$
|
|
700
|
+
var define_process_default$o = { env: {} };
|
|
701
701
|
let _editorWindowIsFocused;
|
|
702
702
|
function setEditorWindowIsFocused(editorWindowIsFocused2) {
|
|
703
703
|
_editorWindowIsFocused = editorWindowIsFocused2;
|
|
704
704
|
}
|
|
705
705
|
function editorWindowIsFocused() {
|
|
706
|
-
if (define_process_default$
|
|
706
|
+
if (define_process_default$o.env.VITEST) {
|
|
707
707
|
return true;
|
|
708
708
|
}
|
|
709
709
|
if (!_editorWindowIsFocused) {
|
|
@@ -733,7 +733,7 @@ const siteVersion = authStatus.pipe(
|
|
|
733
733
|
map$1((siteVersion2) => {
|
|
734
734
|
return isError$3(siteVersion2) ? siteVersion2 : {
|
|
735
735
|
siteVersion: siteVersion2,
|
|
736
|
-
codyAPIVersion: inferCodyApiVersion(siteVersion2
|
|
736
|
+
codyAPIVersion: inferCodyApiVersion(siteVersion2)
|
|
737
737
|
};
|
|
738
738
|
})
|
|
739
739
|
);
|
|
@@ -762,7 +762,7 @@ async function currentSiteVersion() {
|
|
|
762
762
|
}
|
|
763
763
|
return {
|
|
764
764
|
siteVersion: siteVersion2,
|
|
765
|
-
codyAPIVersion: inferCodyApiVersion(siteVersion2
|
|
765
|
+
codyAPIVersion: inferCodyApiVersion(siteVersion2)
|
|
766
766
|
};
|
|
767
767
|
}
|
|
768
768
|
async function isValidVersion({ minimumVersion }) {
|
|
@@ -785,8 +785,8 @@ const LOCAL_BUILD_VERSION_NUMBER = "0.0.0+dev";
|
|
|
785
785
|
function serverSupportsPromptCaching() {
|
|
786
786
|
return _LatestCodyAPIVersion >= 7;
|
|
787
787
|
}
|
|
788
|
-
function inferCodyApiVersion(version2
|
|
789
|
-
if (
|
|
788
|
+
function inferCodyApiVersion(version2) {
|
|
789
|
+
if (version2 === LOCAL_BUILD_VERSION_NUMBER) {
|
|
790
790
|
if (_LatestCodyAPIVersion && _LatestCodyAPIVersion >= LastKnownCodyAPIVersion) {
|
|
791
791
|
return _LatestCodyAPIVersion;
|
|
792
792
|
}
|
|
@@ -830,7 +830,7 @@ function parseDateFromPreReleaseVersion(version2) {
|
|
|
830
830
|
return void 0;
|
|
831
831
|
}
|
|
832
832
|
}
|
|
833
|
-
var define_process_default$
|
|
833
|
+
var define_process_default$n = { env: {} };
|
|
834
834
|
const _ClientConfigSingleton = class _ClientConfigSingleton {
|
|
835
835
|
constructor() {
|
|
836
836
|
// Default values for the legacy GraphQL features API, used when a Sourcegraph instance
|
|
@@ -855,7 +855,7 @@ const _ClientConfigSingleton = class _ClientConfigSingleton {
|
|
|
855
855
|
// activity that can cause OS warnings or authorization flows when the
|
|
856
856
|
// user is not using Cody. See
|
|
857
857
|
// linear.app/sourcegraph/issue/CODY-3745/codys-background-periodic-network-access-causes-2fa.
|
|
858
|
-
filter$
|
|
858
|
+
filter$3((_value) => editorWindowIsFocused()),
|
|
859
859
|
startWith$1(void 0),
|
|
860
860
|
switchMap$1(
|
|
861
861
|
() => promiseFactoryToObservable((signal2) => this.fetchConfig(signal2))
|
|
@@ -867,7 +867,7 @@ const _ClientConfigSingleton = class _ClientConfigSingleton {
|
|
|
867
867
|
distinctUntilChanged$1()
|
|
868
868
|
));
|
|
869
869
|
__publicField2(this, "updates", this.changes.pipe(
|
|
870
|
-
filter$
|
|
870
|
+
filter$3((value) => value !== void 0 && value !== pendingOperation),
|
|
871
871
|
distinctUntilChanged$1()
|
|
872
872
|
));
|
|
873
873
|
}
|
|
@@ -968,7 +968,7 @@ const _ClientConfigSingleton = class _ClientConfigSingleton {
|
|
|
968
968
|
smartContextWindowEnabled: smartContextWindow,
|
|
969
969
|
// Things that did not exist before logically default to disabled.
|
|
970
970
|
modelsAPIEnabled: false,
|
|
971
|
-
userShouldUseEnterprise:
|
|
971
|
+
userShouldUseEnterprise: true,
|
|
972
972
|
notices: [],
|
|
973
973
|
omniBoxEnabled: false,
|
|
974
974
|
codeSearchEnabled: false
|
|
@@ -1014,7 +1014,7 @@ const _ClientConfigSingleton = class _ClientConfigSingleton {
|
|
|
1014
1014
|
};
|
|
1015
1015
|
__publicField2(_ClientConfigSingleton, "instance");
|
|
1016
1016
|
// REFETCH_INTERVAL is only updated via process.env during test execution, otherwise it is 60 seconds.
|
|
1017
|
-
__publicField2(_ClientConfigSingleton, "REFETCH_INTERVAL", define_process_default$
|
|
1017
|
+
__publicField2(_ClientConfigSingleton, "REFETCH_INTERVAL", define_process_default$n.env.CODY_CLIENT_CONFIG_SINGLETON_REFETCH_INTERVAL ? Number.parseInt(define_process_default$n.env.CODY_CLIENT_CONFIG_SINGLETON_REFETCH_INTERVAL, 10) : 60 * 1e3);
|
|
1018
1018
|
let ClientConfigSingleton = _ClientConfigSingleton;
|
|
1019
1019
|
const configOverwrites = authStatus.pipe(
|
|
1020
1020
|
pick("authenticated", "endpoint", "pendingValidation"),
|
|
@@ -1199,7 +1199,7 @@ createModel({
|
|
|
1199
1199
|
usage: [ModelUsage.Chat],
|
|
1200
1200
|
tags: [ModelTag.Enterprise]
|
|
1201
1201
|
});
|
|
1202
|
-
var define_process_default$
|
|
1202
|
+
var define_process_default$m = { env: {} };
|
|
1203
1203
|
const version$1 = "0.5.1";
|
|
1204
1204
|
class ResponseError extends Error {
|
|
1205
1205
|
constructor(error, status_code) {
|
|
@@ -1239,8 +1239,8 @@ const checkOk = async (response) => {
|
|
|
1239
1239
|
function getPlatform() {
|
|
1240
1240
|
if (typeof window !== "undefined" && window.navigator) {
|
|
1241
1241
|
return `${window.navigator.platform.toLowerCase()} Browser/${navigator.userAgent};`;
|
|
1242
|
-
} else if (typeof define_process_default$
|
|
1243
|
-
return `${define_process_default$
|
|
1242
|
+
} else if (typeof define_process_default$m !== "undefined") {
|
|
1243
|
+
return `${define_process_default$m.arch} ${define_process_default$m.platform} Node.js/${define_process_default$m.version}`;
|
|
1244
1244
|
}
|
|
1245
1245
|
return "";
|
|
1246
1246
|
}
|
|
@@ -1483,6 +1483,1344 @@ let Ollama$1 = class Ollama {
|
|
|
1483
1483
|
}
|
|
1484
1484
|
};
|
|
1485
1485
|
const browser$3 = new Ollama$1();
|
|
1486
|
+
const MAX_PATTERN_LENGTH = 1024 * 64;
|
|
1487
|
+
const assertValidPattern = (pattern) => {
|
|
1488
|
+
if (typeof pattern !== "string") {
|
|
1489
|
+
throw new TypeError("invalid pattern");
|
|
1490
|
+
}
|
|
1491
|
+
if (pattern.length > MAX_PATTERN_LENGTH) {
|
|
1492
|
+
throw new TypeError("pattern is too long");
|
|
1493
|
+
}
|
|
1494
|
+
};
|
|
1495
|
+
const posixClasses = {
|
|
1496
|
+
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
|
|
1497
|
+
"[:alpha:]": ["\\p{L}\\p{Nl}", true],
|
|
1498
|
+
"[:ascii:]": ["\\x00-\\x7f", false],
|
|
1499
|
+
"[:blank:]": ["\\p{Zs}\\t", true],
|
|
1500
|
+
"[:cntrl:]": ["\\p{Cc}", true],
|
|
1501
|
+
"[:digit:]": ["\\p{Nd}", true],
|
|
1502
|
+
"[:graph:]": ["\\p{Z}\\p{C}", true, true],
|
|
1503
|
+
"[:lower:]": ["\\p{Ll}", true],
|
|
1504
|
+
"[:print:]": ["\\p{C}", true],
|
|
1505
|
+
"[:punct:]": ["\\p{P}", true],
|
|
1506
|
+
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
|
|
1507
|
+
"[:upper:]": ["\\p{Lu}", true],
|
|
1508
|
+
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
|
|
1509
|
+
"[:xdigit:]": ["A-Fa-f0-9", false]
|
|
1510
|
+
};
|
|
1511
|
+
const braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
|
|
1512
|
+
const regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
1513
|
+
const rangesToString = (ranges2) => ranges2.join("");
|
|
1514
|
+
const parseClass = (glob, position) => {
|
|
1515
|
+
const pos2 = position;
|
|
1516
|
+
if (glob.charAt(pos2) !== "[") {
|
|
1517
|
+
throw new Error("not in a brace expression");
|
|
1518
|
+
}
|
|
1519
|
+
const ranges2 = [];
|
|
1520
|
+
const negs = [];
|
|
1521
|
+
let i2 = pos2 + 1;
|
|
1522
|
+
let sawStart = false;
|
|
1523
|
+
let uflag = false;
|
|
1524
|
+
let escaping = false;
|
|
1525
|
+
let negate = false;
|
|
1526
|
+
let endPos = pos2;
|
|
1527
|
+
let rangeStart = "";
|
|
1528
|
+
WHILE: while (i2 < glob.length) {
|
|
1529
|
+
const c = glob.charAt(i2);
|
|
1530
|
+
if ((c === "!" || c === "^") && i2 === pos2 + 1) {
|
|
1531
|
+
negate = true;
|
|
1532
|
+
i2++;
|
|
1533
|
+
continue;
|
|
1534
|
+
}
|
|
1535
|
+
if (c === "]" && sawStart && !escaping) {
|
|
1536
|
+
endPos = i2 + 1;
|
|
1537
|
+
break;
|
|
1538
|
+
}
|
|
1539
|
+
sawStart = true;
|
|
1540
|
+
if (c === "\\") {
|
|
1541
|
+
if (!escaping) {
|
|
1542
|
+
escaping = true;
|
|
1543
|
+
i2++;
|
|
1544
|
+
continue;
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
if (c === "[" && !escaping) {
|
|
1548
|
+
for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
|
|
1549
|
+
if (glob.startsWith(cls, i2)) {
|
|
1550
|
+
if (rangeStart) {
|
|
1551
|
+
return ["$.", false, glob.length - pos2, true];
|
|
1552
|
+
}
|
|
1553
|
+
i2 += cls.length;
|
|
1554
|
+
if (neg)
|
|
1555
|
+
negs.push(unip);
|
|
1556
|
+
else
|
|
1557
|
+
ranges2.push(unip);
|
|
1558
|
+
uflag = uflag || u;
|
|
1559
|
+
continue WHILE;
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
escaping = false;
|
|
1564
|
+
if (rangeStart) {
|
|
1565
|
+
if (c > rangeStart) {
|
|
1566
|
+
ranges2.push(braceEscape(rangeStart) + "-" + braceEscape(c));
|
|
1567
|
+
} else if (c === rangeStart) {
|
|
1568
|
+
ranges2.push(braceEscape(c));
|
|
1569
|
+
}
|
|
1570
|
+
rangeStart = "";
|
|
1571
|
+
i2++;
|
|
1572
|
+
continue;
|
|
1573
|
+
}
|
|
1574
|
+
if (glob.startsWith("-]", i2 + 1)) {
|
|
1575
|
+
ranges2.push(braceEscape(c + "-"));
|
|
1576
|
+
i2 += 2;
|
|
1577
|
+
continue;
|
|
1578
|
+
}
|
|
1579
|
+
if (glob.startsWith("-", i2 + 1)) {
|
|
1580
|
+
rangeStart = c;
|
|
1581
|
+
i2 += 2;
|
|
1582
|
+
continue;
|
|
1583
|
+
}
|
|
1584
|
+
ranges2.push(braceEscape(c));
|
|
1585
|
+
i2++;
|
|
1586
|
+
}
|
|
1587
|
+
if (endPos < i2) {
|
|
1588
|
+
return ["", false, 0, false];
|
|
1589
|
+
}
|
|
1590
|
+
if (!ranges2.length && !negs.length) {
|
|
1591
|
+
return ["$.", false, glob.length - pos2, true];
|
|
1592
|
+
}
|
|
1593
|
+
if (negs.length === 0 && ranges2.length === 1 && /^\\?.$/.test(ranges2[0]) && !negate) {
|
|
1594
|
+
const r2 = ranges2[0].length === 2 ? ranges2[0].slice(-1) : ranges2[0];
|
|
1595
|
+
return [regexpEscape(r2), false, endPos - pos2, false];
|
|
1596
|
+
}
|
|
1597
|
+
const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges2) + "]";
|
|
1598
|
+
const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
|
|
1599
|
+
const comb = ranges2.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges2.length ? sranges : snegs;
|
|
1600
|
+
return [comb, uflag, endPos - pos2, true];
|
|
1601
|
+
};
|
|
1602
|
+
const unescape = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
1603
|
+
return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
|
|
1604
|
+
};
|
|
1605
|
+
const types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
|
|
1606
|
+
const isExtglobType = (c) => types.has(c);
|
|
1607
|
+
const startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
|
|
1608
|
+
const startNoDot = "(?!\\.)";
|
|
1609
|
+
const addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
|
|
1610
|
+
const justDots = /* @__PURE__ */ new Set(["..", "."]);
|
|
1611
|
+
const reSpecials = new Set("().*{}+?[]^$\\!");
|
|
1612
|
+
const regExpEscape$1 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
1613
|
+
const qmark$1 = "[^/]";
|
|
1614
|
+
const star$2 = qmark$1 + "*?";
|
|
1615
|
+
const starNoEmpty = qmark$1 + "+?";
|
|
1616
|
+
const _AST = class _AST {
|
|
1617
|
+
constructor(type, parent, options = {}) {
|
|
1618
|
+
__privateAdd2(this, _AST_instances);
|
|
1619
|
+
__publicField2(this, "type");
|
|
1620
|
+
__privateAdd2(this, _root);
|
|
1621
|
+
__privateAdd2(this, _hasMagic);
|
|
1622
|
+
__privateAdd2(this, _uflag, false);
|
|
1623
|
+
__privateAdd2(this, _parts, []);
|
|
1624
|
+
__privateAdd2(this, _parent);
|
|
1625
|
+
__privateAdd2(this, _parentIndex);
|
|
1626
|
+
__privateAdd2(this, _negs);
|
|
1627
|
+
__privateAdd2(this, _filledNegs, false);
|
|
1628
|
+
__privateAdd2(this, _options);
|
|
1629
|
+
__privateAdd2(this, _toString);
|
|
1630
|
+
// set to true if it's an extglob with no children
|
|
1631
|
+
// (which really means one child of '')
|
|
1632
|
+
__privateAdd2(this, _emptyExt, false);
|
|
1633
|
+
this.type = type;
|
|
1634
|
+
if (type)
|
|
1635
|
+
__privateSet2(this, _hasMagic, true);
|
|
1636
|
+
__privateSet2(this, _parent, parent);
|
|
1637
|
+
__privateSet2(this, _root, __privateGet2(this, _parent) ? __privateGet2(__privateGet2(this, _parent), _root) : this);
|
|
1638
|
+
__privateSet2(this, _options, __privateGet2(this, _root) === this ? options : __privateGet2(__privateGet2(this, _root), _options));
|
|
1639
|
+
__privateSet2(this, _negs, __privateGet2(this, _root) === this ? [] : __privateGet2(__privateGet2(this, _root), _negs));
|
|
1640
|
+
if (type === "!" && !__privateGet2(__privateGet2(this, _root), _filledNegs))
|
|
1641
|
+
__privateGet2(this, _negs).push(this);
|
|
1642
|
+
__privateSet2(this, _parentIndex, __privateGet2(this, _parent) ? __privateGet2(__privateGet2(this, _parent), _parts).length : 0);
|
|
1643
|
+
}
|
|
1644
|
+
get hasMagic() {
|
|
1645
|
+
if (__privateGet2(this, _hasMagic) !== void 0)
|
|
1646
|
+
return __privateGet2(this, _hasMagic);
|
|
1647
|
+
for (const p2 of __privateGet2(this, _parts)) {
|
|
1648
|
+
if (typeof p2 === "string")
|
|
1649
|
+
continue;
|
|
1650
|
+
if (p2.type || p2.hasMagic)
|
|
1651
|
+
return __privateSet2(this, _hasMagic, true);
|
|
1652
|
+
}
|
|
1653
|
+
return __privateGet2(this, _hasMagic);
|
|
1654
|
+
}
|
|
1655
|
+
// reconstructs the pattern
|
|
1656
|
+
toString() {
|
|
1657
|
+
if (__privateGet2(this, _toString) !== void 0)
|
|
1658
|
+
return __privateGet2(this, _toString);
|
|
1659
|
+
if (!this.type) {
|
|
1660
|
+
return __privateSet2(this, _toString, __privateGet2(this, _parts).map((p2) => String(p2)).join(""));
|
|
1661
|
+
} else {
|
|
1662
|
+
return __privateSet2(this, _toString, this.type + "(" + __privateGet2(this, _parts).map((p2) => String(p2)).join("|") + ")");
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
push(...parts2) {
|
|
1666
|
+
for (const p2 of parts2) {
|
|
1667
|
+
if (p2 === "")
|
|
1668
|
+
continue;
|
|
1669
|
+
if (typeof p2 !== "string" && !(p2 instanceof _AST && __privateGet2(p2, _parent) === this)) {
|
|
1670
|
+
throw new Error("invalid part: " + p2);
|
|
1671
|
+
}
|
|
1672
|
+
__privateGet2(this, _parts).push(p2);
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
toJSON() {
|
|
1676
|
+
var _a3;
|
|
1677
|
+
const ret2 = this.type === null ? __privateGet2(this, _parts).slice().map((p2) => typeof p2 === "string" ? p2 : p2.toJSON()) : [this.type, ...__privateGet2(this, _parts).map((p2) => p2.toJSON())];
|
|
1678
|
+
if (this.isStart() && !this.type)
|
|
1679
|
+
ret2.unshift([]);
|
|
1680
|
+
if (this.isEnd() && (this === __privateGet2(this, _root) || __privateGet2(__privateGet2(this, _root), _filledNegs) && ((_a3 = __privateGet2(this, _parent)) == null ? void 0 : _a3.type) === "!")) {
|
|
1681
|
+
ret2.push({});
|
|
1682
|
+
}
|
|
1683
|
+
return ret2;
|
|
1684
|
+
}
|
|
1685
|
+
isStart() {
|
|
1686
|
+
var _a3;
|
|
1687
|
+
if (__privateGet2(this, _root) === this)
|
|
1688
|
+
return true;
|
|
1689
|
+
if (!((_a3 = __privateGet2(this, _parent)) == null ? void 0 : _a3.isStart()))
|
|
1690
|
+
return false;
|
|
1691
|
+
if (__privateGet2(this, _parentIndex) === 0)
|
|
1692
|
+
return true;
|
|
1693
|
+
const p2 = __privateGet2(this, _parent);
|
|
1694
|
+
for (let i2 = 0; i2 < __privateGet2(this, _parentIndex); i2++) {
|
|
1695
|
+
const pp = __privateGet2(p2, _parts)[i2];
|
|
1696
|
+
if (!(pp instanceof _AST && pp.type === "!")) {
|
|
1697
|
+
return false;
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
return true;
|
|
1701
|
+
}
|
|
1702
|
+
isEnd() {
|
|
1703
|
+
var _a3, _b2, _c2;
|
|
1704
|
+
if (__privateGet2(this, _root) === this)
|
|
1705
|
+
return true;
|
|
1706
|
+
if (((_a3 = __privateGet2(this, _parent)) == null ? void 0 : _a3.type) === "!")
|
|
1707
|
+
return true;
|
|
1708
|
+
if (!((_b2 = __privateGet2(this, _parent)) == null ? void 0 : _b2.isEnd()))
|
|
1709
|
+
return false;
|
|
1710
|
+
if (!this.type)
|
|
1711
|
+
return (_c2 = __privateGet2(this, _parent)) == null ? void 0 : _c2.isEnd();
|
|
1712
|
+
const pl = __privateGet2(this, _parent) ? __privateGet2(__privateGet2(this, _parent), _parts).length : 0;
|
|
1713
|
+
return __privateGet2(this, _parentIndex) === pl - 1;
|
|
1714
|
+
}
|
|
1715
|
+
copyIn(part) {
|
|
1716
|
+
if (typeof part === "string")
|
|
1717
|
+
this.push(part);
|
|
1718
|
+
else
|
|
1719
|
+
this.push(part.clone(this));
|
|
1720
|
+
}
|
|
1721
|
+
clone(parent) {
|
|
1722
|
+
const c = new _AST(this.type, parent);
|
|
1723
|
+
for (const p2 of __privateGet2(this, _parts)) {
|
|
1724
|
+
c.copyIn(p2);
|
|
1725
|
+
}
|
|
1726
|
+
return c;
|
|
1727
|
+
}
|
|
1728
|
+
static fromGlob(pattern, options = {}) {
|
|
1729
|
+
var _a3;
|
|
1730
|
+
const ast = new _AST(null, void 0, options);
|
|
1731
|
+
__privateMethod2(_a3 = _AST, _AST_static, parseAST_fn).call(_a3, pattern, ast, 0, options);
|
|
1732
|
+
return ast;
|
|
1733
|
+
}
|
|
1734
|
+
// returns the regular expression if there's magic, or the unescaped
|
|
1735
|
+
// string if not.
|
|
1736
|
+
toMMPattern() {
|
|
1737
|
+
if (this !== __privateGet2(this, _root))
|
|
1738
|
+
return __privateGet2(this, _root).toMMPattern();
|
|
1739
|
+
const glob = this.toString();
|
|
1740
|
+
const [re, body2, hasMagic, uflag] = this.toRegExpSource();
|
|
1741
|
+
const anyMagic = hasMagic || __privateGet2(this, _hasMagic) || __privateGet2(this, _options).nocase && !__privateGet2(this, _options).nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase();
|
|
1742
|
+
if (!anyMagic) {
|
|
1743
|
+
return body2;
|
|
1744
|
+
}
|
|
1745
|
+
const flags2 = (__privateGet2(this, _options).nocase ? "i" : "") + (uflag ? "u" : "");
|
|
1746
|
+
return Object.assign(new RegExp(`^${re}$`, flags2), {
|
|
1747
|
+
_src: re,
|
|
1748
|
+
_glob: glob
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
get options() {
|
|
1752
|
+
return __privateGet2(this, _options);
|
|
1753
|
+
}
|
|
1754
|
+
// returns the string match, the regexp source, whether there's magic
|
|
1755
|
+
// in the regexp (so a regular expression is required) and whether or
|
|
1756
|
+
// not the uflag is needed for the regular expression (for posix classes)
|
|
1757
|
+
// TODO: instead of injecting the start/end at this point, just return
|
|
1758
|
+
// the BODY of the regexp, along with the start/end portions suitable
|
|
1759
|
+
// for binding the start/end in either a joined full-path makeRe context
|
|
1760
|
+
// (where we bind to (^|/), or a standalone matchPart context (where
|
|
1761
|
+
// we bind to ^, and not /). Otherwise slashes get duped!
|
|
1762
|
+
//
|
|
1763
|
+
// In part-matching mode, the start is:
|
|
1764
|
+
// - if not isStart: nothing
|
|
1765
|
+
// - if traversal possible, but not allowed: ^(?!\.\.?$)
|
|
1766
|
+
// - if dots allowed or not possible: ^
|
|
1767
|
+
// - if dots possible and not allowed: ^(?!\.)
|
|
1768
|
+
// end is:
|
|
1769
|
+
// - if not isEnd(): nothing
|
|
1770
|
+
// - else: $
|
|
1771
|
+
//
|
|
1772
|
+
// In full-path matching mode, we put the slash at the START of the
|
|
1773
|
+
// pattern, so start is:
|
|
1774
|
+
// - if first pattern: same as part-matching mode
|
|
1775
|
+
// - if not isStart(): nothing
|
|
1776
|
+
// - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
|
|
1777
|
+
// - if dots allowed or not possible: /
|
|
1778
|
+
// - if dots possible and not allowed: /(?!\.)
|
|
1779
|
+
// end is:
|
|
1780
|
+
// - if last pattern, same as part-matching mode
|
|
1781
|
+
// - else nothing
|
|
1782
|
+
//
|
|
1783
|
+
// Always put the (?:$|/) on negated tails, though, because that has to be
|
|
1784
|
+
// there to bind the end of the negated pattern portion, and it's easier to
|
|
1785
|
+
// just stick it in now rather than try to inject it later in the middle of
|
|
1786
|
+
// the pattern.
|
|
1787
|
+
//
|
|
1788
|
+
// We can just always return the same end, and leave it up to the caller
|
|
1789
|
+
// to know whether it's going to be used joined or in parts.
|
|
1790
|
+
// And, if the start is adjusted slightly, can do the same there:
|
|
1791
|
+
// - if not isStart: nothing
|
|
1792
|
+
// - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
|
|
1793
|
+
// - if dots allowed or not possible: (?:/|^)
|
|
1794
|
+
// - if dots possible and not allowed: (?:/|^)(?!\.)
|
|
1795
|
+
//
|
|
1796
|
+
// But it's better to have a simpler binding without a conditional, for
|
|
1797
|
+
// performance, so probably better to return both start options.
|
|
1798
|
+
//
|
|
1799
|
+
// Then the caller just ignores the end if it's not the first pattern,
|
|
1800
|
+
// and the start always gets applied.
|
|
1801
|
+
//
|
|
1802
|
+
// But that's always going to be $ if it's the ending pattern, or nothing,
|
|
1803
|
+
// so the caller can just attach $ at the end of the pattern when building.
|
|
1804
|
+
//
|
|
1805
|
+
// So the todo is:
|
|
1806
|
+
// - better detect what kind of start is needed
|
|
1807
|
+
// - return both flavors of starting pattern
|
|
1808
|
+
// - attach $ at the end of the pattern when creating the actual RegExp
|
|
1809
|
+
//
|
|
1810
|
+
// Ah, but wait, no, that all only applies to the root when the first pattern
|
|
1811
|
+
// is not an extglob. If the first pattern IS an extglob, then we need all
|
|
1812
|
+
// that dot prevention biz to live in the extglob portions, because eg
|
|
1813
|
+
// +(*|.x*) can match .xy but not .yx.
|
|
1814
|
+
//
|
|
1815
|
+
// So, return the two flavors if it's #root and the first child is not an
|
|
1816
|
+
// AST, otherwise leave it to the child AST to handle it, and there,
|
|
1817
|
+
// use the (?:^|/) style of start binding.
|
|
1818
|
+
//
|
|
1819
|
+
// Even simplified further:
|
|
1820
|
+
// - Since the start for a join is eg /(?!\.) and the start for a part
|
|
1821
|
+
// is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
|
|
1822
|
+
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
1823
|
+
toRegExpSource(allowDot) {
|
|
1824
|
+
var _a3;
|
|
1825
|
+
const dot2 = allowDot ?? !!__privateGet2(this, _options).dot;
|
|
1826
|
+
if (__privateGet2(this, _root) === this)
|
|
1827
|
+
__privateMethod2(this, _AST_instances, fillNegs_fn).call(this);
|
|
1828
|
+
if (!this.type) {
|
|
1829
|
+
const noEmpty = this.isStart() && this.isEnd();
|
|
1830
|
+
const src = __privateGet2(this, _parts).map((p2) => {
|
|
1831
|
+
var _a4;
|
|
1832
|
+
const [re, _2, hasMagic, uflag] = typeof p2 === "string" ? __privateMethod2(_a4 = _AST, _AST_static, parseGlob_fn).call(_a4, p2, __privateGet2(this, _hasMagic), noEmpty) : p2.toRegExpSource(allowDot);
|
|
1833
|
+
__privateSet2(this, _hasMagic, __privateGet2(this, _hasMagic) || hasMagic);
|
|
1834
|
+
__privateSet2(this, _uflag, __privateGet2(this, _uflag) || uflag);
|
|
1835
|
+
return re;
|
|
1836
|
+
}).join("");
|
|
1837
|
+
let start3 = "";
|
|
1838
|
+
if (this.isStart()) {
|
|
1839
|
+
if (typeof __privateGet2(this, _parts)[0] === "string") {
|
|
1840
|
+
const dotTravAllowed = __privateGet2(this, _parts).length === 1 && justDots.has(__privateGet2(this, _parts)[0]);
|
|
1841
|
+
if (!dotTravAllowed) {
|
|
1842
|
+
const aps = addPatternStart;
|
|
1843
|
+
const needNoTrav = (
|
|
1844
|
+
// dots are allowed, and the pattern starts with [ or .
|
|
1845
|
+
dot2 && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
|
|
1846
|
+
src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
|
|
1847
|
+
src.startsWith("\\.\\.") && aps.has(src.charAt(4))
|
|
1848
|
+
);
|
|
1849
|
+
const needNoDot = !dot2 && !allowDot && aps.has(src.charAt(0));
|
|
1850
|
+
start3 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
let end = "";
|
|
1855
|
+
if (this.isEnd() && __privateGet2(__privateGet2(this, _root), _filledNegs) && ((_a3 = __privateGet2(this, _parent)) == null ? void 0 : _a3.type) === "!") {
|
|
1856
|
+
end = "(?:$|\\/)";
|
|
1857
|
+
}
|
|
1858
|
+
const final2 = start3 + src + end;
|
|
1859
|
+
return [
|
|
1860
|
+
final2,
|
|
1861
|
+
unescape(src),
|
|
1862
|
+
__privateSet2(this, _hasMagic, !!__privateGet2(this, _hasMagic)),
|
|
1863
|
+
__privateGet2(this, _uflag)
|
|
1864
|
+
];
|
|
1865
|
+
}
|
|
1866
|
+
const repeated = this.type === "*" || this.type === "+";
|
|
1867
|
+
const start2 = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
1868
|
+
let body2 = __privateMethod2(this, _AST_instances, partsToRegExp_fn).call(this, dot2);
|
|
1869
|
+
if (this.isStart() && this.isEnd() && !body2 && this.type !== "!") {
|
|
1870
|
+
const s = this.toString();
|
|
1871
|
+
__privateSet2(this, _parts, [s]);
|
|
1872
|
+
this.type = null;
|
|
1873
|
+
__privateSet2(this, _hasMagic, void 0);
|
|
1874
|
+
return [s, unescape(this.toString()), false, false];
|
|
1875
|
+
}
|
|
1876
|
+
let bodyDotAllowed = !repeated || allowDot || dot2 || !startNoDot ? "" : __privateMethod2(this, _AST_instances, partsToRegExp_fn).call(this, true);
|
|
1877
|
+
if (bodyDotAllowed === body2) {
|
|
1878
|
+
bodyDotAllowed = "";
|
|
1879
|
+
}
|
|
1880
|
+
if (bodyDotAllowed) {
|
|
1881
|
+
body2 = `(?:${body2})(?:${bodyDotAllowed})*?`;
|
|
1882
|
+
}
|
|
1883
|
+
let final = "";
|
|
1884
|
+
if (this.type === "!" && __privateGet2(this, _emptyExt)) {
|
|
1885
|
+
final = (this.isStart() && !dot2 ? startNoDot : "") + starNoEmpty;
|
|
1886
|
+
} else {
|
|
1887
|
+
const close = this.type === "!" ? (
|
|
1888
|
+
// !() must match something,but !(x) can match ''
|
|
1889
|
+
"))" + (this.isStart() && !dot2 && !allowDot ? startNoDot : "") + star$2 + ")"
|
|
1890
|
+
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
|
|
1891
|
+
final = start2 + body2 + close;
|
|
1892
|
+
}
|
|
1893
|
+
return [
|
|
1894
|
+
final,
|
|
1895
|
+
unescape(body2),
|
|
1896
|
+
__privateSet2(this, _hasMagic, !!__privateGet2(this, _hasMagic)),
|
|
1897
|
+
__privateGet2(this, _uflag)
|
|
1898
|
+
];
|
|
1899
|
+
}
|
|
1900
|
+
};
|
|
1901
|
+
_root = new WeakMap();
|
|
1902
|
+
_hasMagic = new WeakMap();
|
|
1903
|
+
_uflag = new WeakMap();
|
|
1904
|
+
_parts = new WeakMap();
|
|
1905
|
+
_parent = new WeakMap();
|
|
1906
|
+
_parentIndex = new WeakMap();
|
|
1907
|
+
_negs = new WeakMap();
|
|
1908
|
+
_filledNegs = new WeakMap();
|
|
1909
|
+
_options = new WeakMap();
|
|
1910
|
+
_toString = new WeakMap();
|
|
1911
|
+
_emptyExt = new WeakMap();
|
|
1912
|
+
_AST_instances = new WeakSet();
|
|
1913
|
+
fillNegs_fn = function() {
|
|
1914
|
+
if (this !== __privateGet2(this, _root))
|
|
1915
|
+
throw new Error("should only call on root");
|
|
1916
|
+
if (__privateGet2(this, _filledNegs))
|
|
1917
|
+
return this;
|
|
1918
|
+
this.toString();
|
|
1919
|
+
__privateSet2(this, _filledNegs, true);
|
|
1920
|
+
let n;
|
|
1921
|
+
while (n = __privateGet2(this, _negs).pop()) {
|
|
1922
|
+
if (n.type !== "!")
|
|
1923
|
+
continue;
|
|
1924
|
+
let p2 = n;
|
|
1925
|
+
let pp = __privateGet2(p2, _parent);
|
|
1926
|
+
while (pp) {
|
|
1927
|
+
for (let i2 = __privateGet2(p2, _parentIndex) + 1; !pp.type && i2 < __privateGet2(pp, _parts).length; i2++) {
|
|
1928
|
+
for (const part of __privateGet2(n, _parts)) {
|
|
1929
|
+
if (typeof part === "string") {
|
|
1930
|
+
throw new Error("string part in extglob AST??");
|
|
1931
|
+
}
|
|
1932
|
+
part.copyIn(__privateGet2(pp, _parts)[i2]);
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
p2 = pp;
|
|
1936
|
+
pp = __privateGet2(p2, _parent);
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
return this;
|
|
1940
|
+
};
|
|
1941
|
+
_AST_static = new WeakSet();
|
|
1942
|
+
parseAST_fn = function(str, ast, pos2, opt) {
|
|
1943
|
+
var _a3, _b2;
|
|
1944
|
+
let escaping = false;
|
|
1945
|
+
let inBrace = false;
|
|
1946
|
+
let braceStart = -1;
|
|
1947
|
+
let braceNeg = false;
|
|
1948
|
+
if (ast.type === null) {
|
|
1949
|
+
let i3 = pos2;
|
|
1950
|
+
let acc2 = "";
|
|
1951
|
+
while (i3 < str.length) {
|
|
1952
|
+
const c = str.charAt(i3++);
|
|
1953
|
+
if (escaping || c === "\\") {
|
|
1954
|
+
escaping = !escaping;
|
|
1955
|
+
acc2 += c;
|
|
1956
|
+
continue;
|
|
1957
|
+
}
|
|
1958
|
+
if (inBrace) {
|
|
1959
|
+
if (i3 === braceStart + 1) {
|
|
1960
|
+
if (c === "^" || c === "!") {
|
|
1961
|
+
braceNeg = true;
|
|
1962
|
+
}
|
|
1963
|
+
} else if (c === "]" && !(i3 === braceStart + 2 && braceNeg)) {
|
|
1964
|
+
inBrace = false;
|
|
1965
|
+
}
|
|
1966
|
+
acc2 += c;
|
|
1967
|
+
continue;
|
|
1968
|
+
} else if (c === "[") {
|
|
1969
|
+
inBrace = true;
|
|
1970
|
+
braceStart = i3;
|
|
1971
|
+
braceNeg = false;
|
|
1972
|
+
acc2 += c;
|
|
1973
|
+
continue;
|
|
1974
|
+
}
|
|
1975
|
+
if (!opt.noext && isExtglobType(c) && str.charAt(i3) === "(") {
|
|
1976
|
+
ast.push(acc2);
|
|
1977
|
+
acc2 = "";
|
|
1978
|
+
const ext2 = new _AST(c, ast);
|
|
1979
|
+
i3 = __privateMethod2(_a3 = _AST, _AST_static, parseAST_fn).call(_a3, str, ext2, i3, opt);
|
|
1980
|
+
ast.push(ext2);
|
|
1981
|
+
continue;
|
|
1982
|
+
}
|
|
1983
|
+
acc2 += c;
|
|
1984
|
+
}
|
|
1985
|
+
ast.push(acc2);
|
|
1986
|
+
return i3;
|
|
1987
|
+
}
|
|
1988
|
+
let i2 = pos2 + 1;
|
|
1989
|
+
let part = new _AST(null, ast);
|
|
1990
|
+
const parts2 = [];
|
|
1991
|
+
let acc = "";
|
|
1992
|
+
while (i2 < str.length) {
|
|
1993
|
+
const c = str.charAt(i2++);
|
|
1994
|
+
if (escaping || c === "\\") {
|
|
1995
|
+
escaping = !escaping;
|
|
1996
|
+
acc += c;
|
|
1997
|
+
continue;
|
|
1998
|
+
}
|
|
1999
|
+
if (inBrace) {
|
|
2000
|
+
if (i2 === braceStart + 1) {
|
|
2001
|
+
if (c === "^" || c === "!") {
|
|
2002
|
+
braceNeg = true;
|
|
2003
|
+
}
|
|
2004
|
+
} else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
|
|
2005
|
+
inBrace = false;
|
|
2006
|
+
}
|
|
2007
|
+
acc += c;
|
|
2008
|
+
continue;
|
|
2009
|
+
} else if (c === "[") {
|
|
2010
|
+
inBrace = true;
|
|
2011
|
+
braceStart = i2;
|
|
2012
|
+
braceNeg = false;
|
|
2013
|
+
acc += c;
|
|
2014
|
+
continue;
|
|
2015
|
+
}
|
|
2016
|
+
if (isExtglobType(c) && str.charAt(i2) === "(") {
|
|
2017
|
+
part.push(acc);
|
|
2018
|
+
acc = "";
|
|
2019
|
+
const ext2 = new _AST(c, part);
|
|
2020
|
+
part.push(ext2);
|
|
2021
|
+
i2 = __privateMethod2(_b2 = _AST, _AST_static, parseAST_fn).call(_b2, str, ext2, i2, opt);
|
|
2022
|
+
continue;
|
|
2023
|
+
}
|
|
2024
|
+
if (c === "|") {
|
|
2025
|
+
part.push(acc);
|
|
2026
|
+
acc = "";
|
|
2027
|
+
parts2.push(part);
|
|
2028
|
+
part = new _AST(null, ast);
|
|
2029
|
+
continue;
|
|
2030
|
+
}
|
|
2031
|
+
if (c === ")") {
|
|
2032
|
+
if (acc === "" && __privateGet2(ast, _parts).length === 0) {
|
|
2033
|
+
__privateSet2(ast, _emptyExt, true);
|
|
2034
|
+
}
|
|
2035
|
+
part.push(acc);
|
|
2036
|
+
acc = "";
|
|
2037
|
+
ast.push(...parts2, part);
|
|
2038
|
+
return i2;
|
|
2039
|
+
}
|
|
2040
|
+
acc += c;
|
|
2041
|
+
}
|
|
2042
|
+
ast.type = null;
|
|
2043
|
+
__privateSet2(ast, _hasMagic, void 0);
|
|
2044
|
+
__privateSet2(ast, _parts, [str.substring(pos2 - 1)]);
|
|
2045
|
+
return i2;
|
|
2046
|
+
};
|
|
2047
|
+
partsToRegExp_fn = function(dot2) {
|
|
2048
|
+
return __privateGet2(this, _parts).map((p2) => {
|
|
2049
|
+
if (typeof p2 === "string") {
|
|
2050
|
+
throw new Error("string type in extglob ast??");
|
|
2051
|
+
}
|
|
2052
|
+
const [re, _2, _hasMagic2, uflag] = p2.toRegExpSource(dot2);
|
|
2053
|
+
__privateSet2(this, _uflag, __privateGet2(this, _uflag) || uflag);
|
|
2054
|
+
return re;
|
|
2055
|
+
}).filter((p2) => !(this.isStart() && this.isEnd()) || !!p2).join("|");
|
|
2056
|
+
};
|
|
2057
|
+
parseGlob_fn = function(glob, hasMagic, noEmpty = false) {
|
|
2058
|
+
let escaping = false;
|
|
2059
|
+
let re = "";
|
|
2060
|
+
let uflag = false;
|
|
2061
|
+
for (let i2 = 0; i2 < glob.length; i2++) {
|
|
2062
|
+
const c = glob.charAt(i2);
|
|
2063
|
+
if (escaping) {
|
|
2064
|
+
escaping = false;
|
|
2065
|
+
re += (reSpecials.has(c) ? "\\" : "") + c;
|
|
2066
|
+
continue;
|
|
2067
|
+
}
|
|
2068
|
+
if (c === "\\") {
|
|
2069
|
+
if (i2 === glob.length - 1) {
|
|
2070
|
+
re += "\\\\";
|
|
2071
|
+
} else {
|
|
2072
|
+
escaping = true;
|
|
2073
|
+
}
|
|
2074
|
+
continue;
|
|
2075
|
+
}
|
|
2076
|
+
if (c === "[") {
|
|
2077
|
+
const [src, needUflag, consumed, magic] = parseClass(glob, i2);
|
|
2078
|
+
if (consumed) {
|
|
2079
|
+
re += src;
|
|
2080
|
+
uflag = uflag || needUflag;
|
|
2081
|
+
i2 += consumed - 1;
|
|
2082
|
+
hasMagic = hasMagic || magic;
|
|
2083
|
+
continue;
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
if (c === "*") {
|
|
2087
|
+
if (noEmpty && glob === "*")
|
|
2088
|
+
re += starNoEmpty;
|
|
2089
|
+
else
|
|
2090
|
+
re += star$2;
|
|
2091
|
+
hasMagic = true;
|
|
2092
|
+
continue;
|
|
2093
|
+
}
|
|
2094
|
+
if (c === "?") {
|
|
2095
|
+
re += qmark$1;
|
|
2096
|
+
hasMagic = true;
|
|
2097
|
+
continue;
|
|
2098
|
+
}
|
|
2099
|
+
re += regExpEscape$1(c);
|
|
2100
|
+
}
|
|
2101
|
+
return [re, unescape(glob), !!hasMagic, uflag];
|
|
2102
|
+
};
|
|
2103
|
+
__privateAdd2(_AST, _AST_static);
|
|
2104
|
+
let AST = _AST;
|
|
2105
|
+
const escape$1 = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
2106
|
+
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
2107
|
+
};
|
|
2108
|
+
var define_process_default$l = { env: {} };
|
|
2109
|
+
const minimatch = (p2, pattern, options = {}) => {
|
|
2110
|
+
assertValidPattern(pattern);
|
|
2111
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
2112
|
+
return false;
|
|
2113
|
+
}
|
|
2114
|
+
return new Minimatch(pattern, options).match(p2);
|
|
2115
|
+
};
|
|
2116
|
+
const starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
|
|
2117
|
+
const starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2);
|
|
2118
|
+
const starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2);
|
|
2119
|
+
const starDotExtTestNocase = (ext2) => {
|
|
2120
|
+
ext2 = ext2.toLowerCase();
|
|
2121
|
+
return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2);
|
|
2122
|
+
};
|
|
2123
|
+
const starDotExtTestNocaseDot = (ext2) => {
|
|
2124
|
+
ext2 = ext2.toLowerCase();
|
|
2125
|
+
return (f) => f.toLowerCase().endsWith(ext2);
|
|
2126
|
+
};
|
|
2127
|
+
const starDotStarRE = /^\*+\.\*+$/;
|
|
2128
|
+
const starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
|
|
2129
|
+
const starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
|
|
2130
|
+
const dotStarRE = /^\.\*+$/;
|
|
2131
|
+
const dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
|
|
2132
|
+
const starRE = /^\*+$/;
|
|
2133
|
+
const starTest = (f) => f.length !== 0 && !f.startsWith(".");
|
|
2134
|
+
const starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
|
|
2135
|
+
const qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
2136
|
+
const qmarksTestNocase = ([$0, ext2 = ""]) => {
|
|
2137
|
+
const noext = qmarksTestNoExt([$0]);
|
|
2138
|
+
if (!ext2)
|
|
2139
|
+
return noext;
|
|
2140
|
+
ext2 = ext2.toLowerCase();
|
|
2141
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
|
|
2142
|
+
};
|
|
2143
|
+
const qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
|
|
2144
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
2145
|
+
if (!ext2)
|
|
2146
|
+
return noext;
|
|
2147
|
+
ext2 = ext2.toLowerCase();
|
|
2148
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
|
|
2149
|
+
};
|
|
2150
|
+
const qmarksTestDot = ([$0, ext2 = ""]) => {
|
|
2151
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
2152
|
+
return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
|
|
2153
|
+
};
|
|
2154
|
+
const qmarksTest = ([$0, ext2 = ""]) => {
|
|
2155
|
+
const noext = qmarksTestNoExt([$0]);
|
|
2156
|
+
return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
|
|
2157
|
+
};
|
|
2158
|
+
const qmarksTestNoExt = ([$0]) => {
|
|
2159
|
+
const len2 = $0.length;
|
|
2160
|
+
return (f) => f.length === len2 && !f.startsWith(".");
|
|
2161
|
+
};
|
|
2162
|
+
const qmarksTestNoExtDot = ([$0]) => {
|
|
2163
|
+
const len2 = $0.length;
|
|
2164
|
+
return (f) => f.length === len2 && f !== "." && f !== "..";
|
|
2165
|
+
};
|
|
2166
|
+
const defaultPlatform = typeof define_process_default$l === "object" && define_process_default$l ? typeof define_process_default$l.env === "object" && define_process_default$l.env && define_process_default$l.env.__MINIMATCH_TESTING_PLATFORM__ || define_process_default$l.platform : "posix";
|
|
2167
|
+
const path = {
|
|
2168
|
+
win32: { sep: "\\" },
|
|
2169
|
+
posix: { sep: "/" }
|
|
2170
|
+
};
|
|
2171
|
+
const sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
|
|
2172
|
+
minimatch.sep = sep;
|
|
2173
|
+
const GLOBSTAR = Symbol("globstar **");
|
|
2174
|
+
minimatch.GLOBSTAR = GLOBSTAR;
|
|
2175
|
+
const qmark = "[^/]";
|
|
2176
|
+
const star$1 = qmark + "*?";
|
|
2177
|
+
const twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
|
|
2178
|
+
const twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
|
|
2179
|
+
const filter$1 = (pattern, options = {}) => (p2) => minimatch(p2, pattern, options);
|
|
2180
|
+
minimatch.filter = filter$1;
|
|
2181
|
+
const ext = (a, b = {}) => Object.assign({}, a, b);
|
|
2182
|
+
const defaults = (def) => {
|
|
2183
|
+
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
2184
|
+
return minimatch;
|
|
2185
|
+
}
|
|
2186
|
+
const orig = minimatch;
|
|
2187
|
+
const m = (p2, pattern, options = {}) => orig(p2, pattern, ext(def, options));
|
|
2188
|
+
return Object.assign(m, {
|
|
2189
|
+
Minimatch: class Minimatch extends orig.Minimatch {
|
|
2190
|
+
constructor(pattern, options = {}) {
|
|
2191
|
+
super(pattern, ext(def, options));
|
|
2192
|
+
}
|
|
2193
|
+
static defaults(options) {
|
|
2194
|
+
return orig.defaults(ext(def, options)).Minimatch;
|
|
2195
|
+
}
|
|
2196
|
+
},
|
|
2197
|
+
AST: class AST extends orig.AST {
|
|
2198
|
+
/* c8 ignore start */
|
|
2199
|
+
constructor(type, parent, options = {}) {
|
|
2200
|
+
super(type, parent, ext(def, options));
|
|
2201
|
+
}
|
|
2202
|
+
/* c8 ignore stop */
|
|
2203
|
+
static fromGlob(pattern, options = {}) {
|
|
2204
|
+
return orig.AST.fromGlob(pattern, ext(def, options));
|
|
2205
|
+
}
|
|
2206
|
+
},
|
|
2207
|
+
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
|
|
2208
|
+
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
|
|
2209
|
+
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
|
|
2210
|
+
defaults: (options) => orig.defaults(ext(def, options)),
|
|
2211
|
+
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
|
|
2212
|
+
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
|
|
2213
|
+
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
|
|
2214
|
+
sep: orig.sep,
|
|
2215
|
+
GLOBSTAR
|
|
2216
|
+
});
|
|
2217
|
+
};
|
|
2218
|
+
minimatch.defaults = defaults;
|
|
2219
|
+
const braceExpand = (pattern, options = {}) => {
|
|
2220
|
+
assertValidPattern(pattern);
|
|
2221
|
+
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
|
|
2222
|
+
return [pattern];
|
|
2223
|
+
}
|
|
2224
|
+
return expand(pattern);
|
|
2225
|
+
};
|
|
2226
|
+
minimatch.braceExpand = braceExpand;
|
|
2227
|
+
const makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
|
|
2228
|
+
minimatch.makeRe = makeRe;
|
|
2229
|
+
const match$1 = (list, pattern, options = {}) => {
|
|
2230
|
+
const mm = new Minimatch(pattern, options);
|
|
2231
|
+
list = list.filter((f) => mm.match(f));
|
|
2232
|
+
if (mm.options.nonull && !list.length) {
|
|
2233
|
+
list.push(pattern);
|
|
2234
|
+
}
|
|
2235
|
+
return list;
|
|
2236
|
+
};
|
|
2237
|
+
minimatch.match = match$1;
|
|
2238
|
+
const globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
2239
|
+
const regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
2240
|
+
class Minimatch {
|
|
2241
|
+
constructor(pattern, options = {}) {
|
|
2242
|
+
__publicField2(this, "options");
|
|
2243
|
+
__publicField2(this, "set");
|
|
2244
|
+
__publicField2(this, "pattern");
|
|
2245
|
+
__publicField2(this, "windowsPathsNoEscape");
|
|
2246
|
+
__publicField2(this, "nonegate");
|
|
2247
|
+
__publicField2(this, "negate");
|
|
2248
|
+
__publicField2(this, "comment");
|
|
2249
|
+
__publicField2(this, "empty");
|
|
2250
|
+
__publicField2(this, "preserveMultipleSlashes");
|
|
2251
|
+
__publicField2(this, "partial");
|
|
2252
|
+
__publicField2(this, "globSet");
|
|
2253
|
+
__publicField2(this, "globParts");
|
|
2254
|
+
__publicField2(this, "nocase");
|
|
2255
|
+
__publicField2(this, "isWindows");
|
|
2256
|
+
__publicField2(this, "platform");
|
|
2257
|
+
__publicField2(this, "windowsNoMagicRoot");
|
|
2258
|
+
__publicField2(this, "regexp");
|
|
2259
|
+
assertValidPattern(pattern);
|
|
2260
|
+
options = options || {};
|
|
2261
|
+
this.options = options;
|
|
2262
|
+
this.pattern = pattern;
|
|
2263
|
+
this.platform = options.platform || defaultPlatform;
|
|
2264
|
+
this.isWindows = this.platform === "win32";
|
|
2265
|
+
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
|
|
2266
|
+
if (this.windowsPathsNoEscape) {
|
|
2267
|
+
this.pattern = this.pattern.replace(/\\/g, "/");
|
|
2268
|
+
}
|
|
2269
|
+
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
2270
|
+
this.regexp = null;
|
|
2271
|
+
this.negate = false;
|
|
2272
|
+
this.nonegate = !!options.nonegate;
|
|
2273
|
+
this.comment = false;
|
|
2274
|
+
this.empty = false;
|
|
2275
|
+
this.partial = !!options.partial;
|
|
2276
|
+
this.nocase = !!this.options.nocase;
|
|
2277
|
+
this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
|
|
2278
|
+
this.globSet = [];
|
|
2279
|
+
this.globParts = [];
|
|
2280
|
+
this.set = [];
|
|
2281
|
+
this.make();
|
|
2282
|
+
}
|
|
2283
|
+
hasMagic() {
|
|
2284
|
+
if (this.options.magicalBraces && this.set.length > 1) {
|
|
2285
|
+
return true;
|
|
2286
|
+
}
|
|
2287
|
+
for (const pattern of this.set) {
|
|
2288
|
+
for (const part of pattern) {
|
|
2289
|
+
if (typeof part !== "string")
|
|
2290
|
+
return true;
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
return false;
|
|
2294
|
+
}
|
|
2295
|
+
debug(..._2) {
|
|
2296
|
+
}
|
|
2297
|
+
make() {
|
|
2298
|
+
const pattern = this.pattern;
|
|
2299
|
+
const options = this.options;
|
|
2300
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
2301
|
+
this.comment = true;
|
|
2302
|
+
return;
|
|
2303
|
+
}
|
|
2304
|
+
if (!pattern) {
|
|
2305
|
+
this.empty = true;
|
|
2306
|
+
return;
|
|
2307
|
+
}
|
|
2308
|
+
this.parseNegate();
|
|
2309
|
+
this.globSet = [...new Set(this.braceExpand())];
|
|
2310
|
+
if (options.debug) {
|
|
2311
|
+
this.debug = (...args2) => console.error(...args2);
|
|
2312
|
+
}
|
|
2313
|
+
this.debug(this.pattern, this.globSet);
|
|
2314
|
+
const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
|
|
2315
|
+
this.globParts = this.preprocess(rawGlobParts);
|
|
2316
|
+
this.debug(this.pattern, this.globParts);
|
|
2317
|
+
let set2 = this.globParts.map((s, _2, __) => {
|
|
2318
|
+
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
2319
|
+
const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
|
|
2320
|
+
const isDrive = /^[a-z]:/i.test(s[0]);
|
|
2321
|
+
if (isUNC) {
|
|
2322
|
+
return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
|
|
2323
|
+
} else if (isDrive) {
|
|
2324
|
+
return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
return s.map((ss) => this.parse(ss));
|
|
2328
|
+
});
|
|
2329
|
+
this.debug(this.pattern, set2);
|
|
2330
|
+
this.set = set2.filter((s) => s.indexOf(false) === -1);
|
|
2331
|
+
if (this.isWindows) {
|
|
2332
|
+
for (let i2 = 0; i2 < this.set.length; i2++) {
|
|
2333
|
+
const p2 = this.set[i2];
|
|
2334
|
+
if (p2[0] === "" && p2[1] === "" && this.globParts[i2][2] === "?" && typeof p2[3] === "string" && /^[a-z]:$/i.test(p2[3])) {
|
|
2335
|
+
p2[2] = "?";
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
this.debug(this.pattern, this.set);
|
|
2340
|
+
}
|
|
2341
|
+
// various transforms to equivalent pattern sets that are
|
|
2342
|
+
// faster to process in a filesystem walk. The goal is to
|
|
2343
|
+
// eliminate what we can, and push all ** patterns as far
|
|
2344
|
+
// to the right as possible, even if it increases the number
|
|
2345
|
+
// of patterns that we have to process.
|
|
2346
|
+
preprocess(globParts) {
|
|
2347
|
+
if (this.options.noglobstar) {
|
|
2348
|
+
for (let i2 = 0; i2 < globParts.length; i2++) {
|
|
2349
|
+
for (let j = 0; j < globParts[i2].length; j++) {
|
|
2350
|
+
if (globParts[i2][j] === "**") {
|
|
2351
|
+
globParts[i2][j] = "*";
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
const { optimizationLevel = 1 } = this.options;
|
|
2357
|
+
if (optimizationLevel >= 2) {
|
|
2358
|
+
globParts = this.firstPhasePreProcess(globParts);
|
|
2359
|
+
globParts = this.secondPhasePreProcess(globParts);
|
|
2360
|
+
} else if (optimizationLevel >= 1) {
|
|
2361
|
+
globParts = this.levelOneOptimize(globParts);
|
|
2362
|
+
} else {
|
|
2363
|
+
globParts = this.adjascentGlobstarOptimize(globParts);
|
|
2364
|
+
}
|
|
2365
|
+
return globParts;
|
|
2366
|
+
}
|
|
2367
|
+
// just get rid of adjascent ** portions
|
|
2368
|
+
adjascentGlobstarOptimize(globParts) {
|
|
2369
|
+
return globParts.map((parts2) => {
|
|
2370
|
+
let gs = -1;
|
|
2371
|
+
while (-1 !== (gs = parts2.indexOf("**", gs + 1))) {
|
|
2372
|
+
let i2 = gs;
|
|
2373
|
+
while (parts2[i2 + 1] === "**") {
|
|
2374
|
+
i2++;
|
|
2375
|
+
}
|
|
2376
|
+
if (i2 !== gs) {
|
|
2377
|
+
parts2.splice(gs, i2 - gs);
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
return parts2;
|
|
2381
|
+
});
|
|
2382
|
+
}
|
|
2383
|
+
// get rid of adjascent ** and resolve .. portions
|
|
2384
|
+
levelOneOptimize(globParts) {
|
|
2385
|
+
return globParts.map((parts2) => {
|
|
2386
|
+
parts2 = parts2.reduce((set2, part) => {
|
|
2387
|
+
const prev = set2[set2.length - 1];
|
|
2388
|
+
if (part === "**" && prev === "**") {
|
|
2389
|
+
return set2;
|
|
2390
|
+
}
|
|
2391
|
+
if (part === "..") {
|
|
2392
|
+
if (prev && prev !== ".." && prev !== "." && prev !== "**") {
|
|
2393
|
+
set2.pop();
|
|
2394
|
+
return set2;
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
set2.push(part);
|
|
2398
|
+
return set2;
|
|
2399
|
+
}, []);
|
|
2400
|
+
return parts2.length === 0 ? [""] : parts2;
|
|
2401
|
+
});
|
|
2402
|
+
}
|
|
2403
|
+
levelTwoFileOptimize(parts2) {
|
|
2404
|
+
if (!Array.isArray(parts2)) {
|
|
2405
|
+
parts2 = this.slashSplit(parts2);
|
|
2406
|
+
}
|
|
2407
|
+
let didSomething = false;
|
|
2408
|
+
do {
|
|
2409
|
+
didSomething = false;
|
|
2410
|
+
if (!this.preserveMultipleSlashes) {
|
|
2411
|
+
for (let i2 = 1; i2 < parts2.length - 1; i2++) {
|
|
2412
|
+
const p2 = parts2[i2];
|
|
2413
|
+
if (i2 === 1 && p2 === "" && parts2[0] === "")
|
|
2414
|
+
continue;
|
|
2415
|
+
if (p2 === "." || p2 === "") {
|
|
2416
|
+
didSomething = true;
|
|
2417
|
+
parts2.splice(i2, 1);
|
|
2418
|
+
i2--;
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
if (parts2[0] === "." && parts2.length === 2 && (parts2[1] === "." || parts2[1] === "")) {
|
|
2422
|
+
didSomething = true;
|
|
2423
|
+
parts2.pop();
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
let dd2 = 0;
|
|
2427
|
+
while (-1 !== (dd2 = parts2.indexOf("..", dd2 + 1))) {
|
|
2428
|
+
const p2 = parts2[dd2 - 1];
|
|
2429
|
+
if (p2 && p2 !== "." && p2 !== ".." && p2 !== "**") {
|
|
2430
|
+
didSomething = true;
|
|
2431
|
+
parts2.splice(dd2 - 1, 2);
|
|
2432
|
+
dd2 -= 2;
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
} while (didSomething);
|
|
2436
|
+
return parts2.length === 0 ? [""] : parts2;
|
|
2437
|
+
}
|
|
2438
|
+
// First phase: single-pattern processing
|
|
2439
|
+
// <pre> is 1 or more portions
|
|
2440
|
+
// <rest> is 1 or more portions
|
|
2441
|
+
// <p> is any portion other than ., .., '', or **
|
|
2442
|
+
// <e> is . or ''
|
|
2443
|
+
//
|
|
2444
|
+
// **/.. is *brutal* for filesystem walking performance, because
|
|
2445
|
+
// it effectively resets the recursive walk each time it occurs,
|
|
2446
|
+
// and ** cannot be reduced out by a .. pattern part like a regexp
|
|
2447
|
+
// or most strings (other than .., ., and '') can be.
|
|
2448
|
+
//
|
|
2449
|
+
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
|
|
2450
|
+
// <pre>/<e>/<rest> -> <pre>/<rest>
|
|
2451
|
+
// <pre>/<p>/../<rest> -> <pre>/<rest>
|
|
2452
|
+
// **/**/<rest> -> **/<rest>
|
|
2453
|
+
//
|
|
2454
|
+
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
|
|
2455
|
+
// this WOULD be allowed if ** did follow symlinks, or * didn't
|
|
2456
|
+
firstPhasePreProcess(globParts) {
|
|
2457
|
+
let didSomething = false;
|
|
2458
|
+
do {
|
|
2459
|
+
didSomething = false;
|
|
2460
|
+
for (let parts2 of globParts) {
|
|
2461
|
+
let gs = -1;
|
|
2462
|
+
while (-1 !== (gs = parts2.indexOf("**", gs + 1))) {
|
|
2463
|
+
let gss = gs;
|
|
2464
|
+
while (parts2[gss + 1] === "**") {
|
|
2465
|
+
gss++;
|
|
2466
|
+
}
|
|
2467
|
+
if (gss > gs) {
|
|
2468
|
+
parts2.splice(gs + 1, gss - gs);
|
|
2469
|
+
}
|
|
2470
|
+
let next = parts2[gs + 1];
|
|
2471
|
+
const p2 = parts2[gs + 2];
|
|
2472
|
+
const p22 = parts2[gs + 3];
|
|
2473
|
+
if (next !== "..")
|
|
2474
|
+
continue;
|
|
2475
|
+
if (!p2 || p2 === "." || p2 === ".." || !p22 || p22 === "." || p22 === "..") {
|
|
2476
|
+
continue;
|
|
2477
|
+
}
|
|
2478
|
+
didSomething = true;
|
|
2479
|
+
parts2.splice(gs, 1);
|
|
2480
|
+
const other = parts2.slice(0);
|
|
2481
|
+
other[gs] = "**";
|
|
2482
|
+
globParts.push(other);
|
|
2483
|
+
gs--;
|
|
2484
|
+
}
|
|
2485
|
+
if (!this.preserveMultipleSlashes) {
|
|
2486
|
+
for (let i2 = 1; i2 < parts2.length - 1; i2++) {
|
|
2487
|
+
const p2 = parts2[i2];
|
|
2488
|
+
if (i2 === 1 && p2 === "" && parts2[0] === "")
|
|
2489
|
+
continue;
|
|
2490
|
+
if (p2 === "." || p2 === "") {
|
|
2491
|
+
didSomething = true;
|
|
2492
|
+
parts2.splice(i2, 1);
|
|
2493
|
+
i2--;
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
if (parts2[0] === "." && parts2.length === 2 && (parts2[1] === "." || parts2[1] === "")) {
|
|
2497
|
+
didSomething = true;
|
|
2498
|
+
parts2.pop();
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
let dd2 = 0;
|
|
2502
|
+
while (-1 !== (dd2 = parts2.indexOf("..", dd2 + 1))) {
|
|
2503
|
+
const p2 = parts2[dd2 - 1];
|
|
2504
|
+
if (p2 && p2 !== "." && p2 !== ".." && p2 !== "**") {
|
|
2505
|
+
didSomething = true;
|
|
2506
|
+
const needDot = dd2 === 1 && parts2[dd2 + 1] === "**";
|
|
2507
|
+
const splin = needDot ? ["."] : [];
|
|
2508
|
+
parts2.splice(dd2 - 1, 2, ...splin);
|
|
2509
|
+
if (parts2.length === 0)
|
|
2510
|
+
parts2.push("");
|
|
2511
|
+
dd2 -= 2;
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
} while (didSomething);
|
|
2516
|
+
return globParts;
|
|
2517
|
+
}
|
|
2518
|
+
// second phase: multi-pattern dedupes
|
|
2519
|
+
// {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
|
|
2520
|
+
// {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
|
|
2521
|
+
// {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
|
|
2522
|
+
//
|
|
2523
|
+
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
|
|
2524
|
+
// ^-- not valid because ** doens't follow symlinks
|
|
2525
|
+
secondPhasePreProcess(globParts) {
|
|
2526
|
+
for (let i2 = 0; i2 < globParts.length - 1; i2++) {
|
|
2527
|
+
for (let j = i2 + 1; j < globParts.length; j++) {
|
|
2528
|
+
const matched = this.partsMatch(globParts[i2], globParts[j], !this.preserveMultipleSlashes);
|
|
2529
|
+
if (!matched)
|
|
2530
|
+
continue;
|
|
2531
|
+
globParts[i2] = matched;
|
|
2532
|
+
globParts[j] = [];
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
return globParts.filter((gs) => gs.length);
|
|
2536
|
+
}
|
|
2537
|
+
partsMatch(a, b, emptyGSMatch = false) {
|
|
2538
|
+
let ai = 0;
|
|
2539
|
+
let bi = 0;
|
|
2540
|
+
let result = [];
|
|
2541
|
+
let which = "";
|
|
2542
|
+
while (ai < a.length && bi < b.length) {
|
|
2543
|
+
if (a[ai] === b[bi]) {
|
|
2544
|
+
result.push(which === "b" ? b[bi] : a[ai]);
|
|
2545
|
+
ai++;
|
|
2546
|
+
bi++;
|
|
2547
|
+
} else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
|
|
2548
|
+
result.push(a[ai]);
|
|
2549
|
+
ai++;
|
|
2550
|
+
} else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
|
|
2551
|
+
result.push(b[bi]);
|
|
2552
|
+
bi++;
|
|
2553
|
+
} else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
|
|
2554
|
+
if (which === "b")
|
|
2555
|
+
return false;
|
|
2556
|
+
which = "a";
|
|
2557
|
+
result.push(a[ai]);
|
|
2558
|
+
ai++;
|
|
2559
|
+
bi++;
|
|
2560
|
+
} else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
|
|
2561
|
+
if (which === "a")
|
|
2562
|
+
return false;
|
|
2563
|
+
which = "b";
|
|
2564
|
+
result.push(b[bi]);
|
|
2565
|
+
ai++;
|
|
2566
|
+
bi++;
|
|
2567
|
+
} else {
|
|
2568
|
+
return false;
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
return a.length === b.length && result;
|
|
2572
|
+
}
|
|
2573
|
+
parseNegate() {
|
|
2574
|
+
if (this.nonegate)
|
|
2575
|
+
return;
|
|
2576
|
+
const pattern = this.pattern;
|
|
2577
|
+
let negate = false;
|
|
2578
|
+
let negateOffset = 0;
|
|
2579
|
+
for (let i2 = 0; i2 < pattern.length && pattern.charAt(i2) === "!"; i2++) {
|
|
2580
|
+
negate = !negate;
|
|
2581
|
+
negateOffset++;
|
|
2582
|
+
}
|
|
2583
|
+
if (negateOffset)
|
|
2584
|
+
this.pattern = pattern.slice(negateOffset);
|
|
2585
|
+
this.negate = negate;
|
|
2586
|
+
}
|
|
2587
|
+
// set partial to true to test if, for example,
|
|
2588
|
+
// "/a/b" matches the start of "/*/b/*/d"
|
|
2589
|
+
// Partial means, if you run out of file before you run
|
|
2590
|
+
// out of pattern, then that's fine, as long as all
|
|
2591
|
+
// the parts match.
|
|
2592
|
+
matchOne(file, pattern, partial = false) {
|
|
2593
|
+
const options = this.options;
|
|
2594
|
+
if (this.isWindows) {
|
|
2595
|
+
const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
|
|
2596
|
+
const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
|
|
2597
|
+
const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
|
|
2598
|
+
const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
|
|
2599
|
+
const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
|
|
2600
|
+
const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
|
|
2601
|
+
if (typeof fdi === "number" && typeof pdi === "number") {
|
|
2602
|
+
const [fd, pd] = [file[fdi], pattern[pdi]];
|
|
2603
|
+
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
2604
|
+
pattern[pdi] = fd;
|
|
2605
|
+
if (pdi > fdi) {
|
|
2606
|
+
pattern = pattern.slice(pdi);
|
|
2607
|
+
} else if (fdi > pdi) {
|
|
2608
|
+
file = file.slice(fdi);
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
const { optimizationLevel = 1 } = this.options;
|
|
2614
|
+
if (optimizationLevel >= 2) {
|
|
2615
|
+
file = this.levelTwoFileOptimize(file);
|
|
2616
|
+
}
|
|
2617
|
+
this.debug("matchOne", this, { file, pattern });
|
|
2618
|
+
this.debug("matchOne", file.length, pattern.length);
|
|
2619
|
+
for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
2620
|
+
this.debug("matchOne loop");
|
|
2621
|
+
var p2 = pattern[pi];
|
|
2622
|
+
var f = file[fi];
|
|
2623
|
+
this.debug(pattern, p2, f);
|
|
2624
|
+
if (p2 === false) {
|
|
2625
|
+
return false;
|
|
2626
|
+
}
|
|
2627
|
+
if (p2 === GLOBSTAR) {
|
|
2628
|
+
this.debug("GLOBSTAR", [pattern, p2, f]);
|
|
2629
|
+
var fr = fi;
|
|
2630
|
+
var pr = pi + 1;
|
|
2631
|
+
if (pr === pl) {
|
|
2632
|
+
this.debug("** at the end");
|
|
2633
|
+
for (; fi < fl; fi++) {
|
|
2634
|
+
if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
|
|
2635
|
+
return false;
|
|
2636
|
+
}
|
|
2637
|
+
return true;
|
|
2638
|
+
}
|
|
2639
|
+
while (fr < fl) {
|
|
2640
|
+
var swallowee = file[fr];
|
|
2641
|
+
this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
|
|
2642
|
+
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
|
2643
|
+
this.debug("globstar found match!", fr, fl, swallowee);
|
|
2644
|
+
return true;
|
|
2645
|
+
} else {
|
|
2646
|
+
if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
|
|
2647
|
+
this.debug("dot detected!", file, fr, pattern, pr);
|
|
2648
|
+
break;
|
|
2649
|
+
}
|
|
2650
|
+
this.debug("globstar swallow a segment, and continue");
|
|
2651
|
+
fr++;
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
if (partial) {
|
|
2655
|
+
this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
|
|
2656
|
+
if (fr === fl) {
|
|
2657
|
+
return true;
|
|
2658
|
+
}
|
|
2659
|
+
}
|
|
2660
|
+
return false;
|
|
2661
|
+
}
|
|
2662
|
+
let hit2;
|
|
2663
|
+
if (typeof p2 === "string") {
|
|
2664
|
+
hit2 = f === p2;
|
|
2665
|
+
this.debug("string match", p2, f, hit2);
|
|
2666
|
+
} else {
|
|
2667
|
+
hit2 = p2.test(f);
|
|
2668
|
+
this.debug("pattern match", p2, f, hit2);
|
|
2669
|
+
}
|
|
2670
|
+
if (!hit2)
|
|
2671
|
+
return false;
|
|
2672
|
+
}
|
|
2673
|
+
if (fi === fl && pi === pl) {
|
|
2674
|
+
return true;
|
|
2675
|
+
} else if (fi === fl) {
|
|
2676
|
+
return partial;
|
|
2677
|
+
} else if (pi === pl) {
|
|
2678
|
+
return fi === fl - 1 && file[fi] === "";
|
|
2679
|
+
} else {
|
|
2680
|
+
throw new Error("wtf?");
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
braceExpand() {
|
|
2684
|
+
return braceExpand(this.pattern, this.options);
|
|
2685
|
+
}
|
|
2686
|
+
parse(pattern) {
|
|
2687
|
+
assertValidPattern(pattern);
|
|
2688
|
+
const options = this.options;
|
|
2689
|
+
if (pattern === "**")
|
|
2690
|
+
return GLOBSTAR;
|
|
2691
|
+
if (pattern === "")
|
|
2692
|
+
return "";
|
|
2693
|
+
let m;
|
|
2694
|
+
let fastTest = null;
|
|
2695
|
+
if (m = pattern.match(starRE)) {
|
|
2696
|
+
fastTest = options.dot ? starTestDot : starTest;
|
|
2697
|
+
} else if (m = pattern.match(starDotExtRE)) {
|
|
2698
|
+
fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
|
|
2699
|
+
} else if (m = pattern.match(qmarksRE)) {
|
|
2700
|
+
fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
|
|
2701
|
+
} else if (m = pattern.match(starDotStarRE)) {
|
|
2702
|
+
fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
|
|
2703
|
+
} else if (m = pattern.match(dotStarRE)) {
|
|
2704
|
+
fastTest = dotStarTest;
|
|
2705
|
+
}
|
|
2706
|
+
const re = AST.fromGlob(pattern, this.options).toMMPattern();
|
|
2707
|
+
if (fastTest && typeof re === "object") {
|
|
2708
|
+
Reflect.defineProperty(re, "test", { value: fastTest });
|
|
2709
|
+
}
|
|
2710
|
+
return re;
|
|
2711
|
+
}
|
|
2712
|
+
makeRe() {
|
|
2713
|
+
if (this.regexp || this.regexp === false)
|
|
2714
|
+
return this.regexp;
|
|
2715
|
+
const set2 = this.set;
|
|
2716
|
+
if (!set2.length) {
|
|
2717
|
+
this.regexp = false;
|
|
2718
|
+
return this.regexp;
|
|
2719
|
+
}
|
|
2720
|
+
const options = this.options;
|
|
2721
|
+
const twoStar = options.noglobstar ? star$1 : options.dot ? twoStarDot : twoStarNoDot;
|
|
2722
|
+
const flags2 = new Set(options.nocase ? ["i"] : []);
|
|
2723
|
+
let re = set2.map((pattern) => {
|
|
2724
|
+
const pp = pattern.map((p2) => {
|
|
2725
|
+
if (p2 instanceof RegExp) {
|
|
2726
|
+
for (const f of p2.flags.split(""))
|
|
2727
|
+
flags2.add(f);
|
|
2728
|
+
}
|
|
2729
|
+
return typeof p2 === "string" ? regExpEscape(p2) : p2 === GLOBSTAR ? GLOBSTAR : p2._src;
|
|
2730
|
+
});
|
|
2731
|
+
pp.forEach((p2, i2) => {
|
|
2732
|
+
const next = pp[i2 + 1];
|
|
2733
|
+
const prev = pp[i2 - 1];
|
|
2734
|
+
if (p2 !== GLOBSTAR || prev === GLOBSTAR) {
|
|
2735
|
+
return;
|
|
2736
|
+
}
|
|
2737
|
+
if (prev === void 0) {
|
|
2738
|
+
if (next !== void 0 && next !== GLOBSTAR) {
|
|
2739
|
+
pp[i2 + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
|
|
2740
|
+
} else {
|
|
2741
|
+
pp[i2] = twoStar;
|
|
2742
|
+
}
|
|
2743
|
+
} else if (next === void 0) {
|
|
2744
|
+
pp[i2 - 1] = prev + "(?:\\/|" + twoStar + ")?";
|
|
2745
|
+
} else if (next !== GLOBSTAR) {
|
|
2746
|
+
pp[i2 - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
|
|
2747
|
+
pp[i2 + 1] = GLOBSTAR;
|
|
2748
|
+
}
|
|
2749
|
+
});
|
|
2750
|
+
return pp.filter((p2) => p2 !== GLOBSTAR).join("/");
|
|
2751
|
+
}).join("|");
|
|
2752
|
+
const [open2, close] = set2.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
2753
|
+
re = "^" + open2 + re + close + "$";
|
|
2754
|
+
if (this.negate)
|
|
2755
|
+
re = "^(?!" + re + ").+$";
|
|
2756
|
+
try {
|
|
2757
|
+
this.regexp = new RegExp(re, [...flags2].join(""));
|
|
2758
|
+
} catch (ex) {
|
|
2759
|
+
this.regexp = false;
|
|
2760
|
+
}
|
|
2761
|
+
return this.regexp;
|
|
2762
|
+
}
|
|
2763
|
+
slashSplit(p2) {
|
|
2764
|
+
if (this.preserveMultipleSlashes) {
|
|
2765
|
+
return p2.split("/");
|
|
2766
|
+
} else if (this.isWindows && /^\/\/[^\/]+/.test(p2)) {
|
|
2767
|
+
return ["", ...p2.split(/\/+/)];
|
|
2768
|
+
} else {
|
|
2769
|
+
return p2.split(/\/+/);
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
match(f, partial = this.partial) {
|
|
2773
|
+
this.debug("match", f, this.pattern);
|
|
2774
|
+
if (this.comment) {
|
|
2775
|
+
return false;
|
|
2776
|
+
}
|
|
2777
|
+
if (this.empty) {
|
|
2778
|
+
return f === "";
|
|
2779
|
+
}
|
|
2780
|
+
if (f === "/" && partial) {
|
|
2781
|
+
return true;
|
|
2782
|
+
}
|
|
2783
|
+
const options = this.options;
|
|
2784
|
+
if (this.isWindows) {
|
|
2785
|
+
f = f.split("\\").join("/");
|
|
2786
|
+
}
|
|
2787
|
+
const ff = this.slashSplit(f);
|
|
2788
|
+
this.debug(this.pattern, "split", ff);
|
|
2789
|
+
const set2 = this.set;
|
|
2790
|
+
this.debug(this.pattern, "set", set2);
|
|
2791
|
+
let filename = ff[ff.length - 1];
|
|
2792
|
+
if (!filename) {
|
|
2793
|
+
for (let i2 = ff.length - 2; !filename && i2 >= 0; i2--) {
|
|
2794
|
+
filename = ff[i2];
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2797
|
+
for (let i2 = 0; i2 < set2.length; i2++) {
|
|
2798
|
+
const pattern = set2[i2];
|
|
2799
|
+
let file = ff;
|
|
2800
|
+
if (options.matchBase && pattern.length === 1) {
|
|
2801
|
+
file = [filename];
|
|
2802
|
+
}
|
|
2803
|
+
const hit2 = this.matchOne(file, pattern, partial);
|
|
2804
|
+
if (hit2) {
|
|
2805
|
+
if (options.flipNegate) {
|
|
2806
|
+
return true;
|
|
2807
|
+
}
|
|
2808
|
+
return !this.negate;
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
if (options.flipNegate) {
|
|
2812
|
+
return false;
|
|
2813
|
+
}
|
|
2814
|
+
return this.negate;
|
|
2815
|
+
}
|
|
2816
|
+
static defaults(def) {
|
|
2817
|
+
return minimatch.defaults(def).Minimatch;
|
|
2818
|
+
}
|
|
2819
|
+
}
|
|
2820
|
+
minimatch.AST = AST;
|
|
2821
|
+
minimatch.Minimatch = Minimatch;
|
|
2822
|
+
minimatch.escape = escape$1;
|
|
2823
|
+
minimatch.unescape = unescape;
|
|
1486
2824
|
/*!
|
|
1487
2825
|
* re2js
|
|
1488
2826
|
* RE2JS is the JavaScript port of RE2, a regular expression engine that provides linear time matching
|
|
@@ -2996,10 +4334,10 @@ const _Regexp = class _Regexp {
|
|
|
2996
4334
|
break;
|
|
2997
4335
|
}
|
|
2998
4336
|
case _Regexp.Op.ALTERNATE: {
|
|
2999
|
-
let
|
|
4337
|
+
let sep2 = "";
|
|
3000
4338
|
for (let sub2 of this.subs) {
|
|
3001
|
-
out2 +=
|
|
3002
|
-
|
|
4339
|
+
out2 += sep2;
|
|
4340
|
+
sep2 = "|";
|
|
3003
4341
|
out2 += sub2.appendTo();
|
|
3004
4342
|
}
|
|
3005
4343
|
break;
|
|
@@ -6584,7 +7922,10 @@ const _ContextFiltersProvider = class _ContextFiltersProvider {
|
|
|
6584
7922
|
}
|
|
6585
7923
|
// Visible for testing.
|
|
6586
7924
|
get timerStateForTest() {
|
|
6587
|
-
return {
|
|
7925
|
+
return {
|
|
7926
|
+
delay: this.lastFetchDelay,
|
|
7927
|
+
lifetime: this.lastResultLifetime
|
|
7928
|
+
};
|
|
6588
7929
|
}
|
|
6589
7930
|
// Fetches context filters and updates the cached filter results
|
|
6590
7931
|
async fetchContextFilters() {
|
|
@@ -6659,9 +8000,6 @@ const _ContextFiltersProvider = class _ContextFiltersProvider {
|
|
|
6659
8000
|
await this.lastResultLifetime;
|
|
6660
8001
|
}
|
|
6661
8002
|
async isRepoNameIgnored(repoName) {
|
|
6662
|
-
if (isDotCom(currentAuthStatus())) {
|
|
6663
|
-
return false;
|
|
6664
|
-
}
|
|
6665
8003
|
await this.fetchIfNeeded();
|
|
6666
8004
|
return this.isRepoNameIgnored__noFetch(repoName);
|
|
6667
8005
|
}
|
|
@@ -6688,13 +8026,15 @@ const _ContextFiltersProvider = class _ContextFiltersProvider {
|
|
|
6688
8026
|
return isIgnored;
|
|
6689
8027
|
}
|
|
6690
8028
|
async isUriIgnored(uri) {
|
|
6691
|
-
if (isDotCom(currentAuthStatus())) {
|
|
6692
|
-
return false;
|
|
6693
|
-
}
|
|
6694
8029
|
if (!uri || allowedSchemes.has(uri.scheme)) {
|
|
6695
8030
|
return false;
|
|
6696
8031
|
}
|
|
6697
8032
|
await this.fetchIfNeeded();
|
|
8033
|
+
if (_ContextFiltersProvider.excludePatternGetter) {
|
|
8034
|
+
if (await this.isExcludedByPatterns(uri)) {
|
|
8035
|
+
return "exclude-pattern-match";
|
|
8036
|
+
}
|
|
8037
|
+
}
|
|
6698
8038
|
if (this.hasAllowEverythingFilters()) {
|
|
6699
8039
|
return false;
|
|
6700
8040
|
}
|
|
@@ -6729,6 +8069,41 @@ const _ContextFiltersProvider = class _ContextFiltersProvider {
|
|
|
6729
8069
|
}
|
|
6730
8070
|
return false;
|
|
6731
8071
|
}
|
|
8072
|
+
async isExcludedByPatterns(uri) {
|
|
8073
|
+
try {
|
|
8074
|
+
const workspaceFolder = _ContextFiltersProvider.excludePatternGetter.getWorkspaceFolder(uri);
|
|
8075
|
+
const excludePatternString = await _ContextFiltersProvider.excludePatternGetter.getExcludePattern(workspaceFolder);
|
|
8076
|
+
const patterns = this.parseExcludePatternString(excludePatternString);
|
|
8077
|
+
let relativePath;
|
|
8078
|
+
if (workspaceFolder) {
|
|
8079
|
+
const workspacePath = workspaceFolder.uri.fsPath;
|
|
8080
|
+
if (uri.fsPath.startsWith(workspacePath)) {
|
|
8081
|
+
relativePath = uri.fsPath.substring(workspacePath.length + 1).replace(/\\/g, "/");
|
|
8082
|
+
} else {
|
|
8083
|
+
return false;
|
|
8084
|
+
}
|
|
8085
|
+
} else {
|
|
8086
|
+
relativePath = uri.fsPath.replace(/\\/g, "/");
|
|
8087
|
+
}
|
|
8088
|
+
return patterns.some((pattern) => minimatch(relativePath, pattern, { dot: true }));
|
|
8089
|
+
} catch (error) {
|
|
8090
|
+
logDebug$1("ContextFiltersProvider", "isExcludedByPatterns error", { error });
|
|
8091
|
+
return false;
|
|
8092
|
+
}
|
|
8093
|
+
}
|
|
8094
|
+
parseExcludePatternString(patternString) {
|
|
8095
|
+
if (!patternString || typeof patternString !== "string") {
|
|
8096
|
+
return [];
|
|
8097
|
+
}
|
|
8098
|
+
if (patternString.startsWith("{") && patternString.endsWith("}")) {
|
|
8099
|
+
const content = patternString.slice(1, -1);
|
|
8100
|
+
return content ? content.split(",").filter((pattern) => pattern.trim() !== "") : [];
|
|
8101
|
+
}
|
|
8102
|
+
if (patternString.includes(",") || patternString.includes("{") || patternString.includes("}")) {
|
|
8103
|
+
return [];
|
|
8104
|
+
}
|
|
8105
|
+
return [patternString.trim()].filter((pattern) => pattern !== "");
|
|
8106
|
+
}
|
|
6732
8107
|
reset() {
|
|
6733
8108
|
this.lastFetchTimestamp = 0;
|
|
6734
8109
|
this.lastResultLifetime = Promise.resolve(TRANSIENT_REFETCH_INTERVAL_HINT);
|
|
@@ -6741,7 +8116,7 @@ const _ContextFiltersProvider = class _ContextFiltersProvider {
|
|
|
6741
8116
|
this.reset();
|
|
6742
8117
|
}
|
|
6743
8118
|
hasAllowEverythingFilters() {
|
|
6744
|
-
return
|
|
8119
|
+
return this.lastContextFiltersResponse === INCLUDE_EVERYTHING_CONTEXT_FILTERS;
|
|
6745
8120
|
}
|
|
6746
8121
|
hasIgnoreEverythingFilters() {
|
|
6747
8122
|
return this.lastContextFiltersResponse === EXCLUDE_EVERYTHING_CONTEXT_FILTERS;
|
|
@@ -6753,6 +8128,7 @@ const _ContextFiltersProvider = class _ContextFiltersProvider {
|
|
|
6753
8128
|
}
|
|
6754
8129
|
};
|
|
6755
8130
|
__publicField2(_ContextFiltersProvider, "repoNameResolver");
|
|
8131
|
+
__publicField2(_ContextFiltersProvider, "excludePatternGetter");
|
|
6756
8132
|
let ContextFiltersProvider = _ContextFiltersProvider;
|
|
6757
8133
|
function matchesContextFilter(parsedFilter, repoName) {
|
|
6758
8134
|
return Boolean(parsedFilter.repoNamePattern.matcher(repoName).find(0));
|
|
@@ -6988,11 +8364,9 @@ function syncModels({
|
|
|
6988
8364
|
if (!authStatus22.authenticated) {
|
|
6989
8365
|
return Observable.of({ primaryModels: [], preferences: null });
|
|
6990
8366
|
}
|
|
6991
|
-
const isDotComUser = isDotCom(authStatus22);
|
|
6992
|
-
const isCodyFreeUser = userProductSubscription22 == null || userProductSubscription22.userCanUpgrade === true;
|
|
6993
8367
|
const serverModelsConfig = clientConfig.pipe(
|
|
6994
8368
|
switchMapReplayOperation((maybeServerSideClientConfig) => {
|
|
6995
|
-
if (
|
|
8369
|
+
if (maybeServerSideClientConfig == null ? void 0 : maybeServerSideClientConfig.modelsAPIEnabled) {
|
|
6996
8370
|
logDebug$1("ModelsService", "new models API enabled");
|
|
6997
8371
|
return promiseFactoryToObservable(
|
|
6998
8372
|
(signal2) => fetchServerSideModels_(config, signal2)
|
|
@@ -7029,15 +8403,12 @@ function syncModels({
|
|
|
7029
8403
|
]) => {
|
|
7030
8404
|
if (serverModelsConfig2) {
|
|
7031
8405
|
const filteredModels = serverModelsConfig2 == null ? void 0 : serverModelsConfig2.models.filter(
|
|
7032
|
-
(m) => m.status !== "deprecated" &&
|
|
8406
|
+
(m) => m.status !== "deprecated" && m.status !== "waitlist"
|
|
7033
8407
|
);
|
|
7034
8408
|
data.primaryModels = maybeAdjustContextWindows(
|
|
7035
8409
|
filteredModels,
|
|
7036
8410
|
{
|
|
7037
|
-
tier:
|
|
7038
|
-
authStatus22,
|
|
7039
|
-
userProductSubscription22
|
|
7040
|
-
) ? "pro" : "free" : "enterprise",
|
|
8411
|
+
tier: "enterprise",
|
|
7041
8412
|
enhancedContextWindowFlagEnabled: enhancedContextWindowFlag
|
|
7042
8413
|
}
|
|
7043
8414
|
).map(
|
|
@@ -7050,35 +8421,13 @@ function syncModels({
|
|
|
7050
8421
|
serverModelsConfig2
|
|
7051
8422
|
);
|
|
7052
8423
|
}
|
|
7053
|
-
|
|
7054
|
-
data.primaryModels = data.primaryModels.map(
|
|
7055
|
-
(model2) => {
|
|
7056
|
-
if (model2.tags.includes(ModelTag.Waitlist)) {
|
|
7057
|
-
const newTags = model2.tags.filter(
|
|
7058
|
-
(tag2) => tag2 !== ModelTag.Waitlist
|
|
7059
|
-
);
|
|
7060
|
-
newTags.push(
|
|
7061
|
-
hasEarlyAccess ? ModelTag.EarlyAccess : ModelTag.OnWaitlist
|
|
7062
|
-
);
|
|
7063
|
-
return { ...model2, tags: newTags };
|
|
7064
|
-
}
|
|
7065
|
-
return model2;
|
|
7066
|
-
}
|
|
7067
|
-
);
|
|
7068
|
-
}
|
|
7069
|
-
const isVisionSupported = !isDotComUser && hasEarlyAccess;
|
|
8424
|
+
const isVisionSupported = hasEarlyAccess;
|
|
7070
8425
|
data.primaryModels = data.primaryModels.map((m) => ({
|
|
7071
8426
|
...m,
|
|
7072
8427
|
// Gateway doesn't suppoort vision models for Google yet
|
|
7073
8428
|
tags: isVisionSupported && m.provider !== "google" ? m.tags : m.tags.filter((t) => t !== ModelTag.Vision)
|
|
7074
8429
|
}));
|
|
7075
|
-
|
|
7076
|
-
(m) => m.id.includes("5-haiku")
|
|
7077
|
-
);
|
|
7078
|
-
if (isDotComUser && isCodyFreeUser && defaultToHaiku && haikuModel) {
|
|
7079
|
-
data.preferences.defaults.chat = haikuModel.id;
|
|
7080
|
-
}
|
|
7081
|
-
if (fallbackToFlashFlag && !isFreeUser(authStatus22, userProductSubscription22)) {
|
|
8430
|
+
if (fallbackToFlashFlag) {
|
|
7082
8431
|
if (authStatus22.rateLimited) {
|
|
7083
8432
|
const hasUnlimitedModels = data.primaryModels.some(
|
|
7084
8433
|
(model2) => model2.tags.includes(ModelTag.Unlimited)
|
|
@@ -7475,7 +8824,7 @@ class ModelsService {
|
|
|
7475
8824
|
}
|
|
7476
8825
|
models = models.filter((model2) => !model2.tags.includes(ModelTag.Deprecated));
|
|
7477
8826
|
const firstModelUserCanUse = models.find(
|
|
7478
|
-
(m) => this._isModelAvailable(modelsData, authStatus2,
|
|
8827
|
+
(m) => this._isModelAvailable(modelsData, authStatus2, m) === true && !m.tags.includes(ModelTag.Reasoning)
|
|
7479
8828
|
);
|
|
7480
8829
|
if (modelsData.preferences) {
|
|
7481
8830
|
const selected = this.resolveModel(
|
|
@@ -7483,12 +8832,7 @@ class ModelsService {
|
|
|
7483
8832
|
modelsData.preferences.selected[type] ?? modelsData.preferences.defaults[type]
|
|
7484
8833
|
);
|
|
7485
8834
|
if (selected && // Don't set default model for ModelUsage.Edit if the model has certain tags
|
|
7486
|
-
!(type === ModelUsage.Edit && (selected.tags.includes(ModelTag.Reasoning) || selected.tags.includes(ModelTag.Deprecated))) && this._isModelAvailable(
|
|
7487
|
-
modelsData,
|
|
7488
|
-
authStatus2,
|
|
7489
|
-
userProductSubscription2,
|
|
7490
|
-
selected
|
|
7491
|
-
) === true) {
|
|
8835
|
+
!(type === ModelUsage.Edit && (selected.tags.includes(ModelTag.Reasoning) || selected.tags.includes(ModelTag.Deprecated))) && this._isModelAvailable(modelsData, authStatus2, selected) === true) {
|
|
7492
8836
|
return selected;
|
|
7493
8837
|
}
|
|
7494
8838
|
}
|
|
@@ -7550,23 +8894,23 @@ class ModelsService {
|
|
|
7550
8894
|
isModelAvailable(model2) {
|
|
7551
8895
|
return combineLatest$1(authStatus, this.modelsChanges, userProductSubscription).pipe(
|
|
7552
8896
|
map$1(
|
|
7553
|
-
([authStatus2, modelsData, userProductSubscription2]) => modelsData === pendingOperation || userProductSubscription2 === pendingOperation ? pendingOperation : this._isModelAvailable(modelsData, authStatus2,
|
|
8897
|
+
([authStatus2, modelsData, userProductSubscription2]) => modelsData === pendingOperation || userProductSubscription2 === pendingOperation ? pendingOperation : this._isModelAvailable(modelsData, authStatus2, model2)
|
|
7554
8898
|
),
|
|
7555
8899
|
distinctUntilChanged$1()
|
|
7556
8900
|
);
|
|
7557
8901
|
}
|
|
7558
|
-
_isModelAvailable(modelsData, authStatus2,
|
|
8902
|
+
_isModelAvailable(modelsData, authStatus2, model2) {
|
|
7559
8903
|
const resolved = this.resolveModel(modelsData, model2);
|
|
7560
8904
|
if (!resolved) {
|
|
7561
8905
|
return false;
|
|
7562
8906
|
}
|
|
8907
|
+
if (resolved.tags.includes(ModelTag.Waitlist) || resolved.tags.includes(ModelTag.OnWaitlist)) {
|
|
8908
|
+
return false;
|
|
8909
|
+
}
|
|
7563
8910
|
const tier = modelTier(resolved);
|
|
7564
8911
|
if (isEnterpriseUser(authStatus2)) {
|
|
7565
8912
|
return true;
|
|
7566
8913
|
}
|
|
7567
|
-
if (isCodyProUser(authStatus2, sub2)) {
|
|
7568
|
-
return tier !== "enterprise" && !resolved.tags.includes(ModelTag.Waitlist) && !resolved.tags.includes(ModelTag.OnWaitlist);
|
|
7569
|
-
}
|
|
7570
8914
|
return tier === "free";
|
|
7571
8915
|
}
|
|
7572
8916
|
// does an approximate match on the model id, seeing if there are any models in the
|
|
@@ -8162,7 +9506,7 @@ async function getTokenCounterUtils() {
|
|
|
8162
9506
|
const browser2 = detect();
|
|
8163
9507
|
if (browser2 && browser2.name === "safari") {
|
|
8164
9508
|
_tokenCounterUtilsPromise = import("./cl100k_base-B4kyDDRQ.mjs").then(async (tokenizer2) => {
|
|
8165
|
-
const tiktoken = await import("./lite-
|
|
9509
|
+
const tiktoken = await import("./lite-b2NFi2v9.mjs");
|
|
8166
9510
|
return createTokenCounterUtils(new tiktoken.Tiktoken(tokenizer2.default));
|
|
8167
9511
|
});
|
|
8168
9512
|
} else {
|
|
@@ -9601,7 +10945,7 @@ class APIClient {
|
|
|
9601
10945
|
const socketKeepAliveInterval = 60 * 1e3;
|
|
9602
10946
|
const keepAliveTimeout = setTimeout(() => {
|
|
9603
10947
|
var _a3, _b2;
|
|
9604
|
-
if ((_a3 = fetchOptions == null ? void 0 : fetchOptions.agent) == null ? void 0 : _a3.sockets) {
|
|
10948
|
+
if (fetchOptions && ((_a3 = fetchOptions == null ? void 0 : fetchOptions.agent) == null ? void 0 : _a3.sockets)) {
|
|
9605
10949
|
for (const socket of Object.values((_b2 = fetchOptions == null ? void 0 : fetchOptions.agent) == null ? void 0 : _b2.sockets).flat()) {
|
|
9606
10950
|
if (socket == null ? void 0 : socket.setKeepAlive) {
|
|
9607
10951
|
socket.setKeepAlive(true, socketKeepAliveInterval);
|
|
@@ -12087,7 +13431,7 @@ class SourcegraphBrowserCompletionsClient extends SourcegraphCompletionsClient {
|
|
|
12087
13431
|
try {
|
|
12088
13432
|
await addAuthHeaders(config.auth, headersInstance, url);
|
|
12089
13433
|
} catch (error) {
|
|
12090
|
-
cb.onError(error
|
|
13434
|
+
cb.onError(error instanceof Error ? error : new Error(String(error)));
|
|
12091
13435
|
abort2.abort();
|
|
12092
13436
|
console.error(error);
|
|
12093
13437
|
return;
|
|
@@ -12109,7 +13453,10 @@ class SourcegraphBrowserCompletionsClient extends SourcegraphCompletionsClient {
|
|
|
12109
13453
|
async onopen(response) {
|
|
12110
13454
|
if (!response.ok && response.headers.get("content-type") !== "text/event-stream") {
|
|
12111
13455
|
const error = await verifyResponseCode(response).catch((err2) => err2);
|
|
12112
|
-
cb.onError(
|
|
13456
|
+
cb.onError(
|
|
13457
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
13458
|
+
response.status
|
|
13459
|
+
);
|
|
12113
13460
|
abort2.abort();
|
|
12114
13461
|
return;
|
|
12115
13462
|
}
|
|
@@ -12142,21 +13489,21 @@ class SourcegraphBrowserCompletionsClient extends SourcegraphCompletionsClient {
|
|
|
12142
13489
|
}
|
|
12143
13490
|
this.sendEvents(events2, cb);
|
|
12144
13491
|
} catch (error) {
|
|
12145
|
-
cb.onError(error
|
|
13492
|
+
cb.onError(error instanceof Error ? error : new Error(String(error)));
|
|
12146
13493
|
abort2.abort();
|
|
12147
13494
|
console.error(error);
|
|
12148
13495
|
throw error;
|
|
12149
13496
|
}
|
|
12150
13497
|
},
|
|
12151
13498
|
onerror(error) {
|
|
12152
|
-
cb.onError(error
|
|
13499
|
+
cb.onError(error instanceof Error ? error : new Error(String(error)));
|
|
12153
13500
|
abort2.abort();
|
|
12154
13501
|
console.error(error);
|
|
12155
13502
|
throw error;
|
|
12156
13503
|
},
|
|
12157
13504
|
fetch: globalThis.fetch
|
|
12158
13505
|
}).catch((error) => {
|
|
12159
|
-
cb.onError(error
|
|
13506
|
+
cb.onError(error instanceof Error ? error : new Error(String(error)));
|
|
12160
13507
|
abort2.abort();
|
|
12161
13508
|
console.error(error);
|
|
12162
13509
|
});
|
|
@@ -12192,7 +13539,7 @@ class SourcegraphBrowserCompletionsClient extends SourcegraphCompletionsClient {
|
|
|
12192
13539
|
}
|
|
12193
13540
|
} catch (error) {
|
|
12194
13541
|
console.error(error);
|
|
12195
|
-
cb.onError(error instanceof Error ? error : new Error(
|
|
13542
|
+
cb.onError(error instanceof Error ? error : new Error(String(error)));
|
|
12196
13543
|
}
|
|
12197
13544
|
}
|
|
12198
13545
|
}
|
|
@@ -12312,13 +13659,12 @@ const events$2 = [
|
|
|
12312
13659
|
event(
|
|
12313
13660
|
"cody.chat-question/submitted",
|
|
12314
13661
|
({ feature: feature2, action }) => (params) => {
|
|
12315
|
-
const recordTranscript = params.authStatus.endpoint && isDotCom(params.authStatus);
|
|
12316
|
-
const gitMetadata = isDotCom(params.authStatus) && params.repoIsPublic && lodashExports.isArray(params.repoMetadata) ? params.repoMetadata : void 0;
|
|
12317
13662
|
telemetryRecorder.recordEvent(feature2, action, {
|
|
12318
13663
|
metadata: {
|
|
12319
|
-
// Flag indicating this is a transcript event to go through ML data pipeline.
|
|
13664
|
+
// Flag indicating this is a transcript event to go through ML data pipeline. Not for enterprise users
|
|
12320
13665
|
// See https://github.com/sourcegraph/sourcegraph/pull/59524
|
|
12321
|
-
recordsPrivateMetadataTranscript:
|
|
13666
|
+
recordsPrivateMetadataTranscript: 0,
|
|
13667
|
+
// todo(mk): remove in the scope of PLG sunsetting
|
|
12322
13668
|
isPublicRepo: params.repoIsPublic ? 1 : 0,
|
|
12323
13669
|
// TODO: Remove this field when the transition from commands to prompts is complete
|
|
12324
13670
|
isCommand: params.command ? 1 : 0,
|
|
@@ -12332,11 +13678,9 @@ const events$2 = [
|
|
|
12332
13678
|
requestID: params.requestID,
|
|
12333
13679
|
sessionID: params.sessionID,
|
|
12334
13680
|
traceId: params.traceId,
|
|
12335
|
-
|
|
12336
|
-
//
|
|
12337
|
-
|
|
12338
|
-
promptText: recordTranscript ? truncatePromptString(params.promptText, CHAT_INPUT_TOKEN_BUDGET) : void 0,
|
|
12339
|
-
gitMetadata,
|
|
13681
|
+
promptText: void 0,
|
|
13682
|
+
// todo(mk): remove in the scope of PLG sunsetting
|
|
13683
|
+
gitMetadata: void 0,
|
|
12340
13684
|
chatAgent: params.chatAgent
|
|
12341
13685
|
},
|
|
12342
13686
|
billingMetadata: {
|
|
@@ -12352,7 +13696,7 @@ const events$2 = [
|
|
|
12352
13696
|
event(
|
|
12353
13697
|
"cody.chat-question/executed",
|
|
12354
13698
|
({ feature: feature2, action, map: map2 }) => (params, spans) => {
|
|
12355
|
-
const recordTranscript = params.authStatus.endpoint &&
|
|
13699
|
+
const recordTranscript = params.authStatus.endpoint && isS2(params.authStatus);
|
|
12356
13700
|
const gitMetadata = recordTranscript && params.repoIsPublic && lodashExports.isArray(params.repoMetadata) ? params.repoMetadata : void 0;
|
|
12357
13701
|
const metadata2 = lodashExports.isArray(params.context) ? publicContextSummary("context", params.context) : {
|
|
12358
13702
|
...publicContextSummary("context.used", params.context.used),
|
|
@@ -12377,8 +13721,8 @@ const events$2 = [
|
|
|
12377
13721
|
userSpecifiedIntent: params.userSpecifiedIntent,
|
|
12378
13722
|
traceId: spans.current.spanContext().traceId,
|
|
12379
13723
|
gitMetadata,
|
|
12380
|
-
// 🚨 SECURITY: Chat transcripts are to be included only for S2
|
|
12381
|
-
// V2 telemetry exports privateMetadata only for S2
|
|
13724
|
+
// 🚨 SECURITY: Chat transcripts are to be included only for S2 users AND for V2 telemetry.
|
|
13725
|
+
// V2 telemetry exports privateMetadata only for S2 users. The condition below is an additional safeguard measure.
|
|
12382
13726
|
// Check `SRC_TELEMETRY_SENSITIVEMETADATA_ADDITIONAL_ALLOWED_EVENT_TYPES` env to learn more.
|
|
12383
13727
|
promptText: recordTranscript ? truncatePromptString(params.promptText, CHAT_INPUT_TOKEN_BUDGET) : void 0,
|
|
12384
13728
|
chatAgent: params.chatAgent
|
|
@@ -14110,7 +15454,7 @@ async function groqChatClient({
|
|
|
14110
15454
|
log2 == null ? void 0 : log2.onComplete(completionResponse);
|
|
14111
15455
|
}).catch((error) => {
|
|
14112
15456
|
log2 == null ? void 0 : log2.onError(error);
|
|
14113
|
-
cb.onError(error);
|
|
15457
|
+
cb.onError(error instanceof Error ? error : new Error(String(error)));
|
|
14114
15458
|
});
|
|
14115
15459
|
}
|
|
14116
15460
|
const getContextForChatMessage = async (message, parentSignal) => {
|
|
@@ -14325,7 +15669,7 @@ function createRuleService(providers, {
|
|
|
14325
15669
|
const BUILTIN_RULES = [RULE_EDITING_HELPER_RULE];
|
|
14326
15670
|
const own$2 = {}.hasOwnProperty;
|
|
14327
15671
|
function zwitch(key2, options) {
|
|
14328
|
-
const settings = options;
|
|
15672
|
+
const settings = options || {};
|
|
14329
15673
|
function one2(value, ...parameters) {
|
|
14330
15674
|
let fn = one2.invalid;
|
|
14331
15675
|
const handlers2 = one2.handlers;
|
|
@@ -14766,7 +16110,7 @@ function observeProviderCall(providerClients, fn, { emitPartial, errorHook, logg
|
|
|
14766
16110
|
console.error(error);
|
|
14767
16111
|
}
|
|
14768
16112
|
return Observable.of(null);
|
|
14769
|
-
})).pipe(map$1((items) => items === EMIT_PARTIAL_SENTINEL ? items : (items || []).map((item) => ({ ...item, providerUri: uri })))))) : Observable.of([])), filter$
|
|
16113
|
+
})).pipe(map$1((items) => items === EMIT_PARTIAL_SENTINEL ? items : (items || []).map((item) => ({ ...item, providerUri: uri })))))) : Observable.of([])), filter$2((result) => !emitPartial || result.length === 0 || result.some((v) => v !== EMIT_PARTIAL_SENTINEL)), map$1((result) => result.filter((v) => v !== null && v !== EMIT_PARTIAL_SENTINEL).flat()), distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)), tap$1((items) => {
|
|
14770
16114
|
}));
|
|
14771
16115
|
}
|
|
14772
16116
|
function observeMeta(providerClients, params, opts) {
|
|
@@ -18019,16 +19363,16 @@ function resolveProviderUrisInConfig(config, scope) {
|
|
|
18019
19363
|
return void 0;
|
|
18020
19364
|
}
|
|
18021
19365
|
return Object.fromEntries(Object.entries(providers).map(([providerUri, settings]) => {
|
|
18022
|
-
const isRelativeFilePath = providerUri.startsWith("../") || providerUri.startsWith("./") || providerUri.startsWith(`..${path.sep}`) || providerUri.startsWith(`.${path.sep}`);
|
|
19366
|
+
const isRelativeFilePath = providerUri.startsWith("../") || providerUri.startsWith("./") || providerUri.startsWith(`..${path$1.sep}`) || providerUri.startsWith(`.${path$1.sep}`);
|
|
18023
19367
|
if (isRelativeFilePath) {
|
|
18024
|
-
providerUri = fromUri.with({ path: path.resolve(fromUri.path, providerUri) }).toString();
|
|
19368
|
+
providerUri = fromUri.with({ path: path$1.resolve(fromUri.path, providerUri) }).toString();
|
|
18025
19369
|
}
|
|
18026
19370
|
return [providerUri, settings];
|
|
18027
19371
|
}));
|
|
18028
19372
|
}
|
|
18029
19373
|
const scopeUri = scope && ("uri" in scope ? scope.uri : "fsPath" in scope ? scope : scope.uri);
|
|
18030
19374
|
const workspaceFile = (_a3 = workspace.workspaceFile) == null ? void 0 : _a3.with({
|
|
18031
|
-
path: path.dirname(workspace.workspaceFile.path)
|
|
19375
|
+
path: path$1.dirname(workspace.workspaceFile.path)
|
|
18032
19376
|
});
|
|
18033
19377
|
const workspaceFolder = scopeUri ? workspace.getWorkspaceFolder(scopeUri) : void 0;
|
|
18034
19378
|
const workspaceFolderSettingsFileUri = workspaceFolder ? workspaceFolder.uri.with({ path: workspaceFolder.uri.path + "/.vscode" }) : void 0;
|
|
@@ -20045,9 +21389,9 @@ function requireBuffer() {
|
|
|
20045
21389
|
Object.setPrototypeOf(newBuf, Buffer2.prototype);
|
|
20046
21390
|
return newBuf;
|
|
20047
21391
|
};
|
|
20048
|
-
function checkOffset(offset2,
|
|
21392
|
+
function checkOffset(offset2, ext2, length) {
|
|
20049
21393
|
if (offset2 % 1 !== 0 || offset2 < 0) throw new RangeError("offset is not uint");
|
|
20050
|
-
if (offset2 +
|
|
21394
|
+
if (offset2 + ext2 > length) throw new RangeError("Trying to access beyond buffer length");
|
|
20051
21395
|
}
|
|
20052
21396
|
Buffer2.prototype.readUintLE = Buffer2.prototype.readUIntLE = function readUIntLE(offset2, byteLength3, noAssert) {
|
|
20053
21397
|
offset2 = offset2 >>> 0;
|
|
@@ -20222,10 +21566,10 @@ function requireBuffer() {
|
|
|
20222
21566
|
if (!noAssert) checkOffset(offset2, 8, this.length);
|
|
20223
21567
|
return ieee7542.read(this, offset2, false, 52, 8);
|
|
20224
21568
|
};
|
|
20225
|
-
function checkInt(buf, value, offset2,
|
|
21569
|
+
function checkInt(buf, value, offset2, ext2, max, min) {
|
|
20226
21570
|
if (!Buffer2.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
|
|
20227
21571
|
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
|
|
20228
|
-
if (offset2 +
|
|
21572
|
+
if (offset2 + ext2 > buf.length) throw new RangeError("Index out of range");
|
|
20229
21573
|
}
|
|
20230
21574
|
Buffer2.prototype.writeUintLE = Buffer2.prototype.writeUIntLE = function writeUIntLE(value, offset2, byteLength3, noAssert) {
|
|
20231
21575
|
value = +value;
|
|
@@ -20437,8 +21781,8 @@ function requireBuffer() {
|
|
|
20437
21781
|
Buffer2.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset2 = 0) {
|
|
20438
21782
|
return wrtBigUInt64BE(this, value, offset2, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
20439
21783
|
});
|
|
20440
|
-
function checkIEEE754(buf, value, offset2,
|
|
20441
|
-
if (offset2 +
|
|
21784
|
+
function checkIEEE754(buf, value, offset2, ext2, max, min) {
|
|
21785
|
+
if (offset2 + ext2 > buf.length) throw new RangeError("Index out of range");
|
|
20442
21786
|
if (offset2 < 0) throw new RangeError("Index out of range");
|
|
20443
21787
|
}
|
|
20444
21788
|
function writeFloat(buf, value, offset2, littleEndian, noAssert) {
|
|
@@ -20846,7 +22190,7 @@ function requireBuffer_list() {
|
|
|
20846
22190
|
}
|
|
20847
22191
|
}
|
|
20848
22192
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
20849
|
-
_defineProperties(Constructor.prototype, protoProps);
|
|
22193
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
20850
22194
|
Object.defineProperty(Constructor, "prototype", { writable: false });
|
|
20851
22195
|
return Constructor;
|
|
20852
22196
|
}
|
|
@@ -20858,11 +22202,11 @@ function requireBuffer_list() {
|
|
|
20858
22202
|
if (typeof input !== "object" || input === null) return input;
|
|
20859
22203
|
var prim2 = input[Symbol.toPrimitive];
|
|
20860
22204
|
if (prim2 !== void 0) {
|
|
20861
|
-
var res = prim2.call(input, hint);
|
|
22205
|
+
var res = prim2.call(input, hint || "default");
|
|
20862
22206
|
if (typeof res !== "object") return res;
|
|
20863
22207
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
20864
22208
|
}
|
|
20865
|
-
return String(input);
|
|
22209
|
+
return (hint === "string" ? String : Number)(input);
|
|
20866
22210
|
}
|
|
20867
22211
|
var _require = requireBuffer(), Buffer2 = _require.Buffer;
|
|
20868
22212
|
var _require2 = requireUtil(), inspect = _require2.inspect;
|
|
@@ -23944,6 +25288,13 @@ class LocalStorage {
|
|
|
23944
25288
|
const accountKey = getKeyForAuthStatus(authStatus2);
|
|
23945
25289
|
return (history == null ? void 0 : history[accountKey]) ?? { chat: {} };
|
|
23946
25290
|
}
|
|
25291
|
+
/**
|
|
25292
|
+
* Get all chat history for all accounts without authentication check
|
|
25293
|
+
* Useful for export functionality when user can't authenticate
|
|
25294
|
+
*/
|
|
25295
|
+
getAllChatHistory() {
|
|
25296
|
+
return this.storage.get(this.KEY_LOCAL_HISTORY, null);
|
|
25297
|
+
}
|
|
23947
25298
|
async setChatHistory(authStatus2, history) {
|
|
23948
25299
|
try {
|
|
23949
25300
|
const key2 = getKeyForAuthStatus(authStatus2);
|
|
@@ -24294,19 +25645,22 @@ var define_process_default$h = { env: {} };
|
|
|
24294
25645
|
const CODY_OUTPUT_CHANNEL = "Cody by Sourcegraph";
|
|
24295
25646
|
class OutputChannelManager {
|
|
24296
25647
|
constructor() {
|
|
24297
|
-
__publicField2(this, "defaultOutputChannel", window$1.createOutputChannel(CODY_OUTPUT_CHANNEL,
|
|
25648
|
+
__publicField2(this, "defaultOutputChannel", window$1.createOutputChannel(CODY_OUTPUT_CHANNEL, { log: true }));
|
|
24298
25649
|
__publicField2(this, "outputChannels", /* @__PURE__ */ new Map());
|
|
24299
25650
|
}
|
|
24300
25651
|
getOutputChannel(feature2) {
|
|
24301
|
-
if (!this.outputChannels.has(feature2) && false)
|
|
25652
|
+
if (!this.outputChannels.has(feature2) && false) {
|
|
25653
|
+
const channel2 = window$1.createOutputChannel(`Cody ${feature2}`, { log: true });
|
|
25654
|
+
this.outputChannels.set(feature2, channel2);
|
|
25655
|
+
}
|
|
24302
25656
|
return this.outputChannels.get(feature2);
|
|
24303
25657
|
}
|
|
24304
|
-
appendLine(text2, feature2) {
|
|
24305
|
-
var _a3;
|
|
24306
|
-
(_a3 = this.defaultOutputChannel) == null ? void 0 : _a3.
|
|
25658
|
+
appendLine(level2, text2, feature2) {
|
|
25659
|
+
var _a3, _b2;
|
|
25660
|
+
level2 === "error" ? (_a3 = this.defaultOutputChannel) == null ? void 0 : _a3.error(text2) : (_b2 = this.defaultOutputChannel) == null ? void 0 : _b2.debug(text2);
|
|
24307
25661
|
if (feature2) {
|
|
24308
25662
|
const channel2 = this.getOutputChannel(feature2);
|
|
24309
|
-
channel2 == null ? void 0 : channel2.
|
|
25663
|
+
level2 === "error" ? channel2 == null ? void 0 : channel2.error(text2) : channel2 == null ? void 0 : channel2.debug(text2);
|
|
24310
25664
|
}
|
|
24311
25665
|
const path2 = define_process_default$h.env.CODY_LOG_FILE;
|
|
24312
25666
|
if (path2) {
|
|
@@ -24360,7 +25714,7 @@ class Logger {
|
|
|
24360
25714
|
args: args2,
|
|
24361
25715
|
debugVerbose
|
|
24362
25716
|
});
|
|
24363
|
-
outputChannelManager.appendLine(message, feature2);
|
|
25717
|
+
outputChannelManager.appendLine(level2, message, feature2);
|
|
24364
25718
|
}
|
|
24365
25719
|
}
|
|
24366
25720
|
const outputChannelLogger = new Logger();
|
|
@@ -24985,8 +26339,8 @@ async function signOut(endpoint) {
|
|
|
24985
26339
|
}
|
|
24986
26340
|
}
|
|
24987
26341
|
);
|
|
24988
|
-
await Promise.all([secretStorage.deleteToken(endpoint), localStorage.deleteEndpoint(endpoint)]);
|
|
24989
26342
|
authProvider.signout(endpoint);
|
|
26343
|
+
await Promise.all([secretStorage.deleteToken(endpoint), localStorage.deleteEndpoint(endpoint)]);
|
|
24990
26344
|
}
|
|
24991
26345
|
async function validateCredentials(config, signal2, clientConfig) {
|
|
24992
26346
|
var _a3, _b2;
|
|
@@ -25260,6 +26614,133 @@ function getEditor() {
|
|
|
25260
26614
|
};
|
|
25261
26615
|
return get2();
|
|
25262
26616
|
}
|
|
26617
|
+
async function findWorkspaceFiles() {
|
|
26618
|
+
var _a3;
|
|
26619
|
+
const excludePatternStrings = await Promise.all(
|
|
26620
|
+
((_a3 = workspace.workspaceFolders) == null ? void 0 : _a3.flatMap(
|
|
26621
|
+
(workspaceFolder) => getExcludePattern(workspaceFolder)
|
|
26622
|
+
)) ?? []
|
|
26623
|
+
);
|
|
26624
|
+
const allExcludePatterns = [];
|
|
26625
|
+
for (const patternString of excludePatternStrings) {
|
|
26626
|
+
if ((patternString == null ? void 0 : patternString.startsWith("{")) && patternString.endsWith("}")) {
|
|
26627
|
+
const content = patternString.slice(1, -1);
|
|
26628
|
+
if (content) {
|
|
26629
|
+
allExcludePatterns.push(...content.split(",").filter((p2) => p2.trim()));
|
|
26630
|
+
}
|
|
26631
|
+
}
|
|
26632
|
+
}
|
|
26633
|
+
const config = workspace.getConfiguration();
|
|
26634
|
+
const filesExclude = config.get("files.exclude") || {};
|
|
26635
|
+
const searchExclude = config.get("search.exclude") || {};
|
|
26636
|
+
for (const [pattern, enabled] of Object.entries(filesExclude)) {
|
|
26637
|
+
if (enabled) {
|
|
26638
|
+
allExcludePatterns.push(pattern);
|
|
26639
|
+
}
|
|
26640
|
+
}
|
|
26641
|
+
for (const [pattern, enabled] of Object.entries(searchExclude)) {
|
|
26642
|
+
if (enabled) {
|
|
26643
|
+
allExcludePatterns.push(pattern);
|
|
26644
|
+
}
|
|
26645
|
+
}
|
|
26646
|
+
allExcludePatterns.push("**/.vscode/**");
|
|
26647
|
+
const excludePattern = allExcludePatterns.length > 0 ? `{${allExcludePatterns.join(",")}}` : "";
|
|
26648
|
+
return workspace.findFiles("**/*", excludePattern);
|
|
26649
|
+
}
|
|
26650
|
+
const excludeCache = /* @__PURE__ */ new Map();
|
|
26651
|
+
const fileWatchers = /* @__PURE__ */ new Map();
|
|
26652
|
+
function getCacheKey(workspaceFolder) {
|
|
26653
|
+
return (workspaceFolder == null ? void 0 : workspaceFolder.uri.toString()) ?? "no-workspace";
|
|
26654
|
+
}
|
|
26655
|
+
function setupFileWatcher(workspaceFolder) {
|
|
26656
|
+
const filename = ".sourcegraph/ignore";
|
|
26657
|
+
const watcherKey = `${workspaceFolder.uri.toString()}:${filename}`;
|
|
26658
|
+
if (fileWatchers.has(watcherKey)) {
|
|
26659
|
+
return;
|
|
26660
|
+
}
|
|
26661
|
+
const pattern = new RelativePattern(workspaceFolder, filename);
|
|
26662
|
+
const watcher = workspace.createFileSystemWatcher(pattern);
|
|
26663
|
+
const updateCache = async () => {
|
|
26664
|
+
const cacheKey = getCacheKey(workspaceFolder);
|
|
26665
|
+
const fileUri = Uri.joinPath(workspaceFolder.uri, filename);
|
|
26666
|
+
const ignoreData = await readIgnoreFile(fileUri);
|
|
26667
|
+
excludeCache.set(cacheKey, ignoreData);
|
|
26668
|
+
};
|
|
26669
|
+
watcher.onDidChange(updateCache);
|
|
26670
|
+
watcher.onDidCreate(updateCache);
|
|
26671
|
+
watcher.onDidDelete(async () => {
|
|
26672
|
+
const cacheKey = getCacheKey(workspaceFolder);
|
|
26673
|
+
excludeCache.set(cacheKey, {});
|
|
26674
|
+
});
|
|
26675
|
+
fileWatchers.set(watcherKey, watcher);
|
|
26676
|
+
}
|
|
26677
|
+
async function initializeCache(workspaceFolder) {
|
|
26678
|
+
const cacheKey = getCacheKey(workspaceFolder);
|
|
26679
|
+
if (excludeCache.has(cacheKey)) {
|
|
26680
|
+
return;
|
|
26681
|
+
}
|
|
26682
|
+
let sgignoreExclude = {};
|
|
26683
|
+
if (workspaceFolder) {
|
|
26684
|
+
sgignoreExclude = await readIgnoreFile(
|
|
26685
|
+
Uri.joinPath(workspaceFolder.uri, ".sourcegraph", "ignore")
|
|
26686
|
+
);
|
|
26687
|
+
setupFileWatcher(workspaceFolder);
|
|
26688
|
+
}
|
|
26689
|
+
excludeCache.set(cacheKey, sgignoreExclude);
|
|
26690
|
+
}
|
|
26691
|
+
async function getExcludePattern(workspaceFolder) {
|
|
26692
|
+
await initializeCache(workspaceFolder);
|
|
26693
|
+
const cacheKey = getCacheKey(workspaceFolder);
|
|
26694
|
+
const cached2 = excludeCache.get(cacheKey);
|
|
26695
|
+
const sgignoreExclude = cached2 ?? {};
|
|
26696
|
+
const mergedExclude = {
|
|
26697
|
+
...sgignoreExclude
|
|
26698
|
+
};
|
|
26699
|
+
const excludePatterns = Object.keys(mergedExclude).filter((key2) => mergedExclude[key2] === true);
|
|
26700
|
+
if (excludePatterns.length === 0) {
|
|
26701
|
+
return "";
|
|
26702
|
+
}
|
|
26703
|
+
if (excludePatterns.length === 1) {
|
|
26704
|
+
return excludePatterns[0];
|
|
26705
|
+
}
|
|
26706
|
+
return `{${excludePatterns.join(",")}}`;
|
|
26707
|
+
}
|
|
26708
|
+
async function readIgnoreFile(uri) {
|
|
26709
|
+
const ignore = {};
|
|
26710
|
+
try {
|
|
26711
|
+
const data = await workspace.fs.readFile(uri);
|
|
26712
|
+
const content = Buffer.from(data).toString("utf-8");
|
|
26713
|
+
for (let line of content.split("\n")) {
|
|
26714
|
+
if (line.startsWith("!")) {
|
|
26715
|
+
continue;
|
|
26716
|
+
}
|
|
26717
|
+
line = line.replace(/\s*(#.*)?$/, "").trim();
|
|
26718
|
+
if (line === "") {
|
|
26719
|
+
continue;
|
|
26720
|
+
}
|
|
26721
|
+
if (line.includes(",")) {
|
|
26722
|
+
line = line.replace(/,/g, ".");
|
|
26723
|
+
}
|
|
26724
|
+
if (line.endsWith("/")) {
|
|
26725
|
+
line = line.slice(0, -1);
|
|
26726
|
+
}
|
|
26727
|
+
if (!line.includes("*") && !line.includes("/")) {
|
|
26728
|
+
ignore[`${line}/**`] = true;
|
|
26729
|
+
} else {
|
|
26730
|
+
ignore[line] = true;
|
|
26731
|
+
}
|
|
26732
|
+
}
|
|
26733
|
+
} catch (error) {
|
|
26734
|
+
}
|
|
26735
|
+
return ignore;
|
|
26736
|
+
}
|
|
26737
|
+
function disposeFileWatchers() {
|
|
26738
|
+
for (const watcher of fileWatchers.values()) {
|
|
26739
|
+
watcher.dispose();
|
|
26740
|
+
}
|
|
26741
|
+
fileWatchers.clear();
|
|
26742
|
+
excludeCache.clear();
|
|
26743
|
+
}
|
|
25263
26744
|
function ignoreReason(isIgnore) {
|
|
25264
26745
|
if (lodashExports.isError(isIgnore)) {
|
|
25265
26746
|
return isIgnore.message;
|
|
@@ -25291,6 +26772,15 @@ async function isUriIgnoredByContextFilterWithNotification(uri, feature2) {
|
|
|
25291
26772
|
}
|
|
25292
26773
|
return isIgnored;
|
|
25293
26774
|
}
|
|
26775
|
+
function initializeContextFiltersProvider() {
|
|
26776
|
+
ContextFiltersProvider.excludePatternGetter = {
|
|
26777
|
+
getExcludePattern,
|
|
26778
|
+
getWorkspaceFolder: (uri) => workspace.getWorkspaceFolder(uri) ?? null
|
|
26779
|
+
};
|
|
26780
|
+
return {
|
|
26781
|
+
dispose: disposeFileWatchers
|
|
26782
|
+
};
|
|
26783
|
+
}
|
|
25294
26784
|
const executeChat = async (args2) => {
|
|
25295
26785
|
const clientConfig = await ClientConfigSingleton.getInstance().getConfig();
|
|
25296
26786
|
const isCommand = Boolean(args2.command);
|
|
@@ -26887,7 +28377,8 @@ var treeSitter = { exports: {} };
|
|
|
26887
28377
|
setValue(lengthAddress, 0, "i32");
|
|
26888
28378
|
}
|
|
26889
28379
|
}
|
|
26890
|
-
var
|
|
28380
|
+
var runtimeKeepaliveCounter = 0;
|
|
28381
|
+
var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
|
|
26891
28382
|
var _proc_exit = (code18) => {
|
|
26892
28383
|
var _a3;
|
|
26893
28384
|
EXITSTATUS = code18;
|
|
@@ -27622,14 +29113,14 @@ var treeSitter = { exports: {} };
|
|
|
27622
29113
|
}
|
|
27623
29114
|
return this._namedChildren;
|
|
27624
29115
|
}
|
|
27625
|
-
descendantsOfType(
|
|
27626
|
-
if (!Array.isArray(
|
|
29116
|
+
descendantsOfType(types2, startPosition, endPosition) {
|
|
29117
|
+
if (!Array.isArray(types2)) types2 = [types2];
|
|
27627
29118
|
if (!startPosition) startPosition = ZERO_POINT;
|
|
27628
29119
|
if (!endPosition) endPosition = ZERO_POINT;
|
|
27629
29120
|
const symbols = [];
|
|
27630
29121
|
const typesBySymbol = this.tree.language.types;
|
|
27631
29122
|
for (let i2 = 0, n = typesBySymbol.length; i2 < n; i2++) {
|
|
27632
|
-
if (
|
|
29123
|
+
if (types2.includes(typesBySymbol[i2])) {
|
|
27633
29124
|
symbols.push(i2);
|
|
27634
29125
|
}
|
|
27635
29126
|
}
|
|
@@ -33145,7 +34636,7 @@ async function createParser$1(settings) {
|
|
|
33145
34636
|
if (cachedParser) {
|
|
33146
34637
|
return cachedParser;
|
|
33147
34638
|
}
|
|
33148
|
-
const wasmPath = path.resolve(grammarDirectory, DOCUMENT_LANGUAGE_TO_GRAMMAR[language]);
|
|
34639
|
+
const wasmPath = path$1.resolve(grammarDirectory, DOCUMENT_LANGUAGE_TO_GRAMMAR[language]);
|
|
33149
34640
|
if (!await isRegularFile(Uri.file(wasmPath))) {
|
|
33150
34641
|
return void 0;
|
|
33151
34642
|
}
|
|
@@ -34912,11 +36403,6 @@ class RepoNameResolver {
|
|
|
34912
36403
|
authStatus
|
|
34913
36404
|
).pipe(
|
|
34914
36405
|
switchMapReplayOperation(([remoteUrls, authStatus2]) => {
|
|
34915
|
-
if (isDotCom(authStatus2)) {
|
|
34916
|
-
return Observable.of(
|
|
34917
|
-
remoteUrls.map(convertGitCloneURLToCodebaseName).filter(isDefined)
|
|
34918
|
-
);
|
|
34919
|
-
}
|
|
34920
36406
|
if (remoteUrls.length === 0) {
|
|
34921
36407
|
return Observable.of([]);
|
|
34922
36408
|
}
|
|
@@ -35371,10 +36857,10 @@ function getSearchPatternForTestFiles(file, currentDirectoryOnly, fileNameMatche
|
|
|
35371
36857
|
return root2 + osSep + testPattern;
|
|
35372
36858
|
}
|
|
35373
36859
|
function isValidTestFile(uri) {
|
|
35374
|
-
const
|
|
35375
|
-
const fileNameWithoutExt = uriBasename(uri,
|
|
36860
|
+
const ext2 = uriExtname(uri);
|
|
36861
|
+
const fileNameWithoutExt = uriBasename(uri, ext2);
|
|
35376
36862
|
const prefixTest = /\.(?:py|rb)$/;
|
|
35377
|
-
if (prefixTest.test(
|
|
36863
|
+
if (prefixTest.test(ext2)) {
|
|
35378
36864
|
if (fileNameWithoutExt.startsWith("test_")) {
|
|
35379
36865
|
return true;
|
|
35380
36866
|
}
|
|
@@ -35781,7 +37267,7 @@ async function executeDefaultCommand(id, args2) {
|
|
|
35781
37267
|
case DefaultEditCommands.Doc:
|
|
35782
37268
|
return executeDocCommand(args2);
|
|
35783
37269
|
case DefaultEditCommands.Edit:
|
|
35784
|
-
return { task: await executeEdit(args2), type: "edit" };
|
|
37270
|
+
return { task: await executeEdit(args2 || {}), type: "edit" };
|
|
35785
37271
|
default:
|
|
35786
37272
|
console.log("not a default command");
|
|
35787
37273
|
return void 0;
|
|
@@ -36130,200 +37616,6 @@ class PersistenceTracker {
|
|
|
36130
37616
|
}
|
|
36131
37617
|
}
|
|
36132
37618
|
}
|
|
36133
|
-
const MAX_REPO_COUNT = 10;
|
|
36134
|
-
const workspaceFolders = fromVSCodeEvent(
|
|
36135
|
-
workspace.onDidChangeWorkspaceFolders
|
|
36136
|
-
).pipe(
|
|
36137
|
-
startWith$1(void 0),
|
|
36138
|
-
map$1(() => workspace.workspaceFolders)
|
|
36139
|
-
);
|
|
36140
|
-
const remoteReposForAllWorkspaceFolders = combineLatest$1(
|
|
36141
|
-
workspaceFolders.pipe(
|
|
36142
|
-
// The vscode.git extension has a delay before we can fetch a workspace folder's remote.
|
|
36143
|
-
debounceTime(vscodeGitAPI ? 2e3 : 0)
|
|
36144
|
-
),
|
|
36145
|
-
authStatus
|
|
36146
|
-
).pipe(
|
|
36147
|
-
switchMapReplayOperation(
|
|
36148
|
-
([workspaceFolders2]) => {
|
|
36149
|
-
if (!workspaceFolders2 || workspaceFolders2.length === 0) {
|
|
36150
|
-
return Observable.of([]);
|
|
36151
|
-
}
|
|
36152
|
-
return combineLatest$1(
|
|
36153
|
-
...workspaceFolders2.map((folder2) => repoNameResolver.getRepoNamesContainingUri(folder2.uri))
|
|
36154
|
-
).pipe(
|
|
36155
|
-
map$1((repoNamesLists) => {
|
|
36156
|
-
const completedResults = repoNamesLists.filter((names) => Array.isArray(names)).flat().filter((name2) => typeof name2 === "string");
|
|
36157
|
-
return completedResults.length > 0 ? completedResults : [];
|
|
36158
|
-
}),
|
|
36159
|
-
abortableOperation(async (repoNames, signal2) => {
|
|
36160
|
-
if (repoNames.length === 0) {
|
|
36161
|
-
return [];
|
|
36162
|
-
}
|
|
36163
|
-
const reposOrError = await graphqlClient.getRepoIds(
|
|
36164
|
-
repoNames,
|
|
36165
|
-
MAX_REPO_COUNT,
|
|
36166
|
-
signal2
|
|
36167
|
-
);
|
|
36168
|
-
if (isError$3(reposOrError)) {
|
|
36169
|
-
throw reposOrError;
|
|
36170
|
-
}
|
|
36171
|
-
return reposOrError;
|
|
36172
|
-
})
|
|
36173
|
-
);
|
|
36174
|
-
}
|
|
36175
|
-
)
|
|
36176
|
-
);
|
|
36177
|
-
async function remoteReposForWorkspaceFolder(folder2) {
|
|
36178
|
-
return firstValueFrom$1(
|
|
36179
|
-
repoNameResolver.getRepoNamesContainingUri(folder2.uri).pipe(skipPendingOperation())
|
|
36180
|
-
);
|
|
36181
|
-
}
|
|
36182
|
-
async function workspaceFolderForRepo(repoName) {
|
|
36183
|
-
for (const folder2 of workspace.workspaceFolders ?? []) {
|
|
36184
|
-
const remoteRepos = await remoteReposForWorkspaceFolder(folder2);
|
|
36185
|
-
if (remoteRepos.some((remoteRepo) => remoteRepo === repoName)) {
|
|
36186
|
-
return folder2;
|
|
36187
|
-
}
|
|
36188
|
-
}
|
|
36189
|
-
return void 0;
|
|
36190
|
-
}
|
|
36191
|
-
const _GitHubDotComRepoMetadata = class _GitHubDotComRepoMetadata {
|
|
36192
|
-
constructor() {
|
|
36193
|
-
__publicField2(this, "cache", /* @__PURE__ */ new Map());
|
|
36194
|
-
this.cache.clear();
|
|
36195
|
-
const localStorageData = localStorage.getGitHubRepoAccessibility();
|
|
36196
|
-
for (const data of localStorageData) {
|
|
36197
|
-
this.cache.set(data.repoName, data);
|
|
36198
|
-
}
|
|
36199
|
-
}
|
|
36200
|
-
static getInstance() {
|
|
36201
|
-
if (!_GitHubDotComRepoMetadata.instance) {
|
|
36202
|
-
_GitHubDotComRepoMetadata.instance = new _GitHubDotComRepoMetadata();
|
|
36203
|
-
}
|
|
36204
|
-
return _GitHubDotComRepoMetadata.instance;
|
|
36205
|
-
}
|
|
36206
|
-
getRepoMetadataIfCached(repoBaseName) {
|
|
36207
|
-
const normalizedRepoName = this.getNormalizedRepoNameFromBaseRepoName(repoBaseName);
|
|
36208
|
-
if (!normalizedRepoName) {
|
|
36209
|
-
return void 0;
|
|
36210
|
-
}
|
|
36211
|
-
return this.cache.get(normalizedRepoName);
|
|
36212
|
-
}
|
|
36213
|
-
async getRepoMetadataUsingRepoName(repoBaseName, signal2) {
|
|
36214
|
-
const repoMetadata = this.getRepoMetadataIfCached(repoBaseName);
|
|
36215
|
-
if (repoMetadata) {
|
|
36216
|
-
return repoMetadata;
|
|
36217
|
-
}
|
|
36218
|
-
const repoMetaData = await this.ghMetadataFromGit(repoBaseName, signal2);
|
|
36219
|
-
if (repoMetaData) {
|
|
36220
|
-
this.updateCachedDataToLocalStorageIfNeeded(repoMetaData);
|
|
36221
|
-
}
|
|
36222
|
-
return repoMetaData;
|
|
36223
|
-
}
|
|
36224
|
-
async ghMetadataFromGit(repoBaseName, signal2) {
|
|
36225
|
-
const ownerAndRepoName = this.parseOwnerAndRepoName(repoBaseName);
|
|
36226
|
-
if (!ownerAndRepoName) {
|
|
36227
|
-
return void 0;
|
|
36228
|
-
}
|
|
36229
|
-
const repoMetaData = await this.queryGitHubApi(
|
|
36230
|
-
ownerAndRepoName.owner,
|
|
36231
|
-
ownerAndRepoName.repoName,
|
|
36232
|
-
signal2
|
|
36233
|
-
);
|
|
36234
|
-
return repoMetaData;
|
|
36235
|
-
}
|
|
36236
|
-
async queryGitHubApi(owner2, repoName, signal2) {
|
|
36237
|
-
const apiUrl = `https://api.github.com/repos/${owner2}/${repoName}`;
|
|
36238
|
-
const normalizedRepoName = this.getNormalizedRepoNameFromOwnerAndRepoName(owner2, repoName);
|
|
36239
|
-
const metadata2 = { repoName: normalizedRepoName, isPublic: false, timestamp: Date.now() };
|
|
36240
|
-
try {
|
|
36241
|
-
const response = await fetch(apiUrl, { method: "HEAD", signal: signal2 });
|
|
36242
|
-
metadata2.isPublic = response.ok;
|
|
36243
|
-
} catch (error) {
|
|
36244
|
-
if (!isAbortError(error)) {
|
|
36245
|
-
logDebug(
|
|
36246
|
-
"queryGitHubApi",
|
|
36247
|
-
"error querying GitHub API (assuming repository is non-public",
|
|
36248
|
-
`${owner2}/${repoName}`,
|
|
36249
|
-
error
|
|
36250
|
-
);
|
|
36251
|
-
}
|
|
36252
|
-
}
|
|
36253
|
-
return metadata2;
|
|
36254
|
-
}
|
|
36255
|
-
getNormalizedRepoNameFromBaseRepoName(repoBaseName) {
|
|
36256
|
-
const ownerAndRepoName = this.parseOwnerAndRepoName(repoBaseName);
|
|
36257
|
-
if (!ownerAndRepoName) {
|
|
36258
|
-
return void 0;
|
|
36259
|
-
}
|
|
36260
|
-
return this.getNormalizedRepoNameFromOwnerAndRepoName(
|
|
36261
|
-
ownerAndRepoName.owner,
|
|
36262
|
-
ownerAndRepoName.repoName
|
|
36263
|
-
);
|
|
36264
|
-
}
|
|
36265
|
-
getNormalizedRepoNameFromOwnerAndRepoName(owner2, repoName) {
|
|
36266
|
-
return `github.com/${owner2}/${repoName}`;
|
|
36267
|
-
}
|
|
36268
|
-
parseOwnerAndRepoName(repoBaseName) {
|
|
36269
|
-
const match2 = repoBaseName == null ? void 0 : repoBaseName.match(/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?$/);
|
|
36270
|
-
if (!match2) {
|
|
36271
|
-
return void 0;
|
|
36272
|
-
}
|
|
36273
|
-
const [, owner2, repoName] = match2;
|
|
36274
|
-
return { owner: owner2, repoName };
|
|
36275
|
-
}
|
|
36276
|
-
updateCachedDataToLocalStorageIfNeeded(repoMetaData) {
|
|
36277
|
-
var _a3;
|
|
36278
|
-
if (((_a3 = this.cache.get(repoMetaData.repoName)) == null ? void 0 : _a3.isPublic) === repoMetaData.isPublic) {
|
|
36279
|
-
return;
|
|
36280
|
-
}
|
|
36281
|
-
this.cache.set(repoMetaData.repoName, repoMetaData);
|
|
36282
|
-
const repoAccessibilityData = Array.from(this.cache.values()).filter(isDefined);
|
|
36283
|
-
localStorage.setGitHubRepoAccessibility(repoAccessibilityData);
|
|
36284
|
-
}
|
|
36285
|
-
};
|
|
36286
|
-
// This class is used to get the metadata from the gitApi.
|
|
36287
|
-
__publicField2(_GitHubDotComRepoMetadata, "instance", null);
|
|
36288
|
-
let GitHubDotComRepoMetadata = _GitHubDotComRepoMetadata;
|
|
36289
|
-
const NO_PUBLIC_METADATA = { isPublic: false, repoMetadata: void 0 };
|
|
36290
|
-
const publicRepoMetadataIfAllWorkspaceReposArePublic = remoteReposForAllWorkspaceFolders.pipe(
|
|
36291
|
-
map$1((remoteRepos) => isError$3(remoteRepos) ? [] : remoteRepos),
|
|
36292
|
-
switchMap$1((remoteRepos) => {
|
|
36293
|
-
if (remoteRepos === pendingOperation) {
|
|
36294
|
-
return Observable.of(pendingOperation);
|
|
36295
|
-
}
|
|
36296
|
-
if (remoteRepos.length === 0) {
|
|
36297
|
-
return Observable.of(NO_PUBLIC_METADATA);
|
|
36298
|
-
}
|
|
36299
|
-
return combineLatest$1(
|
|
36300
|
-
...remoteRepos.map(
|
|
36301
|
-
(remoteRepo) => promiseFactoryToObservable(
|
|
36302
|
-
(signal2) => (
|
|
36303
|
-
// This is cached, so it's fast.
|
|
36304
|
-
GitHubDotComRepoMetadata.getInstance().getRepoMetadataUsingRepoName(
|
|
36305
|
-
remoteRepo.name,
|
|
36306
|
-
signal2
|
|
36307
|
-
)
|
|
36308
|
-
)
|
|
36309
|
-
)
|
|
36310
|
-
)
|
|
36311
|
-
).pipe(
|
|
36312
|
-
map$1((repoMetadatas) => {
|
|
36313
|
-
const allReposArePublic = repoMetadatas.length >= 1 && repoMetadatas.every((repoMetadata) => (repoMetadata == null ? void 0 : repoMetadata.isPublic) ?? false);
|
|
36314
|
-
return allReposArePublic ? { isPublic: true, repoMetadata: repoMetadatas.filter(isDefined) } : NO_PUBLIC_METADATA;
|
|
36315
|
-
}),
|
|
36316
|
-
catchError$1((error) => {
|
|
36317
|
-
logDebug(
|
|
36318
|
-
"publicRepoMetadataIfAllWorkspaceReposArePublic",
|
|
36319
|
-
"error getting repository metadata",
|
|
36320
|
-
error
|
|
36321
|
-
);
|
|
36322
|
-
return Observable.of(NO_PUBLIC_METADATA);
|
|
36323
|
-
})
|
|
36324
|
-
);
|
|
36325
|
-
})
|
|
36326
|
-
);
|
|
36327
37619
|
const executeSmartApply = async (args2) => {
|
|
36328
37620
|
return commands$1.executeCommand("cody.command.smart-apply", args2);
|
|
36329
37621
|
};
|
|
@@ -36378,7 +37670,7 @@ async function resolveRelativeOrAbsoluteUri(baseDirUri, uri, fallbackUri) {
|
|
|
36378
37670
|
if (!isFileProvided) {
|
|
36379
37671
|
return fallbackUri;
|
|
36380
37672
|
}
|
|
36381
|
-
const rootDir = Uri.parse(path.join(...uri.split(separatorsRegex).slice(0, 2)));
|
|
37673
|
+
const rootDir = Uri.parse(path$1.join(...uri.split(separatorsRegex).slice(0, 2)));
|
|
36382
37674
|
const hasExistingRoot = await doesFileExist(rootDir);
|
|
36383
37675
|
if (hasExistingRoot) {
|
|
36384
37676
|
return Uri.file(uri);
|
|
@@ -36386,7 +37678,7 @@ async function resolveRelativeOrAbsoluteUri(baseDirUri, uri, fallbackUri) {
|
|
|
36386
37678
|
if (!baseDirUri) {
|
|
36387
37679
|
return fallbackUri;
|
|
36388
37680
|
}
|
|
36389
|
-
const filepath = path.join(baseDirUri.path, uri);
|
|
37681
|
+
const filepath = path$1.join(baseDirUri.path, uri);
|
|
36390
37682
|
const hasExistingFile = await doesFileExist(Uri.file(filepath));
|
|
36391
37683
|
if (hasExistingFile) {
|
|
36392
37684
|
return Uri.file(filepath);
|
|
@@ -36399,7 +37691,7 @@ function smartJoinPath(baseDirUri, relativeFileUri) {
|
|
|
36399
37691
|
const commonPartLength = filePath.findIndex((segment) => segment === workspacePath.at(-1)) + 1;
|
|
36400
37692
|
const hasCommonPart = commonPartLength > 0 && isEqual(workspacePath.slice(-commonPartLength), filePath.slice(0, commonPartLength));
|
|
36401
37693
|
const uniqueFilePath = hasCommonPart ? filePath.slice(commonPartLength) : filePath;
|
|
36402
|
-
const resultPath = path.join(baseDirUri.path, ...uniqueFilePath);
|
|
37694
|
+
const resultPath = path$1.join(baseDirUri.path, ...uniqueFilePath);
|
|
36403
37695
|
return Uri.file(resultPath);
|
|
36404
37696
|
}
|
|
36405
37697
|
const defaultLastStoredCode = {
|
|
@@ -36495,7 +37787,7 @@ async function getSmartApplyModel(authStatus2) {
|
|
|
36495
37787
|
if (isInstantModeEnabled) {
|
|
36496
37788
|
return SMART_APPLY_MODEL_IDENTIFIERS.FireworksQwenCodeDefault;
|
|
36497
37789
|
}
|
|
36498
|
-
if (
|
|
37790
|
+
if (isS2(authStatus2)) {
|
|
36499
37791
|
const defaultModel = "anthropic::2024-10-22::claude-3-5-sonnet-latest";
|
|
36500
37792
|
return defaultModel;
|
|
36501
37793
|
}
|
|
@@ -36525,6 +37817,10 @@ async function handleSmartApply({
|
|
|
36525
37817
|
}
|
|
36526
37818
|
const document2 = uri ? await workspace.openTextDocument(uri) : activeEditor == null ? void 0 : activeEditor.document;
|
|
36527
37819
|
if (!document2) {
|
|
37820
|
+
if (!window$1.activeTextEditor && !uri) {
|
|
37821
|
+
console.warn("Smart apply operation cancelled - no active editor available");
|
|
37822
|
+
return;
|
|
37823
|
+
}
|
|
36528
37824
|
throw new Error("No editor found to insert text");
|
|
36529
37825
|
}
|
|
36530
37826
|
if (isPrefetch) {
|
|
@@ -36922,17 +38218,6 @@ class UpstreamHealthProvider {
|
|
|
36922
38218
|
span2.setAttribute("sampled", true);
|
|
36923
38219
|
return measureLatencyToUri(upstreamHeaders, url.toString());
|
|
36924
38220
|
});
|
|
36925
|
-
if (isDotCom(auth2.serverEndpoint)) {
|
|
36926
|
-
const gatewayHeaders = new Headers(sharedHeaders);
|
|
36927
|
-
const uri = "https://cody-gateway.sourcegraph.com/-/__version";
|
|
36928
|
-
const gatewayResult = await wrapInActiveSpan("upstream-latency.gateway", (span2) => {
|
|
36929
|
-
span2.setAttribute("sampled", true);
|
|
36930
|
-
return measureLatencyToUri(gatewayHeaders, uri);
|
|
36931
|
-
});
|
|
36932
|
-
if (!("error" in gatewayResult)) {
|
|
36933
|
-
this.lastGatewayLatency = gatewayResult.latency;
|
|
36934
|
-
}
|
|
36935
|
-
}
|
|
36936
38221
|
if ("error" in upstreamResult) {
|
|
36937
38222
|
this.lastUpstreamLatency = void 0;
|
|
36938
38223
|
logDebug$1("UpstreamHealth", "Failed to ping upstream host", {
|
|
@@ -37032,37 +38317,6 @@ class AutocompleteStageCounter {
|
|
|
37032
38317
|
}
|
|
37033
38318
|
}
|
|
37034
38319
|
new AutocompleteStageCounter();
|
|
37035
|
-
class GitMetadataForCurrentEditor {
|
|
37036
|
-
constructor() {
|
|
37037
|
-
__publicField2(this, "gitIdentifiersForFile");
|
|
37038
|
-
window$1.onDidChangeActiveTextEditor(() => this.updateStatus());
|
|
37039
|
-
}
|
|
37040
|
-
getGitIdentifiersForFile() {
|
|
37041
|
-
if (this.gitIdentifiersForFile === void 0) {
|
|
37042
|
-
this.updateStatus().catch(() => {
|
|
37043
|
-
});
|
|
37044
|
-
}
|
|
37045
|
-
return this.gitIdentifiersForFile;
|
|
37046
|
-
}
|
|
37047
|
-
async updateStatus() {
|
|
37048
|
-
var _a3, _b2, _c2;
|
|
37049
|
-
let newGitIdentifiersForFile = void 0;
|
|
37050
|
-
const currentFile = (_c2 = (_b2 = (_a3 = getEditor()) == null ? void 0 : _a3.active) == null ? void 0 : _b2.document) == null ? void 0 : _c2.uri;
|
|
37051
|
-
if (currentFile) {
|
|
37052
|
-
const repoName = currentFile ? (await firstResultFromOperation(
|
|
37053
|
-
repoNameResolver.getRepoNamesContainingUri(currentFile)
|
|
37054
|
-
)).at(0) : void 0;
|
|
37055
|
-
const commit2 = gitCommitIdFromGitExtension(currentFile);
|
|
37056
|
-
newGitIdentifiersForFile = {
|
|
37057
|
-
filePath: displayPathWithoutWorkspaceFolderPrefix(currentFile),
|
|
37058
|
-
repoName,
|
|
37059
|
-
commit: commit2
|
|
37060
|
-
};
|
|
37061
|
-
}
|
|
37062
|
-
this.gitIdentifiersForFile = newGitIdentifiersForFile;
|
|
37063
|
-
}
|
|
37064
|
-
}
|
|
37065
|
-
const gitMetadataForCurrentEditor = new GitMetadataForCurrentEditor();
|
|
37066
38320
|
function getLanguageConfig(languageId) {
|
|
37067
38321
|
switch (languageId) {
|
|
37068
38322
|
case "astro":
|
|
@@ -37981,9 +39235,9 @@ const ruleFileInteractiveChanges = defer$2(
|
|
|
37981
39235
|
merge$2(
|
|
37982
39236
|
fromVSCodeEvent(workspace.onDidCreateFiles),
|
|
37983
39237
|
fromVSCodeEvent(workspace.onDidDeleteFiles)
|
|
37984
|
-
).pipe(filter$
|
|
39238
|
+
).pipe(filter$2((e) => e.files.some(isRuleFile))),
|
|
37985
39239
|
fromVSCodeEvent(workspace.onDidChangeTextDocument).pipe(
|
|
37986
|
-
filter$
|
|
39240
|
+
filter$2((e) => isRuleFile(e.document.uri))
|
|
37987
39241
|
)
|
|
37988
39242
|
).pipe(debounceTime(1e3))
|
|
37989
39243
|
);
|
|
@@ -39029,57 +40283,6 @@ function toVSCodeRange(range) {
|
|
|
39029
40283
|
}
|
|
39030
40284
|
return new Range(range.start.line, range.start.character, range.end.line, range.end.character);
|
|
39031
40285
|
}
|
|
39032
|
-
async function findWorkspaceFiles() {
|
|
39033
|
-
var _a3;
|
|
39034
|
-
const excludePatterns = await Promise.all(
|
|
39035
|
-
((_a3 = workspace.workspaceFolders) == null ? void 0 : _a3.flatMap((workspaceFolder) => {
|
|
39036
|
-
return getExcludePattern(workspaceFolder);
|
|
39037
|
-
})) ?? []
|
|
39038
|
-
);
|
|
39039
|
-
return workspace.findFiles("**/*", `{${excludePatterns.join(",")}}`);
|
|
39040
|
-
}
|
|
39041
|
-
async function getExcludePattern(workspaceFolder) {
|
|
39042
|
-
const config = workspace.getConfiguration("", workspaceFolder);
|
|
39043
|
-
const filesExclude = config.get("files.exclude", {});
|
|
39044
|
-
const searchExclude = config.get("search.exclude", {});
|
|
39045
|
-
const useIgnoreFiles = config.get("search.useIgnoreFiles");
|
|
39046
|
-
const gitignoreExclude = useIgnoreFiles && workspaceFolder ? await readIgnoreFile(Uri.joinPath(workspaceFolder.uri, ".gitignore")) : {};
|
|
39047
|
-
const ignoreExclude = useIgnoreFiles && workspaceFolder ? await readIgnoreFile(Uri.joinPath(workspaceFolder.uri, ".ignore")) : {};
|
|
39048
|
-
const mergedExclude = {
|
|
39049
|
-
...filesExclude,
|
|
39050
|
-
...searchExclude,
|
|
39051
|
-
...gitignoreExclude,
|
|
39052
|
-
...ignoreExclude
|
|
39053
|
-
};
|
|
39054
|
-
return Object.keys(mergedExclude).filter((key2) => mergedExclude[key2] === true);
|
|
39055
|
-
}
|
|
39056
|
-
async function readIgnoreFile(uri) {
|
|
39057
|
-
const ignore = {};
|
|
39058
|
-
try {
|
|
39059
|
-
const data = await workspace.fs.readFile(uri);
|
|
39060
|
-
for (let line of Buffer.from(data).toString("utf-8").split("\n")) {
|
|
39061
|
-
if (line.startsWith("!")) {
|
|
39062
|
-
continue;
|
|
39063
|
-
}
|
|
39064
|
-
line = line.replace(/\s*(#.*)?$/, "").trim();
|
|
39065
|
-
if (line === "") {
|
|
39066
|
-
continue;
|
|
39067
|
-
}
|
|
39068
|
-
if (line.includes(",")) {
|
|
39069
|
-
line = line.replace(",", ".");
|
|
39070
|
-
}
|
|
39071
|
-
if (line.endsWith("/")) {
|
|
39072
|
-
line = line.slice(0, -1);
|
|
39073
|
-
}
|
|
39074
|
-
if (!line.startsWith("/") && !line.startsWith("**/")) {
|
|
39075
|
-
line = `**/${line}`;
|
|
39076
|
-
}
|
|
39077
|
-
ignore[line] = true;
|
|
39078
|
-
}
|
|
39079
|
-
} catch {
|
|
39080
|
-
}
|
|
39081
|
-
return ignore;
|
|
39082
|
-
}
|
|
39083
40286
|
const lowScoringPathSegments = ["bin"];
|
|
39084
40287
|
const throttledFindFiles = throttle$1(() => findWorkspaceFiles(), 1e4);
|
|
39085
40288
|
async function getFileContextFiles(options) {
|
|
@@ -39142,7 +40345,9 @@ async function getFileContextFiles(options) {
|
|
|
39142
40345
|
}
|
|
39143
40346
|
const LARGE_SCORE = 1e5;
|
|
39144
40347
|
const adjustedResults = [...results].map((result) => {
|
|
39145
|
-
|
|
40348
|
+
const isVSCodeConfigFile = result.obj.uri.path.includes("/.vscode/");
|
|
40349
|
+
const isOpenDoc = openDocuments.has(result.obj.uri.path);
|
|
40350
|
+
if (isOpenDoc && !isVSCodeConfigFile) {
|
|
39146
40351
|
return {
|
|
39147
40352
|
...result,
|
|
39148
40353
|
score: result.score + LARGE_SCORE
|
|
@@ -39157,6 +40362,13 @@ async function getFileContextFiles(options) {
|
|
|
39157
40362
|
};
|
|
39158
40363
|
}
|
|
39159
40364
|
}
|
|
40365
|
+
if (result.obj.uri.path.includes("/.vscode/")) {
|
|
40366
|
+
return {
|
|
40367
|
+
...result,
|
|
40368
|
+
score: result.score - LARGE_SCORE * 10
|
|
40369
|
+
// Increase penalty significantly to prevent .vscode files from showing up
|
|
40370
|
+
};
|
|
40371
|
+
}
|
|
39160
40372
|
return result;
|
|
39161
40373
|
});
|
|
39162
40374
|
const sortedResults = (await Promise.all(
|
|
@@ -39260,6 +40472,7 @@ async function createContextFileFromUri(uri, source, type, selectionRange, kind2
|
|
|
39260
40472
|
const range = toRangeData(selectionRange);
|
|
39261
40473
|
const repoNames = await firstResultFromOperation(repoNameResolver.getRepoNamesContainingUri(uri));
|
|
39262
40474
|
const repoName = repoNames[0];
|
|
40475
|
+
const isIgnored = await contextFiltersProvider.isUriIgnored(uri);
|
|
39263
40476
|
return [
|
|
39264
40477
|
type === "file" ? {
|
|
39265
40478
|
type,
|
|
@@ -39267,7 +40480,7 @@ async function createContextFileFromUri(uri, source, type, selectionRange, kind2
|
|
|
39267
40480
|
range,
|
|
39268
40481
|
source,
|
|
39269
40482
|
repoName,
|
|
39270
|
-
isIgnored: Boolean(
|
|
40483
|
+
isIgnored: Boolean(isIgnored)
|
|
39271
40484
|
} : {
|
|
39272
40485
|
type,
|
|
39273
40486
|
symbolName,
|
|
@@ -39376,7 +40589,10 @@ async function resolveFileOrSymbolContextItem(contextItem, editor, signal2) {
|
|
|
39376
40589
|
if (contextItem.remoteRepositoryName) {
|
|
39377
40590
|
const repository = contextItem.remoteRepositoryName;
|
|
39378
40591
|
const path2 = contextItem.uri.path.slice(repository.length + 1, contextItem.uri.path.length);
|
|
39379
|
-
const ranges2 = contextItem.range ? {
|
|
40592
|
+
const ranges2 = contextItem.range ? {
|
|
40593
|
+
startLine: contextItem.range.start.line,
|
|
40594
|
+
endLine: contextItem.range.end.line + 1
|
|
40595
|
+
} : void 0;
|
|
39380
40596
|
const { auth: auth2 } = await currentResolvedConfig();
|
|
39381
40597
|
const resultOrError = await graphqlClient.getFileContent(repository, path2, ranges2, signal2);
|
|
39382
40598
|
if (!isErrorLike(resultOrError)) {
|
|
@@ -40322,10 +41538,10 @@ const getInput = async (document2, initialValues, source) => {
|
|
|
40322
41538
|
const disposables = [];
|
|
40323
41539
|
disposables.push(editFlow);
|
|
40324
41540
|
const updateTitle = (newTitle) => {
|
|
40325
|
-
modelInput.input.title = newTitle;
|
|
40326
|
-
rangeSymbolsInput.input.title = newTitle;
|
|
40327
|
-
rangeInput.input.title = newTitle;
|
|
40328
|
-
editInput.input.title = newTitle;
|
|
41541
|
+
if (modelInput) modelInput.input.title = newTitle;
|
|
41542
|
+
if (rangeSymbolsInput) rangeSymbolsInput.input.title = newTitle;
|
|
41543
|
+
if (rangeInput) rangeInput.input.title = newTitle;
|
|
41544
|
+
if (editInput) editInput.input.title = newTitle;
|
|
40329
41545
|
};
|
|
40330
41546
|
const titleListenerCallback = (newTitle) => {
|
|
40331
41547
|
editor.setDecorations(PREVIEW_RANGE_DECORATION, []);
|
|
@@ -41934,7 +43150,7 @@ function getMapping() {
|
|
|
41934
43150
|
return mapping;
|
|
41935
43151
|
}
|
|
41936
43152
|
function getLanguageForFileName(filePath) {
|
|
41937
|
-
const fileName = path.basename(filePath);
|
|
43153
|
+
const fileName = path$1.basename(filePath);
|
|
41938
43154
|
const extension = fileName.split(".").pop() || fileName;
|
|
41939
43155
|
const language = getMapping().get(extension);
|
|
41940
43156
|
return language || extension;
|
|
@@ -42946,13 +44162,13 @@ function vscodeEnableCommandUrisToAgentEnableOnlyCommandUris(enableCommandUris)
|
|
|
42946
44162
|
return Array.isArray(enableCommandUris) ? enableCommandUris : !enableCommandUris ? [] : null;
|
|
42947
44163
|
}
|
|
42948
44164
|
class NativeWebview {
|
|
42949
|
-
constructor(delegate, handle2,
|
|
44165
|
+
constructor(delegate, handle2, _options2) {
|
|
42950
44166
|
__publicField2(this, "didReceiveMessageEmitter", new AgentEventEmitter());
|
|
42951
44167
|
__publicField2(this, "onDidReceiveMessage", this.didReceiveMessageEmitter.event);
|
|
42952
44168
|
__publicField2(this, "_html", "");
|
|
42953
44169
|
this.delegate = delegate;
|
|
42954
44170
|
this.handle = handle2;
|
|
42955
|
-
this._options =
|
|
44171
|
+
this._options = _options2;
|
|
42956
44172
|
}
|
|
42957
44173
|
get html() {
|
|
42958
44174
|
return this._html;
|
|
@@ -44171,7 +45387,7 @@ class LocalStorageDB {
|
|
|
44171
45387
|
constructor(ide, dir) {
|
|
44172
45388
|
__publicField2(this, "storage");
|
|
44173
45389
|
const quota = 1024 * 1024 * 256;
|
|
44174
|
-
this.storage = new LocalStorage_2(path.join(dir, `${ide}-globalState`), quota);
|
|
45390
|
+
this.storage = new LocalStorage_2(path$1.join(dir, `${ide}-globalState`), quota);
|
|
44175
45391
|
}
|
|
44176
45392
|
clear() {
|
|
44177
45393
|
this.storage.clear();
|
|
@@ -44335,8 +45551,8 @@ var define_process_default$8 = { env: {} };
|
|
|
44335
45551
|
function copyExtensionRelativeResources(extensionPath, extensionClient) {
|
|
44336
45552
|
var _a3, _b2, _c2;
|
|
44337
45553
|
const copySources = (relativeSource) => {
|
|
44338
|
-
const source = path.join("/tmp/__dirname", relativeSource);
|
|
44339
|
-
const target = path.join(extensionPath, "dist", relativeSource);
|
|
45554
|
+
const source = path$1.join("/tmp/__dirname", relativeSource);
|
|
45555
|
+
const target = path$1.join(extensionPath, "dist", relativeSource);
|
|
44340
45556
|
try {
|
|
44341
45557
|
const stat2 = statSync(source);
|
|
44342
45558
|
if (!(stat2.isFile() || stat2.isDirectory())) {
|
|
@@ -44347,7 +45563,7 @@ function copyExtensionRelativeResources(extensionPath, extensionClient) {
|
|
|
44347
45563
|
return;
|
|
44348
45564
|
}
|
|
44349
45565
|
try {
|
|
44350
|
-
mkdirSync(path.dirname(target), { recursive: true });
|
|
45566
|
+
mkdirSync(path$1.dirname(target), { recursive: true });
|
|
44351
45567
|
copySync(source, target);
|
|
44352
45568
|
} catch (err2) {
|
|
44353
45569
|
logDebug$1("copyExtensionRelativeResources", `Failed to copy ${source} to dist ${target}`, err2);
|
|
@@ -45252,7 +46468,7 @@ class Agent extends MessageHandler {
|
|
|
45252
46468
|
this.registerAuthenticatedRequest("chat/models", async ({ modelUsage }) => {
|
|
45253
46469
|
const clientConfig = await ClientConfigSingleton.getInstance().getConfig();
|
|
45254
46470
|
return {
|
|
45255
|
-
readOnly: !(
|
|
46471
|
+
readOnly: !(clientConfig == null ? void 0 : clientConfig.modelsAPIEnabled),
|
|
45256
46472
|
models: await modelsService.getModelsAvailabilityStatus(modelUsage)
|
|
45257
46473
|
};
|
|
45258
46474
|
});
|
|
@@ -46764,7 +47980,7 @@ class CommandsProvider {
|
|
|
46764
47980
|
if (!isFileURI(uri)) {
|
|
46765
47981
|
throw new Error("history only supported on local file paths");
|
|
46766
47982
|
}
|
|
46767
|
-
const { getContextFileFromGitLog } = await import("./git-log-
|
|
47983
|
+
const { getContextFileFromGitLog } = await import("./git-log-C0C2_x8P.mjs");
|
|
46768
47984
|
return getContextFileFromGitLog(uri, options);
|
|
46769
47985
|
}
|
|
46770
47986
|
dispose() {
|
|
@@ -46881,7 +48097,7 @@ class ExtensionApi {
|
|
|
46881
48097
|
this.extensionMode = extensionMode;
|
|
46882
48098
|
}
|
|
46883
48099
|
}
|
|
46884
|
-
const uninstallMarker = path.join(codyPaths().config, "uninstall-marker");
|
|
48100
|
+
const uninstallMarker = path$1.join(codyPaths().config, "uninstall-marker");
|
|
46885
48101
|
let isReinstall = void 0;
|
|
46886
48102
|
const isReinstalling = async () => {
|
|
46887
48103
|
if (typeof isReinstall === "boolean") {
|
|
@@ -147118,7 +148334,8 @@ function readDocType$1(xmlData, i2) {
|
|
|
147118
148334
|
} else if (hasBody && isElement(xmlData, i2)) i2 += 8;
|
|
147119
148335
|
else if (hasBody && isAttlist(xmlData, i2)) i2 += 8;
|
|
147120
148336
|
else if (hasBody && isNotation(xmlData, i2)) i2 += 9;
|
|
147121
|
-
else comment2 = true;
|
|
148337
|
+
else if (isComment) comment2 = true;
|
|
148338
|
+
else throw new Error("Invalid DOCTYPE");
|
|
147122
148339
|
angleBracketsCount++;
|
|
147123
148340
|
exp = "";
|
|
147124
148341
|
} else if (xmlData[i2] === ">") {
|
|
@@ -147161,6 +148378,10 @@ function readEntityExp(xmlData, i2) {
|
|
|
147161
148378
|
}
|
|
147162
148379
|
return [entityName2, val2, i2];
|
|
147163
148380
|
}
|
|
148381
|
+
function isComment(xmlData, i2) {
|
|
148382
|
+
if (xmlData[i2 + 1] === "!" && xmlData[i2 + 2] === "-" && xmlData[i2 + 3] === "-") return true;
|
|
148383
|
+
return false;
|
|
148384
|
+
}
|
|
147164
148385
|
function isEntity(xmlData, i2) {
|
|
147165
148386
|
if (xmlData[i2 + 1] === "!" && xmlData[i2 + 2] === "E" && xmlData[i2 + 3] === "N" && xmlData[i2 + 4] === "T" && xmlData[i2 + 5] === "I" && xmlData[i2 + 6] === "T" && xmlData[i2 + 7] === "Y") return true;
|
|
147166
148387
|
return false;
|
|
@@ -149287,12 +150508,6 @@ const _ContextRetrieverDataCollection = class _ContextRetrieverDataCollection {
|
|
|
149287
150508
|
}
|
|
149288
150509
|
return dataLoggingContext;
|
|
149289
150510
|
}
|
|
149290
|
-
shouldCollectContextDatapoint() {
|
|
149291
|
-
if (!isDotComAuthed() || this.dataCollectionRetrievers.length === 0) {
|
|
149292
|
-
return false;
|
|
149293
|
-
}
|
|
149294
|
-
return true;
|
|
149295
|
-
}
|
|
149296
150511
|
createRetriever(config) {
|
|
149297
150512
|
switch (config.identifier) {
|
|
149298
150513
|
case RetrieverIdentifier.RecentEditsRetriever:
|
|
@@ -149488,17 +150703,9 @@ class ContextMixer {
|
|
|
149488
150703
|
return resultsWithDataLogging.filter((result) => originalIdentifiers.has(result.identifier));
|
|
149489
150704
|
}
|
|
149490
150705
|
maybeAddDataLoggingRetrievers(originalRetrievers) {
|
|
149491
|
-
const
|
|
149492
|
-
const combinedRetrievers = [...originalRetrievers, ...dataCollectionRetrievers];
|
|
150706
|
+
const combinedRetrievers = [...originalRetrievers];
|
|
149493
150707
|
return dedupeWith$1(combinedRetrievers, "identifier");
|
|
149494
150708
|
}
|
|
149495
|
-
getDataCollectionRetrievers() {
|
|
149496
|
-
var _a3;
|
|
149497
|
-
if (!((_a3 = this.contextDataCollector) == null ? void 0 : _a3.shouldCollectContextDatapoint())) {
|
|
149498
|
-
return [];
|
|
149499
|
-
}
|
|
149500
|
-
return this.contextDataCollector.dataCollectionRetrievers;
|
|
149501
|
-
}
|
|
149502
150709
|
dispose() {
|
|
149503
150710
|
for (const disposable of this.disposables) {
|
|
149504
150711
|
disposable.dispose();
|
|
@@ -150782,12 +151989,12 @@ const providerConfigs = {
|
|
|
150782
151989
|
function getBaseProviderConfig() {
|
|
150783
151990
|
const mode = isHotStreakEnabled() ? "hotStreak" : "standard";
|
|
150784
151991
|
const config = providerModes[mode];
|
|
150785
|
-
const authConfig =
|
|
151992
|
+
const authConfig = providerConfigs.sgInstance;
|
|
150786
151993
|
return {
|
|
150787
151994
|
...authConfig,
|
|
150788
151995
|
promptProvider: config.promptProvider,
|
|
150789
151996
|
tokenLimit: config.tokenLimit,
|
|
150790
|
-
model:
|
|
151997
|
+
model: config.models.sgInstance
|
|
150791
151998
|
};
|
|
150792
151999
|
}
|
|
150793
152000
|
function getAutoeditsProviderConfig() {
|
|
@@ -153162,8 +154369,8 @@ class AutoeditAnalyticsLogger {
|
|
|
153162
154369
|
otherCompletionProviders: otherCompletionProviders2,
|
|
153163
154370
|
upstreamLatency: upstreamHealthProvider.getUpstreamLatency(),
|
|
153164
154371
|
gatewayLatency: upstreamHealthProvider.getGatewayLatency(),
|
|
153165
|
-
|
|
153166
|
-
|
|
154372
|
+
codeToRewrite: void 0,
|
|
154373
|
+
// todo(mk): remove in the scope of PLG sunsetting
|
|
153167
154374
|
...restPayload
|
|
153168
154375
|
}
|
|
153169
154376
|
};
|
|
@@ -153208,8 +154415,8 @@ class AutoeditAnalyticsLogger {
|
|
|
153208
154415
|
payload: {
|
|
153209
154416
|
...request.payload,
|
|
153210
154417
|
id: stableId,
|
|
153211
|
-
|
|
153212
|
-
|
|
154418
|
+
prediction: void 0,
|
|
154419
|
+
// todo(mk): remove in the scope of PLG sunsetting
|
|
153213
154420
|
source,
|
|
153214
154421
|
isFuzzyMatch,
|
|
153215
154422
|
responseHeaders: "responseHeaders" in modelResponse ? modelResponse.responseHeaders : {},
|
|
@@ -153601,14 +154808,8 @@ class AutoEditBetaOnboarding {
|
|
|
153601
154808
|
return localStorage.setAutoeditBetaEnrollment();
|
|
153602
154809
|
}
|
|
153603
154810
|
async isUserEligibleForAutoEditFeature() {
|
|
153604
|
-
const authStatus2 = currentAuthStatus();
|
|
153605
|
-
const productSubscription = await currentUserProductSubscription();
|
|
153606
154811
|
const autoEditFeatureFlag = this.isAutoEditFeatureFlagEnabled();
|
|
153607
|
-
const { isUserEligible } = isUserEligibleForAutoeditsFeature(
|
|
153608
|
-
autoEditFeatureFlag,
|
|
153609
|
-
authStatus2,
|
|
153610
|
-
productSubscription
|
|
153611
|
-
);
|
|
154812
|
+
const { isUserEligible } = isUserEligibleForAutoeditsFeature(autoEditFeatureFlag);
|
|
153612
154813
|
return isUserEligible;
|
|
153613
154814
|
}
|
|
153614
154815
|
isAutoEditFeatureFlagEnabled() {
|
|
@@ -158515,7 +159716,7 @@ var canvaskit = { exports: {} };
|
|
|
158515
159716
|
Object.assign(c, arguments);
|
|
158516
159717
|
if (a.includes("j")) {
|
|
158517
159718
|
var f = w["dynCall_" + a];
|
|
158518
|
-
f = c.length ? f.apply(null, [b].concat(c)) : f.call(null, b);
|
|
159719
|
+
f = c && c.length ? f.apply(null, [b].concat(c)) : f.call(null, b);
|
|
158519
159720
|
} else f = Xa.get(b).apply(null, c);
|
|
158520
159721
|
return f;
|
|
158521
159722
|
};
|
|
@@ -158857,6 +160058,7 @@ var canvaskit = { exports: {} };
|
|
|
158857
160058
|
return !(a && !Z);
|
|
158858
160059
|
}
|
|
158859
160060
|
function yd(a) {
|
|
160061
|
+
a || (a = A);
|
|
158860
160062
|
if (!a.Xf) {
|
|
158861
160063
|
a.Xf = true;
|
|
158862
160064
|
var b = a.fe;
|
|
@@ -160815,7 +162017,7 @@ let canvasKitInitPromise = null;
|
|
|
160815
162017
|
let canvasKit = null;
|
|
160816
162018
|
let fontCache = null;
|
|
160817
162019
|
async function initFont() {
|
|
160818
|
-
const fontPath = path.join("/tmp/__dirname", "DejaVuSansMono.ttf");
|
|
162020
|
+
const fontPath = path$1.join("/tmp/__dirname", "DejaVuSansMono.ttf");
|
|
160819
162021
|
const buffer2 = await fs.readFile(fontPath);
|
|
160820
162022
|
return new Uint8Array(buffer2).buffer;
|
|
160821
162023
|
}
|
|
@@ -161597,13 +162799,13 @@ var CachedFn = class {
|
|
|
161597
162799
|
}
|
|
161598
162800
|
};
|
|
161599
162801
|
var Theme = class {
|
|
161600
|
-
constructor(_colorMap, _defaults,
|
|
162802
|
+
constructor(_colorMap, _defaults, _root2) {
|
|
161601
162803
|
__publicField2(this, "_cachedMatchRoot", new CachedFn(
|
|
161602
162804
|
(scopeName) => this._root.match(scopeName)
|
|
161603
162805
|
));
|
|
161604
162806
|
this._colorMap = _colorMap;
|
|
161605
162807
|
this._defaults = _defaults;
|
|
161606
|
-
this._root =
|
|
162808
|
+
this._root = _root2;
|
|
161607
162809
|
}
|
|
161608
162810
|
static createFromRawTheme(source, colorMap) {
|
|
161609
162811
|
return this.createFromParsedTheme(parseTheme(source), colorMap);
|
|
@@ -161852,13 +163054,13 @@ function resolveParsedThemeRules(parsedThemeRules, _colorMap) {
|
|
|
161852
163054
|
}
|
|
161853
163055
|
}
|
|
161854
163056
|
let colorMap = new ColorMap(_colorMap);
|
|
161855
|
-
let
|
|
163057
|
+
let defaults2 = new StyleAttributes(defaultFontStyle, colorMap.getId(defaultForeground), colorMap.getId(defaultBackground));
|
|
161856
163058
|
let root2 = new ThemeTrieElement(new ThemeTrieElementRule(0, null, -1, 0, 0), []);
|
|
161857
163059
|
for (let i2 = 0, len2 = parsedThemeRules.length; i2 < len2; i2++) {
|
|
161858
163060
|
let rule = parsedThemeRules[i2];
|
|
161859
163061
|
root2.insert(0, rule.scope, rule.parentScopes, rule.fontStyle, colorMap.getId(rule.foreground), colorMap.getId(rule.background));
|
|
161860
163062
|
}
|
|
161861
|
-
return new Theme(colorMap,
|
|
163063
|
+
return new Theme(colorMap, defaults2, root2);
|
|
161862
163064
|
}
|
|
161863
163065
|
var ColorMap = class {
|
|
161864
163066
|
constructor(_colorMap) {
|
|
@@ -166556,8 +167758,8 @@ function mergeToken(merged, variantsOrder, cssVariablePrefix, defaultColor) {
|
|
|
166556
167758
|
function codeToHast(internal, code18, options, transformerContext = {
|
|
166557
167759
|
meta: {},
|
|
166558
167760
|
options,
|
|
166559
|
-
codeToHast: (_code,
|
|
166560
|
-
codeToTokens: (_code,
|
|
167761
|
+
codeToHast: (_code, _options2) => codeToHast(internal, _code, _options2),
|
|
167762
|
+
codeToTokens: (_code, _options2) => codeToTokens(internal, _code, _options2)
|
|
166561
167763
|
}) {
|
|
166562
167764
|
var _a3, _b2;
|
|
166563
167765
|
let input = code18;
|
|
@@ -166796,8 +167998,8 @@ function codeToHtml(internal, code18, options) {
|
|
|
166796
167998
|
const context2 = {
|
|
166797
167999
|
meta: {},
|
|
166798
168000
|
options,
|
|
166799
|
-
codeToHast: (_code,
|
|
166800
|
-
codeToTokens: (_code,
|
|
168001
|
+
codeToHast: (_code, _options2) => codeToHast(internal, _code, _options2),
|
|
168002
|
+
codeToTokens: (_code, _options2) => codeToTokens(internal, _code, _options2)
|
|
166801
168003
|
};
|
|
166802
168004
|
let result = toHtml(codeToHast(internal, code18, options, context2));
|
|
166803
168005
|
for (const transformer of getTransformers(options))
|
|
@@ -171087,6 +172289,64 @@ class Fzf {
|
|
|
171087
172289
|
this.find = this.finder.find.bind(this.finder);
|
|
171088
172290
|
}
|
|
171089
172291
|
}
|
|
172292
|
+
const MAX_REPO_COUNT = 10;
|
|
172293
|
+
const workspaceFolders = fromVSCodeEvent(
|
|
172294
|
+
workspace.onDidChangeWorkspaceFolders
|
|
172295
|
+
).pipe(
|
|
172296
|
+
startWith$1(void 0),
|
|
172297
|
+
map$1(() => workspace.workspaceFolders)
|
|
172298
|
+
);
|
|
172299
|
+
const remoteReposForAllWorkspaceFolders = combineLatest$1(
|
|
172300
|
+
workspaceFolders.pipe(
|
|
172301
|
+
// The vscode.git extension has a delay before we can fetch a workspace folder's remote.
|
|
172302
|
+
debounceTime(vscodeGitAPI ? 2e3 : 0)
|
|
172303
|
+
),
|
|
172304
|
+
authStatus
|
|
172305
|
+
).pipe(
|
|
172306
|
+
switchMapReplayOperation(
|
|
172307
|
+
([workspaceFolders2]) => {
|
|
172308
|
+
if (!workspaceFolders2 || workspaceFolders2.length === 0) {
|
|
172309
|
+
return Observable.of([]);
|
|
172310
|
+
}
|
|
172311
|
+
return combineLatest$1(
|
|
172312
|
+
...workspaceFolders2.map((folder2) => repoNameResolver.getRepoNamesContainingUri(folder2.uri))
|
|
172313
|
+
).pipe(
|
|
172314
|
+
map$1((repoNamesLists) => {
|
|
172315
|
+
const completedResults = repoNamesLists.filter((names) => Array.isArray(names)).flat().filter((name2) => typeof name2 === "string");
|
|
172316
|
+
return completedResults.length > 0 ? completedResults : [];
|
|
172317
|
+
}),
|
|
172318
|
+
abortableOperation(async (repoNames, signal2) => {
|
|
172319
|
+
if (repoNames.length === 0) {
|
|
172320
|
+
return [];
|
|
172321
|
+
}
|
|
172322
|
+
const reposOrError = await graphqlClient.getRepoIds(
|
|
172323
|
+
repoNames,
|
|
172324
|
+
MAX_REPO_COUNT,
|
|
172325
|
+
signal2
|
|
172326
|
+
);
|
|
172327
|
+
if (isError$3(reposOrError)) {
|
|
172328
|
+
throw reposOrError;
|
|
172329
|
+
}
|
|
172330
|
+
return reposOrError;
|
|
172331
|
+
})
|
|
172332
|
+
);
|
|
172333
|
+
}
|
|
172334
|
+
)
|
|
172335
|
+
);
|
|
172336
|
+
async function remoteReposForWorkspaceFolder(folder2) {
|
|
172337
|
+
return firstValueFrom$1(
|
|
172338
|
+
repoNameResolver.getRepoNamesContainingUri(folder2.uri).pipe(skipPendingOperation())
|
|
172339
|
+
);
|
|
172340
|
+
}
|
|
172341
|
+
async function workspaceFolderForRepo(repoName) {
|
|
172342
|
+
for (const folder2 of workspace.workspaceFolders ?? []) {
|
|
172343
|
+
const remoteRepos = await remoteReposForWorkspaceFolder(folder2);
|
|
172344
|
+
if (remoteRepos.some((remoteRepo) => remoteRepo === repoName)) {
|
|
172345
|
+
return folder2;
|
|
172346
|
+
}
|
|
172347
|
+
}
|
|
172348
|
+
return void 0;
|
|
172349
|
+
}
|
|
171090
172350
|
function starTiebreaker(a, b) {
|
|
171091
172351
|
return b.item.stars - a.item.stars;
|
|
171092
172352
|
}
|
|
@@ -172399,7 +173659,7 @@ function filterLocallyModifiedFilesOutOfRemoteContext(roots, localFilesByRoot, r
|
|
|
172399
173659
|
const relLocalFiles = /* @__PURE__ */ new Set();
|
|
172400
173660
|
const localFiles = localFilesByRoot[i2] || [];
|
|
172401
173661
|
for (const localFile of localFiles) {
|
|
172402
|
-
relLocalFiles.add(path.relative(localRoot.fsPath, localFile));
|
|
173662
|
+
relLocalFiles.add(path$1.relative(localRoot.fsPath, localFile));
|
|
172403
173663
|
}
|
|
172404
173664
|
for (const remoteRepo of remoteRepos) {
|
|
172405
173665
|
repoNameToLocalFiles.set(remoteRepo.name, relLocalFiles);
|
|
@@ -172891,7 +174151,7 @@ class ChatHandler {
|
|
|
172891
174151
|
delegate.postError(contextResult.error, "transcript");
|
|
172892
174152
|
}
|
|
172893
174153
|
if (contextResult.abort) {
|
|
172894
|
-
delegate.postDone(
|
|
174154
|
+
delegate.postDone();
|
|
172895
174155
|
return;
|
|
172896
174156
|
}
|
|
172897
174157
|
const corpusContext = contextResult.contextItems ?? [];
|
|
@@ -173182,8 +174442,7 @@ __publicField2(_DeepCodyHandler, "observable", combineLatest$1(
|
|
|
173182
174442
|
config
|
|
173183
174443
|
]) => {
|
|
173184
174444
|
var _a3, _b2, _c2, _d2;
|
|
173185
|
-
|
|
173186
|
-
if (sub2 === pendingOperation || isDotComUser && (sub2 == null ? void 0 : sub2.userCanUpgrade) || !models || isCodyTesting || isDisabledOnInstance || ((_a3 = config.configuration) == null ? void 0 : _a3.chatAgenticContext) === false) {
|
|
174445
|
+
if (sub2 === pendingOperation || !models || isCodyTesting || isDisabledOnInstance || ((_a3 = config.configuration) == null ? void 0 : _a3.chatAgenticContext) === false) {
|
|
173187
174446
|
_DeepCodyHandler.model = void 0;
|
|
173188
174447
|
_DeepCodyHandler.isToolboxEnabled = false;
|
|
173189
174448
|
return null;
|
|
@@ -173229,7 +174488,7 @@ async function getContextFileFromShell(command) {
|
|
|
173229
174488
|
return [];
|
|
173230
174489
|
}
|
|
173231
174490
|
const cwd = (_e2 = (_d2 = (_c2 = workspace.workspaceFolders) == null ? void 0 : _c2[0]) == null ? void 0 : _d2.uri) == null ? void 0 : _e2.fsPath;
|
|
173232
|
-
const filteredCommand = command.replaceAll(/(\s~\/)/g, ` ${HOME_DIR}${path.sep}`);
|
|
174491
|
+
const filteredCommand = command.replaceAll(/(\s~\/)/g, ` ${HOME_DIR}${path$1.sep}`);
|
|
173233
174492
|
const allowList = new Set((agenticShellConfig == null ? void 0 : agenticShellConfig.allow) ?? []);
|
|
173234
174493
|
const blockList = /* @__PURE__ */ new Set([...BASE_DISALLOWED_COMMANDS, ...(agenticShellConfig == null ? void 0 : agenticShellConfig.block) ?? []]);
|
|
173235
174494
|
try {
|
|
@@ -175846,9 +177105,9 @@ class ZodUnion extends ZodType {
|
|
|
175846
177105
|
return this._def.options;
|
|
175847
177106
|
}
|
|
175848
177107
|
}
|
|
175849
|
-
ZodUnion.create = (
|
|
177108
|
+
ZodUnion.create = (types2, params) => {
|
|
175850
177109
|
return new ZodUnion({
|
|
175851
|
-
options:
|
|
177110
|
+
options: types2,
|
|
175852
177111
|
typeName: ZodFirstPartyTypeKind.ZodUnion,
|
|
175853
177112
|
...processCreateParams(params)
|
|
175854
177113
|
});
|
|
@@ -177928,8 +179187,8 @@ class McpError extends Error {
|
|
|
177928
179187
|
}
|
|
177929
179188
|
const DEFAULT_REQUEST_TIMEOUT_MSEC = 6e4;
|
|
177930
179189
|
class Protocol {
|
|
177931
|
-
constructor(
|
|
177932
|
-
this._options =
|
|
179190
|
+
constructor(_options2) {
|
|
179191
|
+
this._options = _options2;
|
|
177933
179192
|
this._requestMessageId = 0;
|
|
177934
179193
|
this._requestHandlers = /* @__PURE__ */ new Map();
|
|
177935
179194
|
this._requestHandlerAbortControllers = /* @__PURE__ */ new Map();
|
|
@@ -182209,6 +183468,10 @@ class ChatsController {
|
|
|
182209
183468
|
}),
|
|
182210
183469
|
commands$1.registerCommand("cody.chat.toggle", async () => this.toggleChatPanel()),
|
|
182211
183470
|
commands$1.registerCommand("cody.chat.history.export", () => this.exportHistory()),
|
|
183471
|
+
commands$1.registerCommand(
|
|
183472
|
+
"cody.chat.history.export.all",
|
|
183473
|
+
() => this.exportAllChatsUnauthenticated()
|
|
183474
|
+
),
|
|
182212
183475
|
commands$1.registerCommand("cody.chat.history.clear", (arg) => this.clearHistory(arg)),
|
|
182213
183476
|
commands$1.registerCommand("cody.chat.history.delete", (item) => this.clearHistory(item)),
|
|
182214
183477
|
commands$1.registerCommand("cody.chat.history.rename", (arg) => this.renameHistory(arg)),
|
|
@@ -182388,6 +183651,61 @@ class ChatsController {
|
|
|
182388
183651
|
}
|
|
182389
183652
|
}
|
|
182390
183653
|
}
|
|
183654
|
+
/**
|
|
183655
|
+
* Export all chat history to file system without authentication check
|
|
183656
|
+
* Useful for users who can't authenticate but still have local chat data
|
|
183657
|
+
*/
|
|
183658
|
+
async exportAllChatsUnauthenticated() {
|
|
183659
|
+
var _a3, _b2;
|
|
183660
|
+
telemetryRecorder.recordEvent("cody.exportAllChats", "clicked", {
|
|
183661
|
+
billingMetadata: {
|
|
183662
|
+
product: "cody",
|
|
183663
|
+
category: "billable"
|
|
183664
|
+
}
|
|
183665
|
+
});
|
|
183666
|
+
try {
|
|
183667
|
+
const allChatHistory = localStorage.getAllChatHistory();
|
|
183668
|
+
if (!allChatHistory || Object.keys(allChatHistory).length === 0) {
|
|
183669
|
+
void window$1.showInformationMessage("No chat history found to export.");
|
|
183670
|
+
return;
|
|
183671
|
+
}
|
|
183672
|
+
const allChats = Object.values(allChatHistory).flatMap(
|
|
183673
|
+
(userHistory) => Object.values(userHistory.chat || {})
|
|
183674
|
+
);
|
|
183675
|
+
if (allChats.length === 0) {
|
|
183676
|
+
void window$1.showInformationMessage("No chat history found to export.");
|
|
183677
|
+
return;
|
|
183678
|
+
}
|
|
183679
|
+
const workspaceFolder = (_b2 = (_a3 = workspace.workspaceFolders) == null ? void 0 : _a3[0]) == null ? void 0 : _b2.uri;
|
|
183680
|
+
const defaultDir = workspaceFolder || Uri.file(require("node:os").homedir());
|
|
183681
|
+
const filename = `cody-all-chats-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.json`;
|
|
183682
|
+
const exportPath = await window$1.showSaveDialog({
|
|
183683
|
+
title: "Cody: Export All Chat History",
|
|
183684
|
+
filters: { "Chat History": ["json"] },
|
|
183685
|
+
defaultUri: Uri.joinPath(defaultDir, filename)
|
|
183686
|
+
});
|
|
183687
|
+
if (!exportPath) {
|
|
183688
|
+
return;
|
|
183689
|
+
}
|
|
183690
|
+
const logContent = new TextEncoder().encode(JSON.stringify(allChats, null, 2));
|
|
183691
|
+
await workspace.fs.writeFile(exportPath, logContent);
|
|
183692
|
+
void window$1.showInformationMessage(
|
|
183693
|
+
`Successfully exported ${allChats.length} chat conversations.`,
|
|
183694
|
+
"Open"
|
|
183695
|
+
).then((choice) => {
|
|
183696
|
+
if (choice === "Open") {
|
|
183697
|
+
void commands$1.executeCommand("vscode.open", exportPath);
|
|
183698
|
+
}
|
|
183699
|
+
});
|
|
183700
|
+
} catch (error) {
|
|
183701
|
+
logError$1(
|
|
183702
|
+
"ChatsController:exportAllChatsUnauthenticated",
|
|
183703
|
+
"Failed to export all chat history",
|
|
183704
|
+
error
|
|
183705
|
+
);
|
|
183706
|
+
void window$1.showErrorMessage("Failed to export chat history. See output for details.");
|
|
183707
|
+
}
|
|
183708
|
+
}
|
|
182391
183709
|
async clearHistory(chatID) {
|
|
182392
183710
|
const ClearWithoutConfirmID = "clear-all-no-confirm";
|
|
182393
183711
|
const isClearAll = !chatID || chatID === ClearWithoutConfirmID;
|
|
@@ -182627,6 +183945,142 @@ class InitDoer {
|
|
|
182627
183945
|
});
|
|
182628
183946
|
}
|
|
182629
183947
|
}
|
|
183948
|
+
const _GitHubDotComRepoMetadata = class _GitHubDotComRepoMetadata {
|
|
183949
|
+
constructor() {
|
|
183950
|
+
__publicField2(this, "cache", /* @__PURE__ */ new Map());
|
|
183951
|
+
this.cache.clear();
|
|
183952
|
+
const localStorageData = localStorage.getGitHubRepoAccessibility();
|
|
183953
|
+
for (const data of localStorageData) {
|
|
183954
|
+
this.cache.set(data.repoName, data);
|
|
183955
|
+
}
|
|
183956
|
+
}
|
|
183957
|
+
static getInstance() {
|
|
183958
|
+
if (!_GitHubDotComRepoMetadata.instance) {
|
|
183959
|
+
_GitHubDotComRepoMetadata.instance = new _GitHubDotComRepoMetadata();
|
|
183960
|
+
}
|
|
183961
|
+
return _GitHubDotComRepoMetadata.instance;
|
|
183962
|
+
}
|
|
183963
|
+
getRepoMetadataIfCached(repoBaseName) {
|
|
183964
|
+
const normalizedRepoName = this.getNormalizedRepoNameFromBaseRepoName(repoBaseName);
|
|
183965
|
+
if (!normalizedRepoName) {
|
|
183966
|
+
return void 0;
|
|
183967
|
+
}
|
|
183968
|
+
return this.cache.get(normalizedRepoName);
|
|
183969
|
+
}
|
|
183970
|
+
async getRepoMetadataUsingRepoName(repoBaseName, signal2) {
|
|
183971
|
+
const repoMetadata = this.getRepoMetadataIfCached(repoBaseName);
|
|
183972
|
+
if (repoMetadata) {
|
|
183973
|
+
return repoMetadata;
|
|
183974
|
+
}
|
|
183975
|
+
const repoMetaData = await this.ghMetadataFromGit(repoBaseName, signal2);
|
|
183976
|
+
if (repoMetaData) {
|
|
183977
|
+
this.updateCachedDataToLocalStorageIfNeeded(repoMetaData);
|
|
183978
|
+
}
|
|
183979
|
+
return repoMetaData;
|
|
183980
|
+
}
|
|
183981
|
+
async ghMetadataFromGit(repoBaseName, signal2) {
|
|
183982
|
+
const ownerAndRepoName = this.parseOwnerAndRepoName(repoBaseName);
|
|
183983
|
+
if (!ownerAndRepoName) {
|
|
183984
|
+
return void 0;
|
|
183985
|
+
}
|
|
183986
|
+
const repoMetaData = await this.queryGitHubApi(
|
|
183987
|
+
ownerAndRepoName.owner,
|
|
183988
|
+
ownerAndRepoName.repoName,
|
|
183989
|
+
signal2
|
|
183990
|
+
);
|
|
183991
|
+
return repoMetaData;
|
|
183992
|
+
}
|
|
183993
|
+
async queryGitHubApi(owner2, repoName, signal2) {
|
|
183994
|
+
const apiUrl = `https://api.github.com/repos/${owner2}/${repoName}`;
|
|
183995
|
+
const normalizedRepoName = this.getNormalizedRepoNameFromOwnerAndRepoName(owner2, repoName);
|
|
183996
|
+
const metadata2 = { repoName: normalizedRepoName, isPublic: false, timestamp: Date.now() };
|
|
183997
|
+
try {
|
|
183998
|
+
const response = await fetch(apiUrl, { method: "HEAD", signal: signal2 });
|
|
183999
|
+
metadata2.isPublic = response.ok;
|
|
184000
|
+
} catch (error) {
|
|
184001
|
+
if (!isAbortError(error)) {
|
|
184002
|
+
logDebug(
|
|
184003
|
+
"queryGitHubApi",
|
|
184004
|
+
"error querying GitHub API (assuming repository is non-public",
|
|
184005
|
+
`${owner2}/${repoName}`,
|
|
184006
|
+
error
|
|
184007
|
+
);
|
|
184008
|
+
}
|
|
184009
|
+
}
|
|
184010
|
+
return metadata2;
|
|
184011
|
+
}
|
|
184012
|
+
getNormalizedRepoNameFromBaseRepoName(repoBaseName) {
|
|
184013
|
+
const ownerAndRepoName = this.parseOwnerAndRepoName(repoBaseName);
|
|
184014
|
+
if (!ownerAndRepoName) {
|
|
184015
|
+
return void 0;
|
|
184016
|
+
}
|
|
184017
|
+
return this.getNormalizedRepoNameFromOwnerAndRepoName(
|
|
184018
|
+
ownerAndRepoName.owner,
|
|
184019
|
+
ownerAndRepoName.repoName
|
|
184020
|
+
);
|
|
184021
|
+
}
|
|
184022
|
+
getNormalizedRepoNameFromOwnerAndRepoName(owner2, repoName) {
|
|
184023
|
+
return `github.com/${owner2}/${repoName}`;
|
|
184024
|
+
}
|
|
184025
|
+
parseOwnerAndRepoName(repoBaseName) {
|
|
184026
|
+
const match2 = repoBaseName == null ? void 0 : repoBaseName.match(/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?$/);
|
|
184027
|
+
if (!match2) {
|
|
184028
|
+
return void 0;
|
|
184029
|
+
}
|
|
184030
|
+
const [, owner2, repoName] = match2;
|
|
184031
|
+
return { owner: owner2, repoName };
|
|
184032
|
+
}
|
|
184033
|
+
updateCachedDataToLocalStorageIfNeeded(repoMetaData) {
|
|
184034
|
+
var _a3;
|
|
184035
|
+
if (((_a3 = this.cache.get(repoMetaData.repoName)) == null ? void 0 : _a3.isPublic) === repoMetaData.isPublic) {
|
|
184036
|
+
return;
|
|
184037
|
+
}
|
|
184038
|
+
this.cache.set(repoMetaData.repoName, repoMetaData);
|
|
184039
|
+
const repoAccessibilityData = Array.from(this.cache.values()).filter(isDefined);
|
|
184040
|
+
localStorage.setGitHubRepoAccessibility(repoAccessibilityData);
|
|
184041
|
+
}
|
|
184042
|
+
};
|
|
184043
|
+
// This class is used to get the metadata from the gitApi.
|
|
184044
|
+
__publicField2(_GitHubDotComRepoMetadata, "instance", null);
|
|
184045
|
+
let GitHubDotComRepoMetadata = _GitHubDotComRepoMetadata;
|
|
184046
|
+
const NO_PUBLIC_METADATA = { isPublic: false, repoMetadata: void 0 };
|
|
184047
|
+
const publicRepoMetadataIfAllWorkspaceReposArePublic = remoteReposForAllWorkspaceFolders.pipe(
|
|
184048
|
+
map$1((remoteRepos) => isError$3(remoteRepos) ? [] : remoteRepos),
|
|
184049
|
+
switchMap$1((remoteRepos) => {
|
|
184050
|
+
if (remoteRepos === pendingOperation) {
|
|
184051
|
+
return Observable.of(pendingOperation);
|
|
184052
|
+
}
|
|
184053
|
+
if (remoteRepos.length === 0) {
|
|
184054
|
+
return Observable.of(NO_PUBLIC_METADATA);
|
|
184055
|
+
}
|
|
184056
|
+
return combineLatest$1(
|
|
184057
|
+
...remoteRepos.map(
|
|
184058
|
+
(remoteRepo) => promiseFactoryToObservable(
|
|
184059
|
+
(signal2) => (
|
|
184060
|
+
// This is cached, so it's fast.
|
|
184061
|
+
GitHubDotComRepoMetadata.getInstance().getRepoMetadataUsingRepoName(
|
|
184062
|
+
remoteRepo.name,
|
|
184063
|
+
signal2
|
|
184064
|
+
)
|
|
184065
|
+
)
|
|
184066
|
+
)
|
|
184067
|
+
)
|
|
184068
|
+
).pipe(
|
|
184069
|
+
map$1((repoMetadatas) => {
|
|
184070
|
+
const allReposArePublic = repoMetadatas.length >= 1 && repoMetadatas.every((repoMetadata) => (repoMetadata == null ? void 0 : repoMetadata.isPublic) ?? false);
|
|
184071
|
+
return allReposArePublic ? { isPublic: true, repoMetadata: repoMetadatas.filter(isDefined) } : NO_PUBLIC_METADATA;
|
|
184072
|
+
}),
|
|
184073
|
+
catchError$1((error) => {
|
|
184074
|
+
logDebug(
|
|
184075
|
+
"publicRepoMetadataIfAllWorkspaceReposArePublic",
|
|
184076
|
+
"error getting repository metadata",
|
|
184077
|
+
error
|
|
184078
|
+
);
|
|
184079
|
+
return Observable.of(NO_PUBLIC_METADATA);
|
|
184080
|
+
})
|
|
184081
|
+
);
|
|
184082
|
+
})
|
|
184083
|
+
);
|
|
182630
184084
|
class OmniboxTelemetry {
|
|
182631
184085
|
constructor(baseProperties) {
|
|
182632
184086
|
__publicField2(this, "intentInfo");
|
|
@@ -183363,17 +184817,17 @@ const getDefaultOptions = (options) => ({
|
|
|
183363
184817
|
...options
|
|
183364
184818
|
});
|
|
183365
184819
|
const getRefs = (options) => {
|
|
183366
|
-
const
|
|
183367
|
-
const currentPath =
|
|
184820
|
+
const _options2 = getDefaultOptions(options);
|
|
184821
|
+
const currentPath = _options2.name !== void 0 ? [..._options2.basePath, _options2.definitionPath, _options2.name] : _options2.basePath;
|
|
183368
184822
|
return {
|
|
183369
|
-
...
|
|
184823
|
+
..._options2,
|
|
183370
184824
|
currentPath,
|
|
183371
184825
|
propertyPath: void 0,
|
|
183372
|
-
seen: new Map(Object.entries(
|
|
184826
|
+
seen: new Map(Object.entries(_options2.definitions).map(([name2, def]) => [
|
|
183373
184827
|
def._def,
|
|
183374
184828
|
{
|
|
183375
184829
|
def: def._def,
|
|
183376
|
-
path: [...
|
|
184830
|
+
path: [..._options2.basePath, _options2.definitionPath, name2],
|
|
183377
184831
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
183378
184832
|
jsonSchema: void 0
|
|
183379
184833
|
}
|
|
@@ -184035,15 +185489,15 @@ function parseUnionDef(def, refs) {
|
|
|
184035
185489
|
return asAnyOf(def, refs);
|
|
184036
185490
|
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
184037
185491
|
if (options.every((x) => x._def.typeName in primitiveMappings && (!x._def.checks || !x._def.checks.length))) {
|
|
184038
|
-
const
|
|
185492
|
+
const types2 = options.reduce((types3, x) => {
|
|
184039
185493
|
const type = primitiveMappings[x._def.typeName];
|
|
184040
|
-
return type && !
|
|
185494
|
+
return type && !types3.includes(type) ? [...types3, type] : types3;
|
|
184041
185495
|
}, []);
|
|
184042
185496
|
return {
|
|
184043
|
-
type:
|
|
185497
|
+
type: types2.length > 1 ? types2 : types2[0]
|
|
184044
185498
|
};
|
|
184045
185499
|
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
184046
|
-
const
|
|
185500
|
+
const types2 = options.reduce((acc, x) => {
|
|
184047
185501
|
const type = typeof x._def.value;
|
|
184048
185502
|
switch (type) {
|
|
184049
185503
|
case "string":
|
|
@@ -184062,8 +185516,8 @@ function parseUnionDef(def, refs) {
|
|
|
184062
185516
|
return acc;
|
|
184063
185517
|
}
|
|
184064
185518
|
}, []);
|
|
184065
|
-
if (
|
|
184066
|
-
const uniqueTypes =
|
|
185519
|
+
if (types2.length === options.length) {
|
|
185520
|
+
const uniqueTypes = types2.filter((x, i2, a) => a.indexOf(x) === i2);
|
|
184067
185521
|
return {
|
|
184068
185522
|
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
184069
185523
|
enum: options.reduce((acc, x) => {
|
|
@@ -186497,15 +187951,6 @@ class ChatController {
|
|
|
186497
187951
|
async getConfigForWebview() {
|
|
186498
187952
|
var _a3, _b2, _c2, _d2;
|
|
186499
187953
|
const { configuration, auth: auth2 } = await currentResolvedConfig();
|
|
186500
|
-
const [experimentalPromptEditorEnabled, internalAgentModeEnabled] = await Promise.all([
|
|
186501
|
-
firstValueFrom$1(
|
|
186502
|
-
featureFlagProvider.evaluatedFeatureFlag(FeatureFlag.CodyExperimentalPromptEditor)
|
|
186503
|
-
),
|
|
186504
|
-
firstValueFrom$1(
|
|
186505
|
-
featureFlagProvider.evaluatedFeatureFlag(FeatureFlag.NextAgenticChatInternal)
|
|
186506
|
-
)
|
|
186507
|
-
]);
|
|
186508
|
-
const experimentalAgenticChatEnabled = internalAgentModeEnabled && isS2(auth2.serverEndpoint);
|
|
186509
187954
|
const sidebarViewOnly = ((_b2 = (_a3 = this.extensionClient.capabilities) == null ? void 0 : _a3.webviewNativeConfig) == null ? void 0 : _b2.view) === "single";
|
|
186510
187955
|
const isEditorViewType = ((_c2 = this.webviewPanelOrView) == null ? void 0 : _c2.viewType) === "cody.editorPanel";
|
|
186511
187956
|
const webviewType = isEditorViewType && !sidebarViewOnly ? "editor" : "sidebar";
|
|
@@ -186525,8 +187970,6 @@ class ChatController {
|
|
|
186525
187970
|
internalDebugContext: configuration.internalDebugContext,
|
|
186526
187971
|
internalDebugTokenUsage: configuration.internalDebugTokenUsage,
|
|
186527
187972
|
allowEndpointChange: configuration.overrideServerEndpoint === void 0,
|
|
186528
|
-
experimentalPromptEditorEnabled,
|
|
186529
|
-
experimentalAgenticChatEnabled,
|
|
186530
187973
|
attribution
|
|
186531
187974
|
};
|
|
186532
187975
|
}
|
|
@@ -186744,16 +188187,14 @@ class ChatController {
|
|
|
186744
188187
|
});
|
|
186745
188188
|
return confirmation;
|
|
186746
188189
|
},
|
|
186747
|
-
postDone: async (
|
|
188190
|
+
postDone: async () => {
|
|
188191
|
+
var _a3;
|
|
186748
188192
|
span2.end();
|
|
186749
|
-
if ((
|
|
186750
|
-
|
|
188193
|
+
if ((_a3 = this.chatBuilder) == null ? void 0 : _a3.isEmpty()) {
|
|
188194
|
+
this.postViewTranscript();
|
|
188195
|
+
return;
|
|
186751
188196
|
}
|
|
186752
|
-
if (
|
|
186753
|
-
this.saveSession();
|
|
186754
|
-
} else if (messageInProgress && (["search", "insert", "edit"].includes((messageInProgress == null ? void 0 : messageInProgress.intent) ?? "") || (messageInProgress == null ? void 0 : messageInProgress.search) || (messageInProgress == null ? void 0 : messageInProgress.error))) {
|
|
186755
|
-
this.chatBuilder.addBotMessage(messageInProgress, model2);
|
|
186756
|
-
} else if (messageInProgress.subMessages && messageInProgress.subMessages.length > 0) {
|
|
188197
|
+
if (["search", "insert", "edit"].includes((messageInProgress == null ? void 0 : messageInProgress.intent) ?? "") || (messageInProgress == null ? void 0 : messageInProgress.search) || (messageInProgress == null ? void 0 : messageInProgress.error) || messageInProgress.subMessages && messageInProgress.subMessages.length > 0) {
|
|
186757
188198
|
this.chatBuilder.addBotMessage(messageInProgress, model2);
|
|
186758
188199
|
} else if (messageInProgress == null ? void 0 : messageInProgress.text) {
|
|
186759
188200
|
this.addBotMessage(
|
|
@@ -186764,6 +188205,7 @@ class ChatController {
|
|
|
186764
188205
|
);
|
|
186765
188206
|
}
|
|
186766
188207
|
this.postViewTranscript();
|
|
188208
|
+
void this.saveSession();
|
|
186767
188209
|
}
|
|
186768
188210
|
}
|
|
186769
188211
|
);
|
|
@@ -187192,7 +188634,6 @@ class ChatController {
|
|
|
187192
188634
|
async addBotMessage(requestID, rawResponse, didYouMeanQuery, model2) {
|
|
187193
188635
|
const messageText = reformatBotMessageForChat(rawResponse);
|
|
187194
188636
|
this.chatBuilder.addBotMessage({ text: messageText, didYouMeanQuery }, model2);
|
|
187195
|
-
void this.saveSession();
|
|
187196
188637
|
this.postViewTranscript();
|
|
187197
188638
|
const authStatus2 = currentAuthStatus();
|
|
187198
188639
|
const generatedCode = countGeneratedCode(messageText.toString());
|
|
@@ -187288,12 +188729,13 @@ class ChatController {
|
|
|
187288
188729
|
}
|
|
187289
188730
|
clearAndRestartSession(chatMessages) {
|
|
187290
188731
|
var _a3;
|
|
187291
|
-
this.cancelSubmitOrEditOperation();
|
|
187292
188732
|
if (!((_a3 = this.chatBuilder) == null ? void 0 : _a3.isEmpty())) {
|
|
188733
|
+
this.saveSession();
|
|
187293
188734
|
this.chatBuilder = new ChatBuilder(this.chatBuilder.selectedModel, void 0, chatMessages);
|
|
187294
188735
|
this.lastKnownTokenUsage = void 0;
|
|
187295
188736
|
this.postViewTranscript();
|
|
187296
188737
|
}
|
|
188738
|
+
this.cancelSubmitOrEditOperation();
|
|
187297
188739
|
}
|
|
187298
188740
|
get webviewPanelOrView() {
|
|
187299
188741
|
return this._webviewPanelOrView;
|
|
@@ -187719,12 +189161,8 @@ function createAutoEditsProvider({
|
|
|
187719
189161
|
promiseFactoryToObservable(async () => await currentUserProductSubscription())
|
|
187720
189162
|
).pipe(
|
|
187721
189163
|
skipPendingOperation(),
|
|
187722
|
-
createDisposables((
|
|
187723
|
-
const userEligibilityInfo = isUserEligibleForAutoeditsFeature(
|
|
187724
|
-
autoeditFeatureFlagEnabled,
|
|
187725
|
-
authStatus2,
|
|
187726
|
-
userProductSubscription2
|
|
187727
|
-
);
|
|
189164
|
+
createDisposables(() => {
|
|
189165
|
+
const userEligibilityInfo = isUserEligibleForAutoeditsFeature(autoeditFeatureFlagEnabled);
|
|
187728
189166
|
if (!userEligibilityInfo.isUserEligible) {
|
|
187729
189167
|
handleAutoeditsNotificationForNonEligibleUser(userEligibilityInfo.nonEligibilityReason);
|
|
187730
189168
|
return [];
|
|
@@ -187785,13 +189223,7 @@ function isSettingsEditorOpen() {
|
|
|
187785
189223
|
}
|
|
187786
189224
|
return activeTab.label === "Settings";
|
|
187787
189225
|
}
|
|
187788
|
-
function isUserEligibleForAutoeditsFeature(autoeditsFeatureFlagEnabled
|
|
187789
|
-
if (isFreeUser(authStatus2, productSubscription)) {
|
|
187790
|
-
return {
|
|
187791
|
-
isUserEligible: false,
|
|
187792
|
-
nonEligibilityReason: AUTOEDITS_NON_ELIGIBILITY_MESSAGES.PRO_USER_ONLY
|
|
187793
|
-
};
|
|
187794
|
-
}
|
|
189226
|
+
function isUserEligibleForAutoeditsFeature(autoeditsFeatureFlagEnabled) {
|
|
187795
189227
|
return {
|
|
187796
189228
|
isUserEligible: autoeditsFeatureFlagEnabled,
|
|
187797
189229
|
nonEligibilityReason: autoeditsFeatureFlagEnabled ? void 0 : AUTOEDITS_NON_ELIGIBILITY_MESSAGES.FEATURE_FLAG_NOT_ELIGIBLE
|
|
@@ -189079,8 +190511,8 @@ function parseMentionURI(uri) {
|
|
|
189079
190511
|
}
|
|
189080
190512
|
}
|
|
189081
190513
|
async function execFileAsync(program2, args2, { cwd }) {
|
|
189082
|
-
const { promisify } = await import("./util-
|
|
189083
|
-
const { execFile } = await import("./vscode-shim-
|
|
190514
|
+
const { promisify } = await import("./util-C44wiTt8.mjs").then((n) => n.u);
|
|
190515
|
+
const { execFile } = await import("./vscode-shim-H_ThTWLs.mjs").then((n) => n.fO);
|
|
189084
190516
|
return promisify(execFile)(program2, args2, { cwd });
|
|
189085
190517
|
}
|
|
189086
190518
|
var __create = Object.create;
|
|
@@ -189573,7 +191005,8 @@ var require_DocTypeReader = __commonJS({
|
|
|
189573
191005
|
} else if (hasBody && isElement2(xmlData, i2)) i2 += 8;
|
|
189574
191006
|
else if (hasBody && isAttlist2(xmlData, i2)) i2 += 8;
|
|
189575
191007
|
else if (hasBody && isNotation2(xmlData, i2)) i2 += 9;
|
|
189576
|
-
else comment2 = true;
|
|
191008
|
+
else if (isComment2) comment2 = true;
|
|
191009
|
+
else throw new Error("Invalid DOCTYPE");
|
|
189577
191010
|
angleBracketsCount++;
|
|
189578
191011
|
exp = "";
|
|
189579
191012
|
} else if (xmlData[i2] === ">") {
|
|
@@ -189616,6 +191049,10 @@ var require_DocTypeReader = __commonJS({
|
|
|
189616
191049
|
}
|
|
189617
191050
|
return [entityName2, val2, i2];
|
|
189618
191051
|
}
|
|
191052
|
+
function isComment2(xmlData, i2) {
|
|
191053
|
+
if (xmlData[i2 + 1] === "!" && xmlData[i2 + 2] === "-" && xmlData[i2 + 3] === "-") return true;
|
|
191054
|
+
return false;
|
|
191055
|
+
}
|
|
189619
191056
|
function isEntity2(xmlData, i2) {
|
|
189620
191057
|
if (xmlData[i2 + 1] === "!" && xmlData[i2 + 2] === "E" && xmlData[i2 + 3] === "N" && xmlData[i2 + 4] === "T" && xmlData[i2 + 5] === "I" && xmlData[i2 + 6] === "T" && xmlData[i2 + 7] === "Y") return true;
|
|
189621
191058
|
return false;
|
|
@@ -190916,8 +192353,8 @@ async function getAccessTokenLinearConnect() {
|
|
|
190916
192353
|
if (!vscode2) {
|
|
190917
192354
|
return void 0;
|
|
190918
192355
|
}
|
|
190919
|
-
const
|
|
190920
|
-
if (!
|
|
192356
|
+
const ext2 = vscode2.extensions.getExtension(LINEAR_AUTHENTICATION_EXTENSION_ID);
|
|
192357
|
+
if (!ext2) {
|
|
190921
192358
|
vscode2.window.showWarningMessage(
|
|
190922
192359
|
"Cody requires the Linear Connect extension to be installed and activated."
|
|
190923
192360
|
);
|
|
@@ -191474,14 +192911,14 @@ async function getViewerSettingsProviders() {
|
|
|
191474
192911
|
}
|
|
191475
192912
|
}
|
|
191476
192913
|
async function warnIfOpenCtxExtensionConflict() {
|
|
191477
|
-
const
|
|
191478
|
-
if (!
|
|
192914
|
+
const ext2 = extensions.getExtension("sourcegraph.openctx");
|
|
192915
|
+
if (!ext2) {
|
|
191479
192916
|
return;
|
|
191480
192917
|
}
|
|
191481
192918
|
window$1.showWarningMessage(
|
|
191482
192919
|
"Cody directly provides OpenCtx support, please disable the Sourcegraph OpenCtx extension."
|
|
191483
192920
|
);
|
|
191484
|
-
await commands$1.executeCommand("workbench.extensions.action.showExtensionsWithIds", [[
|
|
192921
|
+
await commands$1.executeCommand("workbench.extensions.action.showExtensionsWithIds", [[ext2.id]]);
|
|
191485
192922
|
}
|
|
191486
192923
|
const logger = new Logger();
|
|
191487
192924
|
const LOG_LABEL = "Guardrails";
|
|
@@ -191594,6 +193031,37 @@ class EditGuardrails {
|
|
|
191594
193031
|
}
|
|
191595
193032
|
}
|
|
191596
193033
|
}
|
|
193034
|
+
class GitMetadataForCurrentEditor {
|
|
193035
|
+
constructor() {
|
|
193036
|
+
__publicField2(this, "gitIdentifiersForFile");
|
|
193037
|
+
window$1.onDidChangeActiveTextEditor(() => this.updateStatus());
|
|
193038
|
+
}
|
|
193039
|
+
getGitIdentifiersForFile() {
|
|
193040
|
+
if (this.gitIdentifiersForFile === void 0) {
|
|
193041
|
+
this.updateStatus().catch(() => {
|
|
193042
|
+
});
|
|
193043
|
+
}
|
|
193044
|
+
return this.gitIdentifiersForFile;
|
|
193045
|
+
}
|
|
193046
|
+
async updateStatus() {
|
|
193047
|
+
var _a3, _b2, _c2;
|
|
193048
|
+
let newGitIdentifiersForFile = void 0;
|
|
193049
|
+
const currentFile = (_c2 = (_b2 = (_a3 = getEditor()) == null ? void 0 : _a3.active) == null ? void 0 : _b2.document) == null ? void 0 : _c2.uri;
|
|
193050
|
+
if (currentFile) {
|
|
193051
|
+
const repoName = currentFile ? (await firstResultFromOperation(
|
|
193052
|
+
repoNameResolver.getRepoNamesContainingUri(currentFile)
|
|
193053
|
+
)).at(0) : void 0;
|
|
193054
|
+
const commit2 = gitCommitIdFromGitExtension(currentFile);
|
|
193055
|
+
newGitIdentifiersForFile = {
|
|
193056
|
+
filePath: displayPathWithoutWorkspaceFolderPrefix(currentFile),
|
|
193057
|
+
repoName,
|
|
193058
|
+
commit: commit2
|
|
193059
|
+
};
|
|
193060
|
+
}
|
|
193061
|
+
this.gitIdentifiersForFile = newGitIdentifiersForFile;
|
|
193062
|
+
}
|
|
193063
|
+
}
|
|
193064
|
+
const gitMetadataForCurrentEditor = new GitMetadataForCurrentEditor();
|
|
191597
193065
|
const MAX_LOGGING_PAYLOAD_SIZE_BYTES = 1024 * 1024;
|
|
191598
193066
|
class EditLoggingFeatureFlagManager {
|
|
191599
193067
|
constructor() {
|
|
@@ -191767,7 +193235,7 @@ function getEditLoggingContext(param) {
|
|
|
191767
193235
|
}
|
|
191768
193236
|
function shouldLogEditContextItem(payload, isFeatureFlagEnabledForLogging) {
|
|
191769
193237
|
const authStatus2 = currentAuthStatus();
|
|
191770
|
-
if (
|
|
193238
|
+
if (isS2(authStatus2) && isFeatureFlagEnabledForLogging) {
|
|
191771
193239
|
const payloadSize = calculatePayloadSizeInBytes(payload);
|
|
191772
193240
|
return payloadSize !== void 0 && payloadSize < MAX_LOGGING_PAYLOAD_SIZE_BYTES;
|
|
191773
193241
|
}
|
|
@@ -191828,7 +193296,7 @@ he.exports;
|
|
|
191828
193296
|
(function(module2, exports2) {
|
|
191829
193297
|
(function(root2) {
|
|
191830
193298
|
var freeExports = exports2;
|
|
191831
|
-
var freeModule = module2.exports == freeExports && module2;
|
|
193299
|
+
var freeModule = module2 && module2.exports == freeExports && module2;
|
|
191832
193300
|
var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal;
|
|
191833
193301
|
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
|
|
191834
193302
|
root2 = freeGlobal;
|
|
@@ -191878,14 +193346,14 @@ he.exports;
|
|
|
191878
193346
|
}
|
|
191879
193347
|
return false;
|
|
191880
193348
|
};
|
|
191881
|
-
var merge2 = function(options,
|
|
193349
|
+
var merge2 = function(options, defaults2) {
|
|
191882
193350
|
if (!options) {
|
|
191883
|
-
return
|
|
193351
|
+
return defaults2;
|
|
191884
193352
|
}
|
|
191885
193353
|
var result = {};
|
|
191886
193354
|
var key3;
|
|
191887
|
-
for (key3 in
|
|
191888
|
-
result[key3] = has2(options, key3) ? options[key3] :
|
|
193355
|
+
for (key3 in defaults2) {
|
|
193356
|
+
result[key3] = has2(options, key3) ? options[key3] : defaults2[key3];
|
|
191889
193357
|
}
|
|
191890
193358
|
return result;
|
|
191891
193359
|
};
|
|
@@ -197412,8 +198880,7 @@ const _CodyStatusBar = class _CodyStatusBar {
|
|
|
197412
198880
|
this.errors.changes,
|
|
197413
198881
|
this.loaders.changes,
|
|
197414
198882
|
this.ignoreStatus,
|
|
197415
|
-
featureFlagProvider.evaluatedFeatureFlag(FeatureFlag.CodyAutoEditExperimentEnabledFeatureFlag)
|
|
197416
|
-
promiseFactoryToObservable(async () => await currentUserProductSubscription())
|
|
198883
|
+
featureFlagProvider.evaluatedFeatureFlag(FeatureFlag.CodyAutoEditExperimentEnabledFeatureFlag)
|
|
197417
198884
|
).pipe(
|
|
197418
198885
|
map$1((combined) => {
|
|
197419
198886
|
return {
|
|
@@ -197562,7 +199029,7 @@ const _CodyStatusBar = class _CodyStatusBar {
|
|
|
197562
199029
|
assertUnreachable(newState.style);
|
|
197563
199030
|
}
|
|
197564
199031
|
}
|
|
197565
|
-
buildState(authStatus2, config, errors, loaders, ignoreStatus, autoeditsFeatureFlagEnabled
|
|
199032
|
+
buildState(authStatus2, config, errors, loaders, ignoreStatus, autoeditsFeatureFlagEnabled) {
|
|
197566
199033
|
const tags = /* @__PURE__ */ new Set();
|
|
197567
199034
|
if (authStatus2.authenticated) {
|
|
197568
199035
|
tags.add(InvisibleStatusBarTag.IsAuthenticated);
|
|
@@ -197606,9 +199073,7 @@ const _CodyStatusBar = class _CodyStatusBar {
|
|
|
197606
199073
|
config,
|
|
197607
199074
|
errors,
|
|
197608
199075
|
isIgnored: ignoreStatus,
|
|
197609
|
-
autoeditsFeatureFlagEnabled
|
|
197610
|
-
userProductSubscription: userProductSubscription2,
|
|
197611
|
-
authStatus: authStatus2
|
|
199076
|
+
autoeditsFeatureFlagEnabled
|
|
197612
199077
|
})
|
|
197613
199078
|
};
|
|
197614
199079
|
}
|
|
@@ -197641,9 +199106,7 @@ const _CodyStatusBar = class _CodyStatusBar {
|
|
|
197641
199106
|
config,
|
|
197642
199107
|
errors,
|
|
197643
199108
|
isIgnored: ignoreStatus,
|
|
197644
|
-
autoeditsFeatureFlagEnabled
|
|
197645
|
-
userProductSubscription: userProductSubscription2,
|
|
197646
|
-
authStatus: authStatus2
|
|
199109
|
+
autoeditsFeatureFlagEnabled
|
|
197647
199110
|
})
|
|
197648
199111
|
};
|
|
197649
199112
|
}
|
|
@@ -197658,9 +199121,7 @@ const _CodyStatusBar = class _CodyStatusBar {
|
|
|
197658
199121
|
config,
|
|
197659
199122
|
errors,
|
|
197660
199123
|
isIgnored: ignoreStatus,
|
|
197661
|
-
autoeditsFeatureFlagEnabled
|
|
197662
|
-
userProductSubscription: userProductSubscription2,
|
|
197663
|
-
authStatus: authStatus2
|
|
199124
|
+
autoeditsFeatureFlagEnabled
|
|
197664
199125
|
})
|
|
197665
199126
|
};
|
|
197666
199127
|
}
|
|
@@ -197670,9 +199131,7 @@ const _CodyStatusBar = class _CodyStatusBar {
|
|
|
197670
199131
|
config,
|
|
197671
199132
|
errors,
|
|
197672
199133
|
isIgnored: ignoreStatus,
|
|
197673
|
-
autoeditsFeatureFlagEnabled
|
|
197674
|
-
userProductSubscription: userProductSubscription2,
|
|
197675
|
-
authStatus: authStatus2
|
|
199134
|
+
autoeditsFeatureFlagEnabled
|
|
197676
199135
|
})
|
|
197677
199136
|
};
|
|
197678
199137
|
}
|
|
@@ -197698,9 +199157,7 @@ function interactDefault({
|
|
|
197698
199157
|
config,
|
|
197699
199158
|
errors,
|
|
197700
199159
|
isIgnored,
|
|
197701
|
-
autoeditsFeatureFlagEnabled
|
|
197702
|
-
userProductSubscription: userProductSubscription2,
|
|
197703
|
-
authStatus: authStatus2
|
|
199160
|
+
autoeditsFeatureFlagEnabled
|
|
197704
199161
|
}) {
|
|
197705
199162
|
return async (abort2) => {
|
|
197706
199163
|
var _a3;
|
|
@@ -197778,12 +199235,7 @@ function interactDefault({
|
|
|
197778
199235
|
}
|
|
197779
199236
|
),
|
|
197780
199237
|
{ label: currentSuggestionMode, kind: QuickPickItemKind.Separator },
|
|
197781
|
-
await createFeatureEnumChoice(
|
|
197782
|
-
"Code Suggestion Settings",
|
|
197783
|
-
autoeditsFeatureFlagEnabled,
|
|
197784
|
-
userProductSubscription2,
|
|
197785
|
-
authStatus2
|
|
197786
|
-
),
|
|
199238
|
+
await createFeatureEnumChoice("Code Suggestion Settings", autoeditsFeatureFlagEnabled),
|
|
197787
199239
|
{ label: "settings", kind: QuickPickItemKind.Separator },
|
|
197788
199240
|
{
|
|
197789
199241
|
label: "$(gear) Cody Extension Settings",
|
|
@@ -197851,13 +199303,9 @@ function interactDefault({
|
|
|
197851
199303
|
};
|
|
197852
199304
|
}
|
|
197853
199305
|
function featureCodySuggestionEnumBuilder(workspaceConfig) {
|
|
197854
|
-
return async (name2, autoeditsFeatureFlagEnabled
|
|
199306
|
+
return async (name2, autoeditsFeatureFlagEnabled) => {
|
|
197855
199307
|
const currentSuggestionMode = await getCurrentCodySuggestionMode(workspaceConfig);
|
|
197856
|
-
const { isUserEligible } = isUserEligibleForAutoeditsFeature(
|
|
197857
|
-
autoeditsFeatureFlagEnabled,
|
|
197858
|
-
authStatus2,
|
|
197859
|
-
userProductSubscription2
|
|
197860
|
-
);
|
|
199308
|
+
const { isUserEligible } = isUserEligibleForAutoeditsFeature(autoeditsFeatureFlagEnabled);
|
|
197861
199309
|
const suggestionModes = [
|
|
197862
199310
|
{
|
|
197863
199311
|
label: "Autocomplete",
|
|
@@ -198691,7 +200139,7 @@ async function start(context2, platform2) {
|
|
|
198691
200139
|
setResolvedConfigurationObservable(
|
|
198692
200140
|
combineLatest$1(
|
|
198693
200141
|
fromVSCodeEvent(workspace.onDidChangeConfiguration).pipe(
|
|
198694
|
-
filter$
|
|
200142
|
+
filter$2(
|
|
198695
200143
|
(event2) => event2.affectsConfiguration("cody") || event2.affectsConfiguration("openctx") || event2.affectsConfiguration("http")
|
|
198696
200144
|
),
|
|
198697
200145
|
startWith$1(void 0),
|
|
@@ -198838,6 +200286,7 @@ const register = async (context2, platform2, isExtensionModeDevOrTest) => {
|
|
|
198838
200286
|
})
|
|
198839
200287
|
)
|
|
198840
200288
|
);
|
|
200289
|
+
disposables.push(initializeContextFiltersProvider());
|
|
198841
200290
|
return Disposable.from(...disposables);
|
|
198842
200291
|
};
|
|
198843
200292
|
async function initializeSingletons(platform2, disposables) {
|
|
@@ -198950,12 +200399,22 @@ async function registerCodyCommands({
|
|
|
198950
200399
|
(a) => unifiedPromptsEnabled ? executeTestChatCommand(a) : executeTestEditCommand(a)
|
|
198951
200400
|
)
|
|
198952
200401
|
];
|
|
198953
|
-
const unifiedPromptsCommands = [
|
|
198954
|
-
|
|
198955
|
-
|
|
198956
|
-
(
|
|
198957
|
-
|
|
198958
|
-
|
|
200402
|
+
const unifiedPromptsCommands = [];
|
|
200403
|
+
try {
|
|
200404
|
+
unifiedPromptsCommands.push(
|
|
200405
|
+
commands$1.registerCommand(
|
|
200406
|
+
"cody.command.prompt-document-code",
|
|
200407
|
+
(a) => executeDocChatCommand(a)
|
|
200408
|
+
)
|
|
200409
|
+
);
|
|
200410
|
+
} catch (error) {
|
|
200411
|
+
if (false !== "true") {
|
|
200412
|
+
throw error;
|
|
200413
|
+
}
|
|
200414
|
+
console.warn(
|
|
200415
|
+
"Command cody.command.prompt-document-code already registered (testing mode)"
|
|
200416
|
+
);
|
|
200417
|
+
}
|
|
198959
200418
|
return unifiedPromptsEnabled ? [
|
|
198960
200419
|
...chatCommands,
|
|
198961
200420
|
...editCommands,
|
|
@@ -199032,7 +200491,7 @@ function registerAuthCommands(disposables) {
|
|
|
199032
200491
|
)
|
|
199033
200492
|
);
|
|
199034
200493
|
}
|
|
199035
|
-
async function registerTestCommands(
|
|
200494
|
+
async function registerTestCommands(_context, disposables) {
|
|
199036
200495
|
await commands$1.executeCommand("setContext", "cody.devOrTest", true);
|
|
199037
200496
|
disposables.push(
|
|
199038
200497
|
commands$1.registerCommand("cody.test.set-context-filters", async () => {
|
|
@@ -199153,7 +200612,7 @@ function registerAutocomplete(platform2, statusBar, disposables) {
|
|
|
199153
200612
|
if (res === NEVER$1 && !authStatus2.pendingValidation) {
|
|
199154
200613
|
finishLoading();
|
|
199155
200614
|
}
|
|
199156
|
-
return res.tap((
|
|
200615
|
+
return res.tap((_res) => {
|
|
199157
200616
|
finishLoading();
|
|
199158
200617
|
});
|
|
199159
200618
|
}),
|
|
@@ -199768,7 +201227,7 @@ const extractSafariExtensionDetails = (func2, filename) => {
|
|
|
199768
201227
|
const MAX_ALLOWED_STRING_LENGTH = 1024;
|
|
199769
201228
|
const INTEGRATION_NAME$5 = "Breadcrumbs";
|
|
199770
201229
|
const _breadcrumbsIntegration = (options = {}) => {
|
|
199771
|
-
const
|
|
201230
|
+
const _options2 = {
|
|
199772
201231
|
console: true,
|
|
199773
201232
|
dom: true,
|
|
199774
201233
|
fetch: true,
|
|
@@ -199784,22 +201243,22 @@ const _breadcrumbsIntegration = (options = {}) => {
|
|
|
199784
201243
|
},
|
|
199785
201244
|
// eslint-disable-line @typescript-eslint/no-empty-function
|
|
199786
201245
|
setup(client) {
|
|
199787
|
-
if (
|
|
201246
|
+
if (_options2.console) {
|
|
199788
201247
|
addConsoleInstrumentationHandler(_getConsoleBreadcrumbHandler(client));
|
|
199789
201248
|
}
|
|
199790
|
-
if (
|
|
199791
|
-
addClickKeypressInstrumentationHandler(_getDomBreadcrumbHandler(client,
|
|
201249
|
+
if (_options2.dom) {
|
|
201250
|
+
addClickKeypressInstrumentationHandler(_getDomBreadcrumbHandler(client, _options2.dom));
|
|
199792
201251
|
}
|
|
199793
|
-
if (
|
|
201252
|
+
if (_options2.xhr) {
|
|
199794
201253
|
addXhrInstrumentationHandler(_getXhrBreadcrumbHandler(client));
|
|
199795
201254
|
}
|
|
199796
|
-
if (
|
|
201255
|
+
if (_options2.fetch) {
|
|
199797
201256
|
addFetchInstrumentationHandler(_getFetchBreadcrumbHandler(client));
|
|
199798
201257
|
}
|
|
199799
|
-
if (
|
|
201258
|
+
if (_options2.history) {
|
|
199800
201259
|
addHistoryInstrumentationHandler(_getHistoryBreadcrumbHandler(client));
|
|
199801
201260
|
}
|
|
199802
|
-
if (
|
|
201261
|
+
if (_options2.sentry && client.on) {
|
|
199803
201262
|
client.on("beforeSendEvent", _getSentryBreadcrumbHandler(client));
|
|
199804
201263
|
}
|
|
199805
201264
|
}
|
|
@@ -200142,7 +201601,7 @@ function _getFramesFromEvent(event2) {
|
|
|
200142
201601
|
}
|
|
200143
201602
|
const INTEGRATION_NAME$3 = "GlobalHandlers";
|
|
200144
201603
|
const _globalHandlersIntegration = (options = {}) => {
|
|
200145
|
-
const
|
|
201604
|
+
const _options2 = {
|
|
200146
201605
|
onerror: true,
|
|
200147
201606
|
onunhandledrejection: true,
|
|
200148
201607
|
...options
|
|
@@ -200153,11 +201612,11 @@ const _globalHandlersIntegration = (options = {}) => {
|
|
|
200153
201612
|
Error.stackTraceLimit = 50;
|
|
200154
201613
|
},
|
|
200155
201614
|
setup(client) {
|
|
200156
|
-
if (
|
|
201615
|
+
if (_options2.onerror) {
|
|
200157
201616
|
_installGlobalOnErrorHandler(client);
|
|
200158
201617
|
globalHandlerLog("onerror");
|
|
200159
201618
|
}
|
|
200160
|
-
if (
|
|
201619
|
+
if (_options2.onunhandledrejection) {
|
|
200161
201620
|
_installGlobalOnUnhandledRejectionHandler(client);
|
|
200162
201621
|
globalHandlerLog("onunhandledrejection");
|
|
200163
201622
|
}
|
|
@@ -200381,7 +201840,7 @@ const DEFAULT_EVENT_TARGET = [
|
|
|
200381
201840
|
];
|
|
200382
201841
|
const INTEGRATION_NAME = "TryCatch";
|
|
200383
201842
|
const _browserApiErrorsIntegration = (options = {}) => {
|
|
200384
|
-
const
|
|
201843
|
+
const _options2 = {
|
|
200385
201844
|
XMLHttpRequest: true,
|
|
200386
201845
|
eventTarget: true,
|
|
200387
201846
|
requestAnimationFrame: true,
|
|
@@ -200394,19 +201853,19 @@ const _browserApiErrorsIntegration = (options = {}) => {
|
|
|
200394
201853
|
// TODO: This currently only works for the first client this is setup
|
|
200395
201854
|
// We may want to adjust this to check for client etc.
|
|
200396
201855
|
setupOnce() {
|
|
200397
|
-
if (
|
|
201856
|
+
if (_options2.setTimeout) {
|
|
200398
201857
|
fill(WINDOW, "setTimeout", _wrapTimeFunction);
|
|
200399
201858
|
}
|
|
200400
|
-
if (
|
|
201859
|
+
if (_options2.setInterval) {
|
|
200401
201860
|
fill(WINDOW, "setInterval", _wrapTimeFunction);
|
|
200402
201861
|
}
|
|
200403
|
-
if (
|
|
201862
|
+
if (_options2.requestAnimationFrame) {
|
|
200404
201863
|
fill(WINDOW, "requestAnimationFrame", _wrapRAF);
|
|
200405
201864
|
}
|
|
200406
|
-
if (
|
|
201865
|
+
if (_options2.XMLHttpRequest && "XMLHttpRequest" in WINDOW) {
|
|
200407
201866
|
fill(XMLHttpRequest.prototype, "send", _wrapXHR);
|
|
200408
201867
|
}
|
|
200409
|
-
const eventTargetOption =
|
|
201868
|
+
const eventTargetOption = _options2.eventTarget;
|
|
200410
201869
|
if (eventTargetOption) {
|
|
200411
201870
|
const eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;
|
|
200412
201871
|
eventTarget.forEach(_wrapEventTarget);
|
|
@@ -200546,7 +202005,7 @@ const defaultIntegrations = [
|
|
|
200546
202005
|
dedupeIntegration(),
|
|
200547
202006
|
httpContextIntegration()
|
|
200548
202007
|
];
|
|
200549
|
-
function getDefaultIntegrations(
|
|
202008
|
+
function getDefaultIntegrations(_options2) {
|
|
200550
202009
|
return [
|
|
200551
202010
|
// eslint-disable-next-line deprecation/deprecation
|
|
200552
202011
|
...defaultIntegrations
|