forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstructions.swift
More file actions
83 lines (70 loc) · 2.97 KB
/
Instructions.swift
File metadata and controls
83 lines (70 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import ComposableArchitecture
import Foundation
import MarkdownUI
import SwiftUI
struct Instruction: View {
let chat: StoreOf<Chat>
var body: some View {
WithPerceptionTracking {
Group {
Markdown(
"""
You can use plugins to perform various tasks.
| Plugin Name | Description |
| --- | --- |
| `/shell` | Runs a command under the project root |
| `/shortcut(name)` | Runs a shortcut from the Shortcuts.app, with the previous message as input |
To use plugins, you can prefix a message with `/pluginName`.
"""
)
.modifier(InstructionModifier())
Markdown(
"""
You can use scopes to give the bot extra abilities.
| Scope Name | Abilities |
| --- | --- |
| `@file` | Read the metadata of the editing file |
| `@code` | Read the code and metadata in the editing file |
| `@sense`| Experimental. Read the relevant code of the focused editor |
| `@project` | Experimental. Access content of the project |
| `@web` (beta) | Search on Bing or query from a web page |
To use scopes, you can prefix a message with `@code`.
You can use shorthand to represent a scope, such as `@c`, and enable multiple scopes with `@c+web`.
"""
)
.modifier(InstructionModifier())
let scopes = chat.chatMenu.defaultScopes
Markdown(
"""
Hello, I am your AI programming assistant. I can identify issues, explain and even improve code.
\({
if scopes.isEmpty {
return "No scope is enabled by default"
} else {
let scopes = scopes.map(\.rawValue).sorted()
.joined(separator: ", ")
return "Default scopes: `\(scopes)`"
}
}())
"""
)
.modifier(InstructionModifier())
}
}
}
struct InstructionModifier: ViewModifier {
@AppStorage(\.chatFontSize) var chatFontSize
func body(content: Content) -> some View {
content
.textSelection(.enabled)
.markdownTheme(.instruction(fontSize: chatFontSize))
.opacity(0.8)
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
.overlay {
RoundedRectangle(cornerRadius: 8)
.stroke(Color(nsColor: .separatorColor), lineWidth: 1)
}
}
}
}