メモ
Copilot コーディング エージェント is in パブリック プレビュー and subject to change.
Copilot コーディング エージェント について詳しくは、「Copilot へのタスクの割り当てについて」をご覧ください。
Copilot コーディング エージェント の開発環境のカスタマイズについて
タスクの作業中、Copilot は、GitHub Actions によって実現される独自の一時的な開発環境にアクセスして、コードの探索、変更の実施、自動的なテストとリンターの実行などを行うことができます。
Copilot の環境を次のようにカスタマイズできます。
- Copilot の環境にツールまたは依存関係をプレインストールする。
- 標準の GitHub ホステッド GitHub Actions ランナーから、ラージャー ランナーにアップグレードする。
- Git Large File Storage (LFS) を有効にする
- エージェントのファイアウォールを無効にする、またはカスタマイズする。
Copilot の環境にツールまたは依存関係をプレインストールする
Copilot は、一時的な開発環境で、プロジェクトをビルドまたはコンパイルして、自動化されたテスト、リンター、その他のツールを実行できます。 そのためには、プロジェクトの依存関係をインストールする必要があります。
Copilot は、試行錯誤のプロセスを通じてこれらの依存関係自体を検出してインストールできますが、大規模言語モデル (LLM) の非決定論的な性質のため、処理が遅く信頼性が低くなる可能性があり、場合によっては (プライベートの場合など)、これらの依存関係をまったくダウンロードできないこともあります。
代わりに、リポジトリ内の .github/workflows/copilot-setup-steps.yml
に置かれる特別な GitHub Actions ワークフロー ファイルを作成して、エージェントの開始前に Copilot の環境を事前構成できます。
copilot-setup-steps.yml
ファイルは普通の GitHub Actions ワークフロー ファイルのように見えますが、1 つの copilot-setup-steps
ジョブを含む必要があります。 このジョブは、Copilot が動作を始める前に、GitHub Actions で実行されます。 GitHub Actions ワークフロー ファイルについて詳しくは、「GitHub Actions のワークフロー構文」をご覧ください。
次に示すのは、プロジェクトのクローン、Node.js のインストール、プロジェクトの依存関係のダウンロードとキャッシュを行う TypeScript プロジェクト用の copilot-setup-steps.yml
ファイルの簡単な例です。 実際のプロジェクトの言語と依存関係に合わせて、これをカスタマイズする必要があります。
name: "Copilot Setup Steps" # Automatically run the setup steps when they are changed to allow for easy validation, and # allow manual testing through the repository's "Actions" tab on: workflow_dispatch: push: paths: - .github/workflows/copilot-setup-steps.yml pull_request: paths: - .github/workflows/copilot-setup-steps.yml jobs: # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. copilot-setup-steps: runs-on: ubuntu-latest # Set the permissions to the lowest permissions possible needed for your steps. # Copilot will be given its own token for its operations. permissions: # If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete. contents: read # You can define any steps you want, and they will run before the agent starts. # If you do not check out your code, Copilot will do this for you. steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: "20" cache: "npm" - name: Install JavaScript dependencies run: npm ci
name: "Copilot Setup Steps"
# Automatically run the setup steps when they are changed to allow for easy validation, and
# allow manual testing through the repository's "Actions" tab
on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yml
jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
copilot-setup-steps:
runs-on: ubuntu-latest
# Set the permissions to the lowest permissions possible needed for your steps.
# Copilot will be given its own token for its operations.
permissions:
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
contents: read
# You can define any steps you want, and they will run before the agent starts.
# If you do not check out your code, Copilot will do this for you.
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install JavaScript dependencies
run: npm ci
copilot-setup-steps.yml
ファイルでは、copilot-setup-steps
ジョブの次の設定のみをカスタマイズできます。 他の設定をカスタマイズしようとすると、変更は無視されます。
steps
(上記を参照)permissions
(上記を参照)runs-on
(下記参照)container
services
snapshot
timeout-minutes
(最大値:59
)
これらのオプションの詳細については、「GitHub Actions のワークフロー構文」を参照してください。
変更が加えられると、copilot-setup-steps.yml
ファイルは通常の GitHub Actions ワークフローとして自動的に実行されるため、正常に実行されたかどうかを確認できます。 これは、ファイルを作成または変更した pull request 内の他のチェックと共に表示されます。
yml ファイルを既定のブランチにマージしたら、いつでもリポジトリの [Actions] タブからワークフローを手動で実行し、すべてが期待どおりに機能することをチェックできます。 詳しくは、「ワークフローの手動実行」をご覧ください。
より大きな GitHub ホステッド GitHub Actions ランナーにアップグレードする
既定では、Copilot はリソースが限られた標準の GitHub Actions ランナーで動作します。
代わりに、より高度な機能を備えたラージャー ランナーを使用できます (たとえば、より多くの RAM、CPU、ディスク領域、高度なネットワーク制御など)。 パフォーマンスが低い場合は (依存関係のダウンロード時やテストの実行時など)、ラージャー ランナーへのアップグレードが必要になることがあります。 詳しくは、「より大きなランナーの概要」をご覧ください。
Copilot でラージャー ランナーを使用できるようにするには、先にラージャー ランナーを 1 つ以上追加してから、それを使うようにリポジトリを構成する必要があります。 「より大きなランナーを管理する」を参照してください。 これを行った後、copilot-setup-steps.yml
ファイルを使って、ラージャー ランナーを使うよう Copilot に指示できます。
ラージャー ランナーを使うには、Copilot で使うラージャー ランナーのラベルまたはグループに、copilot-setup-steps
ジョブの runs-on
ステップを設定します。 runs-on
でのラージャー ランナーの指定について詳しくは、「より大きなランナーでジョブを実行する」をご覧ください。
# ...
jobs:
copilot-setup-steps:
runs-on: ubuntu-4-core
# ...
メモ
- Copilot コーディング エージェント は、Ubuntu x64 Linux ランナーとのみ互換性があります。 Windows、macOS、またはその他のオペレーティング システムのランナーはサポートされていません。
- セルフホステッド GitHub Actions ランナーはサポートされていません。
Git Large File Storage (LFS) を有効にする
Git Large File Storage (LFS) を使ってリポジトリに大きなファイルを格納する場合は、Git LFS をインストールし、LFS オブジェクトをフェッチできるように Copilot の環境をカスタマイズする必要があります。
Git LFS を有効にするには、lfs
オプションを true
に設定し、copilot-setup-steps
ジョブに actions/checkout
ステップを追加します。
# ... jobs: copilot-setup-steps: runs-on: ubuntu-latest permissions: contents: read # for actions/checkout steps: - uses: actions/checkout@v4 with: lfs: true
# ...
jobs:
copilot-setup-steps:
runs-on: ubuntu-latest
permissions:
contents: read # for actions/checkout
steps:
- uses: actions/checkout@v4
with:
lfs: true