Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/**
* Represents a feedback file with its name and content.
*/
export
interface
FeedbackFile
{
:
string
;
:
string
;
}
/**
* Configuration for the feedback repository.
*/
interface
FeedbackRepoConfig
{
readonly
:
string
;
readonly
:
string
;
readonly
:
string
;
}
/**
* Handles submission of NES feedback captures to a private GitHub repository.
* Responsible for file collection, user confirmation, filtering, and upload.
*/
export
class
NesFeedbackSubmitter
{
private
static
readonly
DEFAULT_REPO_CONFIG
:
=
{
:
'microsoft'
,
:
'copilot-nes-feedback'
,
:
'https://api.github.com'
}
;
private
readonly
:
;
constructor
(
:
,
private
readonly
:
,
private
readonly
:
,
private
readonly
:
=
.
DEFAULT_REPO_CONFIG
)
{
this
.
=
.
createSubLogger
(
[
'NES'
,
'FeedbackSubmitter'
]
)
;
}
/**
* Submit feedback files from the given folder to the private GitHub repository.
* Shows a preview dialog allowing users to select which files to include.
*/
public
async
submitFromFolder
(
:
)
:
Promise
<
void
>
{
try
{
// Check if feedback folder exists and has files
const
=
await
this
.
_collectFeedbackFiles
(
)
;
if
(
.
===
0
)
{
.
showInformationMessage
(
'No NES feedback captures found to submit. Use "Copilot: Record Expected Edit (NES)" to capture feedback first.'
)
;
return
;
}
// Read file contents
const
=
await
this
.
_readFeedbackFiles
(
,
)
;
if
(
.
===
0
)
{
.
showErrorMessage
(
'Failed to read feedback files.'
)
;
return
;
}
// Extract unique document paths from the recordings to show the user
const
=
this
.
_extractDocumentPathsFromRecordings
(
)
;
// Extract nextUserEdit paths to calculate accurate recording counts
const
=
this
.
_extractNextUserEditPaths
(
)
;
// Show confirmation with file preview and allow filtering
// Returns excluded paths for efficiency (empty in the default case when all files are selected)
const
=
await
this
.
_showFilePreviewAndConfirm
(
,
)
;
if
(
!
)
{
return
;
}
// Filter recordings to remove excluded documents
const
=
this
.
_filterRecordingsByExcludedPaths
(
,
,
)
;
if
(
.
===
0
)
{
.
showInformationMessage
(
'No files to submit after filtering.'
)
;
return
;
}
// Get GitHub auth token - need permissive session for repo access
const
=
await
this
.
.
getGitHubSession
(
'permissive'
,
{
:
{
:
.
t
(
'Sign in to GitHub to submit feedback.'
)
}
}
)
;
if
(
!
)
{
.
showErrorMessage
(
'GitHub authentication required with repo access. Please sign in to GitHub.'
)
;
return
;
}
// Upload files to the private repo
const
=
await
this
.
_uploadToPrivateRepo
(
,
.
)
;
if
(
)
{
await
this
.
_showSuccessDialog
(
)
;
this
.
.
info
(
`Uploaded feedback to private repo: ${folderUrl}`
)
;
}
}
catch
(
)
{
this
.
.
error
(
instanceof
Error
?
:
String
(
)
,
'Error submitting feedback'
)
;
.
showErrorMessage
(
`Failed to submit NES feedback: ${error instanceofError? error.message :'Unknown error'}`
)
;
}
}
/**
* Show success dialog with options to open the PR in GitHub or copy the link.
*/
private
async
_showSuccessDialog
(
:
string
)
:
Promise
<
void
>
{
const
=
await
.
showInformationMessage
(
'Feedback submitted! A pull request has been created.'
,
'Open Pull Request'
,
'Copy Link'
)
;
if
(
===
'Open Pull Request'
)
{
await
.
openExternal
(
.
parse
(
)
)
;
}
else
if
(
===
'Copy Link'
)
{
await
.
.
writeText
(
)
;
.
showInformationMessage
(
'Pull request URL copied to clipboard!'
)
;
}
}
/**
* Collect all feedback files from the capture folder.
*/
private
async
_collectFeedbackFiles
(
:
)
:
Promise
<
[
]
>
{
try
{
const
=
await
.
.
readDirectory
(
)
;
return
.
filter
(
(
[
,
]
)
=>
===
1
&&
.
endsWith
(
'.json'
)
)
// FileType.File = 1
.
map
(
(
[
]
)
=>
.
joinPath
(
,
)
)
;
}
catch
{
return
[
]
;
}
}
/**
* Read contents of feedback files.
*/
private
async
_readFeedbackFiles
(
:
[
]
,
:
)
:
Promise
<
[
]
>
{
const
:
[
]
=
[
]
;
for
(
const
of
)
{
try
{
const
=
await
.
.
readFile
(
)
;
const
=
new
TextDecoder
(
)
.
decode
(
)
;
const
=
.
.
replace
(
.
+
'/'
,
''
)
;
.
push
(
{
:
,
:
}
)
;
}
catch
(
)
{
this
.
.
warn
(
`Failed to read file: ${fileUri.fsPath}: ${e}`
)
;
}
}
return
;
}
/**
* Extract unique document paths from recording files.
* Parses the log entries to find all documentEncountered events.
*/
private
_extractDocumentPathsFromRecordings
(
:
[
]
)
:
string
[
]
{
const
=
new
Set<string>
(
)
;
for
(
const
of
)
{
// Only process recording files, not metadata
if
(
!
.
.
endsWith
(
'.recording.w.json'
)
)
{
continue
;
}
try
{
const
=
JSON
.
parse
(
.
)
as
{
?
:
[
]
}
;
if
(
.
)
{
for
(
const
of
.
)
{
if
(
.
===
'documentEncountered'
)
{
.
add
(
.
)
;
}
}
}
}
catch
{
// Ignore parse errors
}
}
return
Array
.
from
(
)
.
sort
(
)
;
}
/**
* Extract the nextUserEdit path for each recording.
* Returns a map from recording name to its nextUserEdit relativePath (or undefined if none).
*/
private
_extractNextUserEditPaths
(
:
[
]
)
:
<
string
,
string
|
undefined
>
{
const
=
new
Map<string,string|undefined>
(
)
;
for
(
const
of
)
{
if
(
!
.
.
endsWith
(
'.recording.w.json'
)
)
{
continue
;
}
try
{
const
=
JSON
.
parse
(
.
)
as
{
?
:
{
:
string
}
;
}
;
.
set
(
.
,
.
?.
)
;
}
catch
{
// If parsing fails, assume it has no nextUserEdit
.
set
(
.
,
undefined
)
;
}
}
return
;
}
/**
* Count how many recordings will be included after excluding certain paths.
* A recording is included only if its nextUserEdit path is not excluded.
*/
private
_countIncludedRecordings
(
:
<
string
,
string
|
undefined
>
,
:
<
string
>
)
:
number
{
let
=
0
;
for
(
const
[
,
]
of
)
{
if
(
!==
undefined
&&
!
.
has
(
)
)
{
++
;
}
}
return
;
}
/**
* Create a summary string for a list of file paths.
* Shows up to maxFiles paths inline, with "and N more..." for the rest.
*/
private
_createFilesSummary
(
:
string
[
]
,
:
number
=
5
)
:
string
{
const
=
[
...
]
.
sort
(
)
;
if
(
.
length<= maxFiles){return sortedPaths.join(', ');}const shownFiles = sortedPaths.slice(0, maxFiles).join(', ');return`${shownFiles}, and ${sortedPaths.length - maxFiles} more...`;}/**
* Show a preview of files that will be uploaded and ask for confirmation.
* Uses a QuickPick to allow users to select which files to include.
* @returns The excluded file paths (empty array if all selected), or undefined if cancelled.
*/privateasync_showFilePreviewAndConfirm(
documentPaths:string[],
nextUserEditPaths: Map<string,string|undefined>):Promise<string[]|undefined>{const totalRecordingCount =this._countIncludedRecordings(nextUserEditPaths,newSet());if(documentPaths.length ===0){// No document paths found, just show basic confirmationconst result =await window.showInformationMessage(`Found ${totalRecordingCount} feedback recording(s). This will upload your NES feedback to the internal feedback repository.\n\n`+`Only team members with access to the private repo can view this data.`,{ modal:true},'Submit Feedback');return result ==='Submit Feedback'?[]:undefined;// Empty array = no exclusions}// Create a summary of filesconst filesSummary =this._createFilesSummary(documentPaths);const result =await window.showInformationMessage(`Found ${totalRecordingCount} recording(s) containing ${documentPaths.length} file(s):\n${filesSummary}\n\n`+`This will upload your NES feedback to the internal feedback repository.`,{ modal:true},'Submit Feedback','Select Files to Include');if(result ==='Submit Feedback'){return[];// No exclusions - all files selected}if(result ==='Select Files to Include'){returnthis._showFileSelectionQuickPick(documentPaths, nextUserEditPaths);}returnundefined;}/**
* Show a multi-select QuickPick for file selection.
* Loops until user confirms or cancels, allowing them to edit their selection.
* @returns The excluded file paths, or undefined if cancelled.
*/privateasync_showFileSelectionQuickPick(
documentPaths:string[],
nextUserEditPaths: Map<string,string|undefined>):Promise<string[]|undefined>{let currentSelection =newSet(documentPaths);// Start with all selectedwhile(true){const items = documentPaths.map(path =>
(
{
:
,
:
''
,
:
.
has
(
)
}
)
)
;
const
=
await
.
showQuickPick
(
,
{
:
'Select files to include in the upload'
,
:
'Deselect files you want to exclude, then press Enter to confirm'
,
:
true
,
:
true
}
)
;
if
(
!
)
{
// User cancelled QuickPick
return
undefined
;
}
const
=
new
Set
(
.
map
(
=>
.
)
)
;
const
=
.
filter
(
=>
!
.
has
(
)
)
;
if
(
.
===
0
)
{
.
showInformationMessage
(
'No files selected. Upload cancelled.'
)
;
return
undefined
;
}
// Calculate how many recordings will actually be included
const
=
new
Set
(
)
;
const
=
this
.
_countIncludedRecordings
(
,
)
;
if
(
===
0
)
{
const
=
await
.
showInformationMessage
(
'No recordings would be included with this selection (all nextUserEdit files are excluded).'
,
{
:
true
}
,
'Edit Selection'
)
;
if
(
===
'Edit Selection'
)
{
=
;
continue
;
}
return
undefined
;
}
// Show final confirmation with accurate recording count and file summary
const
=
Array
.
from
(
)
;
const
=
this
.
_createFilesSummary
(
)
;
const
=
.
>
0
?
`Submit ${includedRecordingCount} recording(s) with ${selectedPaths.size} file(s)? (${excludedPaths.length} excluded)\n\nIncluded: ${filesSummary}`
// Update current selection and loop back to QuickPick
=
;
continue
;
}
// User clicked Cancel or dismissed the dialog
return
undefined
;
}
}
/**
* Filter recording files to remove excluded document paths.
* Removes documentEncountered entries and all related events for excluded documents.
* Recordings whose nextUserEdit is excluded are skipped entirely,
* along with their associated metadata files.
* Optimized for the common case where excludedPaths is empty (all files selected).
*/
private
_filterRecordingsByExcludedPaths
(
:
[
]
,
:
string
[
]
,
:
<
string
,
string
|
undefined
>
)
:
[
]
{
// Fast path: no exclusions, return files as-is
if
(
.
===
0
)
{
return
;
}
const
=
new
Set
(
)
;
const
:
[
]
=
[
]
;
const
=
new
Set<string>
(
)
;
// First pass: filter recordings and track which ones to skip
for
(
const
of
)
{
if
(
!
.
.
endsWith
(
'.recording.w.json'
)
)
{
continue
;
}
// Use precomputed nextUserEditPaths to quickly skip recordings
const
=
.
get
(
.
)
;
if
(
===
undefined
||
.
has
(
)
)
{
// Skip this recording - no nextUserEdit or it's excluded
const
=
.
.
replace
(
'.recording.w.json'
,
''
)
;
.
add
(
)
;
this
.
.
debug
(
`Skipping recording ${file.name}: nextUserEdit excluded or missing`
)
;
continue
;
}
try
{
const
=
this
.
_filterSingleRecording
(
,
)
;
.
push
(
)
;
}
catch
{
// If parsing fails, include the file as-is
.
push
(
)
;
}
}
// Second pass: include metadata files only if their recording wasn't skipped
const
:
[
]
=
[
...
]
;
for
(
const
of
)
{
if
(
.
.
endsWith
(
'.metadata.json'
)
)
{
const
=
.
.
replace
(
'.metadata.json'
,
''
)
;
if
(
!
.
has
(
)
)
{
.
push
(
)
;
}
else
{
this
.
.
debug
(
`Skipping metadata ${file.name}: associated recording was skipped`
)
;
}
}
}
return
;
}
/**
* Filter a single recording file based on excluded document paths.
* Assumes the recording will be included (nextUserEdit already checked).
*/
private
_filterSingleRecording
(
:
,
:
<
string
>
)
:
{
const
=
JSON
.
parse
(
.
)
as
{
?
:
[
]
;
?
:
{
:
string
;
:
unknown
}
;
}
;
if
(
!
.
)
{
return
;
}
// Find document IDs that should be excluded
const
=
new
Set<number>
(
)
;
for
(
const
of
.
)
{
if
(
.
===
'documentEncountered'
&&
.
has
(
.
)
)
{
.
add
(
.
)
;
}
}
// Filter log entries to remove excluded documents
const
=
.
.
filter
(
=>
{
if
(
.
===
'header'
)
{
return
true
;
}
if
(
'id'
in
&&
typeof
.
===
'number'
)
{
return
!
.
has
(
.
)
;
}
return
true
;
}
)
;
// Create filtered recording (nextUserEdit is preserved - we already checked it's not excluded)
const
=
{
...
,
:
}
;
return
{
:
.
,
:
JSON
.
stringify
(
,
null
,
2
)
}
;
}
/**
* Upload feedback files to the private GitHub repository via a pull request.
* Creates a new branch, uploads files to a timestamped folder, and opens a PR.
* @returns The URL to the pull request, or undefined on failure.
*/
private
async
_uploadToPrivateRepo
(
:
[
]
,
:
string
)
:
Promise
<
string
|
undefined
>
{
const
=
new
Date
(
)
.
toISOString
(
)
.
replace
(
/[:.]/g
,
'-'
)
.
slice
(
0
,
-
5
)
;
const
=
`feedback/${timestamp}`
;
// Get the current user for commit attribution
const
=
await
this
.
_getCurrentUser
(
)
;
const
=
?.
??
'anonymous'
;
// Create a unique branch name for this feedback submission
const
=
`feedback/${username}/${timestamp}`
;
// Get the SHA of the main branch to create our branch from
`This feedback was automatically submitted via the "Copilot: Submit NES Feedback" command.`
}
;
const
=
await
fetch
(
,
{
:
'POST'
,
:
{
'Authorization'
:
`Bearer ${token}`
,
'Accept'
:
'application/vnd.github+json'
,
'Content-Type'
:
'application/json'
,
'X-GitHub-Api-Version'
:
'2022-11-28'
,
'User-Agent'
:
this
.
.
getUserAgentLibrary
(
)
}
,
:
JSON
.
stringify
(
)
}
)
;
if
(
!
.
)
{
const
=
await
.
text
(
)
;
this
.
.
error
(
`Failed to create pull request: ${response.status}${response.statusText} - ${errorText}`
)
;
throw
new
Error
(
`Failed to create pull request: ${response.statusText}`
)
;
}
const
=
await
.
json
(
)
as
{
:
string
}
;
return
.
;
}
/**
* Create a file in the private feedback repository on a specific branch.
* Uses native fetch API since IFetcherService only supports GET/POST,
* but GitHub Contents API requires PUT for file creation.
*/