mskadu/opencode-agent-skills

ollama-sync

'Synchronizes the list of available models in the ''opencode.json'' configuration file''s ''ollama'' provider models list with the actual models available on the system via the ''ollama list'' command.

소스 보기

사용 방법

  1. 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
  2. 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
  3. 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/mskadu/opencode-agent-skills --skill ollama-sync

시작 전 확인

  • 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
  • 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 Skill 문서

원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.

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.
  1. 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.
  1. 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):

json
"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.


관련 작업

같은 저장소의 Skills

더 많은 Skills

모든 Skills