Compare commits

...
13 Commits
Author SHA1 Message Date
ziadarafat a69f108c27 Merge remote-tracking branch 'origin/main' 2026-12-02 09:20:38 -07:00
ziadarafat 50153a9a8e Save Pi worker and model configuration 2026-12-02 09:20:37 -07:00
Ziad cde0fd97fe bin/pi-spark: pi-lens covers post-edit checks, make verify-on-write opt-in 2026-12-01 15:57:59 -07:00
Ziad 665806b2cd bin/pi-spark: load pi-verify-on-write when the checkout is present 2026-12-01 15:32:25 -07:00
Ziad 3618086af0 pi-spark: seed small-model operating rules, raise Spark context to 64k
Baseline test: the 4B model made zero tool calls and invented mise syntax.
With an APPEND_SYSTEM of tool-first rules plus a golang-mise skill it built,
tested and ran a working CLI in 36 tool calls. Rules now live in
config/pi/small-model-APPEND_SYSTEM.md and are seeded per project; Ollama
serves 64k context, which measured equal or faster than 32k.
2026-12-01 15:07:19 -07:00
Ziad ffc0d6d83d bin/pi-spark: launch the pi agent against the local Spark model in tmux
Spark only implements thinking low/high, and pi's default reasoning level
(medium) makes its chat template raise, so the launcher pins the level and
drops the free-pi session env so pi reads ~/.pi/agent.
2026-12-01 11:56:23 -07:00
Ziad b70572b269 pi agent: spark models and a working wiki/lapis MCP set
- models.json: add spark:ablit and spark:4b from the local Ollama endpoint
  (OLLAMA_CONTEXT_LENGTH is now 32k on yveltal so long prompts fit)
- mcp.json: replace the stale ETV wikijs entry and WIKI_BEARER_TOKEN with
  the homelab wiki over _mcp and WIKI3_MCP_TOKEN, and add LaPis memory
2026-12-01 11:42:55 -07:00
Ziad Arafat c6199ec824 free-pi mcp: authenticate the wiki server with WIKI3_MCP_TOKEN
The wiki header looked up WIKI_BEARER_TOKEN, which does not exist in
secrets.txt, so free-pi reported 'wiki: failed' and the wiki tools were
missing from every session. Point the header at the secret the wiki-mcp
bridge and the skills already use.
2026-11-30 17:46:19 -07:00
Ziad Arafat e246c1328c Add Kontroll to Moonlander skill 2026-11-30 15:07:11 -07:00
Ziad Arafat 7bc67e42ac Add ZSA Moonlander skill for Riolu 2026-11-30 15:04:19 -07:00
Ziad Arafat b888fa5bc7 Verify Roku HDMI selection through active input status 2026-11-29 00:42:39 -07:00
Ziad Arafat df631c921c Add agent tool and skill for Roku TV HDMI-CEC 2026-11-29 00:37:15 -07:00
Ziad Arafat 632ae00711 fix(pi): use non-strict Cohere tools in free profile 2026-11-28 20:12:21 -07:00
13 changed files with 325 additions and 65 deletions

No files matched your search

Executable
+43
View File
@@ -0,0 +1,43 @@
#!/bin/sh
# pi-spark — run the pi coding agent against the local Spark model in tmux.
#
# The Spark models live on yveltal (Ollama behind the gpu-broker). Spark only
# implements thinking levels low and high, so medium breaks its chat template:
# the launcher defaults to low. Everything else comes from ~/.pi/agent:
# skills, the wiki + lapis MCP servers and the LaPis memory layer.
#
# pi-spark attach, or create the session
# PI_SPARK_MODEL=ollama/spark:4b pi-spark
set -eu
SESSION=${PI_SPARK_SESSION:-pi-spark}
MODEL=${PI_SPARK_MODEL:-ollama/spark:ablit}
THINKING=${PI_SPARK_THINKING:-low}
DIR=${PI_SPARK_DIR:-$HOME/Projects/pi-spark}
if tmux has-session -t "$SESSION" 2>/dev/null; then
if [ -t 1 ]; then exec tmux attach -t "$SESSION"; fi
echo "session $SESSION already running: tmux attach -t $SESSION"
exit 0
fi
# pi-lens (npm:pi-lens) already injects language-server findings after an edit,
# so the home-grown verify-on-write extension is opt-in only: PI_SPARK_VERIFY=1.
EXTRA=""
VERIFY_EXT="$HOME/Projects/pi-verify-on-write/src/index.ts"
if [ -n "${PI_SPARK_VERIFY:-}" ] && [ -f "$VERIFY_EXT" ]; then
EXTRA="--extension $VERIFY_EXT"
fi
mkdir -p "$DIR/.pi"
# Small models need explicit tool-first rules; seed them into a new project.
if [ ! -f "$DIR/.pi/APPEND_SYSTEM.md" ] && [ -f "$HOME/.dotfiles/config/pi/small-model-APPEND_SYSTEM.md" ]; then
cp "$HOME/.dotfiles/config/pi/small-model-APPEND_SYSTEM.md" "$DIR/.pi/APPEND_SYSTEM.md"
echo "seeded $DIR/.pi/APPEND_SYSTEM.md (small-model rules)"
fi
# Drop the free-pi session environment so pi uses ~/.pi/agent, not the free-pi agent dir.
tmux new-session -d -s "$SESSION" -x "${PI_SPARK_COLS:-210}" -y "${PI_SPARK_ROWS:-50}" -c "$DIR" \
"env -u PI_CODING_AGENT_DIR -u PI_SESSION_FILE -u PI_SESSION_ID -u PI_MODEL -u PI_PROVIDER -u PI_REASONING_LEVEL PI_SKIP_VERSION_CHECK=1 pi --model $MODEL --thinking $THINKING $EXTRA"
if [ -t 1 ]; then exec tmux attach -t "$SESSION"; fi
echo "session $SESSION ready with $MODEL (thinking $THINKING): tmux attach -t $SESSION"
Executable
+94
View File
@@ -0,0 +1,94 @@
#!/usr/bin/env bash
set -euo pipefail
umask 077
export PATH="$HOME/.local/bin:$HOME/.nix-profile/bin:/usr/bin:/bin"
root="${XDG_STATE_HOME:-$HOME/.local/state}/pi-workers"
self="$(realpath "$0")"
profiles="$(dirname "$self")/../config/free-pi/models.json"
mkdir -p "$root"
case "${2:-}" in
cohere|local) provider=$2 ;;
*) echo 'Usage: pi-worker {start|serve} {cohere|local} | pi-worker submit {cohere|local} REPO TASK.md' >&2; exit 2 ;;
esac
queue="$root/$provider"
mkdir -p "$queue"
case "$1" in
start)
if ! tmux has-session -t "=pi-worker-$provider" 2>/dev/null; then
tmux new-session -d -s "pi-worker-$provider" -- "$self" serve "$provider"
tmux set-option -w -t "pi-worker-$provider:" remain-on-exit on
fi
;;
stop)
tmux kill-session -t "=pi-worker-$provider"
;;
submit)
[[ $# == 4 && -s "$4" ]]
task=$(realpath "$4")
job=$(mktemp -d "$queue/job-XXXXXXXX")
git -C "$3" worktree add --detach "$job/work" HEAD >&2
cp -- "$task" "$job/task.md"
touch "$job/ready"
printf '%s\n' "$job"
;;
serve)
exec 9>"$queue/worker.lock"
flock -n 9
shopt -s nullglob
trap 'exit 0' TERM INT
printf 'Waiting for %s jobs in %s\n' "$provider" "$queue"
for marker in "$queue"/job-*/running; do
job=${marker%/running}
printf '125\n' >"$job/exit-code"
mv -- "$marker" "$job/done"
done
while true; do
for ready in "$queue"/job-*/ready; do
job=${ready%/ready}
mv -- "$ready" "$job/running"
printf 'Running %s\n' "${job##*/}"
code=0
"$self" run "$provider" "$job" >"$job/result.txt" 2>&1 || code=$?
printf '%s\n' "$code" >"$job/exit-code"
mv -- "$job/running" "$job/done"
printf '%s finished with status %s\n' "${job##*/}" "$code"
done
sleep 3
done
;;
run)
job=$3
[[ "$job" == "$queue"/job-* && -f "$job/running" ]]
pi_path=$(mise which pi)
node_path=$(mise which node)
modules=$(dirname "$(dirname "$pi_path")")
mkdir -p "$job/profile"
if [[ "$provider" == cohere ]]; then
model=cohere/command-a-03-2025
jq '{providers: {cohere: (.providers.cohere | .apiKey = "$COHERE_API_KEY")}}' "$profiles" > "$job/profile/models.json"
else
model=ollama/gemma4-12b-qat-64k
jq '{providers: {ollama: (.providers.ollama | .apiKey = "ollama")}}' "$profiles" > "$job/profile/models.json"
fi
sandbox=(bwrap --die-with-parent --unshare-user --unshare-pid --unshare-ipc
--proc /proc --dev /dev --tmpfs /tmp
--ro-bind /usr /usr --ro-bind /nix/store /nix/store
--symlink usr/bin /bin --symlink usr/lib /lib --symlink usr/lib64 /lib64
--ro-bind /etc/resolv.conf /etc/resolv.conf --ro-bind /etc/ssl/certs /etc/ssl/certs
--ro-bind "$modules" /runtime/node_modules --ro-bind "$node_path" /runtime/node
--bind "$job/profile" /profile --ro-bind "$job/task.md" /task.md
--bind "$job/work" /work --tmpfs /home --chdir /work)
while IFS= read -r name; do
sandbox+=(--unsetenv "$name")
done < <(compgen -e | sed '/^COHERE_API_KEY$/d')
sandbox+=(--setenv HOME /home --setenv PATH /usr/bin:/bin --setenv PI_CODING_AGENT_DIR /profile)
sandbox+=(/runtime/node /runtime/node_modules/@earendil-works/pi-coding-agent/dist/bundle/cli.js
--no-session --no-extensions --no-mcp --tools read,edit,write,grep,find,ls
--model "$model" --print @/task.md)
if [[ "$provider" == cohere ]]; then
exec timeout -k 10 300 secretctl get COHERE_API_KEY -- "${sandbox[@]}"
fi
exec timeout -k 10 300 "${sandbox[@]}"
;;
*) exit 2 ;;
esac
Executable
+84
View File
@@ -0,0 +1,84 @@
#!/usr/bin/env bash
set -euo pipefail
usage() {
printf '%s\n' 'Usage: roku-tv {status|kodi|standby}' \
' status Read TV power and the reported HDMI-CEC source' \
' kodi Wake the TV and select Bounsweet (Kodi)' \
' standby Send standby to the TV'
}
if [[ $# != 1 ]]; then
usage >&2
exit 2
fi
case "$1" in
-h|--help) usage; exit 0 ;;
status|kodi|standby) ;;
*) usage >&2; exit 2 ;;
esac
timeout 20 ssh -T -o BatchMode=yes -o ConnectTimeout=5 bounsweet sh -s -- "$1" <<'REMOTE'
set -eu
cec() {
cec-ctl -d /dev/cec0 "$@"
}
address=$(cec | awk '/Physical Address[[:space:]]*:/ {print $NF; exit}')
case "$address" in
[1-9a-e].[0-9a-f].[0-9a-f].[0-9a-f]) ;;
*) echo 'Bounsweet has no usable HDMI-CEC address' >&2; exit 1 ;;
esac
status() {
power_reply=$(cec --to 0 --give-device-power-status)
source_reply=$(cec --request-active-source)
power=$(printf '%s\n' "$power_reply" | awk -F': ' '/pwr-state:/ {sub(/ \(.*$/, "", $2); print $2; exit}')
source=$(printf '%s\n' "$source_reply" | awk '/phys-addr:/ {print $NF; exit}')
printf 'tv_power=%s\nactive_source=%s\nkodi_source=%s\n' "${power:-unknown}" "${source:-unknown}" "$address"
}
roku_reports_kodi() {
case "$address" in
[1-4].0.0.0) input="tvinput.hdmi${address%%.*}" ;;
*) return 1 ;;
esac
active_app=$(curl -fsS --max-time 4 http://10.56.5.46:8060/query/active-app 2>/dev/null) || return 1
printf '%s\n' "$active_app" | grep -Fq "<app id=\"$input\""
}
send() {
reply=$(cec "$@")
if printf '%s\n' "$reply" | grep -qi 'Tx, Not OK'; then
printf '%s\n' 'HDMI-CEC transmit failed.' >&2
exit 1
fi
}
case "$1" in
status)
status
;;
kodi)
send --to 0 --image-view-on
sleep 1
send --active-source "phys-addr=$address"
printf 'requested_source=%s\n' "$address"
sleep 1
status
if [ "${source:-unknown}" = "$address" ]; then
printf '%s\n' 'source_verified_by=cec'
elif roku_reports_kodi; then
printf '%s\n' 'source_verified_by=roku_active_app'
else
echo 'Kodi source selection could not be confirmed.' >&2
exit 1
fi
;;
standby)
send --to 0 --standby
printf '%s\n' 'requested_power=standby'
status
;;
esac
REMOTE
+1 -1
View File
@@ -4,7 +4,7 @@
"url": "https://wiki.godemperordoge.org/_mcp",
"description": "Wiki.js homelab docs at godemperordoge.org: search, browse, read and update pages.",
"headers": {
"Authorization": "!secretctl get WIKI_BEARER_TOKEN -- sh -c 'printf \"Bearer %s\" \"$WIKI_BEARER_TOKEN\"'"
"Authorization": "!secretctl get WIKI3_MCP_TOKEN -- sh -c 'printf \"Bearer %s\" \"$WIKI3_MCP_TOKEN\"'"
},
"exposure": "codemode",
"toolExposure": {
+3 -3
View File
@@ -6,7 +6,7 @@
},
"fallback": {
"provider": "ollama",
"model": "gemma4-12b-qat-128k",
"thinking": "low"
"model": "gemma4-26b-a4b-qat-128k",
"thinking": "high"
}
}
}
+13 -58
View File
@@ -1,66 +1,21 @@
{
"mcpServers": {
"websearch-simple": {
"url": "https://RivalSearchMCP.fastmcp.app/mcp",
"exposure": "direct"
},
"wiki": {
"command": "npx",
"args": [
"-y",
"@yowu-dev/requarks-wiki-mcp@latest"
],
"env": {
"WIKI_BASE_URL": "https://wikijs.etvamerica.com/",
"WIKI_API_TOKEN": "${WIKI_API_TOKEN}",
"WIKI_MUTATIONS_ENABLED": "true",
"WIKI_MUTATION_DRY_RUN": "false"
"url": "https://wiki.godemperordoge.org/_mcp",
"description": "Wiki.js homelab docs at godemperordoge.org: search, browse, read and update pages.",
"headers": {
"Authorization": "!secretctl get WIKI3_MCP_TOKEN -- sh -c 'printf \"Bearer %s\" \"$WIKI3_MCP_TOKEN\"'"
},
"exposure": "direct"
},
"mise-en-place": {
"command": "${HOME}/.nix-profile/bin/mise",
"args": [
"mcp"
],
"env": {
"MISE_EXPERIMENTAL": "1"
},
"exposure": "direct"
},
"playwright-browser-automation": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--extension"
],
"env": {
"PLAYWRIGHT_MCP_EXECUTABLE_PATH": "${HOME}/chrome.sh",
"PLAYWRIGHT_MCP_EXTENSION_TOKEN": "${PLAYWRIGHT_MCP_EXTENSION_TOKEN}"
},
"exposure": "direct"
},
"web-search-advanced": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/Shelpuk-AI-Technology-Consulting/kindly-web-search-mcp-server",
"kindly-web-search-mcp-server",
"start-mcp-server"
],
"env": {
"SEARXNG_BASE_URL": "https://google.godemperordoge.org/",
"SEARXNG_USER_AGENT": "Mozilla/5.0 ..."
"exposure": "codemode",
"toolExposure": {
"get_page": "direct"
}
},
"gitea": {
"command": "${HOME}/.nix-profile/bin/gitea-mcp",
"args": [
"-H",
"https://gitea.etvamerica.com",
"-T",
"${ETV_GITEA_TOKEN}"
]
"lapis": {
"command": "sh",
"args": ["-c", "exec \"$HOME/.dotfiles/bin/mcp-lapis\""],
"description": "LaPis persistent memory (SQLite ~/.pi/memory/memory.db): memory-save, memory-search, memory-get, memory-code and memory-doc for the current project.",
"exposure": "codemode"
}
}
}
}
+20
View File
@@ -5,6 +5,26 @@
"api": "openai-completions",
"apiKey": "ollama",
"models": [
{
"id": "spark:ablit",
"name": "Spark-X2.6-4B abliterated (GTX 1080)",
"contextWindow": 65536,
"maxTokens": 8192,
"reasoning": true,
"input": [
"text"
]
},
{
"id": "spark:4b",
"name": "Spark-X2.6-4B official (GTX 1080)",
"contextWindow": 65536,
"maxTokens": 8192,
"reasoning": true,
"input": [
"text"
]
},
{
"id": "gemma4-12b-qat-64k:latest",
"contextWindow": 65536,
+3 -2
View File
@@ -5,7 +5,8 @@
"npm:@juicesharp/rpiv-ask-user-question",
"npm:pi-background-tasks",
"npm:context-mode",
"npm:pi-auto-models"
"npm:pi-auto-models",
"npm:pi-lens"
],
"extensionChangelogVersions": {
"{\"source\":\"git:github.com/GeneGulanesJr/LaPis\",\"scope\":\"user\"}": "1.4.0"
@@ -25,4 +26,4 @@
"ollama/gemma4-26b-a4b-qat:latest",
"ollama/gemma4-12b-qat-uncensored-64k:latest"
]
}
}
+14
View File
@@ -0,0 +1,14 @@
# Working rules (small-model session)
Text you write is not the work — tool calls are the work.
1. **Act with tools.** Create or change files with `write`/`edit`. Never paste file contents or commands as prose.
2. **One step at a time.** One tool call, read the result, then the next. Do not plan more than two steps ahead.
3. **Verify before you deliberate.** After writing code, run the build or test immediately. Decide design questions from the command output, not from memory.
4. **Read a file at most once per task.** Use `edit` with a unique anchor instead of re-reading.
5. **Keep output small.** Pipe long output through `| tail -20` or `| head -20`; prefer `-count`, `-q` and `--json` flags. Your context is limited.
6. **Do not invent syntax.** Unsure of a command or file format? Run `--help`, `ls-remote`, or read the relevant skill.
7. **Cap deliberation.** If two options are acceptable, take the first and continue; the test result decides.
8. **Stop with evidence.** When acceptance criteria are met, run the final verification command and report the exact commands and their output. Nothing else.
Go projects: use the `golang-mise` skill for the exact `mise.toml` format and command list.
+14
View File
@@ -0,0 +1,14 @@
---
name: roku-tv
description: Control the homelab Roku TV over HDMI-CEC through Bounsweet, the LibreELEC Kodi Raspberry Pi. Use for TV power, checking the HDMI source, or switching the TV to Kodi.
---
Run `~/.dotfiles/bin/roku-tv` on a machine with the configured `bounsweet` SSH alias.
- `roku-tv status` reports the TV's power state, the active CEC source if a device answers, and Kodi's physical address.
- `roku-tv kodi` asks the TV to wake and selects Bounsweet's HDMI input.
- `roku-tv standby` sends standby directly to the TV. Use when the user asks to turn off the TV.
Use the action that matches the user's request. An active source matching `kodi_source` confirms CEC source selection. A successful switch reports `source_verified_by=cec` or `source_verified_by=roku_active_app`. The latter uses a read-only Roku LAN query when the CEC broadcast does not confirm the switch. If the command fails, report that source selection was unconfirmed. If the Roku still reports `0.0.0.0`, check **Settings → System → Control other devices (CEC) → 1-touch play** on the TV before retrying. CEC does not provide Roku Home navigation or app launching via this tool.
[Hardware and troubleshooting notes](https://wiki.godemperordoge.org/homelab/reference/clients/kodi-bounsweet#roku-tv-hdmi-cec)
+20
View File
@@ -0,0 +1,20 @@
---
name: zsa-moonlander
description: Use ZSA Kontroll for live Moonlander control and Zapp for firmware from Arceus via Riolu. Use for Moonlander firmware, Oryx layout revisions, QMK tap-hold tuning and flash detection or recovery.
---
The physical Moonlander normally plugs into Arceus USB 9-2. Proxmox VM 141 (Riolu) owns this port, including bootloader re-enumeration. Run Kontroll and Zapp in Riolu through the existing Arceus handoff SSH config.
```bash
ssh -F ~/handoffs/homelab/lucario/riolu/ssh-config riolu-bootstrap '~/.local/bin/kontroll status; ~/.local/bin/zapp devices --skip-bluetooth'
```
Kontroll 2.0.0 talks directly to the keyboard over USB. Use `kontroll list` or `kontroll status` for read-only discovery, and inspect `--help` before changing the layer, RGB, or brightness. Riolu grants the `zsa-moonlander` group access specifically to Moonlander hidraw interface `01`. Status identified the device and firmware but reported protocol and current layer as unknown on the installed firmware.
Zapp 1.2.0 is installed for `svc`. The guest's `70-zsa-moonlander.rules` grants that account USB access through the `zsa-moonlander` group. Runtime Moonlander is `3297:1969`. The STM32 DFU bootloader is `0483:df11`. If Zapp cannot see the device, check `qm monitor` USB inventory on Arceus and the USB tree in Riolu. When flashing directly on the Deck, confirm the Deck itself sees the DFU device before investigating browser or Flatpak access.
Use Oryx to edit or clone the layout and Zapp to fetch and flash a compiled revision. Retain the last known-good revision or binary and confirm the exact Moonlander target at the time of flashing. Review published artifacts at [ZSA Downloads](https://downloads.zsa.io/zapp/) and check the archive SHA-256. `zapp flash <local .bin or Oryx revision URL>` writes firmware. `zapp update` can immediately fetch and flash the latest Oryx revision, so use `devices` for discovery.
For Shift/Ctrl/Alt tap-hold changes, preserve the assignments and start with one key or a cloned layout. Test an intentional chord and rapid ordinary typing. See [ZSA tap-hold guidance](https://blog.zsa.io/tap-hold-explained/) and [QMK per-key options](https://docs.qmk.fm/tap_hold).
A DFU cycle can detach the input devices from Riolu's static Xorg configuration. Keep the Deck's local controls available. If input is missing after the keyboard returns in normal USB mode, stop `riolu-deskflow`, restart `riolu-xorg`, then start `riolu-deskflow` in Riolu. Confirm both input devices reopen and the Deck reconnects. See the [Riolu Wiki notes](https://wiki.godemperordoge.org/homelab/reference/virtualization/cachyos-gaming-gtx1080#5-moonlander-and-mouse-switching).
+15
View File
@@ -0,0 +1,15 @@
[Unit]
Description=Start the Pi task worker tmux sessions
Wants=network-online.target
After=network-online.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=%h/.dotfiles/bin/pi-worker start cohere
ExecStart=%h/.dotfiles/bin/pi-worker start local
ExecStop=-%h/.dotfiles/bin/pi-worker stop cohere
ExecStop=-%h/.dotfiles/bin/pi-worker stop local
[Install]
WantedBy=default.target
+1 -1
View File
@@ -8,7 +8,7 @@ let
# through codemode, the CLI flavour through the mcp bridge (no sandbox).
sharedSkills = [
"git" "gt" "mise-cli" "secrets_man" "searxng" "playwright-cli"
"context-discipline" "homelab-policies" "memory-layer"
"context-discipline" "homelab-policies" "memory-layer" "roku-tv" "zsa-moonlander"
];
cliSkills = [ "infra-change" "wiki-update" "wiki-view" "lapis-memory" "handoff" ];
allSkills = sharedSkills ++ cliSkills;