Skip to content

Commit 3625c14

Browse files
authored
Merge pull request #40543 from github/repo-sync
Repo sync
2 parents 08f7838 + e1713a7 commit 3625c14

File tree

15 files changed

+239
-120
lines changed

15 files changed

+239
-120
lines changed

content/copilot/how-tos/use-copilot-agents/coding-agent/create-a-pr.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Asking GitHub Copilot to create a pull request
33
shortTitle: Create a PR
4-
intro: 'You can ask {% data variables.product.prodname_copilot_short %} to create a pull request from many places, including the agents panel, {% data variables.copilot.copilot_chat_short %}, and agentic coding tools and IDEs with Model Context Protocol (MCP) support.'
4+
intro: 'You can ask {% data variables.product.prodname_copilot_short %} to create a pull request from many places, including the agents panel, {% data variables.copilot.copilot_chat_short %}, the {% data variables.product.prodname_cli %}, and agentic coding tools and IDEs with Model Context Protocol (MCP) support.'
55
product: '{% data reusables.gated-features.copilot-coding-agent %}<br><a href="https://github.com/features/copilot/plans?ref_cta=Copilot+plans+signup&ref_loc=asking+copilot+to+create+a+pull+request&ref_page=docs" target="_blank" class="btn btn-primary mt-3 mr-3 no-underline"><span>Sign up for {% data variables.product.prodname_copilot_short %}</span> {% octicon "link-external" height:16 %}</a>'
66
versions:
77
feature: copilot
@@ -28,6 +28,7 @@ You can ask {% data variables.product.prodname_copilot_short %} to work on a tas
2828
* The agents panel, available across {% data variables.product.github %}
2929
* The agents page on {% data variables.product.github %}
3030
* {% data variables.copilot.copilot_chat_short %} in {% data variables.product.prodname_vscode %}, {% data variables.product.prodname_vs %}, JetBrains IDEs and {% data variables.product.prodname_dotcom_the_website %}
31+
* The {% data variables.product.prodname_cli %}
3132
* Your preferred IDE or agentic coding tool with Model Context Protocol (MCP) support
3233
* The Raycast launcher on macOS
3334

@@ -100,6 +101,25 @@ You can ask {% data variables.product.prodname_copilot_short %} to open a pull r
100101

101102
{% data variables.product.prodname_copilot_short %} will start a new session and respond with a link to the pull request it creates. It will work on the task and push changes to the pull request, and then add you as a reviewer when it has finished, triggering a notification.
102103

104+
## Asking {% data variables.product.prodname_copilot_short %} to create a pull request from the {% data variables.product.prodname_cli %}
105+
106+
> [!NOTE]
107+
> The `agent-task` command set is only available in v2.80.0 or later of the {% data variables.product.prodname_cli %}. This command set is a {% data variables.release-phases.public_preview %} and is subject to change.
108+
109+
You can start a new {% data variables.copilot.copilot_coding_agent %} session with the `gh agent-task create` command in the {% data variables.product.prodname_cli %}.
110+
111+
When you run the command without any arguments, you are asked to enter a prompt. {% data variables.copilot.copilot_coding_agent %} acts on the prompt and opens a pull request in the current repository.
112+
113+
You can use command line options to:
114+
115+
* Provide the prompt (`gh agent-task create "Example prompt"`)
116+
* Choose a base branch, instead of using the repository's default branch (`--base`)
117+
* Select a repository, instead of targeting the current repository (`--repo`)
118+
* Follow the session log in real time (`--follow`)
119+
120+
121+
To see all of the available options, run `gh agent-task create --help`.
122+
103123
## Asking {% data variables.product.prodname_copilot_short %} to create a pull request from the {% data variables.product.github %} MCP server
104124

105125
As an alternative to using {% data variables.copilot.copilot_chat_short %}, you can use the remote {% data variables.product.github %} MCP server to trigger {% data variables.copilot.copilot_coding_agent %} from any MCP host.

content/copilot/how-tos/use-copilot-agents/coding-agent/track-copilot-sessions.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Tracking GitHub Copilot's sessions
33
shortTitle: Track Copilot sessions
4-
intro: 'You can use the agents panel or page, {% data variables.product.prodname_vscode %}, Raycast and session logs to track {% data variables.product.prodname_copilot_short %}''s progress and understand its approach.'
4+
intro: 'You can use the agents panel or page, {% data variables.product.prodname_vscode %}, the {% data variables.product.prodname_cli %}, Raycast and session logs to track {% data variables.product.prodname_copilot_short %}''s progress and understand its approach.'
55
product: '{% data reusables.gated-features.copilot-coding-agent %}<br><a href="https://github.com/features/copilot/plans?ref_cta=Copilot+plans+signup&ref_loc=using+the+copilot+coding+agent+logs&ref_page=docs" target="_blank" class="btn btn-primary mt-3 mr-3 no-underline"><span>Sign up for {% data variables.product.prodname_copilot_short %}</span> {% octicon "link-external" height:16 %}</a>'
66
versions:
77
feature: copilot
@@ -24,7 +24,7 @@ contentType: how-tos
2424

2525
After you give {% data variables.product.prodname_copilot_short %} a task, it works autonomously in the background to complete it. See [AUTOTITLE](/copilot/concepts/about-copilot-coding-agent).
2626

27-
The agents panel, [agents page](https://github.com/copilot/agents), and {% data variables.product.prodname_copilot %} extension for Raycast provide an overview of your agent sessions across repositories. You can use them to kick off new tasks and track {% data variables.product.prodname_copilot_short %}'s progress.
27+
The agents panel, [agents page](https://github.com/copilot/agents), the {% data variables.product.prodname_cli %}, and {% data variables.product.prodname_copilot %} extension for Raycast provide an overview of your agent sessions across repositories. You can use them to kick off new tasks and track {% data variables.product.prodname_copilot_short %}'s progress.
2828

2929
You can also track {% data variables.product.prodname_copilot_short %}'s sessions in a specific repository from {% data variables.product.prodname_vscode %}.
3030

@@ -46,6 +46,19 @@ To view the session logs, click through to the pull request in the list, then fi
4646

4747
You can also start new agent sessions from the page and panel. See [AUTOTITLE](/copilot/how-tos/agents/copilot-coding-agent/asking-copilot-to-create-a-pull-request).
4848

49+
## Tracking agent sessions from the {% data variables.product.prodname_cli %}
50+
51+
> [!NOTE]
52+
> The `agent-task` command set is only available in v2.80.0 or later of the {% data variables.product.prodname_cli %}. This command set is a {% data variables.release-phases.public_preview %} and is subject to change.
53+
54+
You can see a list of your running and past agent sessions from the {% data variables.product.prodname_cli %} with the `gh agent-task list` command. The output will show a list of your recent sessions.
55+
56+
To see more information on a specific session, use the `gh agent-task view` command. For example, to view information about the session associated with pull request #123 in the `monalisa/bookstore` repository, run `gh agent-task view --repo monalisa/bookstore 123`.
57+
58+
To view the session logs, add the `--log` option. Optionally, use the `--follow` option to stream live logs as the agent works.
59+
60+
To see all of the available options, run `gh agent-task list --help` or `gh agent-task view --help`.
61+
4962
## Tracking agent sessions from Raycast
5063

5164
{% data reusables.copilot.coding-agent.raycast-intro %}

src/content-linter/lib/diff-files.js renamed to src/content-linter/lib/diff-files.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import fs from 'fs'
55
// is unpredictable in GitHub Actions because of how it does `git clone`.
66
// So we rely on environment variables instead.
77

8-
export function getDiffFiles() {
8+
export function getDiffFiles(): string[] {
99
// Instead of testing every single file possible, if there's
1010
// an environment variable called `DIFF_FILES` or one called
1111
// `DIFF_FILE` then use that.
1212
// If `DIFF_FILES` is set, it's expected to be a space separated
1313
// string. If `DIFF_FILE` is set, it's expected to be a text file
1414
// which contains a space separated string.
15-
const diffFiles = []
15+
const diffFiles: string[] = []
1616
// Setting an environment variable called `DIFF_FILES` is optional.
1717
// But if and only if it's set, we will respect it.
1818
// And if it set, turn it into a cleaned up Set so it's made available

src/content-linter/lib/linting-rules/code-fence-line-length.js renamed to src/content-linter/lib/linting-rules/code-fence-line-length.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1+
// @ts-ignore - markdownlint-rule-helpers doesn't provide TypeScript declarations
12
import { addError, filterTokens, newLineRe } from 'markdownlint-rule-helpers'
23

3-
export const codeFenceLineLength = {
4+
import type { RuleParams, RuleErrorCallback, MarkdownToken, Rule } from '@/content-linter/types'
5+
6+
export const codeFenceLineLength: Rule = {
47
names: ['GHD030', 'code-fence-line-length'],
58
description: 'Code fence lines should not exceed a maximum length',
69
tags: ['code', 'accessibility'],
710
parser: 'markdownit',
8-
function: (params, onError) => {
9-
const MAX_LINE_LENGTH = String(params.config.maxLength || 60)
10-
filterTokens(params, 'fence', (token) => {
11-
const lines = token.content.split(newLineRe)
12-
lines.forEach((line, index) => {
11+
function: (params: RuleParams, onError: RuleErrorCallback) => {
12+
const MAX_LINE_LENGTH: number = params.config?.maxLength || 60
13+
filterTokens(params, 'fence', (token: MarkdownToken) => {
14+
if (!token.content) return
15+
const lines: string[] = token.content.split(newLineRe)
16+
lines.forEach((line: string, index: number) => {
1317
if (line.length > MAX_LINE_LENGTH) {
1418
// The token line number is the line number of the first line of the
1519
// code fence. We want to report the line number of the content within
1620
// the code fence so we need to add 1 + the index.
17-
const lineNumber = token.lineNumber + index + 1
21+
const lineNumber: number = token.lineNumber + index + 1
1822
addError(
1923
onError,
2024
lineNumber,

src/content-render/liquid/post.js renamed to src/content-render/liquid/post.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// used below to remove extra newlines in TOC lists
2-
const endLine = '</a>\r?\n'
3-
const blankLine = '\\s*?[\r\n]*'
4-
const startNextLine = '[^\\S\r\n]*?[-\\*] <a'
5-
const blankLineInList = new RegExp(`(${endLine})${blankLine}(${startNextLine})`, 'mg')
2+
const endLine: string = '</a>\r?\n'
3+
const blankLine: string = '\\s*?[\r\n]*'
4+
const startNextLine: string = '[^\\S\r\n]*?[-\\*] <a'
5+
const blankLineInList: RegExp = new RegExp(`(${endLine})${blankLine}(${startNextLine})`, 'mg')
66

7-
export function processLiquidPost(template) {
7+
export function processLiquidPost(template: string): string {
88
template = cleanUpListEmptyLines(template)
99
template = cleanUpExtraEmptyLines(template)
1010
return template
1111
}
1212

13-
function cleanUpListEmptyLines(template) {
13+
function cleanUpListEmptyLines(template: string): string {
1414
// clean up empty lines in TOC lists left by unrendered list items (due to productVersions)
1515
// for example, remove the blank line here:
1616
// - <a>foo</a>
@@ -22,7 +22,7 @@ function cleanUpListEmptyLines(template) {
2222
return template
2323
}
2424

25-
function cleanUpExtraEmptyLines(template) {
25+
function cleanUpExtraEmptyLines(template: string): string {
2626
// this removes any extra newlines left by (now resolved) liquid
2727
// statements so that extra space doesn't mess with list numbering
2828
template = template.replace(/(\r?\n){3}/g, '\n\n')
Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
// src/content-render/liquid/prompt.js
1+
// src/content-render/liquid/prompt.ts
22
// Defines {% prompt %}…{% endprompt %} to wrap its content in <code> and append the Copilot icon.
33

4+
// @ts-ignore - @primer/octicons doesn't provide TypeScript declarations
45
import octicons from '@primer/octicons'
56

6-
export const Prompt = {
7+
interface LiquidTag {
8+
type: 'block'
9+
templates?: any[] // Note: Using 'any' because liquidjs doesn't provide proper types for template objects
10+
// Note: Using 'any' for liquid-related parameters because liquidjs doesn't provide comprehensive TypeScript definitions
11+
parse(tagToken: any, remainTokens: any): void
12+
render(scope: any): Generator<any, string, unknown>
13+
}
14+
15+
export const Prompt: LiquidTag = {
716
type: 'block',
817

918
// Collect everything until {% endprompt %}
10-
parse(tagToken, remainTokens) {
19+
parse(tagToken: any, remainTokens: any): void {
1120
this.templates = []
1221
const stream = this.liquid.parser.parseStream(remainTokens)
1322
stream
14-
.on('template', (tpl) => this.templates.push(tpl))
23+
.on('template', (tpl: any) => this.templates.push(tpl))
1524
.on('tag:endprompt', () => stream.stop())
1625
.on('end', () => {
1726
throw new Error(`{% prompt %} tag not closed`)
@@ -20,12 +29,12 @@ export const Prompt = {
2029
},
2130

2231
// Render the inner Markdown, wrap in <code>, then append the SVG
23-
render: function* (scope) {
32+
render: function* (scope: any): Generator<any, string, unknown> {
2433
const content = yield this.liquid.renderer.renderTemplates(this.templates, scope)
2534

2635
// build a URL with the prompt text encoded as query parameter
27-
const promptParam = encodeURIComponent(content)
28-
const href = `https://github.com/copilot?prompt=${promptParam}`
36+
const promptParam: string = encodeURIComponent(content as string)
37+
const href: string = `https://github.com/copilot?prompt=${promptParam}`
2938
return `<code>${content}</code><a href="${href}" target="_blank" class="tooltipped tooltipped-nw ml-1" aria-label="Run this prompt in Copilot Chat" style="text-decoration:none;">${octicons.copilot.toSVG()}</a>`
3039
},
3140
}

src/content-render/tests/prompt.js renamed to src/content-render/tests/prompt.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { renderContent } from '@/content-render/index'
33

44
describe('prompt tag', () => {
55
test('wraps content in <code> and appends svg', async () => {
6-
const input = 'Here is your prompt: {% prompt %}example prompt text{% endprompt %}.'
7-
const output = await renderContent(input)
6+
const input: string = 'Here is your prompt: {% prompt %}example prompt text{% endprompt %}.'
7+
const output: string = await renderContent(input)
88
expect(output).toContain('<code>example prompt text</code><a')
99
expect(output).toContain('<svg')
1010
})

src/content-render/unified/parse-info-string.js

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Based on https://spec.commonmark.org/0.30/#info-string
2+
// Parse out info strings on fenced code blocks, example:
3+
// ```javascript lineNumbers:left copy:all annotate
4+
// becomes...
5+
// node.lang = javascript
6+
// node.meta = { lineNumbers: 'left', copy: 'all', annotate: true }
7+
// Also parse equals signs, where id=some-id becomes { id: 'some-id' }
8+
9+
import { visit } from 'unist-util-visit'
10+
11+
interface CodeNode {
12+
type: 'code'
13+
lang?: string
14+
meta?: string | Record<string, string | boolean>
15+
value: string
16+
}
17+
18+
// Note: Using 'any' for node because unist-util-visit's type constraints
19+
// don't easily allow for proper code node typing without complex generics
20+
const matcher = (node: any): node is CodeNode => node.type === 'code' && node.lang
21+
22+
export default function parseInfoString() {
23+
// Note: Using 'any' for tree because unified's AST types are complex and
24+
// this function works with different tree types depending on the processor
25+
return (tree: any) => {
26+
visit(tree, matcher, (node: CodeNode) => {
27+
node.meta = strToObj(node.meta as string)
28+
29+
// Temporary, remove {:copy} to avoid highlight parse error in translations.
30+
if (node.lang) {
31+
node.lang = node.lang.replace('{:copy}', '')
32+
}
33+
})
34+
}
35+
}
36+
37+
function strToObj(str?: string): Record<string, string | boolean> {
38+
if (!str) return {}
39+
return Object.fromEntries(
40+
str
41+
.split(/\s+/g)
42+
.map((k: string) => k.split(/[:=]/)) // split by colon or equals sign
43+
.map(([k, ...v]: string[]) => [k, v.length ? v.join(':') : true]),
44+
)
45+
}

src/content-render/unified/use-english-headings.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)