Thanks to visit codestin.com
Credit goes to github.com

Skip to content

opencode compability #1

@bstoltefuss

Description

@bstoltefuss

Hi,

i did some experiments with running this extension with opencode instead of copilot and would suggest some small improvements.

  1. The get_incomplete_task_count seems to return "0 0" instead of "0" in my tests using WSL bash. Changing the method like this fixed the issue:
get_incomplete_task_count() {
    local path="$1"

    # 1. Check if file exists and is readable
    if [[ ! -f "$path" ]]; then
        printf "0"
        return 0
    fi

    # 2. Use grep -c to count, and ensure it defaults to 0 if no matches found
    # We use 'local count' to capture the output first
    local count
    count=$(grep -c '^- \[ \]' "$path" 2>/dev/null)
    
    # 3. Output the result (defaulting to 0 if count is empty)
    echo "${count:-0}"
}
  1. The run command has "Haiku" as hardcoded model. Is this necessary? When using only local models this will fail. Removing the two lines mentioning the model will use the current active model instead.

  2. Although the AGENT_CLI is a env variable, the command string passed to it is not. It's hardcoded in the script. As other agents (like opencode) have a different parameter syntax, it would be nice if the command string could be overwritten by an env variable too. I was able to workaround by either changing the line in the script or use a copilot wrapper script like this:

#!/bin/bash

# Loop through all provided arguments
while [[ $# -gt 0 ]]; do
  case "$1" in
    --agent)
      # get agent
      shift
      agent=("$1")
      shift
      ;;
    --model)
      # get model
      shift
      model=("$1")
      shift
      ;;
    -p)
      # get prompt
      shift
      prompt=("$1")
      shift
      ;;
    *)
shift
      ;;
  esac
done

# Execute opencode with the translated arguments
#echo opencode run --model "${model}" --log-level ERROR --command "${agent}" "${prompt}"
opencode run --model "${model}" --command "${agent}" "${prompt}" 
exit $?

After this small changes your extension works nicely with opencode. Though starting the loop from the shell seemed more stable then running as command inside opencode (probably some terminal issues in opencode with large outputs. Or some error on my part ,-)). Also when running the command inside opencode i had to prompt-push my local model (qwen35_a3b_thinking) a bit to really execute the scripts instead of thinking about it or adding code to it (may be the run template should emphasize this more?). Qwen 3.5 is a great local model but has a tendency to overthink.

Thanks for the extension. Nice work :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions