Documentation
¶
Index ¶
- Variables
- type Agent
- type Choice
- type CompletionResponse
- type CompletionTokensDetails
- type ContentFilterResults
- type Copilot
- type GithubEndpoint
- type GithubToken
- type Hate
- type Message
- type Model
- type ModelCapabilities
- type ModelCapabilityLimit
- type PromptFilterResult
- type PromptMessage
- type PromptTokensDetails
- type Usage
Constants ¶
This section is empty.
Variables ¶
View Source
var BASE_PROMPT = fmt.Sprintf(` When asked for your name, you must respond with "GitHub Copilot". Follow the user's requirements carefully & to the letter. Follow Microsoft content policies. Avoid content that violates copyrights. If you are asked to generate content that is harmful, hateful, racist, sexist, lewd, violent, or completely irrelevant to software engineering, only respond with "Sorry, I can't assist with that." Keep your answers short and impersonal. The user works in an IDE called Neovim which has a concept for editors with open files, integrated unit test support, an output pane that shows the output of running the code as well as an integrated terminal. The user is working on a %s machine. Please respond with system specific commands if applicable. `, utils.SetCurrentOSName())
View Source
var COPILOT_EXPLAIN = ` You are a programming instructor focused on clear, practical explanations. When explaining code: - Balance high-level concepts with implementation details - Highlight key programming principles and patterns - Address any code diagnostics or warnings ` + BASE_PROMPT
View Source
var COPILOT_GENERATE = COPILOT_INSTRUCTIONS + `
Your task is to modify the provided code according to the user's request. Follow these instructions precisely:
1. Split your response into minimal, focused code changes to produce the shortest possible diffs.
2. IMPORTANT: Every code block MUST have a header with this exact format:
[file:<file_name>](<file_path>) line:<start_line>-<end_line>
The line numbers are REQUIRED - never omit them.
3. Return ONLY the modified code blocks - no explanations or comments.
4. Each code block should contain:
- Only the specific lines that need to change
- Exact indentation matching the source
- Complete code that can directly replace the original
5. When fixing code, check and address any diagnostics issues.
6. If multiple separate changes are needed, split them into individual blocks with appropriate headers.
7. If response would be too long:
- Never cut off in the middle of a code block
- Complete the current code block
- End with "**` + "`[Response truncated] Please ask for the remaining changes.`" + `**"
- Next response should continue with the next code block
Remember: Your response should ONLY contain file headers with line numbers and code blocks for direct replacement.
`
View Source
var COPILOT_INSTRUCTIONS = ` You are a code-focused AI programming assistant that specializes in practical software engineering solutions. ` + BASE_PROMPT
View Source
var COPILOT_REVIEW = COPILOT_INSTRUCTIONS + `
Review the code for readability and maintainability issues. Report problems in this format:
line=<line_number>: <issue_description>
line=<start_line>-<end_line>: <issue_description>
Check for:
- Unclear or non-conventional naming
- Comment quality (missing or unnecessary)
- Complex expressions needing simplification
- Deep nesting
- Inconsistent style
- Code duplication
Multiple issues on one line should be separated by semicolons.
End with: "**` + "`To clear buffer highlights, please ask a different question.`" + `**"
If no issues found, confirm the code is well-written.
`
View Source
var ErrGithubTokenNotSet = errors.New("no GitHub token found, please use `:Copilot auth` to set it up from copilot.lua or `:Copilot setup` for copilot.vim")
Functions ¶
This section is empty.
Types ¶
type Choice ¶
type Choice struct {
ContentFilterResults ContentFilterResults `json:"content_filter_results"`
FinishReason string `json:"finish_reason"`
Index int64 `json:"index"`
Message Message `json:"message"`
}
type CompletionResponse ¶
type CompletionResponse struct {
Choices []Choice `json:"choices"`
Created int64 `json:"created"`
ID string `json:"id"`
Model string `json:"model"`
PromptFilterResults []PromptFilterResult `json:"prompt_filter_results"`
SystemFingerprint string `json:"system_fingerprint"`
Usage Usage `json:"usage"`
}
type CompletionTokensDetails ¶
type CompletionTokensDetails struct {
ReasoningTokens int64 `json:"reasoning_tokens"`
}
type ContentFilterResults ¶
type Copilot ¶
type Copilot interface {
FetchModels(ctx context.Context) (map[string]*Model, error)
FetchAgents(ctx context.Context) (map[string]*Agent, error)
Ask(ctx context.Context, prompt string, opts any) (string, error)
}
func NewCopilot ¶
func NewCopilot() Copilot
type GithubEndpoint ¶
type GithubToken ¶
type GithubToken struct {
AnnotationsEnabled bool `json:"annotations_enabled"`
ChatEnabled bool `json:"chat_enabled"`
ChatJetbrainsEnabled bool `json:"chat_jetbrains_enabled"`
CodeQuoteEnabled bool `json:"code_quote_enabled"`
CodeReviewEnabled bool `json:"code_review_enabled"`
Codesearch bool `json:"codesearch"`
CopilotignoreEnabled bool `json:"copilotignore_enabled"`
Endpoints GithubEndpoint `json:"endpoints"`
ExpiresAt int `json:"expires_at"`
Individual bool `json:"individual"`
LimitedUserQuotas any `json:"limited_user_quotas"`
LimitedUserResetDate any `json:"limited_user_reset_date"`
NesEnabled bool `json:"nes_enabled"`
Prompt8K bool `json:"prompt_8k"`
PublicSuggestions string `json:"public_suggestions"`
RefreshIn int `json:"refresh_in"`
Sku string `json:"sku"`
SnippyLoadTestEnabled bool `json:"snippy_load_test_enabled"`
Telemetry string `json:"telemetry"`
Token string `json:"token"`
TrackingID string `json:"tracking_id"`
TriggerCompletionAfterAccept bool `json:"trigger_completion_after_accept"`
VscElectronFetcherV2 bool `json:"vsc_electron_fetcher_v2"`
Xcode bool `json:"xcode"`
XcodeChat bool `json:"xcode_chat"`
}
type ModelCapabilities ¶
type ModelCapabilities struct {
Family string `json:"family"`
Limits ModelCapabilityLimit `json:"limits"`
Object string `json:"object"`
Supports struct {
Streaming bool `json:"streaming"`
ToolCalls bool `json:"tool_calls"`
} `json:"supports"`
Tokenizer string `json:"tokenizer"`
Type string `json:"type"`
}
type ModelCapabilityLimit ¶
type PromptFilterResult ¶
type PromptFilterResult struct {
ContentFilterResults ContentFilterResults `json:"content_filter_results"`
PromptIndex int64 `json:"prompt_index"`
}
type PromptMessage ¶
type PromptTokensDetails ¶
type PromptTokensDetails struct {
CachedTokens int64 `json:"cached_tokens"`
}
type Usage ¶
type Usage struct {
CompletionTokens int64 `json:"completion_tokens"`
CompletionTokensDetails CompletionTokensDetails `json:"completion_tokens_details"`
PromptTokens int64 `json:"prompt_tokens"`
PromptTokensDetails PromptTokensDetails `json:"prompt_tokens_details"`
TotalTokens int64 `json:"total_tokens"`
}
Click to show internal directories.
Click to hide internal directories.