ide на основе vs code
Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
// Copyright 2025 OpenAI
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Based on reference implementation from
// https://cookbook.openai.com/examples/gpt4-1_prompting_guide#reference-implementation-apply_patchpy
// eslint-disable-next-line header/header
import type { TextDocument } from 'vscode';
import { AbstractDocumentWithLanguageId } from '../../../../platform/editing/common/abstractText';
import { getFilepathComment } from '../../../../util/common/markdown';
import { computeLevenshteinDistance } from '../../../../util/vs/base/common/diff/diff';
import { count, isFalsyOrWhitespace
Lines
computeIndentLevel2 getIndentationChar guessIndentation IGuessedIndentation transformIndentation
ActionType
type ActionType
oldContent
newContent
movePath
changes Record FileChange
Fuzz
None
IgnoredTrailingWhitespace
NormalizedExplicitTab
IgnoredWhitespace
EditDistanceMatch
IgnoredEofSignal
MergedOperatorSection
NormalizedExplicitNL
line
fuzz Fuzz
orig Record
updatedFiles Record
Commit
commit Commit changes
p newContent ObjectupdatedFiles
oldContent origp
oldContent newContent
oldContent newContent
commitchangesp
type ActionType
oldContent
newContent
newContent
commitchangesp
type ActionType
newContent
oldContent
commitchangesp
type ActionType
oldContent
commit
origIndex
delLines
insLines
type ActionType
newFile
chunks Chunk
movePath
actions Record PatchAction
message file kindForTelemetry
message
message kindForTelemetry
message
current_files Record AbstractDocumentWithLanguageId TextDocument
indent_styles Record IGuessedIndentation
lines
index
patch Patch actions
fuzz
currentFiles Record AbstractDocumentWithLanguageId TextDocument lines
current_files currentFiles
lines lines
path doc ObjectcurrentFiles
indent_stylespath Linesdoc
prefixes
index lineslength
prefixes
prefixesp linesindexp
prefix
prefixes prefix prefix prefix
prefixesp linesindexp
prefix returnEverything
index lineslength
linesindexprefix
text returnEverything
linesindex
linesindexprefixlength
index
text
path
path
patchactionspath
moveTo
path current_files
textDocument current_filespath
indentStyle indent_stylespath
text textDocument
action textDocumentlanguageId path text indentStyle
actionmovePath moveTo
patchactionspath action
path
path
patchactionspath
path current_files
patchactionspath type ActionType chunks
path
path
patchactionspath
path current_files
patchactionspath
index
path text targetIndentStyle IGuessedIndentation PatchAction
action PatchAction type ActionType chunks
fileLines text
replaceExplicitTabsByDefault path
index
sectionStr
defStr sectionStrlength
sectionStr index
defStr
found
canonLocal s
s
c
Record
c c
fileLines
index
s s defStr
i index i fileLineslength i
fileLinesi defStr
index i
found
found
fileLines
index
s s defStr
i index i fileLineslength i
fileLinesi defStr
index i
fuzz
found
nextSection
lines
index
match FuzzMatch
i i nextSectionfuzzMerges match i
i
nextSection lines index i
match
path
fileLines
nextSectionnextChunkContext
index
nextSectioneof
match
match
path
fileLines
nextSectionnextChunkContext
nextSectioneof
i match
matchfuzz FuzzMergedOperatorSection
match
ctxText nextSectionnextChunkContext
nextSectioneof
text
kindForTelemetry ctxText
ctxText
text kindForTelemetry
fuzz matchfuzz
srcIndentStyle
nextSectionchunksc cinsLinesnextSectionnextChunkContext
targetIndentStyletabSize
targetIndentStyleinsertSpaces
matchedLineIndent fileLinesmatchline targetIndentStyletabSize
normalizedNextChunkContext matchfuzz FuzzNormalizedExplicitTab
nextSectionnextChunkContext
matchfuzz FuzzNormalizedExplicitNL
nextSectionnextChunkContext
nextSectionnextChunkContext
srcLineIndent nextSectionnextChunkContext nextSectionnextChunkContextlength
normalizedNextChunkContext srcIndentStyletabSize
additionalIndentation targetIndentStyleMath matchedLineIndent srcLineIndent
ch nextSectionchunks
chorigIndex matchline
matchfuzz FuzzNormalizedExplicitNL
chinsLines chinsLinesreplace_explicit_nl
chdelLines chdelLinesreplace_explicit_nl
replaceExplicitTabsByDefault matchfuzz FuzzNormalizedExplicitTab
chinsLines chinsLinesreplace_explicit_tabs
chinsLines chinsLinesins ins ins additionalIndentation ins srcIndentStyle targetIndentStyle
matchfuzz FuzzNormalizedExplicitTab
chdelLines chdelLinesreplace_explicit_tabs
actionchunksch
index matchline nextSectionnextChunkContextlength
index nextSectionendPatchIndex
action
PatchAction
lines
s
s
liness
type ActionType
newFile lines
chunks
s
s r r
s
s
lines
context
start
line fuzz Fuzz indent
Record
canon s
s
c c c
contextlength
line start fuzz FuzzNone
ctxPass1 context
workingLines linescanon
i start i workingLineslength i
segment workingLinesi i contextlength
segment ctxPass1
line i fuzz FuzzNone
ctxPass2 ctxPass1l l
fuzz FuzzIgnoredTrailingWhitespace
i start i workingLineslength i
workingLinesi workingLinesi
i start i lineslength i
workingLinesi i contextlength ctxPass2
line i fuzz
ctxPass3 ctxPass2
ctxPass3 ctxPass2
fuzz FuzzNormalizedExplicitTab
i start i lineslength i
workingLinesi i contextlength ctxPass3
line i fuzz
contextlength
ctxPass4 ctxPass3
ctxPass4 ctxPass3
newContextLines ctxPass4
i start i lineslength i
workingLinesi i newContextLines ctxPass4
line i fuzz fuzz FuzzNormalizedExplicitNL FuzzNormalizedExplicitTab
ctxPass5 ctxPass3l l
fuzz FuzzIgnoredWhitespace
i start i workingLineslength i
workingLinesi workingLinesi
i start i lineslength i
workingLinesi i contextlength ctxPass5
line i fuzz indent workingLinesi
maxDistance Mathcontextlength
fuzz FuzzEditDistanceMatch
maxDistance
ctxPass6 ctxPass5
i start i lineslength i
totalDistance
j j ctxPass6length totalDistance maxDistance j
totalDistance workingLinesi j ctxPass6j
totalDistance maxDistance
line i fuzz
path
lines
context
start
eof
path path
linespath
lines lines
contextpath
context context
eof
match1
lines
context
lineslength contextlength
match1
match1
match2 lines context start
match2
match2fuzz FuzzIgnoredEofSignal
match2
lines context start
lines
initialIndex
fuzzMerge
nextChunkContext chunks Chunk endPatchIndex eof fuzzMerges
Mode
Add
Delete
Keep
index initialIndex
old
delLines
insLines
chunks Chunk
mode Mode ModeKeep
fuzzMergeNo
index lineslength
s linesindex
p sp
mode ModeKeep oldlength oldoldlength
old
s
s
index
lastMode Mode mode
line s
line
mode ModeAdd
line
mode ModeDelete
line
mode ModeKeep
nextLine linesindex
nextOp nextLine ModeAdd nextLine ModeDelete ModeKeep
canFuzz mode ModeKeep nextOp mode
mode ModeKeep
line line
canFuzz
fuzzMergeNo
fuzzMerge fuzzMergeNo
mode nextOp
line line
mode ModeKeep lastMode mode
insLineslength delLineslength
chunks
origIndex oldlength delLineslength
delLines delLines
insLines insLines
delLines
insLines
mode ModeDelete
delLinesline
oldline
mode ModeAdd
insLinesline
oldline
insLineslength delLineslength
chunks
origIndex oldlength delLineslength
delLines
insLines
index lineslength linesindex
index
nextChunkContext old chunks endPatchIndex index eof fuzzMerges fuzzMergeNo
nextChunkContext old chunks endPatchIndex index eof fuzzMerges fuzzMergeNo
text
orig Record AbstractDocumentWithLanguageId TextDocument
Patch
lines text
lineslength
patchPrefix
lines patchPrefix
patchSuffix
lineslineslength patchSuffix
linespatchSuffix
parser orig lines
parserindex
parser
parserpatch parserfuzz
text
lines text
result
line lines
line
resultlinelength
line
resultlinelength
line
resultlinelength
line
resultlinelength
line
resultlinelength
result
text
lines text
result
line lines
line
resultlinelength
line
resultlinelength
result
text
lines text
result
line lines
line
resultlinelength
result
text
action PatchAction
path
actiontype ActionType
origLines text
destLines
origIndex
chunk actionchunks
chunkorigIndex origLineslength
origIndex chunkorigIndex
destLinesorigLinesorigIndex chunkorigIndex
delta chunkorigIndex origIndex
origIndex delta
chunkinsLineslength
l chunkinsLines
destLinesl
origIndex chunkdelLineslength
destLinesorigLinesorigIndex
destLines
patch Patch
orig Record AbstractDocumentWithLanguageId TextDocument
Commit
commit Commit changes
pathKey action Objectpatchactions
actiontype ActionType
commitchangespathKey
type ActionType
oldContent origpathKey
actiontype ActionType
commitchangespathKey
type ActionType
newContent actionnewFile
actiontype ActionType
text origpathKey
newContent text action pathKey
commitchangespathKey
type ActionType
oldContent text
newContent newContent
movePath actionmovePath
commit
paths
p AbstractDocumentWithLanguageId TextDocument
Record AbstractDocumentWithLanguageId TextDocument
orig Record AbstractDocumentWithLanguageId TextDocument
p paths
origp p
orig
text
p AbstractDocumentWithLanguageId TextDocument
Commit
text
paths text
orig paths openFn
patch _fuzz text orig
patch orig