這是本文件的舊版!


安裝 OpenCode (Ubuntu 24.04)

  • curl -fsSL https://opencode.ai/install | bash

  • 之後如果要更新也是執行

    curl -fsSL https://opencode.ai/install | bash

    • 看畫面
  • 進入專案目錄執行

    opencode

  • Ref - https://github.com/code-yeongyu/oh-my-opencode

    sudo snap remove bun-js
    sudo apt install unzip
    curl -fsSL https://bun.sh/install | bash
    source ~/.bashrc
    cp ~/.config/opencode/opencode.json ~/.config/opencode/opencode.json.bak
    bunx oh-my-opencode install

  • Oh My OpenCode 內建配置熱門的 MCP Exp. context7(動態文檔), grep_app, websearch , 因此就不需要安裝這三個 MCP
  • Serena MCP : OpenCode 原生就支援 LSP 因此就不需要安裝 Serena MCP
  • ulw : UltraWork Mode → 讓所有 Agent 可以儘可能最大極限合作執行 Exp.

    ulw 請優化後台 UI/UX 讓操作更簡易

  • ralph-loop : 自主持續迭代 → 讓 AI 持續不停優化 Exp. 搭配 ulw 使用

    ulw /ralph-loop "優化首頁載入時間 <1.5s(Lighthouse 分數 >95)" --max-iterations 25 --completion-promise "Lighthouse 性能分數 >95"

  • mcp_tool 執行 playwrite 出現 JSON 異常問題 - 參考解法 - https://github.com/code-yeongyu/oh-my-opencode/issues/729
  • # Install CLI globally
    sudo npm install -g uipro-cli
    
    # Go to your project
    cd /path/to/your/project
    # Install for your AI assistant
    uipro init --ai opencode    # OpenCode

  • 重新啟動 opencode 輸入 “Build a landing page for a SaaS product”
  • Step 1.

    sudo npm install -g @fission-ai/openspec@latest
    jonathan@claude-code-194:~$ openspec --version
    0.21.0

  • Step 2.

    cd my-project
    openspec init

    • 看畫面
    • 複製畫面看到的這段

      1. Populate your project context:
         "Please read openspec/project.md and help me fill it out
          with details about my project, tech stack, and conventions"
      
      2. Create your first change proposal:
         "I want to add [YOUR FEATURE HERE]. Please create an
          OpenSpec change proposal for this feature"
      
      3. Learn the OpenSpec workflow:
         "Please explain the OpenSpec workflow from openspec/AGENTS.md
          and how I should work with you on this project"

      等等貼到 opencode , 分析目前專案狀態產生 openspec/project.md (PRD 檔), 當然也可以使用原本的 PRD 檔案複製成 project.md

  • 進入 opencode 執行 /openspec 命令
    1. Draft the Proposal Exp.

      /openspec:proposal Add profile search filters

    2. Verify & Review
      $ openspec list                             # Confirm the change folder exists
      $ openspec validate add-profile-filters     # Validate spec formatting
      $ openspec show add-profile-filters         # Review proposal, tasks, and spec delta
    3. Refine the Specs

      請修正 xxx 功能, 將 abc 改成 zyx

    4. Implement the Change

      The specs look good. Let's implement this change.

    5. Archive the Completed Change

      $ openspec archive add-profile-filters --yes  # Archive the completed change without prompts

  • 查看規格清單

    openspec list

  • 更版方式

    sudo npm install -g @fission-ai/openspec@latest
    cd myproject
    openspec update

  • # Quick install (auto-detects your package manager)
    curl -fsSL https://raw.githubusercontent.com/btriapitsyn/openchamber/main/scripts/install.sh | bash
    
    # Quick start daemon
    openchamber --port 6001 --daemon
    
    # 其他參數
    openchamber                          # Start on port 3000
    openchamber --port 8080              # Custom port
    openchamber --daemon                 # Background mode
    openchamber --ui-password secret     # Password-protect UI
    openchamber --try-cf-tunnel          # Create a Cloudflare Quick Tunnel for remote access
    openchamber --try-cf-tunnel --tunnel-qr              # Show QR code for easy mobile access
    openchamber --try-cf-tunnel --tunnel-password-url   # Include password in URL for auto-login
    OPENCODE_PORT=4096 OPENCODE_SKIP_START=true openchamber  # Connect to external OpenCode server
    openchamber stop                     # Stop server
    openchamber update                   # Update to latest version

  1. 先將 opencode.json 進行備份

    cp -a ~/.config/opencode/opencode.json ~/.config/opencode/opencode.json.bak

  2. 編輯 opencode.json

    vi ~/.config/opencode/opencode.json

    {
      "plugin": ["opencode-antigravity-auth@beta"],
      :
      :
    }
  3. 進行 Google oAuth 認證

    opencode auth login

    1. 選擇 *Google**
    2. 將產生的 URL 貼到瀏覽器, 進行 Google oAuth 認證
    3. 如果是 ssh 登入遠端主機, 沒有進行 port redirect 認證成功後會找不到網頁, 可以將網址完整複製下來 Exp.

      http://localhost:51121/oauth-callback?state=eyJ2ZXJpZmllciI6IklW......nfigs%20openid&authuser=0&prompt=consent

      貼到 opencode 對話內就可完成

  4. 繼續修改 opencode.json 將需要的模型加入

    vi ~/.config/opencode/opencode.json

    {
      "plugin": [
        "oh-my-opencode",
        "opencode-antigravity-auth@beta"
      ],
      "provider": {
        "google": {
          "name": "Google",
          "models": {
            "antigravity-gemini-3-pro": {
              "name": "Gemini 3 Pro (Antigravity)",
              "limit": { "context": 1048576, "output": 65535 },
              "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
              "variants": {
                "low": { "thinkingLevel": "low" },
                "high": { "thinkingLevel": "high" }
              }
            },
            "antigravity-gemini-3-flash": {
              "name": "Gemini 3 Flash (Antigravity)",
              "limit": { "context": 1048576, "output": 65536 },
              "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
              "variants": {
                "minimal": { "thinkingLevel": "minimal" },
                "low": { "thinkingLevel": "low" },
                "medium": { "thinkingLevel": "medium" },
                "high": { "thinkingLevel": "high" }
              }
            },
            "antigravity-claude-sonnet-4-5": {
              "name": "Claude Sonnet 4.5 (Antigravity)",
              "limit": { "context": 200000, "output": 64000 },
              "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
            },
            "antigravity-claude-sonnet-4-5-thinking": {
              "name": "Claude Sonnet 4.5 Thinking (Antigravity)",
              "limit": { "context": 200000, "output": 64000 },
              "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
              "variants": {
                "low": { "thinkingConfig": { "thinkingBudget": 8192 } },
                "max": { "thinkingConfig": { "thinkingBudget": 32768 } }
              }
            },
            "antigravity-claude-opus-4-5-thinking": {
              "name": "Claude Opus 4.5 Thinking (Antigravity)",
              "limit": { "context": 200000, "output": 64000 },
              "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
              "variants": {
                "low": { "thinkingConfig": { "thinkingBudget": 8192 } },
                "max": { "thinkingConfig": { "thinkingBudget": 32768 } }
              }
            },
    :
    :
            }
          }
        }
      },
      "$schema": "https://opencode.ai/config.json"
    }
  • tech/opencode.1769313185.txt.gz
  • 上一次變更: 2026/01/25 11:53
  • jonathan