Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/**
* GitHub `owner/repo` parsed from a clone URL. Only `https://github.com/...` URLs
* are supported in the browser implementation.
*/
export
interface
IGitHubRepoRef
{
readonly
:
string
;
readonly
:
string
;
}
const
GITHUB_HOSTS
=
new
Set
(
[
'github.com'
,
'www.github.com'
]
)
;
/**
* Parse a clone URL into an `owner/repo` pair.
* @returns the parsed reference, or `undefined` if the URL is not a recognised
* GitHub HTTPS clone URL.
*/
export
function
parseGitHubCloneUrl
(
:
string
)
:
|
undefined
{
let
:
URL
;
try
{
=
new
URL
(
)
;
}
catch
{
return
undefined
;
}
if
(
.
!==
'https:'
||
!
GITHUB_HOSTS
.
has
(
.
.
toLowerCase
(
)
)
)
{
return
undefined
;
}
// Trim slashes before stripping `.git` so `.../o/r.git/` normalises to `o/r`.
const
=
.
.
replace
(
/^\/+/
,
''
)
.
replace
(
/\/+$/
,
''
)
.
replace
(
/\.git$/i
,
''
)
;
const
=
.
split
(
'/'
)
;
// Require exactly two segments to avoid mis-parsing `.../owner/repo/issues/42`.
if
(
.
!==
2
||
!
[
0
]
||
!
[
1
]
)
{
return
undefined
;
}
return
{
:
[
0
]
,
:
[
1
]
}
;
}
/** Response shape from GitHub's `GET /repos/{owner}/{repo}/commits/{ref}`. */
interface
IGitHubCommitResponse
{
readonly
:
string
;
}
/**
* Wrap a `requestService.request` call so transport-level errors (browser
* `fetch` throws an opaque `TypeError: Failed to fetch` for CORS / DNS /
* connection failures) include the URL and call site.
*/
async
function
loggedRequest
(
:
,
:
{
:
string
;
:
<
string
,
string
>
;
:
string
}
,
:
,
)
{
try
{
return
await
.
request
(
{
:
'GET'
,
:
.
,
:
.
,
:
.
}
,
)
;
}
catch
(
)
{
const
=
instanceof
Error
?
`${err.name}: ${err.message}`
:
String
(
)
;
throw
new
Error
(
`Network error during ${options.callSite} (GET ${options.url}): ${reason}`
,
{
:
instanceof
Error
?
:
undefined
}
)
;
}
}
/**
* Resolve a ref (branch / tag / SHA / undefined for default branch) to a
* commit SHA via the GitHub commits API.
*/
`GitHub rate limit hit resolving ref '${ref ??'HEAD'}' on ${repo.owner}/${repo.repo}`
,
retryAfterFromHeaders
(
.
.
)
)
;
}
if
(
===
401
||
===
403
)
{
throw
new
GitHubAuthRequiredError
(
`GitHub returned ${status} resolving ref '${ref ??'HEAD'}' on ${repo.owner}/${repo.repo}`
)
;
}
if
(
===
404
)
{
throw
new
Error
(
`GitHub repository or ref not found: ${repo.owner}/${repo.repo}@${ref ??'HEAD'}`
)
;
}
if
(
!
isSuccess
(
)
)
{
throw
new
Error
(
`GitHub returned ${status}${isClientError(ctx)?' (client error)':''} resolving ref for ${repo.owner}/${repo.repo}`
)
;
}
const
=
await
asJson<IGitHubCommitResponse>
(
)
;
if
(
!
||
typeof
.
!==
'string'
)
{
throw
new
Error
(
`GitHub commit response for ${repo.owner}/${repo.repo} missing 'sha' field`
)
;
}
return
.
;
}
/**
* Thrown when GitHub responds with 401/403 to indicate the caller needs to
* sign in (or has insufficient permissions) for a private repository.
*/
export
class
GitHubAuthRequiredError
extends
Error
{
constructor
(
:
string
)
{
super
(
)
;
this
.
=
'GitHubAuthRequiredError'
;
}
}
/**
* Thrown when GitHub responds with 403 + `X-RateLimit-Remaining: 0` to
* indicate the caller has exhausted the request quota for the current
* window. Distinct from {@link GitHubAuthRequiredError} so callers don't
* push users to sign in when the actual fix is "wait".
*/
export
class
GitHubRateLimitError
extends
Error
{
constructor
(
:
string
,
public
readonly
?
:
number
)
{
super
(
)
;
this
.
=
'GitHubRateLimitError'
;
}
}
function
isRateLimited
(
:
<
string
,
string
|
string
[
]
|
undefined
>
|
undefined
)
:
boolean
{
if
(
!
)
{
return
false
;
}
if
(
readHeader
(
,
'x-ratelimit-remaining'
)
===
'0'
)
{
return
true
;
}
// Secondary rate limit: GitHub omits X-RateLimit-Remaining but sets Retry-After.
return
readHeader
(
,
'retry-after'
)
!==
undefined
;
}
/**
* Fetches the file tree of a GitHub repository at the given SHA and writes
* each blob into {@link targetDir} via {@link IFileService}.
*
* Uses two CORS-friendly endpoints on `api.github.com` (the `/tarball/` host
* has no CORS, and `raw.githubusercontent.com` rejects the OPTIONS preflight
* forced by an `Authorization` header):
*
* - `GET /repos/{owner}/{repo}/git/trees/{sha}?recursive=1` for the listing.
* - `GET /repos/{owner}/{repo}/git/blobs/{blob_sha}` for each blob (base64).
*
* Extraction is staged to a sibling directory and atomically swapped into
* place on success; failures clean up the staging dir and leave `targetDir`
* untouched. Symlinks (`mode === '120000'`) and submodules (`type === 'commit'`)
* are skipped — neither is representable in the workbench virtual file system.
*/
export
async
function
fetchAndExtractGitHubRepo
(
:
,
:
,
:
,
:
,
:
string
,
:
URI
,
:
string
|
undefined
,
:
,
)
:
Promise
<
void
>
{
const
=
await
fetchGitHubTree
(
,
,
,
,
)
;
if
(
.
)
{
// GitHub caps the recursive tree response at ~100K entries / ~7MB.
.
warn
(
`[GitHubRepoFetcher] Tree for ${repo.owner}/${repo.repo}@${sha} is truncated; some files will be missing from the install`
`GitHub rate limit hit fetching blob '${entry.path}' for ${repo.owner}/${repo.repo}@${commitSha}`
,
retryAfterFromHeaders
(
.
.
)
)
;
}
if
(
===
401
||
===
403
)
{
throw
new
GitHubAuthRequiredError
(
`GitHub returned ${status} fetching blob '${entry.path}' for ${repo.owner}/${repo.repo}@${commitSha}`
)
;
}
if
(
!
isSuccess
(
)
)
{
throw
new
Error
(
`GitHub returned ${status} fetching blob '${entry.path}' for ${repo.owner}/${repo.repo}@${commitSha}`
)
;
}
const
=
await
asJson<IGitHubBlobResponse>
(
)
;
if
(
!
||
typeof
.
!==
'string'
)
{
throw
new
Error
(
`GitHub blob response for '${entry.path}' missing 'content' field`
)
;
}
if
(
.
!==
'base64'
)
{
throw
new
Error
(
`GitHub blob response for '${entry.path}' has unsupported encoding '${body.encoding}'`
)
;
}
// GitHub wraps base64 at 60 columns; strip whitespace before decoding.
return
decodeBase64
(
.
.
replace
(
/\s+/g
,
''
)
)
;
}
/** Response shape from `GET /repos/{owner}/{repo}/git/blobs/{sha}`. */
interface
IGitHubBlobResponse
{
readonly
:
string
;
readonly
:
string
;
}
/**
* Sanitize a tree entry path to safe segments under {@link targetDir}. Rejects
* NUL bytes, absolute paths, `.`/`..` segments, and segments containing a
* backslash (which Windows path APIs would treat as a separator). The result
* is double-checked with `isEqualOrParent` as defence in depth.
*
* @returns the resolved URI, or `undefined` for paths that should be skipped.
*/
function
safeJoinUnderTarget
(
:
URI
,
:
string
)
:
URI
|
undefined
{
if
(
.
includes
(
'\0'
)
||
.
startsWith
(
'/'
)
||
.
startsWith
(
'\\'
)
)
{
return
undefined
;
}
const
:
string
[
]
=
[
]
;
for
(
const
of
.
split
(
'/'
)
)
{
if
(
.
===
0
||
===
'.'
)
{
continue
;
}
if
(
===
'..'
||
.
includes
(
'\\'
)
)
{
return
undefined
;
}
.
push
(
)
;
}
if
(
.
===
0
)
{
return
undefined
;
}
const
=
joinPath
(
,
...
)
;
// Defence in depth: ensure the joined URI has not escaped via any