gemini cli作業ログ、調べたことメモ
- install
npm install -g @google/gemini-cli
gemini
█████████ ██████████ ██████ ██████ █████ ██████ █████ █████
███░░░░░███░░███░░░░░█░░██████ ██████ ░░███ ░░██████ ░░███ ░░███
███ ░░░ ░███ █ ░ ░███░█████░███ ░███ ░███░███ ░███ ░███
░███ ░██████ ░███░░███ ░███ ░███ ░███░░███░███ ░███
░███ █████ ░███░░█ ░███ ░░░ ░███ ░███ ░███ ░░██████ ░███
░░███ ░░███ ░███ ░ █ ░███ ░███ ░███ ░███ ░░█████ ░███
░░█████████ ██████████ █████ █████ █████ █████ ░░█████ █████
░░░░░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░
色々初期設定がはじまる。調べたものだけメモ
- googleアカウント無料枠の範囲でいける
- gemini api key。モデルの変更とかできるらしい。google ai studioから取得するやつ
- google workspaceアカウントユーザーの場合ははproject idの設定も必要
設定値は環境変数としてecho 'export GEMINI_API_KEY="YOUR_GEMINI_API_KEY"' >> ~/.bashrc source ~/.bashrcしてねというやつ - vertex ai GOOGLE_GENAI_USE_VERTEXAI=true で有効になる。使ったことない、
│ Select Auth Method │
│ ● Login with Google │
│ ○ Gemini API Key │
│ ○ Login with Google (for Workspace or licensed Code Assist users) │
│ ○ Vertex AI │
│
googleでログインにした
cliでググれる
gemini -p 'claude codeについて概要を教えて'
...
「Claude Code」は、Anthropic社が開発したAI搭載のコーディングアシスタントです。ターミナルに統合され、様々なプログラミングタスクを支援します。
主な特徴は以下の通りです。
...
現在、Claude Proプランの一部として提供されています。
より詳しい情報や、具体的な使用方法について知りたい場合は、お気軽にご質問ください。
情報古いので検索してもらったら情報が新しいものになっている(提供プランの部分)
gemini -p 'claude codeについて概要を教えて。最新情報を 知りたいので検索して教えて'
...
はい、「Claude Code」について、最新情報を含めてWeb検索し、その概要を説明しますね。
まず、Web検索を実行します。Web検索の結果、Claude CodeはAnthropic社が開発したAI搭載のコーディングアシスタントです。ターミナル上で自然言語の指示を使って、様々なコーディングタスクをこなす「エージェント」として機能します。
...
### 入手方法
* Anthropicの有料プラン「Pro」および「Max」の一部として提供されています。
* `npm` (Node Package Manager) を通じてインストールできます。
* Visual Studio Codeの拡張機能も利用可能です。
- sandbox?
https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/configuration.md#sandboxing
有効にするとdocker image環境内でファイルの編集やコマンドの実行をおこなう
危ない操作を直接local PCで行わない
geminiを実行した際のコンソールにて独自のコマンドが存在する/入力すると提案出てくる
- compressするとトークン減るって
> /compress
✦ Chat history compressed from 11589 to 287 tokens.
- セッション復帰
chatコマンド saveしてresumeする。makefileにhelpを追加する指示をだしたが、復帰時にサマリを出してくれた save前にcompressしたからかもしれない
> /chat save
> /chat resume
✦ We successfully refactored the Makefile in the /home/user/dev/{repo} project.
Here's a summary of the changes:
1. `help` Command: A new help target was added. This command dynamically generates a help message by parsing the
Makefile itself. It finds all targets that have a comment on the same line (e.g., target: # description) and prints
a formatted list of the targets and their descriptions.
The process involved several steps of implementation and debugging, particularly for the help command, to correct
Makefile syntax issues related to quoting, tab characters, and shell command formatting. The final Makefile is now
clean, functional, and self-documenting via the make help command.
- quit
> /quit
╭──────────────────────────────────╮
│ │
│ Agent powering down. Goodbye! │
│ │
│ │
│ Cumulative Stats (5 Turns) │
│ │
│ Input Tokens 332,541 │
│ Output Tokens 5,198 │
│ Thoughts Tokens 16,324 │
│ ────────────────────────────── │
│ Total Tokens 354,063 │
│ │
│ Total duration (API) 3m 19s │
│ Total duration (wall) 32m 59s │
│ │
- mcpサーバーの追加
設定方法のページに飛ばされた
ℹ No MCP servers configured. Opening documentation in your
browser: https://goo.gle/gemini-cli-docs-mcp
該当セクションはここ
定番のplaywrightいれてみる。この辺の設定ファイルとか構成はAI agentツールでも共通となっている気がする
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"],
"timeout": 30000
}
}
}
いっかい /quit してから、有効になっていることを確認
> /mcp
ℹ Configured MCP servers:
🟢 playwright - Ready (25 tools)
- browser_close
- browser_resize
- browser_console_messages
- browser_handle_dialog
...
適当にツール使ってみる
> https://blog.uni-3.app/の記事一覧からタイトル4つ取得してき表示
して
✦ はい、承知いたしました。指定されたURLにアクセスし、記事一覧から
タイトルを4つ取得して表示します。
╭─────────────────────────────────────────────────────────────────╮
│ ✔ browser_navigate (playwright MCP Server) {"url":"https://bl… │
│ │
│ ... first 3052 lines hidden ... │
│ - paragraph [ref=e1107]
...
✦ はい、承知いたしました。https://blog.uni-3.app/
の記事一覧からタイトルを4つ取得しました。
* 対象サイトを検索するai agent with Agent2Agent (A2A)
* astro markdownのコードブロックのハイライトとmermaidのレンダ
リング設定
* gitの認証切り替えるfor mac
* サイトの構築をastroに移行
賢い
cliはgemini code assistという機能の一部なのでそのあたりの料金プランと規約が適用される
code assistはgoogleが提供するgeminiやAI関連の機能を使うためのライセンスみたいなもの(ChatGPT Plusみたいな)
現状無料なのでお金の面では問題ないのだが、課金体系とポリシーなどについてメモ
code assist
-
個人向け
個人で契約するならこちら- standardとenterprice。ユーザー単位で課金
https://cloud.google.com/products/gemini/pricing?hl=ja - individual。無料版。プロンプトから、入力ファイルなどを含め、学習で使用される
https://developers.google.com/gemini-code-assist/resources/privacy-notice-gemini-code-assist-individuals?hl=ja - developer program
いろいろな特典がついているため総合的に見るとお得
https://developers.google.com/program/plans-and-pricing?hl=ja
- standardとenterprice。ユーザー単位で課金
-
組織向け
セキュリティとかそのへんが考慮されるやつ- google workspaceアカウント
https://workspace.google.com/pricing
に契約していると、適用される。学習にもつかわれない
https://support.google.com/a/answer/15706919
- google workspaceアカウント
code assistを使うにはgcpから有効にする必要があるので、code assistへの課金が必要になる
gemini api key
api keyの設定もできる。こちらは基本GCPのサービスとしての側面が強い
GCP projectに対して発行する。発行するのはなぜかGoogle AI Studio画面からになっている https://ai.google.dev/gemini-api/terms?hl=ja
無料版(課金設定のしていないprojectに対してapi keyを発行した場合など)においては学習データとして用いられる
本無料サービス(Google AI Studio や Gemini API の無料枠など)を使用する場合、 Google は使用者が本サービスに送信したコンテンツと生成された回答を使用し、 Google のプライバシー ポリシーに従って、 Google のプロダクト、サービス、機械学習技術 (Google の企業向けの機能、プロダクト、サービスを含む)の 提供、改良、開発を行います
いつのまにかgemini cliリポジトリの記述が網羅的かつ気になるところがFAQになっていたので抜き出しておく https://github.com/google-gemini/gemini-cli/blob/main/docs/tos-privacy.md
- github actionsでgemini cli
公式のactionsがいたのでexampleにいたのをためした
動くように少し改修している
.github/workflows/gemini-issue-triage.yml
name: Gemini Issue Triage
on:
issues:
types: [opened, reopened]
jobs:
triage-issue:
if: github.event_name == 'issues'
permissions:
contents: read
issues: write
concurrency:
group: ${{ github.workflow }}-${{ github.event.issue.number }}
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run Gemini Issue Triage
uses: google-gemini/gemini-cli-action@main
env:
# どちらかでいいのだが、GH_TOKENでないと動かなかったので両方に設定している
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
prompt: |
You are an issue triage assistant for GitHub issues.
Your task is to analyze the issue and apply appropriate labels from the repository's list of available labels.
**IMPORTANT: Your only action should be to apply labels. Do not post any comments or modify any code.**
**Triage Workflow:**
1. **Fetch Available Labels:**
- Execute the following shell command to get the list of all labels in the repository:
`gh label list`
2. **Analyze the Issue:**
- Based on the issue title, body, and any comments, determine the most appropriate labels.
- Consider the type of issue.
3. **Apply Labels:**
- Use the `gh` command-line tool to add the selected labels to the issue.
- Example command: `gh issue edit ${{ github.event.issue.number }} --add-label "bug,enhancement"`
- You can add multiple labels in a single command.
**Guidelines:**
- Only use labels that exist in the repository (from the `gh label list` command).
- Do not add a comment to the issue.
- If no labels seem appropriate, do not apply any.
**Issue Information:**
- Repository: ${{ github.repository }}
- Issue Number: ${{ github.event.issue.number }}
- Issue Title: ${{ github.event.issue.title }}
- Issue Body: ${{ github.event.issue.body }}
- Comment (if any): ${{ github.event.comment.body }}
Run gemini --yolo --prompt "You are an issue triage assistant for GitHub issues. ... などと実行されているよう
確かにactions経由でlabelが付与された。issueの中身考慮してない気もするが、ひとまずそこは気にしない
