Skip to content

ccebelenski/oc-ls-configer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oc-ls-configer

A bash script that automatically configures opencode to use a local llama-swap instance. It detects the currently running model, resolves context window metadata for auto-compaction, and launches opencode with a generated config.

Features

  • Auto-detects the active model from llama-swap's /running endpoint
  • Resolves context length for opencode auto-compaction via a fallback chain:
    1. LOCAL_CONTEXT environment variable
    2. meta.llamaswap.context_length from llama-swap's /v1/models metadata
    3. --ctx-size parsed from the running llama-server command line
  • Generates a temporary opencode.json config and cleans up on exit
  • Can be sourced or executed directly

Prerequisites

Usage

# Basic usage (auto-detects model from llama-swap)
./oc.sh

# Override the llama-swap endpoint
LOCAL_ENDPOINT=http://host:port ./oc.sh

# Specify a model explicitly
LOCAL_MODEL=my-model ./oc.sh

# Override context/output limits
LOCAL_CONTEXT=16384 LOCAL_OUTPUT=4096 ./oc.sh

# Resume an existing opencode session
./oc.sh -s <session-id>

Environment Variables

Variable Default Description
LOCAL_ENDPOINT http://localhost:8080 llama-swap API endpoint
LOCAL_MODEL (auto-detected) Model ID to use
LOCAL_CONTEXT (auto-detected) Context window size (tokens)
LOCAL_OUTPUT (auto-detected) Max output tokens

llama-swap Metadata

For best results, configure metadata in your llama-swap YAML so the script can automatically pick up context and output limits:

models:
  my-model:
    cmd: "llama-server --ctx-size 16384 ..."
    metadata:
      context_length: 16384
      output_length: 4096

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

License

MIT

About

Auto-configure opencode to use a local llama-swap instance with model and context detection

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages