wip(docs): i18n (#12681)
This commit is contained in:
195
packages/web/src/content/docs/ja/gitlab.mdx
Normal file
195
packages/web/src/content/docs/ja/gitlab.mdx
Normal file
@@ -0,0 +1,195 @@
|
||||
---
|
||||
title: GitLab
|
||||
description: GitLab の問題とマージリクエストで OpenCode を使用します。
|
||||
---
|
||||
|
||||
OpenCode は、GitLab CI/CD パイプラインまたは GitLab Duo を通じて GitLab ワークフローと統合します。
|
||||
|
||||
どちらの場合も、OpenCode は GitLab ランナー上で実行されます。
|
||||
|
||||
---
|
||||
|
||||
## GitLab CI
|
||||
|
||||
OpenCode は通常の GitLab パイプラインで動作します。 [CI コンポーネント](https://docs.gitlab.com/ee/ci/components/) としてパイプラインに組み込むことができます。
|
||||
|
||||
ここでは、コミュニティが作成した OpenCode 用の CI/CD コンポーネント — [nagyv/gitlab-opencode](https://gitlab.com/nagyv/gitlab-opencode).
|
||||
|
||||
---
|
||||
|
||||
### 特徴
|
||||
|
||||
- **ジョブごとにカスタム構成を使用する**: カスタム構成ディレクトリ (`./config/#custom-directory` など) を使用して OpenCode を構成し、OpenCode の呼び出しごとに機能を有効または無効にします。
|
||||
- **最小限のセットアップ**: CI コンポーネントはバックグラウンドで OpenCode をセットアップします。必要なのは、OpenCode 構成と初期プロンプトを作成することだけです。
|
||||
- **柔軟性**: CI コンポーネントは、動作をカスタマイズするための複数の入力をサポートしています。
|
||||
|
||||
---
|
||||
|
||||
### 設定
|
||||
|
||||
1. OpenCode 認証 JSON をファイル タイプ CI 環境変数として [**設定**] > [**CI/CD**] > [**変数**] に保存します。必ず「マスクして非表示」としてマークしてください。
|
||||
2. 以下を `.gitlab-ci.yml` ファイルに追加します。
|
||||
|
||||
```yaml title=".gitlab-ci.yml"
|
||||
include:
|
||||
- component: $CI_SERVER_FQDN/nagyv/gitlab-opencode/opencode@2
|
||||
inputs:
|
||||
config_dir: ${CI_PROJECT_DIR}/opencode-config
|
||||
auth_json: $OPENCODE_AUTH_JSON # The variable name for your OpenCode authentication JSON
|
||||
command: optional-custom-command
|
||||
message: "Your prompt here"
|
||||
```
|
||||
|
||||
さらに多くの入力と使用例については、このコンポーネントの docs](https://gitlab.com/explore/catalog/nagyv/gitlab-opencode) をチェックしてください。
|
||||
|
||||
---
|
||||
|
||||
## GitLab デュオ
|
||||
|
||||
OpenCode は GitLab ワークフローと統合します。
|
||||
コメントで `@opencode` に言及すると、OpenCode が GitLab CI パイプライン内でタスクを実行します。
|
||||
|
||||
---
|
||||
|
||||
### 特徴
|
||||
|
||||
- **問題のトリアージ**: OpenCode に問題を調べて説明してもらいます。
|
||||
- **修正と実装**: OpenCode に問題の修正または機能の実装を依頼します。
|
||||
新しいブランチを作成し、変更を加えたマージリクエストを発行します。
|
||||
- **安全**: OpenCode は GitLab ランナー上で実行されます。
|
||||
|
||||
---
|
||||
|
||||
### 設定
|
||||
|
||||
OpenCode は GitLab CI/CD パイプラインで実行されます。セットアップするには次のものが必要です。
|
||||
|
||||
:::ヒント
|
||||
最新の手順については、[**GitLab ドキュメント**](https://docs.gitlab.com/user/duo_agent_platform/agent_assistant/) を参照してください。
|
||||
:::
|
||||
|
||||
1. GitLab 環境を構成する
|
||||
2. CI/CD のセットアップ
|
||||
3. AI モデル プロバイダー API キーを取得する
|
||||
4. サービスアカウントを作成する
|
||||
5. CI/CD変数を構成する
|
||||
6. フロー構成ファイルを作成します。例を次に示します。
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Flow configuration</summary>
|
||||
|
||||
```yaml
|
||||
image: node:22-slim
|
||||
commands:
|
||||
- echo "Installing opencode"
|
||||
- npm install --global opencode-ai
|
||||
- echo "Installing glab"
|
||||
- export GITLAB_TOKEN=$GITLAB_TOKEN_OPENCODE
|
||||
- apt-get update --quiet && apt-get install --yes curl wget gpg git && rm --recursive --force /var/lib/apt/lists/*
|
||||
- curl --silent --show-error --location "https://raw.githubusercontent.com/upciti/wakemeops/main/assets/install_repository" | bash
|
||||
- apt-get install --yes glab
|
||||
- echo "Configuring glab"
|
||||
- echo $GITLAB_HOST
|
||||
- echo "Creating OpenCode auth configuration"
|
||||
- mkdir --parents ~/.local/share/opencode
|
||||
- |
|
||||
cat > ~/.local/share/opencode/auth.json << EOF
|
||||
{
|
||||
"anthropic": {
|
||||
"type": "api",
|
||||
"key": "$ANTHROPIC_API_KEY"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
- echo "Configuring git"
|
||||
- git config --global user.email "opencode@gitlab.com"
|
||||
- git config --global user.name "OpenCode"
|
||||
- echo "Testing glab"
|
||||
- glab issue list
|
||||
- echo "Running OpenCode"
|
||||
- |
|
||||
opencode run "
|
||||
You are an AI assistant helping with GitLab operations.
|
||||
|
||||
Context: $AI_FLOW_CONTEXT
|
||||
Task: $AI_FLOW_INPUT
|
||||
Event: $AI_FLOW_EVENT
|
||||
|
||||
Please execute the requested task using the available GitLab tools.
|
||||
Be thorough in your analysis and provide clear explanations.
|
||||
|
||||
<important>
|
||||
Please use the glab CLI to access data from GitLab. The glab CLI has already been authenticated. You can run the corresponding commands.
|
||||
|
||||
If you are asked to summarize an MR or issue or asked to provide more information then please post back a note to the MR/Issue so that the user can see it.
|
||||
You don't need to commit or push up changes, those will be done automatically based on the file changes you make.
|
||||
</important>
|
||||
"
|
||||
- git checkout --branch $CI_WORKLOAD_REF origin/$CI_WORKLOAD_REF
|
||||
- echo "Checking for git changes and pushing if any exist"
|
||||
- |
|
||||
if ! git diff --quiet || ! git diff --cached --quiet || [ --not --zero "$(git ls-files --others --exclude-standard)" ]; then
|
||||
echo "Git changes detected, adding and pushing..."
|
||||
git add .
|
||||
if git diff --cached --quiet; then
|
||||
echo "No staged changes to commit"
|
||||
else
|
||||
echo "Committing changes to branch: $CI_WORKLOAD_REF"
|
||||
git commit --message "Codex changes"
|
||||
echo "Pushing changes up to $CI_WORKLOAD_REF"
|
||||
git push https://gitlab-ci-token:$GITLAB_TOKEN@$GITLAB_HOST/gl-demo-ultimate-dev-ai-epic-17570/test-java-project.git $CI_WORKLOAD_REF
|
||||
echo "Changes successfully pushed"
|
||||
fi
|
||||
else
|
||||
echo "No git changes detected, skipping push"
|
||||
fi
|
||||
variables:
|
||||
- ANTHROPIC_API_KEY
|
||||
- GITLAB_TOKEN_OPENCODE
|
||||
- GITLAB_HOST
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
詳細な手順については、「GitLab CLI エージェント docs](https://docs.gitlab.com/user/duo_agent_platform/agent_assistant/)」を参照してください。
|
||||
|
||||
---
|
||||
|
||||
### 例
|
||||
|
||||
GitLab で OpenCode を使用する方法の例をいくつか示します。
|
||||
|
||||
:::ヒント
|
||||
`@opencode` とは異なるトリガー フレーズを使用するように設定できます。
|
||||
:::
|
||||
|
||||
- **問題の説明**
|
||||
|
||||
このコメントを GitLab の問題に追加します。
|
||||
|
||||
```
|
||||
@opencode explain this issue
|
||||
```
|
||||
|
||||
OpenCode は問題を読み、明確な説明を返信します。
|
||||
|
||||
- **問題を修正**
|
||||
|
||||
GitLab の問題では、次のように言います。
|
||||
|
||||
```
|
||||
@opencode fix this
|
||||
```
|
||||
|
||||
OpenCode は新しいブランチを作成し、変更を実装し、変更を含むマージ リクエストを開きます。
|
||||
|
||||
- **マージリクエストを確認する**
|
||||
|
||||
GitLab マージ リクエストに次のコメントを残してください。
|
||||
|
||||
```
|
||||
@opencode review this merge request
|
||||
```
|
||||
|
||||
OpenCode はマージ リクエストをレビューし、フィードバックを提供します。
|
||||
Reference in New Issue
Block a user