Category: Technical Notes

  • AGENTS.md

    # Coding Rules & Execution Guardrails (OpenCode)
    
    ## CRITICAL EXECUTION POLICY: Terminal & Tool Loops
    
    1. **Strict Command Deduplication:**
       - NEVER execute the exact same shell command twice in a row.
       - If a bash command returns output (stdout or stderr), you MUST analyze the output text before taking your next action.
       - You may only re-run a previously failed or executed command if you have modified its flags, arguments, or underlying files based on the output.
    
    2. **Acknowledge Output & State Transitions:**
       - After any bash command execution, your immediate next step must be to assess the state:
         - **Command succeeded?** Proceed to the next logical step in the task.
         - **Command failed / error thrown?** Diagnose the error and attempt a fix or alternative command. Do NOT blindly re-run the failed command.
         - **Command hung / timed out?** Terminate the process and attempt a non-blocking or targeted alternative.
    
    3. **Disallowed Command Hallucinations & Tool Rules:**
       - NEVER attempt to run `task`, `todowrite`, `todoread`, or `opencode` as shell/bash commands.
       - `todowrite` is an internal OpenCode tool (`todowrite`), NOT a CLI executable.
       - If you need to manage task items or step tracking, call the native `todowrite` tool function directly.
       - Do NOT assume interactive session runners or terminal tools (such as `tmux`) are globally required unless specified in the project's `./Testing Strategy.md`. Parse interactive runner protocols directly from `./Testing Strategy.md`.
    
    ---
    
    ## FILE EDIT POLICY: Match Anchors & Edits
    
    1. **Keep `oldString` Ultra-Short (1-2 Lines Max):**
       - NEVER pass full code blocks or multi-line paragraphs inside `oldString`.
       - Your `oldString` must contain ONLY 1 to 2 lines of unique code to pinpoint the edit location.
       - Example:
         ```json
         // BAD (Do NOT do this):
         "oldString": "def calculate_total(items):\n    total = 0\n    for item in items:\n        total += item.price\n    return total"
    
         // GOOD (Do this):
         "oldString": "def calculate_total(items):"
         ```
    
    2. **Always Re-Read First:**
       - Execute `read_file` on the target area immediately before calling an edit. Never edit from distant memory.
       - Copy the exact characters directly from the most recent `read_file` output block.
    
    3. **Fallback Procedure on Match Failure:**
       - If you get "Could not find oldString in the file", STOP immediately.
       - Re-read the file to check line numbers and whitespace.
       - Retry using a single unique line as the `oldString` anchor.
    
    4. **Disambiguate Duplicate Anchors:**
       - If the target `oldString` line appears multiple times in the file (e.g., `return True` or `pass`), expand `oldString` to 2–3 lines *only* until it includes a completely unique structural element (like a specific variable name or function header) to ensure the edit lands in the correct location.
    
    5. **Strict Indentation Mirroring:**
       - When writing the `newString` replacement block, perfectly mirror the exact spaces or tabs observed in the preceding `read_file` output. Do not assume or alter the indentation level unless explicitly instructed to refactor it.
  • llama-server-manager config.json

    {
      "options": {},
      "llama-server": {
        "options": {
          "host": "0.0.0.0",
          "port": "11235",
          "models-max": 1,
          "parallel": 1,
          "sleep-idle-seconds": 600,
          "fit-target": 512,
          "flash-attn": "on",
          "no-mmap": "",
          "cache-type-k": "q8_0",
          "cache-type-v": "q8_0",
          "n-gpu-layers": 999,
          "n-cpu-moe": 30
        }
      },
      "logging": {
        "enabled": true,
        "level": "INFO",
        "file": null
      }
    }
  • opencode.json

    { “$schema”: “https://opencode.ai/config.json”, “autoupdate”: true, “server”: { “port”: 4096 }, “permission”: “allow”, “provider”: { “llama-server”: { “npm”: “@ai-sdk/openai-compatible”, “name”: “LLama Server (Local)”, “options”: { “baseURL”: “http://192.168.1.151:11235/v1”, “timeout”: false, “chunkTimeout”: 28800000 }, “models”: { “Jackrong/Qwen3.5-9B-Neo-GGUF:Q5_K_M”: { “name”: “Qwen 3.5 Coder Neo (9B Q5)”, “options”: { “presence-penalty”: 0.2, “repeat-penalty”: 1.2, “temp”: 0.7, “top-k”: 20, “top-p”: 0.95, “min-p”: 0.1 } }, “Jackrong/Qwopus3.5-9B-Coder-MTP-GGUF:Q5_K_M”: { “name”: “Qwopus 3.5 Coder MTP (9B Q5)”, “options”: { “presence-penalty”: 0.2, “repeat-penalty”: 1.2, “temp”: 0.7, “top-k”: 20, “top-p”: 0.95, “min-p”: 0.1 } }, “unsloth/gemma-4-12B-it-qat-GGUF:Q4_K_XL”: { “name”: “Gemma 4 QAT Unsloth (12B Q4)”, “options”: { “presence-penalty”: 0.1, “repeat-penalty”: 1.05, “temp”: 0.4, “top-k”: 40, “top-p”: 0.9, “min-p”: 0.05 } } } }, “openrouter”: { “name”: “OpenRouter”, “models”: { “nvidia/nemotron-3-super-120b-a12b:free”: { “name”: “NVIDIA: Nemotron 3 Super (free – custom)” } } } }, “mcp”: { “chrome-devtools”: { “type”: “local”, “command”: [“npx”, “chrome-devtools-mcp@latest”], “enabled”: false } } }

  • AI Model from Hugging Face to Ollama

    Modelfile Setup Guide

    To import a model from Hugging Face into Ollama for coding, do the following.

    1. Download the model

    $ ollama pull hf.co/Jackrong/Qwen3.5-9B-Claude-4.6-Opus-Reasoning-Distilled-GGUF:Q8_0
    

    2. Find the correct blob

    Hint: It’s the big one.

    $ ollama show --modelfile hf.co/Jackrong/Qwen3.5-9B-Claude-4.6-Opus-Reasoning-Distilled-GGUF:Q8_0 \
      | awk '/^FROM/ {print $2}' \
      | xargs -r du -h
    

    3. Create a new Modelfile

    Set the context length to at least 16k or 32k, and add the TEMPLATE to enable tool calling.

    Sources:
    The TEMPLATE is from a GitHub comment.
    The additional Coding parameters for Qwen 3.5 are from hf.co. Parameters for additional uses are also available.

    # Modelfile generated by "ollama show"
    # To build a new Modelfile based on this, replace FROM with:
    # FROM hf.co/Jackrong/Qwen3.5-9B-Claude-4.6-Opus-Reasoning-Distilled-GGUF:Q8_0
    
    FROM /usr/share/ollama/.ollama/models/blobs/sha256-01ab75e862bf61c2fd20babc55d396181580722b7af76ec4ebfb83224218c723
    
    PARAMETER num_ctx 32768
    PARAMETER temperature 0.6
    PARAMETER top_p 0.95
    PARAMETER top_k 20
    PARAMETER min_p 0.0
    PARAMETER presence_penalty 0.0
    PARAMETER repeat_penalty 1.0
    
    TEMPLATE """{{- if .Suffix }}<|fim_prefix|>{{ .Prompt }}<|fim_suffix|>{{ .Suffix }}<|fim_middle|>
    {{- else -}}
    {{- $lastUserIdx := -1 -}}
    {{- range $idx, $msg := .Messages -}}
    {{- if eq $msg.Role "user" }}{{ $lastUserIdx = $idx }}{{ end -}}
    {{- end }}
    {{- if or .System .Tools }}<|im_start|>system
    {{ if .System }}
    {{ .System }}
    {{- end }}
    {{- if .Tools }}
    
    # Tools
    
    You may call one or more functions to assist with the user query.
    
    You are provided with function signatures within <tools></tools> XML tags:
    <tools>
    {{- range .Tools }}
    {"type": "function", "function": {{ .Function }}}
    {{- end }}
    </tools>
    
    For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
    <tool_call>
    {"name": <function-name>, "arguments": <args-json-object>}
    </tool_call>
    {{- end -}}
    <|im_end|>
    {{ end }}
    {{- range $i, $_ := .Messages }}
    {{- $last := eq (len (slice $.Messages $i)) 1 -}}
    {{- if eq .Role "user" }}<|im_start|>user
    {{ .Content }}
    {{ else if eq .Role "assistant" }}<|im_start|>assistant
    {{- if .Content }}
    {{ .Content }}
    {{- else if .ToolCalls }}
    {{- range .ToolCalls }}
    <tool_call>
    {"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
    </tool_call>
    {{- end }}
    {{- end }}{{ if not $last }}<|im_end|>
    {{ end }}
    {{- else if eq .Role "tool" }}<|im_start|>user
    <tool_response>
    {{ .Content }}
    </tool_response><|im_end|>
    {{ end }}
    {{- if and (ne .Role "assistant") $last }}<|im_start|>assistant
    {{ end }}
    {{- end }}
    {{- end }}
    """
    

    4. Create a new model from the Modelfile

    $ ollama create Qwen3.5-Coder-Distilled