Это 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{ CharCode }from'./charCode';exportfunctionisFalsyOrWhitespace(str:string|undefined):boolean{if(!str ||typeof str !=='string'){returntrue;}return str.trim().length ===0;}const _formatRegexp =/{(\d+)}
value args
argslength
value
value_formatRegexp match group
idx group
idx idx idx argslength
match
argsidx
_format2Regexp
template values Record
template_format2Regexp match group valuesgroup match
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
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
regexpValue
regexpValue
regexp RegExp
regexpglobal
regexpignoreCase
regexpmultiline
regexp unicode
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
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
textlength n
text
re
i
retext
textlength relastIndex n
i relastIndex
relastIndex
texti
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
noBreakWhitespace
_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
{
return
.
replace
(
,
(
,
)
=>
(
[
]
??
)
as
string
)
;
}
/**
* 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`.
*/
export
function
count
(
:
string
,
:
string
)
:
number
{
let
=
0
;
const
=
.
charCodeAt
(
0
)
;
for
(
let
=
.
-
1
;
>=
0
;
--
)
{
if
(
.
charCodeAt
(
)
===
)
{
++
;
}
}
return
;
}
export
function
truncate
(
:
string
,
:
number
,
=
'…'
)
:
string
{
if
(
.
<=
)
{
return
;
}
return
`${value.substr(0, maxLength)}${suffix}`
;
}
/**
* 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
regExpContainsBackreference
(
:
string
)
:
boolean
{
return
!
!
.
match
(
/([^\\]|^)(\\\\)*\\\d+/
)
;
}
export
function
regExpFlags
(
:
)
:
string
{
return
(
.
?
'g'
:
''
)
+
(
.
?
'i'
:
''
)
+
(
.
?
'm'
:
''
)
+
(
(
as
any
/* standalone editor compilation */
)
.
?
'u'
:
''
)
;
}
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.
*/
export
function
lcut
(
:
string
,
:
number
)
{
if
(
.
<
)
{
return
;
}
const
=
/\b/g
;
let
=
0
;
while
(
.
test
(
)
)
{
if
(
.
-
.
<
)
{
break
;
}
=
.
;
.
+=
1
;
}
return
.
substring
(
)
.
replace
(
/^\s/
,
''
)
;
}
// Escape codes, compiled from https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
/**
* 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.
*/