はじめに
11/19にGoogleからAntigravityが公開されました。
最近AIエージェントを利用した開発がClaude codeやcodex cliなど色々と出ており、仕事でも話に出てくることが増えてきました。
ということで、ちょっと使ってみよー!ということで、適当に遊んでみた結果を書いてみました。
Antigravityについて
公式サイトは以下にあります。MacとLinux、Windowsで使えますし、ベースはVistual Studio Codeなので、VSCodeに慣れている人は使いやすいかなーと思います。
https://antigravity.google
インストールとか
多分ここはそんなに迷うことないと思いますので、今回は割愛します。
私の場合は、MacBook Airにインストールしたので、何も考えることなくApplicationにコピーで終わりました。LinuxやWindowsですと、インストール方法も違うと思いますので、公式サイトや他のQiitaの記事などをご参考になさってください。
遊んでみた
今回はあまり考えずに、どこまでできるかなーということで、command+Eを押してエージェントマネージャーを開いて、以下のようにお願いを入れてみました。
Youtubeにある直近7日間のおすすめのホロライブの動画のタイトルと概要およびURLをメールアドレスに送信するAIエージェントを作成してください。このAIエージェントはGCPのcloud runを使って毎日20時に実行されるようにしてください。
AIエンジンにはGemini3 proを利用して、推論の過程を出すようにして実行してみました。
あっという間に、色々と考えて、以下のようなimplementation.md、つまり実装の仕様書を作ってくれました。
日本語でお願いしても、仕様書が英語で出てくるのはうーんという感じもありますが、あっという間に仕様書を作ってくれるのはいいですね。今回はまだやっていないですが、仕様書にレビューコメントなども入れられるので、解釈が異なっていたり、おかしなことがあったら、指摘して修正してもらえるので、そこもいい感じだなと思いました。
# Hololive Newsletter Agent Implementation Plan
## Goal Description
Create an AI agent that fetches recommended Hololive videos from the last 7 days on YouTube and sends them via email. The agent will be containerized and deployed on Google Cloud Run, scheduled to run daily at 20:00.
## User Review Required
> [!IMPORTANT]
> You will need a Google Cloud Project with YouTube Data API v3 enabled and an API Key.
> You will also need an SMTP server (e.g., Gmail App Password) to send emails.
## Proposed Changes
### Project Structure
#### [NEW] [requirements.txt](file:///Users/charoro/git/holo-newsletter/requirements.txt)
- `google-api-python-client`
- `python-dotenv`
- `google-auth`
#### [NEW] [.env.example](file:///Users/charoro/git/holo-newsletter/.env.example)
- `YOUTUBE_API_KEY`
- `SMTP_SERVER`
- `SMTP_PORT`
- `SMTP_USER`
- `SMTP_PASSWORD`
- `RECIPIENT_EMAIL`
### Source Code
#### [NEW] [src/youtube_client.py](file:///Users/charoro/git/holo-newsletter/src/youtube_client.py)
- Class `YouTubeClient` to interact with YouTube Data API.
- Method `get_recommended_videos(days=7)`:
- Search query: "Hololive"
- Order: `viewCount` (to simulate "recommended" or popular)
- PublishedAfter: `datetime.now() - timedelta(days=7)`
- Returns: List of dicts (title, description, url, thumbnail).
#### [NEW] [src/mailer.py](file:///Users/charoro/git/holo-newsletter/src/mailer.py)
- Class `Mailer` to handle email sending.
- Method `send_newsletter(videos)`:
- Formats the video list into an HTML email.
- Sends via SMTP.
#### [NEW] [src/main.py](file:///Users/charoro/git/holo-newsletter/src/main.py)
- Main entry point.
- Loads env vars.
- Instantiates `YouTubeClient` and `Mailer`.
- Fetches videos and sends email.
### Deployment
#### [NEW] [Dockerfile](file:///Users/charoro/git/holo-newsletter/Dockerfile)
- Python 3.9-slim base.
- Installs requirements.
- CMD `python src/main.py`.
## Verification Plan
### Automated Tests
- I will create a simple test script `tests/test_local.py` (not for prod) to verify the logic locally without sending real emails if possible, or just run `src/main.py` with a dry-run flag.
- For this task, direct execution of `src/main.py` with valid credentials is the best verification.
### Manual Verification
1. **Local Run**:
- Fill `.env` with valid credentials.
- Run `python src/main.py`.
- Check inbox for the email.
2. **Docker Build**:
- Run `docker build -t holo-newsletter .`.
- Run `docker run --env-file .env holo-newsletter`.
そのまま放っておくと、次はこの仕様書をもとに、フォルダ構成やファイルの中身を全部作ってくれます。え、こんな速いの??って感じです。
今回は、GCPのcloud runで動かすように設定してね、とお願いしたので、その際のデプロイ手順書まで作ってくれます。
# Deployment Instructions
## Prerequisites
1. **Google Cloud Project**: Ensure you have a GCP project.
2. **APIs Enabled**: Enable "Cloud Run Admin API" and "Cloud Scheduler API".
3. **gcloud CLI**: Installed and authenticated (`gcloud auth login`).
## 1. Build and Push Docker Image
Replace `YOUR_PROJECT_ID` with your actual Google Cloud Project ID.
```bash
# Set your project ID
export PROJECT_ID=YOUR_PROJECT_ID
# Build the image using Cloud Build (easiest way)
gcloud builds submit --tag gcr.io/$PROJECT_ID/holo-newsletter .
```bash
## 2. Deploy as Cloud Run Job
Since this is a batch task (run once and exit), we use **Cloud Run Jobs**.
```bash
# Create the job
gcloud run jobs create holo-newsletter-job \
--image gcr.io/$PROJECT_ID/holo-newsletter \
--region asia-northeast1 \
--set-env-vars YOUTUBE_API_KEY=your_key,SMTP_SERVER=smtp.gmail.com,SMTP_PORT=587,SMTP_USER=your_email,SMTP_PASSWORD=your_password,RECIPIENT_EMAIL=target_email
```bash
*Note: For better security, use Google Secret Manager for sensitive environment variables.*
## 3. Schedule with Cloud Scheduler
Run the job every day at 20:00 JST.
```bash
gcloud scheduler jobs create http holo-newsletter-scheduler \
--location asia-northeast1 \
--schedule "0 20 * * *" \
--time-zone "Asia/Tokyo" \
--uri "https://asia-northeast1-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/$PROJECT_ID/jobs/holo-newsletter-job:run" \
--http-method POST \
--oauth-service-account-email=PROJECT_NUMBER-compute@developer.gserviceaccount.com
```bash
ほわーって感じです。ここまでやってくれるなんて、私のやることは何?? といった感じです。
で、何を作りましたよーというのを教えてくれます。これがWalkthroughです。
# Hololive Newsletter Agent Walkthrough
I have created the Hololive Newsletter Agent. It fetches recommended videos from YouTube and sends them via email.
## Changes Made
### Source Code
- **[src/youtube_client.py](file:///Users/charoro/git/holo-newsletter/src/youtube_client.py)**: Handles interaction with YouTube Data API.
- **[src/mailer.py](file:///Users/charoro/git/holo-newsletter/src/mailer.py)**: Handles sending HTML emails via SMTP.
- **[src/main.py](file:///Users/charoro/git/holo-newsletter/src/main.py)**: Main script that orchestrates the process.
### Configuration
- **[requirements.txt](file:///Users/charoro/git/holo-newsletter/requirements.txt)**: Python dependencies.
- **[.env.example](file:///Users/charoro/git/holo-newsletter/.env.example)**: Template for environment variables.
- **[Dockerfile](file:///Users/charoro/git/holo-newsletter/Dockerfile)**: Container definition for deployment.
- **[DEPLOYMENT.md](file:///Users/charoro/git/holo-newsletter/DEPLOYMENT.md)**: Detailed instructions for deploying to Google Cloud Run.
## How to Verify
### 1. Local Verification
1. Copy `.env.example` to `.env` and fill in your API keys and SMTP credentials.
2. Install dependencies: `pip install -r requirements.txt`
3. Run the script: `python src/main.py`
4. Check your email inbox.
### 2. Docker Verification
1. Build the image: `docker build -t holo-newsletter .`
2. Run the container: `docker run --env-file .env holo-newsletter`
## Deployment
Refer to **[DEPLOYMENT.md](file:///Users/charoro/git/holo-newsletter/DEPLOYMENT.md)** for step-by-step instructions on how to deploy this agent to Google Cloud Run and schedule it with Cloud Scheduler.
あっという間に、ソースコードやデプロイ手段などが用意されて、あとはクラウドやローカルでデプロイするだけという(そのやり方も書いてくれている)、すごいなあの一言です。
感想とか
今回は結構適当にお願いを書いているので、実装は微妙なところが多いです。
ただ、その辺はお願いをもうちょっと明確に書いたり、レビュー時に指摘したりとかで、改善できるのかなと思います。そう考えると、要件定義や外部仕様を明確に書くという、まあソフトウェアエンジニアとしては大事な能力はしっかり持っていないと、AIエージェントさんもちゃんと設計できないということかなと思いました(その辺は、人間のエンジニアさん相手のプロジェクトと全く一緒ですね)。
やりたいことはあるけど、どうやって実装したらいいかわからないとか、時間をかければ実装はできるけど、忙しくでできないというエンジニアにはとっても助かるツールなのかなと思いました。
