diff --git a/dot_config/opencode/opencode.json b/dot_config/opencode/opencode.json --- a/dot_config/opencode/opencode.json +++ b/dot_config/opencode/opencode.json @@ -1,10 +1,17 @@ { "$schema": "https://opencode.ai/config.json", "theme": "system", - "small_model": "github-copilot/gpt-4o", + "small_model": "openai/gpt-5.4-mini", "lsp": true, "agent": { + "general": { + "model": "openai/gpt-5.4" + }, + "explore": { + "model": "openai/gpt-5.4-mini" + }, "commit-review": { + "model": "openai/gpt-5.4-mini", "description": "Review the current staged git changes. Provide feedback on code quality, style, and potential issues.", "prompt": "You are a senior software engineer reviewing the following git changes. Provide constructive feedback on code quality, style, and potential issues. Suggest improvements where necessary.", "permission": { @@ -21,6 +28,19 @@ "options": { "baseURL": "http://localhost:11434/v1" }, "models": { + "qwen3.5:4b": { + "name": "Qwen 3.5 4B", + "tool_call": true, + "reasoning": false, + "limit": { + "context": 65536, + "output": 8192 + }, + "modalities": { + "input": ["text"], + "output": ["text"] + } + }, "gemma4:e2b": { "name": "Gemma 4 E2B", "tool_call": true, diff --git a/dot_config/private_k9s/plugins/executable_loki-logcli b/dot_config/private_k9s/plugins/executable_loki-logcli new file mode 100644 --- /dev/null +++ b/dot_config/private_k9s/plugins/executable_loki-logcli @@ -0,0 +1,94 @@ +#!/bin/sh +set -eu + +context="${1:-}" +query="${2:-}" + +if [ -z "$query" ]; then + echo "usage: loki-logcli [logcli args...]" >&2 + exit 2 +fi + +shift 2 + +state_dir="${XDG_RUNTIME_DIR:-/tmp}/k9s-loki-port-forward" +pid_file="$state_dir/pid" +log_file="$state_dir/kubectl.log" +addr="http://127.0.0.1:3100" + +mkdir -p "$state_dir" + +is_alive() { + [ -n "${1:-}" ] && kill -0 "$1" 2>/dev/null +} + +is_loki_up() { + nc -z 127.0.0.1 3100 >/dev/null 2>&1 +} + +k9s_pid() { + pid="$PPID" + while [ -n "$pid" ] && [ "$pid" -gt 1 ] 2>/dev/null; do + comm="$(ps -p "$pid" -o comm= 2>/dev/null || true)" + if [ "$comm" = "k9s" ]; then + printf '%s\n' "$pid" + return 0 + fi + pid="$(ps -p "$pid" -o ppid= 2>/dev/null | tr -d ' ' || true)" + done +} + +start_port_forward() { + if [ -f "$pid_file" ]; then + pid="$(cat "$pid_file" 2>/dev/null || true)" + if is_alive "$pid" && is_loki_up; then + return 0 + fi + fi + + if is_loki_up; then + return 0 + fi + + : >"$log_file" + if [ -n "$context" ]; then + kubectl --context "$context" port-forward -n loki svc/loki 3100:3100 --address 127.0.0.1 >>"$log_file" 2>&1 & + else + kubectl port-forward -n loki svc/loki 3100:3100 --address 127.0.0.1 >>"$log_file" 2>&1 & + fi + + pf_pid="$!" + printf '%s\n' "$pf_pid" >"$pid_file" + + owner_pid="$(k9s_pid || true)" + if [ -n "$owner_pid" ]; then + ( + while kill -0 "$owner_pid" 2>/dev/null; do + sleep 2 + done + if kill -0 "$pf_pid" 2>/dev/null; then + kill "$pf_pid" 2>/dev/null || true + fi + rm -f "$pid_file" + ) >/dev/null 2>&1 & + fi + + i=0 + while [ "$i" -lt 50 ]; do + if is_loki_up; then + return 0 + fi + if ! is_alive "$pf_pid"; then + cat "$log_file" >&2 + exit 1 + fi + i=$((i + 1)) + sleep 0.1 + done + + cat "$log_file" >&2 + exit 1 +} + +start_port_forward +exec logcli query "$query" --addr "$addr" "$@" diff --git a/dot_config/private_k9s/plugins/log-jq.yaml b/dot_config/private_k9s/plugins/log-jq.yaml --- a/dot_config/private_k9s/plugins/log-jq.yaml +++ b/dot_config/private_k9s/plugins/log-jq.yaml @@ -1,15 +1,17 @@ plugins: - # Sends logs over to jq for processing. This leverages kubectl plugin kubectl-jq. + # Streams pod logs through jq without requiring the kubectl-jq plugin. jqlogs: shortCut: Ctrl-J confirm: false description: "Logs (jq)" scopes: - po - command: kubectl + command: sh background: false args: - - jq + - -c + - kubectl logs --context "$3" --namespace "$2" "$1" --follow --ignore-errors=true | jq --unbuffered -R 'fromjson? // .' + - -- - $NAME - $NAMESPACE - $CONTEXT diff --git a/dot_config/private_k9s/plugins/log-loki.yaml b/dot_config/private_k9s/plugins/log-loki.yaml --- a/dot_config/private_k9s/plugins/log-loki.yaml +++ b/dot_config/private_k9s/plugins/log-loki.yaml @@ -1,95 +1,130 @@ plugins: - # https://grafana.com/docs/loki/latest/query/logcli/ - # you must set the LOKI_ADDR environment variable ("export LOKI_ADDR=https://loki.internal" in bash) before starting k9s to use logcli + # Starts a local Loki port-forward on first use, then queries it with logcli. loki-container: shortCut: Shift-L description: "loki fmt" scopes: - containers - command: logcli + command: sh background: false args: - - query - - '{ namespace = "$NAMESPACE", pod = "$POD", container = "$NAME" }' + - -c + - exec "${XDG_CONFIG_HOME:-$HOME/.config}/k9s/plugins/loki-logcli" "$@" + - -- + - $CONTEXT + - '{namespace="$NAMESPACE",pod="$POD",container="$NAME"}' + - --quiet - -f loki-container-raw: shortCut: Ctrl-E description: "loki raw" scopes: - containers - command: logcli + command: sh background: false args: - - query - - '{ namespace = "$NAMESPACE", pod = "$POD", container = "$NAME" }' + - -c + - exec "${XDG_CONFIG_HOME:-$HOME/.config}/k9s/plugins/loki-logcli" "$@" + - -- + - $CONTEXT + - '{namespace="$NAMESPACE",pod="$POD",container="$NAME"}' + - --quiet - -f - - -oraw + - -o + - raw loki-pods: shortCut: Shift-L description: "loki fmt" scopes: - po - command: logcli + command: sh background: false args: - - query - - '{ namespace = "$NAMESPACE", pod = "$NAME" }' + - -c + - exec "${XDG_CONFIG_HOME:-$HOME/.config}/k9s/plugins/loki-logcli" "$@" + - -- + - $CONTEXT + - '{namespace="$NAMESPACE",pod="$NAME"}' + - --quiet - -f loki-pods-raw: shortCut: Ctrl-L description: "loki raw" scopes: - po - command: logcli + command: sh background: false args: - - query - - '{ namespace = "$NAMESPACE", pod = "$NAME" }' + - -c + - exec "${XDG_CONFIG_HOME:-$HOME/.config}/k9s/plugins/loki-logcli" "$@" + - -- + - $CONTEXT + - '{namespace="$NAMESPACE",pod="$NAME"}' + - --quiet - -f - - -oraw + - -o + - raw loki-node: shortCut: Shift-L description: "loki fmt" scopes: - node - command: logcli + command: sh background: false args: - - query - - '{ node_name = "$NAME" }' + - -c + - exec "${XDG_CONFIG_HOME:-$HOME/.config}/k9s/plugins/loki-logcli" "$@" + - -- + - $CONTEXT + - '{node_name="$NAME"}' + - --quiet - -f loki-node-raw: shortCut: Ctrl-L description: "loki raw" scopes: - node - command: logcli + command: sh background: false args: - - query - - '{ node_name = "$NAME" }' + - -c + - exec "${XDG_CONFIG_HOME:-$HOME/.config}/k9s/plugins/loki-logcli" "$@" + - -- + - $CONTEXT + - '{node_name="$NAME"}' + - --quiet - -f - - -oraw + - -o + - raw loki-ns: shortCut: Shift-L description: "loki fmt" scopes: - namespace - command: logcli + command: sh background: false args: - - query - - '{ namespace = "$NAME" }' + - -c + - exec "${XDG_CONFIG_HOME:-$HOME/.config}/k9s/plugins/loki-logcli" "$@" + - -- + - $CONTEXT + - '{namespace="$NAME"}' + - --quiet - -f loki-ns-raw: shortCut: Ctrl-L description: "loki raw" scopes: - namespace - command: logcli + command: sh background: false args: - - query - - '{ namespace = "$NAME" }' + - -c + - exec "${XDG_CONFIG_HOME:-$HOME/.config}/k9s/plugins/loki-logcli" "$@" + - -- + - $CONTEXT + - '{namespace="$NAME"}' + - --quiet - -f - - -oraw + - -o + - raw