Skip to content

Instantly share code, notes, and snippets.

@coji
coji / gemini-cli-autonomy-analysis.md
Created June 26, 2025 14:24
Gemini CLIのアーキテクチャ分析:自律性を実現する仕組みと工夫

Gemini CLI が自律的に機能するための理由、仕組み、そして様々な工夫を読み解くことができます。以下にそれらを整理して解説します。

このツールは、単なるコマンド実行ツールではなく、**大規模言語モデル(LLM、おそらくGemini)がユーザーの意図を理解し、自ら状況判断を行い、必要なツールを選択・実行してタスクを解決する「自律型AIエージェント」**として設計されています。

その自律性を実現している理由、仕組み、工夫は以下の通りです。

1. 自律性の核となる仕組み:AIとツールの連携 (Function Calling)

このツールの根幹には、AIがプログラム(ツール)を呼び出す「Function Calling」または「Tool Use」と呼ばれる仕組みがあります。

/**
* 佐藤と高橋の特殊コーディングシステム
* このコードは二人だけが理解できる独自の構造と意味を持つ
*/
// 1. 文脈依存型変数命名
type Context = 'sato' | 'takahashi' | 'combined';
type DataShape = 'linear' | 'branched' | 'circular';
// コンテキストによって意味が変わる変数
APICallError [AI_APICallError]: Failed to process successful response
at postToApi (file:///var/task/node_modules/.pnpm/@ai-sdk+provider-utils@1.0.2_zod@3.23.8/node_modules/@ai-sdk/provider-utils/dist/index.mjs:353:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
... 3 lines matching cause stack trace ...
at async file:///var/task/build/server/nodejs-eyJydW50aW1lIjoibm9kZWpzIn0/index.js:152:18
at async Object.callRouteAction (/var/task/node_modules/.pnpm/@remix-run+server-runtime@2.10.2_typescript@5.5.3/node_modules/@remix-run/server-runtime/dist/data.js:37:16)
at async /var/task/node_modules/.pnpm/@remix-run+server-runtime@2.10.2_typescript@5.5.3/node_modules/@remix-run/server-runtime/dist/single-fetch.js:88:20
at async callLoaderOrAction (/var/task/node_modules/.pnpm/@remix-run+router@1.17.1/node_modules/@remix-run/router/dist/router.cjs.js:4713:16)
at async /var/task/node_modules/.pnpm/@remix-run+server-runtime@2.10.2_typescript@5.5.3/node_mo
[11:43:09.676] Running build in Washington, D.C., USA (East) – iad1
[11:43:09.845] Cloning github.com/coji/vercel-remix-singlefetch-test (Branch: main, Commit: 4ee24a3)
[11:43:09.858] Skipping build cache, deployment was triggered without cache.
[11:43:10.350] Cloning completed: 502.46ms
[11:43:11.171] Running "vercel build"
[11:43:11.860] Vercel CLI 34.3.0
[11:43:12.520] Warning: Detected "engines": { "node": ">=20.0.0" } in your `package.json` that will automatically upgrade when a new major Node.js Version is released. Learn More: http://vercel.link/node-version
[11:43:12.538] Detected `pnpm-lock.yaml` version 9 generated by pnpm 9
[11:43:12.552] Installing dependencies...
[11:43:13.110] Lockfile is up to date, resolution step is skipped
@coji
coji / remix-terminology.md
Created June 6, 2024 08:45
Remix 用語集

Remix 用語集

基本的な概念

  • ルート: Remix アプリケーションの基礎となる部分。通常は app/root.jsx ファイルに記述されます。
  • ルート モジュール: URL に対応する Remix アプリケーションのコードの単位。通常は app/routes ディレクトリに配置されます。
  • ルート ファイル: ルート モジュールが記述されているファイル。.jsx, .tsx, .js, .ts, .md, .mdx などの拡張子が使用されます。
  • ルート コンポーネント: ルート モジュールから export された、ルートに関連する React コンポーネント。通常はルート ファイルの default export です。
  • データ: サーバーからロードされたデータ。通常は [loader][loader] 関数で取得されます。
  • アクション: ユーザーによる操作 (フォームの送信など) に対応するサーバー側の処理。通常はルート ファイルの action 関数で定義されます。

了解です。neverthrow、remeda、ts-patternを使って、問い合わせフォームの登録処理を一本道で処理するコードを書いてみましょう。

import { ok, err, Result } from 'neverthrow';
import { pipe } from 'remeda';
import { match, P } from 'ts-pattern';

// エラーの型定義
type ValidationError = { type: 'ValidationError'; message: string };
type EmailSendError = { type: 'EmailSendError'; message: string };
import { pipe } from "remeda";
import { match } from "ts-pattern";
type Failure = { errorCode: number };
type Result<Ok, Ng extends Failure> =
| { type: "ok"; value: Ok }
| { type: "failure"; error: Ng };
function bypass<
PreviousOk,
import { pipe } from "remeda";
import { match } from "ts-pattern";
type Failure = { errorCode: number };
type Result<Ok, Ng extends Failure> =
| { type: "ok"; value: Ok }
| { type: "failure"; error: Ng };
function bypass<
PreviousOk,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Classic Composer Search</title>
</head>
<body>
<h1>Classic Composer Search</h1>
@coji
coji / app.ts
Created August 20, 2022 06:39
slack app tutorial
import { App } from '@slack/bolt'
import dotenv from 'dotenv'
dotenv.config()
const main = async () => {
const app = new App({
signingSecret: process.env.SLACK_SIGNING_SECRET,
token: process.env.SLACK_BOT_TOKEN,
})