@@ -75,67 +75,67 @@ public final class ActiveDocumentChatContextCollector: ChatContextCollector {
7575
7676 func extractSystemPrompt( _ context: ActiveDocumentContext , isSensitive: Bool ) -> String {
7777 let start = """
78- ## File and Code Scope
78+ ## Active Document
7979
80- You can use the following context to answer my questions about the editing document. \
81- The context shows only a part of the code in the editing document.
80+ The active document is the source code the user is editing right now.
8281
8382 \(
8483 context. focusedContext == nil
8584 ? " "
86- : " When you don't known what I am asking, I am probably referring to the code . "
85+ : " When you don't known what I am asking, I am probably referring to the document . "
8786 )
88-
89- ### Editing Document Context
9087 """
9188 let relativePath = " Document Relative Path: \( context. relativePath) "
9289 let language = " Language: \( context. language. rawValue) "
9390
94- if let focusedContext = context. focusedContext {
95- let codeContext = focusedContext. context. isEmpty || isSensitive
91+ let focusingContextExplanation =
92+ " Below is the code inside the active document that the user is looking at right now: "
93+
94+ if let focusingContext = context. focusedContext {
95+ let codeContext = focusingContext. context. isEmpty || isSensitive
9696 ? " "
9797 : """
98- Focused Context:
98+ Focusing Context:
9999 ```
100- \( focusedContext . context. map ( \. signature) . joined ( separator: " \n " ) )
100+ \( focusingContext . context. map ( \. signature) . joined ( separator: " \n " ) )
101101 ```
102102 """
103103
104- let codeRange = " Focused Range [line, character]: \( focusedContext . codeRange) "
104+ let codeRange = " Focusing Range [line, character]: \( focusingContext . codeRange) "
105105
106106 let code = context. selectionRange. isEmpty && isSensitive
107107 ? """
108108 The file is in gitignore, you can't read the file.
109109 Ask the user to select the code in the editor to get help. Also tell them the file is in gitignore.
110110 """
111111 : """
112- Focused Code (from line \(
113- focusedContext . codeRange. start. line + 1
114- ) to line \( focusedContext . codeRange. end. line + 1 ) ):
112+ Focusing Code (from line \(
113+ focusingContext . codeRange. start. line + 1
114+ ) to line \( focusingContext . codeRange. end. line + 1 ) ):
115115 ``` \( context. language. rawValue)
116- \( focusedContext . code)
116+ \( focusingContext . code)
117117 ```
118118 """
119119
120- let fileAnnotations = focusedContext . otherLineAnnotations. isEmpty || isSensitive
120+ let fileAnnotations = focusingContext . otherLineAnnotations. isEmpty || isSensitive
121121 ? " "
122122 : """
123123 Out-of-scope Annotations: \" " "
124- (They are not inside the focused code. You can get the code at the line for details)
124+ (They are not inside the focusing code. You can get the code at the line for details)
125125 \(
126- focusedContext . otherLineAnnotations
126+ focusingContext . otherLineAnnotations
127127 . map ( convertAnnotationToText)
128128 . joined ( separator: " \n " )
129129 )
130130 \" " "
131131 """
132132
133- let codeAnnotations = focusedContext . lineAnnotations. isEmpty || isSensitive
133+ let codeAnnotations = focusingContext . lineAnnotations. isEmpty || isSensitive
134134 ? " "
135135 : """
136- Annotations Inside Focused Range: \" " "
136+ Annotations Inside Focusing Range: \" " "
137137 \(
138- focusedContext . lineAnnotations
138+ focusingContext . lineAnnotations
139139 . map ( convertAnnotationToText)
140140 . joined ( separator: " \n " )
141141 )
@@ -146,6 +146,7 @@ public final class ActiveDocumentChatContextCollector: ChatContextCollector {
146146 start,
147147 relativePath,
148148 language,
149+ focusingContextExplanation,
149150 codeContext,
150151 codeRange,
151152 code,
0 commit comments