| 1 | --- |
| 2 | title: 斜杠命令 |
| 3 | description: 以 '/' 为开头激活的快捷方式 |
| 4 | keywords: [斜杠命令, 自定义命令, 步骤] |
| 5 | --- |
| 6 | |
| 7 | 斜杠命令是可以通过输入 '/' 来激活,并从下拉框中选择的快捷方式。例如,内置的 '/edit' 斜杠命令,让你可以直接在你的编辑器中流式地编辑。 |
| 8 | |
| 9 |  |
| 10 | |
| 11 | ## 内置的斜杠命令 |
| 12 | |
| 13 | 为了使用任何内置的斜杠命令,打开 `config.json` 并添加它到 `slashCommands` 列表中。 |
| 14 | |
| 15 | ### `/Edit` |
| 16 | |
| 17 | 使用 `ctrl/cmd + L` (VS Code) 或 `ctrl/cmd + J` (JetBrains) 选择代码,然后输入 `/Edit` ,跟着编辑的指令。 Continue 将会流式地在一个并排 diff 编辑器中修改。 |
| 18 | |
| 19 | ```json title="config.json" |
| 20 | { |
| 21 | "slashCommands": [ |
| 22 | { |
| 23 | "name": "edit", |
| 24 | "description": "Edit highlighted code" |
| 25 | } |
| 26 | ] |
| 27 | } |
| 28 | ``` |
| 29 | |
| 30 | ### `/Comment` |
| 31 | |
| 32 | Comment 工作就像 `/Edit` ,除了它将自动地给 LLM 注释代码的提示词。 |
| 33 | |
| 34 | ```json title="config.json" |
| 35 | { |
| 36 | "slashCommands": [ |
| 37 | { |
| 38 | "name": "comment", |
| 39 | "description": "Write comments for the highlighted code" |
| 40 | } |
| 41 | ] |
| 42 | } |
| 43 | ``` |
| 44 | |
| 45 | ### `/Share` |
| 46 | |
| 47 | 生成一个关于你当前聊天历史的可分享的 markdown 副本。 |
| 48 | |
| 49 | ```json title="config.json" |
| 50 | { |
| 51 | "slashCommands": [ |
| 52 | { |
| 53 | "name": "share", |
| 54 | "description": "Export the current chat session to markdown", |
| 55 | "params": { "outputDir": "~/.continue/session-transcripts" } |
| 56 | } |
| 57 | ] |
| 58 | } |
| 59 | ``` |
| 60 | |
| 61 | 使用 `outputDir` 参数指定你想要把 markdown 文件保存在哪里。 |
| 62 | |
| 63 | ### `/Cmd` |
| 64 | |
| 65 | 通过自然语言生成一个 shell 命令,并且(只在 VS Code 中)自动地粘贴它到终端中。 |
| 66 | |
| 67 | ```json title="config.json" |
| 68 | { |
| 69 | "slashCommands": [ |
| 70 | { |
| 71 | "name": "cmd", |
| 72 | "description": "Generate a shell command" |
| 73 | } |
| 74 | ] |
| 75 | } |
| 76 | ``` |
| 77 | |
| 78 | ### `/Commit` |
| 79 | |
| 80 | 显示给 LLM 你当前的 git diff ,并询问生成一个 commit 消息。 |
| 81 | |
| 82 | ```json title="config.json" |
| 83 | { |
| 84 | "slashCommands": [ |
| 85 | { |
| 86 | "name": "commit", |
| 87 | "description": "Generate a commit message for the current changes" |
| 88 | } |
| 89 | ] |
| 90 | } |
| 91 | ``` |
| 92 | |
| 93 | ### `/Http` |
| 94 | |
| 95 | 编写一个自定义的斜杠命令,在你自己的 HTTP 端点。在参数对象中对于你设置的端点设置 'url' 。端点应该返回一个字符串更新序列,将会流式地输出到 Continue 侧边栏。查看我们基本的 [FastAPI 示例](https://github.com/continuedev/continue/blob/74002369a5e435735b83278fb965e004ae38a97d/core/context/providers/context_provider_server.py#L34-L45) 作为参考。 |
| 96 | |
| 97 | ```json title="config.json" |
| 98 | { |
| 99 | "slashCommands": [ |
| 100 | { |
| 101 | "name": "http", |
| 102 | "description": "Does something custom", |
| 103 | "params": { "url": "<my server endpoint>" } |
| 104 | } |
| 105 | ] |
| 106 | } |
| 107 | ``` |
| 108 | |
| 109 | ### `/Issue` |
| 110 | |
| 111 | 描述你想要生成的 issue , Continue 会转换为格式良好的标题和正文,然后给你一个草稿的链接,让你可以提交。确保设置你想要生成 issue 的仓库的 URL 。 |
| 112 | |
| 113 | ```json title="config.json" |
| 114 | { |
| 115 | "slashCommands": [ |
| 116 | { |
| 117 | "name": "issue", |
| 118 | "description": "Generate a link to a drafted GitHub issue", |
| 119 | "params": { "repositoryUrl": "https://github.com/continuedev/continue" } |
| 120 | } |
| 121 | ] |
| 122 | } |
| 123 | ``` |
| 124 | |
| 125 | ### `/So` |
| 126 | |
| 127 | StackOverflow 斜杠命令将会自动地拉取 StackOverflow 的结果来回答你的问题,引用链接和它的答案一起。 |
| 128 | |
| 129 | ```json title="config.json" |
| 130 | { |
| 131 | "slashCommands": [ |
| 132 | { |
| 133 | "name": "so", |
| 134 | "description": "Reference StackOverflow to answer the question" |
| 135 | } |
| 136 | ] |
| 137 | } |
| 138 | ``` |
| 139 | |
| 140 | ### `/Onboard` |
| 141 | |
| 142 | Onboard 斜杠命令帮助你熟悉一个新的项目,通过分析项目结构, README 和依赖文件。它发现关键目录,解释它们的目的,并高亮使用的流行的包。另外,它提供对项目架构的了解。 |
| 143 | |
| 144 | ```json title="config.json" |
| 145 | { |
| 146 | "slashCommands": [ |
| 147 | { |
| 148 | "name": "onboard", |
| 149 | "description": "Familiarize yourself with the codebase" |
| 150 | } |
| 151 | ] |
| 152 | } |
| 153 | ``` |