Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/import{ LRUCachedFunction }from'vs/base/common/cache';import{ CharCode }from'vs/base/common/charCode';import{ Lazy }from'vs/base/common/lazy';import{ Constants }from'vs/base/common/uint';exportfunctionisFalsyOrWhitespace(str:string|undefined):boolean{if(!str ||typeof str !=='string'){returntrue;}
strlength
_formatRegexp
value args
argslength
value
value_formatRegexp match group
idx group
idx idx idx argslength
match
argsidx
_format2Regexp
template values Record
Objectvalueslength
template
template_format2Regexp match group valuesgroup match
value
value ch
ch
ch
html
html match
match
match
value
value
value character
result
ch character
i valuelength i i
valuei ch
result
result
value maxLength suffix
valuelength maxLength
value
value maxLength suffix
valuelength maxLength
value
prefixLength MathmaxLength suffixlength
suffixLength MathmaxLength suffixlength
haystack needle
trimmed haystack needle
trimmed needle
haystack needle
haystack needle
haystack
needleLen needlelength
needleLen haystacklength
haystack
offset
haystackneedle offset offset
offset offset needleLen
haystackoffset
haystack needle
haystack needle
haystack
needleLen needlelength
haystackLen haystacklength
needleLen haystackLen
haystack
offset haystackLen
idx
idx haystackneedle offset
idx idx needleLen offset
idx
offset idx
haystack offset
pattern
pattern
pattern
pattern
matchCase
wholeWord
multiline
global
unicode
searchString isRegex options RegExpOptions RegExp
searchString
isRegex
searchString searchString
optionswholeWord
searchString
searchString searchString
searchStringsearchStringlength
searchString searchString
modifiers
optionsglobal
modifiers
optionsmatchCase
modifiers
optionsmultiline
modifiers
optionsunicode
modifiers
searchString modifiers
regexp RegExp
regexpsource regexpsource regexpsource regexpsource
match regexp
match regexplastIndex
str
str
str
i len strlength i len i
chCode stri
chCode CharCodeSpace chCode CharCodeTab
i
str start end strlength
i start i end i
chCode stri
chCode CharCodeSpace chCode CharCodeTab
strstart i
strstart end
str startIndex strlength
i startIndex i i
chCode stri
chCode CharCodeSpace chCode CharCodeTab
i
str search RegExp match args
parts
last
match strsearch
partsstrlast matchindex
matchindex
last matchindex matchlength
partsmatch match matchindex str matchgroups
partsstrlast
partsp p
a b
a b
a b
a b aStart aEnd alength bStart bEnd blength
aStart aEnd bStart bEnd aStart bStart
codeA aaStart
codeB bbStart
codeA codeB
codeA codeB
aLen aEnd aStart
bLen bEnd bStart
aLen bLen
aLen bLen
a b
a b alength blength
a b aStart aEnd alength bStart bEnd blength
aStart aEnd bStart bEnd aStart bStart
codeA aaStart
codeB bbStart
codeA codeB
codeA codeB
a b aStart aEnd bStart bEnd
codeA
codeA
codeB
codeB
diff codeA codeB
diff
diff
aLen aEnd aStart
bLen bEnd bStart
aLen bLen
aLen bLen
code
code CharCodeDigit0 code CharCodeDigit9
code
code CharCodea code CharCodez
code
code CharCode code CharCode
a b
alength blength a b
str candidate
candidateLength candidatelength
candidatelength strlength
str candidate candidateLength
a b
len Mathalength blength
i
i i len i
ai bi
i
len
a b
len Mathalength blength
i
aLastIndex alength
bLastIndex blength
i i len i
aaLastIndex i bbLastIndex i
i
len
charCode
charCode charCode
charCode
charCode charCode
highSurrogate lowSurrogate
highSurrogate lowSurrogate
str len offset
charCode stroffset
charCode offset len
nextCharCode stroffset
nextCharCode
charCode nextCharCode
charCode
str offset
charCode stroffset
charCode offset
prevCharCode stroffset
prevCharCode
prevCharCode charCode
charCode
_str
_len
_offset
_offset
str offset
_str str
_len strlength
_offset offset
offset
_offset offset
codePoint _str _offset
_offset codePoint Constants
codePoint
codePoint _str _len _offset
_offset codePoint Constants
codePoint
_offset _len
_iterator CodePointIterator
_iteratoroffset
str offset
_iterator str offset
graphemeBreakTree GraphemeBreakTree
iterator _iterator
initialOffset iteratoroffset
graphemeBreakType graphemeBreakTreeiterator
iterator
offset iteratoroffset
nextGraphemeBreakType graphemeBreakTreeiterator
graphemeBreakType nextGraphemeBreakType
iteratoroffset
graphemeBreakType nextGraphemeBreakType
iteratoroffset initialOffset
graphemeBreakTree GraphemeBreakTree
iterator _iterator
initialOffset iteratoroffset
graphemeBreakType graphemeBreakTreeiterator
iteratoroffset
offset iteratoroffset
prevGraphemeBreakType graphemeBreakTreeiterator
prevGraphemeBreakType graphemeBreakType
iteratoroffset
graphemeBreakType prevGraphemeBreakType
initialOffset iteratoroffset
_iterator
str initialOffset
iterator str initialOffset
iterator
str initialOffset
iterator str initialOffset
iterator
str offset
offset stroffset
offset
endOffset offset str offset
startOffset endOffset str endOffset
startOffset endOffset
str
iterator str
length
iterator
length
iterator
length
RegExp
str
str
str
str
str
str
charCode
charCode charCode
charCode charCode
charCode charCode
x
x x x x x
x x x x x
x x x x
x x x x
x x
text n prefix
trimmed text
trimmedlength n
trimmed
re
i
retrimmed
trimmedlength relastIndex n
i relastIndex
relastIndex
i
trimmed
prefix trimmedi
str
str
str str
str
StringCharCode
str
str strlength str CharCode
str
str str str
target query
target query
targetlength querylength
queryLen querylength
targetLower target
index
lastIndexOf
index queryLen
indexOf targetLowerqueryindex lastIndexOf
indexOf
lastIndexOf indexOf
index
target ignoreEscapedChars
target
ignoreEscapedChars
target target
target target
str
str str
str n
n
idx
idx str idx
n
n idx
idx
str
stridx
idx
str idx
n
CharCode CharCode
n n
n
StringCharCodea n
StringCharCode n
codePoint GraphemeBreakType
graphemeBreakTree GraphemeBreakTree
graphemeBreakTreecodePoint
breakTypeA GraphemeBreakType breakTypeB GraphemeBreakType
breakTypeA GraphemeBreakTypeOther
breakTypeB GraphemeBreakTypeExtend breakTypeB GraphemeBreakTypeSpacingMark
breakTypeA GraphemeBreakType
breakTypeB GraphemeBreakType
breakTypeA GraphemeBreakTypeControl breakTypeA GraphemeBreakType breakTypeA GraphemeBreakType
breakTypeB GraphemeBreakTypeControl breakTypeB GraphemeBreakType breakTypeB GraphemeBreakType
breakTypeA GraphemeBreakType
breakTypeB GraphemeBreakType breakTypeB GraphemeBreakType breakTypeB GraphemeBreakType breakTypeB GraphemeBreakType
breakTypeA GraphemeBreakType breakTypeA GraphemeBreakType
breakTypeB GraphemeBreakType breakTypeB GraphemeBreakType
breakTypeA GraphemeBreakType breakTypeA GraphemeBreakType
breakTypeB GraphemeBreakType
breakTypeB GraphemeBreakTypeExtend breakTypeB GraphemeBreakType
breakTypeB GraphemeBreakTypeSpacingMark
breakTypeA GraphemeBreakTypePrepend
breakTypeA GraphemeBreakType breakTypeB GraphemeBreakTypeExtended_Pictographic
breakTypeA GraphemeBreakTypeRegional_Indicator breakTypeB GraphemeBreakTypeRegional_Indicator
GraphemeBreakType
Other
Prepend
Control
Extend
Regional_Indicator
SpacingMark
Extended_Pictographic
_INSTANCE GraphemeBreakTree
GraphemeBreakTree
GraphemeBreakTree_INSTANCE
GraphemeBreakTree_INSTANCE
GraphemeBreakTree_INSTANCE
_data
_data
codePoint GraphemeBreakType
codePoint
codePoint CharCodeLineFeed
GraphemeBreakType
codePoint CharCodeCarriageReturn
GraphemeBreakType
GraphemeBreakTypeControl
codePoint
GraphemeBreakTypeOther
data _data
nodeCount datalength
nodeIndex
nodeIndex nodeCount
codePoint data nodeIndex
nodeIndex nodeIndex
codePoint data nodeIndex
nodeIndex nodeIndex
data nodeIndex
GraphemeBreakTypeOther
offset str
offset
emojiOffset offset str
emojiOffset
emojiOffset
iterator str offset
iterator
iteratoroffset
initialOffset str
iterator str initialOffset
codePoint iterator
codePoint codePoint CodePointemojiVariantSelector codePoint CodePointenclosingKeyCap
iteratoroffset
codePoint iterator
codePoint
resultOffset iteratoroffset
resultOffset
optionalZwjCodePoint iterator
optionalZwjCodePoint CodePointzwj
resultOffset iteratoroffset
resultOffset
codePoint
codePoint
cache locales
arr Map
result
i i arrlength i
resultarri arri
result
map1 Map
map2 Map
Map
result map1
key value map2
resultkey value
result
map1 Map
map2 Map
map1
map2
result
key value map1
map2key
resultkey value
result
data ambiguousCharacterDatavalue
filteredLocales locales
l l l data
filteredLocaleslength
filteredLocales
languageSpecificMap Map
locale filteredLocales
map datalocale
languageSpecificMap languageSpecificMap map
commonMap data
map commonMap languageSpecificMap
map
locales Set AmbiguousCharacters
AmbiguousCharacterscachelocales
_locales
ObjectAmbiguousCharactersambiguousCharacterDatavalue
k k
AmbiguousCharacters_localesvalue
confusableDictionary Map
codePoint
confusableDictionarycodePoint
codePoint
confusableDictionarycodePoint
ReadonlySet
confusableDictionary
_data Set
_data
_data InvisibleCharacters
_data
codePoint
InvisibleCharacterscodePoint
ReadonlySet
InvisibleCharacters
/**
* Helper to produce a string with a variable number of arguments. Insert variable segments
* into the string using the {n} notation where N is the index of the argument following the string.
* @paramvalue string to which formatting is applied
* @paramargs replacements for {n}-entries
*/
export
function
format
(
:
string
,
...
:
any
[
]
)
:
string
{
if
(
.
===
0
)
{
return
;
}
return
.
replace
(
,
function
(
,
)
{
const
=
parseInt
(
,
10
)
;
return
isNaN
(
)
||
<
0
||
>=
.
?
:
[
]
;
}
)
;
}
const
=
/{([^}]+)}/g
;
/**
* Helper to create a string from a template and a string record.
* Similar to `format` but with objects instead of positional arguments.
*/
export
function
format2
(
:
string
,
:
<
string
,
unknown
>
)
:
string
{
if
(
.
keys
(
)
.
===
0
)
{
return
;
}
return
.
replace
(
,
(
,
)
=>
(
[
]
??
)
as
string
)
;
}
/**
* Encodes the given value so that it can be used as literal value in html attributes.
*
* In other words, computes `$val`, such that `attr` in `<div attr="$val" />` has the runtime value `value`.
* This prevents XSS injection.
*/
export
function
htmlAttributeEncodeValue
(
:
string
)
:
string
{
return
.
replace
(
/[<>"'&]/g
,
=>
{
switch
(
)
{
case
'<'
:
return
'<'
;
case
'>'
:
return
'>'
;
case
'"'
:
return
'"'
;
case
'\''
:
return
'''
;
case
'&'
:
return
'&'
;
}
return
;
}
)
;
}
/**
* Converts HTML characters inside the string to use entities instead. Makes the string safe from
* being used e.g. in HTMLElement.innerHTML.
*/
export
function
escape
(
:
string
)
:
string
{
return
.
replace
(
/[<>&]/g
,
function
(
)
{
switch
(
)
{
case
'<'
:
return
'<'
;
case
'>'
:
return
'>'
;
case
'&'
:
return
'&'
;
default
:
return
;
}
}
)
;
}
/**
* Escapes regular expression characters in a given string
*/
export
function
escapeRegExpCharacters
(
:
string
)
:
string
{
return
.
replace
(
/[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g
,
'\\$&'
)
;
}
/**
* Counts how often `character` occurs inside `value`.
*/
/**
* Removes all occurrences of needle from the beginning and end of haystack.
* @paramhaystack string to trim
* @paramneedle the thing to trim (default is a blank)
*/
export
function
trim
(
:
string
,
:
string
=
' '
)
:
string
{
const
=
ltrim
(
,
)
;
return
rtrim
(
,
)
;
}
/**
* Removes all occurrences of needle from the beginning of haystack.
* @paramhaystack string to trim
* @paramneedle the thing to trim
*/
export
function
ltrim
(
:
string
,
:
string
)
:
string
{
if
(
!
||
!
)
{
return
;
}
const
=
.
;
if
(
===
0
||
.
===
0
)
{
return
;
}
let
=
0
;
while
(
.
indexOf
(
,
)
===
)
{
=
+
;
}
return
.
substring
(
)
;
}
/**
* Removes all occurrences of needle from the end of haystack.
* @paramhaystack string to trim
* @paramneedle the thing to trim
*/
export
function
rtrim
(
:
string
,
:
string
)
:
string
{
if
(
!
||
!
)
{
return
;
}
const
=
.
,
=
.
;
if
(
===
0
||
===
0
)
{
return
;
}
let
=
,
=
-
1
;
while
(
true
)
{
=
.
lastIndexOf
(
,
-
1
)
;
if
(
===
-
1
||
+
!==
)
{
break
;
}
if
(
===
0
)
{
return
''
;
}
=
;
}
return
.
substring
(
0
,
)
;
}
export
function
convertSimple2RegExpPattern
(
:
string
)
:
string
{
return
.
replace
(
/[\-\\\{\}\+\?\|\^\$\.\,\[\]\(\)\#\s]/g
,
'\\$&'
)
.
replace
(
/[\*]/g
,
'.*'
)
;
}
export
function
stripWildcards
(
:
string
)
:
string
{
return
.
replace
(
/\*/g
,
''
)
;
}
export
interface
RegExpOptions
{
?
:
boolean
;
?
:
boolean
;
?
:
boolean
;
?
:
boolean
;
?
:
boolean
;
}
export
function
createRegExp
(
:
string
,
:
boolean
,
:
=
{
}
)
:
{
if
(
!
)
{
throw
new
Error
(
'Cannot create regex from empty string'
)
;
}
if
(
!
)
{
=
escapeRegExpCharacters
(
)
;
}
if
(
.
)
{
if
(
!
/\B/
.
test
(
.
charAt
(
0
)
)
)
{
=
'\\b'
+
;
}
if
(
!
/\B/
.
test
(
.
charAt
(
.
-
1
)
)
)
{
=
+
'\\b'
;
}
}
let
=
''
;
if
(
.
)
{
+=
'g'
;
}
if
(
!
.
)
{
+=
'i'
;
}
if
(
.
)
{
+=
'm'
;
}
if
(
.
)
{
+=
'u'
;
}
return
new
RegExp
(
,
)
;
}
export
function
regExpLeadsToEndlessLoop
(
:
)
:
boolean
{
// Exit early if it's one of these special cases which are meant to match
// against an empty string
if
(
.
===
'^'
||
.
===
'^$'
||
.
===
'$'
||
.
===
'^\\s*$'
)
{
return
false
;
}
// We check against an empty string. If the regular expression doesn't advance
// (e.g. ends in an endless loop) it will match an empty string.
const
=
.
exec
(
''
)
;
return
!
!
(
&&
.
===
0
)
;
}
export
function
splitLines
(
:
string
)
:
string
[
]
{
return
.
split
(
/\r\n|\r|\n/
)
;
}
/**
* Returns first index of the string that is not whitespace.
* If string is empty or contains only whitespaces, returns -1
*/
export
function
firstNonWhitespaceIndex
(
:
string
)
:
number
{
for
(
let
=
0
,
=
.
;
<
;
++
)
{
const
=
.
charCodeAt
(
)
;
if
(
!==
.
&&
!==
.
)
{
return
;
}
}
return
-
1
;
}
/**
* Returns the leading whitespace of the string.
* If the string contains only whitespaces, returns entire string
*/
export
function
getLeadingWhitespace
(
:
string
,
:
number
=
0
,
:
number
=
.
)
:
string
{
for
(
let
=
;
<
;
++
)
{
const
=
.
charCodeAt
(
)
;
if
(
!==
.
&&
!==
.
)
{
return
.
substring
(
,
)
;
}
}
return
.
substring
(
,
)
;
}
/**
* Returns last index of the string that is not whitespace.
* If string is empty or contains only whitespaces, returns -1
*/
export
function
lastNonWhitespaceIndex
(
:
string
,
:
number
=
.
-
1
)
:
number
{
for
(
let
=
;
>=
0
;
--
)
{
const
=
.
charCodeAt
(
)
;
if
(
!==
.
&&
!==
.
)
{
return
;
}
}
return
-
1
;
}
/**
* Function that works identically to String.prototype.replace, except, the
* replace function is allowed to be async and return a Promise.
*/
export
function
replaceAsync
(
:
string
,
:
,
replacer
:
(
:
string
,
...
:
any
[
]
)
=>
Promise
<
string
>
)
:
Promise
<
string
>
{
const
:
(
string
|
Promise
<
string
>
)
[
]
=
[
]
;
let
=
0
;
for
(
const
of
.
matchAll
(
)
)
{
.
push
(
.
slice
(
,
.
)
)
;
if
(
.
===
undefined
)
{
throw
new
Error
(
'match.index should be defined'
)
;
}
=
.
+
[
0
]
.
;
.
push
(
replacer
(
[
0
]
,
...
.
slice
(
1
)
,
.
,
,
.
)
)
;
}
.
push
(
.
slice
(
)
)
;
return
Promise
.
all
(
)
.
then
(
=>
.
join
(
''
)
)
;
}
export
function
compare
(
:
string
,
:
string
)
:
number
{
if
(
<
)
{
return
-
1
;
}
else
if
(
>
)
{
return
1
;
}
else
{
return
0
;
}
}
export
function
compareSubstring
(
:
string
,
:
string
,
:
number
=
0
,
:
number
=
.
,
:
number
=
0
,
:
number
=
.
)
:
number
{
for
(
;
<
&&
<
;
++
,
++
)
{
const
=
.
charCodeAt
(
)
;
const
=
.
charCodeAt
(
)
;
if
(
<
)
{
return
-
1
;
}
else
if
(
>
)
{
return
1
;
}
}
const
=
-
;
const
=
-
;
if
(
<
)
{
return
-
1
;
}
else
if
(
>
)
{
return
1
;
}
return
0
;
}
export
function
compareIgnoreCase
(
:
string
,
:
string
)
:
number
{
return
compareSubstringIgnoreCase
(
,
,
0
,
.
,
0
,
.
)
;
}
export
function
compareSubstringIgnoreCase
(
:
string
,
:
string
,
:
number
=
0
,
:
number
=
.
,
:
number
=
0
,
:
number
=
.
)
:
number
{
for
(
;
<
&&
<
;
++
,
++
)
{
let
=
.
charCodeAt
(
)
;
let
=
.
charCodeAt
(
)
;
if
(
===
)
{
// equal
continue
;
}
if
(
>=
128
||
>=
128
)
{
// not ASCII letters -> fallback to lower-casing strings
return
compareSubstring
(
.
toLowerCase
(
)
,
.
toLowerCase
(
)
,
,
,
,
)
;
}
// mapper lower-case ascii letter onto upper-case varinats
// of which FF01 - FF5E fullwidth ASCII of 21 to 7E
// [IGNORE] and FF65 - FFDC halfwidth of Katakana and Hangul
// [IGNORE] FFF0 - FFFF Specials
return
(
(
>=
0x2E80
&&
<=
0xD7AF
)
||
(
>=
0xF900
&&
<=
0xFAFF
)
||
(
>=
0xFF01
&&
<=
0xFF5E
)
)
;
}
/**
* A fast function (therefore imprecise) to check if code points are emojis.
* Generated using https://github.com/alexdima/unicode-utils/blob/main/emoji-test.js
*/
export
function
isEmojiImprecise
(
:
number
)
:
boolean
{
return
(
(
>=
0x1F1E6
&&
<=
0x1F1FF
)
||
(
===
8986
)
||
(
===
8987
)
||
(
===
9200
)
||
(
===
9203
)
||
(
>=
9728
&&
<=
10175
)
||
(
===
11088
)
||
(
===
11093
)
||
(
>=
127744
&&
<=
128591
)
||
(
>=
128640
&&
<=
128764
)
||
(
>=
128992
&&
<=
129008
)
||
(
>=
129280
&&
<=
129535
)
||
(
>=
129648
&&
<=
129782
)
)
;
}
/**
* Given a string and a max length returns a shorted version. Shorting
* happens at favorable positions - such as whitespace or punctuation characters.
* The return value can be longer than the given value of `n`. Leading whitespace is always trimmed.
*/
export
function
lcut
(
:
string
,
:
number
,
=
''
)
{
const
=
.
trimStart
(
)
;
if
(
.
<
)
{
return
;
}
const
=
/\b/g
;
let
=
0
;
while
(
.
test
(
)
)
{
if
(
.
-
.
<
)
{
break
;
}
=
.
;
.
+=
1
;
}
if
(
===
0
)
{
return
;
}
return
+
.
substring
(
)
.
trimStart
(
)
;
}
// Escape codes, compiled from https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
// Plus additional markers for custom `\x1b]...\x07` instructions.
const
CSI_CUSTOM_SEQUENCE
=
/\x1b\].*?\x07/g
;
export
function
removeAnsiEscapeCodes
(
:
string
)
:
string
{
if
(
)
{
=
.
replace
(
CSI_SEQUENCE
,
''
)
.
replace
(
CSI_CUSTOM_SEQUENCE
,
''
)
;
}
return
;
}
// -- UTF-8 BOM
export
const
UTF8_BOM_CHARACTER
=
.
fromCharCode
(
.
UTF8_BOM
)
;
export
function
startsWithUTF8BOM
(
:
string
)
:
boolean
{
return
!
!
(
&&
.
>
0
&&
.
charCodeAt
(
0
)
===
.
UTF8_BOM
)
;
}
export
function
stripUTF8BOM
(
:
string
)
:
string
{
return
startsWithUTF8BOM
(
)
?
.
substr
(
1
)
:
;
}
/**
* Checks if the characters of the provided query string are included in the
* target string. The characters do not have to be contiguous within the string.
*/
export
function
fuzzyContains
(
:
string
,
:
string
)
:
boolean
{
if
(
!
||
!
)
{
return
false
;
// return early if target or query are undefined
}
if
(
.
<
.
)
{
return
false
;
// impossible for query to be contained in target
}
const
=
.
;
const
=
.
toLowerCase
(
)
;
let
=
0
;
let
=
-
1
;
while
(
<
)
{
const
=
.
indexOf
(
[
]
,
+
1
)
;
if
(
<
0
)
{
return
false
;
}
=
;
++
;
}
return
true
;
}
export
function
containsUppercaseCharacter
(
:
string
,
=
false
)
:
boolean
{
if
(
!
)
{
return
false
;
}
if
(
)
{
=
.
replace
(
/\\./g
,
''
)
;
}
return
.
toLowerCase
(
)
!==
;
}
export
function
uppercaseFirstLetter
(
:
string
)
:
string
{
return
.
charAt
(
0
)
.
toUpperCase
(
)
+
.
slice
(
1
)
;
}
export
function
getNLines
(
:
string
,
=
1
)
:
string
{
if
(
===
0
)
{
return
''
;
}
let
=
-
1
;
do
{
=
.
indexOf
(
'\n'
,
+
1
)
;
--
;
}
while
(
>
0
&&
>=
0
)
;
if
(
===
-
1
)
{
return
;
}
if
(
[
-
1
]
===
'\r'
)
{
--
;
}
return
.
substr
(
0
,
)
;
}
/**
* Produces 'a'-'z', followed by 'A'-'Z'... followed by 'a'-'z', etc.
*/