mcpField
O
ollama-sync

ollama-sync

github.com/mskaduAgent workflows141 installsUpdated 21w ago
Repository

About ollama-sync

ollama-sync is an agent skill that synchronizes the Ollama model list in `opencode.json` with models reported by the local `ollama list` command. It is for maintaining an accurate Ollama provider configuration, including empty-list and command-failure cases.

Key features

  1. 01Checks for the `ollama` command
  2. 02Reads models with `ollama list`
  3. 03Extracts model names
  4. 04Updates the Ollama provider in `opencode.json`
  5. 05Handles empty lists and command errors

Use cases

  1. 01Refresh configured models after adding or removing local models
  2. 02Clear the configured list when no models are available
  3. 03Identify environment issues that prevent synchronization

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/mskadu/opencode-agent-skills --skill ollama-sync

After installing, type/ollama-syncin Claude Code to confirm it loaded.

Bundled filesREADME.md

Details

From the project README

Ollama Model Synchronizer

Your Task

When asked to synchronize the local Ollama configuration, your primary goal is to ensure that the model list in the opencode.json file is an accurate reflection of the models available on the host system.

The process must involve three main steps:

  1. Fetch Live List: Execute ollama list via the bash tool to retrieve all currently available model names and tags on the machine.
  2. Parse and Extract: Parse the output of ollama list to extract only the clean list of model names (e.g., llama2, mistral).
  3. Update Config: Use the edit tool to replace the existing model list in opencode.json (specifically the ollama provider section) with the newly fetched, accurate list.

Workflow Details

  1. Primary Command Execution:
    • Run ollama list using the bash tool.
  2. Parsing Logic (Internal):
    • The output of ollama list needs to be parsed to isolate model names. Assume the output format is reliable enough to grep for model names.
  3. File Manipulation:
    • Use the read tool on opencode.json to understand the current structure.
    • Use the edit tool to modify the specific section containing the model list.
Step-by-step Logic
  1. Check Dependency: Confirm if the ollama command is available in the execution environment.
  2. Get System Models: Execute ollama list to get the current list of models.
  3. Isolate Names: Programmatically parse the output to create a comma-separated string of model names.
  4. Write Back: Use the edit tool to replace the old model list with the new comma-separated list in opencode.json.

Examples & Edge Cases

  • Empty List: If ollama list returns no models, the opencode.json model list should be cleared or set to an empty array, and the user should be warned.
  • Error Handling: If the ollama command fails or is not found, the process must stop, and the user should be informed that the synchronization failed due to environment issues.

Target File Structure (Conceptual)

The target file is opencode.json. The relevant section looks like this (structure for context):

"providers": {
    "ollama": {
        "models": ["model-a", "model-b", "model-c"], // <-- This list must be updated
        "base_url": "http://localhost:11434"
    },
    // ... other providers
}

Always prioritize using the bash tool for OS interactions (ollama list) and the edit tool for configuration management.

Comments

Markdown supported