1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

opencode+LM StudioでセキュアなAIプログラム解析

1
Last updated at Posted at 2026-04-19

opencode を LM Studioと接続

これにより、ソースコードなどが外部に出ることがなく、もちろん課金もされないため、安心して利用可能となります。

環境

以下の環境で実施しています

LM StudioはMacBookPro M5 メモリ32GBで動かしています

インストールなど

opencodeのインストール

npm install -g opencode-ai

失敗しました。。。

npm error code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm error errno UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm error request to https://registry.npmjs.org/opencode-ai failed, reason: unable to get local issuer certificate
npm error A complete log of this run can be found in: /Users/xxxx/.npm/_logs/2026-04-19T02_53_46_174Z-debug-0.log

仕方ないので、証明書検証をオフにしてやります(やったあとに戻します)

# 証明書検証をオフに設定
npm config set strict-ssl false

# 再度インストールを試行
npm install -g opencode-ai

# インストールが終わったら、安全のために設定を戻しておく
npm config set strict-ssl true
% opencode -version
1.4.17

設定関連

LM Studioに接続するための設定などを行います

/Users/xxxx/.config/opencode/opencode.json を新規作成します

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "local": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Local LLM",
      "options": {
        "baseURL": "http://192.168.〇.〇:1234/v1",
        "apiKey": "lm-studio"
      },
      "models": {
        "google/gemma-4-26b-a4b": {
          "name": "gemma-4-26b-a4b",
          "limit": {
            "context": 16384,
            "output": 8192
          }
        },
        "google/gemma-3-27b": {
          "name": "gemma-3-27b",
          "limit": {
            "context": 16384,
            "output": 8192
          }
        },
        "qwen/qwen2.5-coder-14b": {
          "name": "qwen2.5-coder-14b",
          "limit": {
            "context": 16384,
            "output": 8192
          }
        },
        "qwen/qwen3-coder-30b": {
          "name": "qwen3-coder-30b",
          "limit": {
            "context": 16384,
            "output": 8192
          }
        }
      }
    }
  },
}

モデルは一旦4種類セットしてみた

AGENTS.md の設定(他にもいろいろあるので、調べてみてください)

/Users/xxxx/.config/opencode/AGENTS.md を新規作成します

# Instructions
- 回答はすべて日本語で行ってください。
- コードの解説も日本語で丁寧に行ってください。
- 実行コマンドの確認などは英語のままでも構いませんが、ユーザーへの説明は日本語に徹してください。
- 出力するファイル内のコメントも(必要であれば)日本語で記述してください。
- 分析タスクの後は、ユーザーの許可なくコードの修正や実行フェーズに移行しないでください。
- 各ステップの完了後に必ず「待機」し、次の指示を仰いでください。
- 提案(Suggestions)は、ユーザーから求められた場合のみ出力してください。

実行

opencode

なんかロゴが化けてるな。。
image.png

最初にモデル選択

ctrl + p で Switch model
image.png

今回は「gemma-4-26b-a4b」を使います

プロンプトに指示

image.png

いつものHello World作成をお願いして、できたコード

image.png

opencodeさんは、ほっておくと、ずっといろいろやってくれるので、頃合いをみて(笑) escキーを押してください。

感想など

今回は、プログラムを作らせましたが、opencodeは解析とかが得意なので色々試してみたいです!

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?