Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/opencode/opencode.tpl.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
},
"models": {
"glm-4.7": {
"id": "@preset/glm-4-7",
"id": "@preset/__GLM_NONDOT__",
"name": "Preset GLM-4.7 (via OpenRouter)"
}
}
Expand Down
26 changes: 25 additions & 1 deletion config/pi/models.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"providers": {
"cli-proxy-api": {
"cliproxyapi": {
"baseUrl": "http://localhost:8317/v1",
"apiKey": "CLIPROXY_API_KEY",
"api": "openai-responses",
Expand Down Expand Up @@ -181,6 +181,30 @@
"maxTokens": 16384
}
]
},
"lmstudio": {
"baseUrl": "http://127.0.0.1:1234/v1",
"apiKey": "LM_API_TOKEN",
"api": "openai-responses",
"models": [
{
"id": "qwen/qwen3.5-9b",
"name": "Qwen 3.5 9B (LM Studio)",
"reasoning": true,
"input": [
"text",
"image"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 262144,
"maxTokens": 32768
}
]
}
}
}
28 changes: 26 additions & 2 deletions config/pi/models.tpl.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"providers": {
"cli-proxy-api": {
"cliproxyapi": {
"baseUrl": "http://localhost:8317/v1",
"apiKey": "CLIPROXY_API_KEY",
"api": "openai-responses",
Expand Down Expand Up @@ -165,7 +165,7 @@
"api": "openai-completions",
"models": [
{
"id": "@preset/glm-4-7",
"id": "@preset/__GLM_NONDOT__",
"name": "GLM-4.7 (Z-AI)",
"reasoning": false,
"input": [
Expand All @@ -181,6 +181,30 @@
"maxTokens": 16384
}
]
},
"lmstudio": {
"baseUrl": "http://127.0.0.1:1234/v1",
"apiKey": "LM_API_TOKEN",
"api": "openai-responses",
"models": [
{
"id": "__QWEN_LOCAL__",
"name": "Qwen 3.5 9B (LM Studio)",
"reasoning": true,
"input": [
"text",
"image"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 262144,
"maxTokens": 32768
}
]
}
}
}
6 changes: 4 additions & 2 deletions config/pi/settings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"theme": "dark",
"quietStartup": true,
"defaultProvider": "cli-proxy-api",
"defaultProvider": "cliproxyapi",
"defaultModel": "glm-4.7",
"defaultThinkingLevel": "medium",
"enabledModels": [
"cli-proxy-api/*",
"cliproxyapi/*",
"lmstudio/*",
"*gpt-5*",
"*gemini*",
"*claude*",
"*glm*",
"*qwen*",
"*kimi*"
],
"steeringMode": "one-at-a-time",
Expand Down
6 changes: 4 additions & 2 deletions config/pi/settings.tpl.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"theme": "dark",
"quietStartup": true,
"defaultProvider": "cli-proxy-api",
"defaultProvider": "cliproxyapi",
"defaultModel": "__GLM__",
"defaultThinkingLevel": "medium",
"enabledModels": [
"cli-proxy-api/*",
"cliproxyapi/*",
"lmstudio/*",
"*gpt-5*",
"*gemini*",
"*claude*",
"*glm*",
"*qwen*",
"*kimi*"
],
"steeringMode": "one-at-a-time",
Expand Down
4 changes: 4 additions & 0 deletions home-manager/programs/fish/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
ocxeh = "_ocxeh_function";
ocxelh = "_ocxelh_function";
pixe = "_pixe_function";
pixel = "_pixel_function";
pixelh = "_pixelh_function";
pixeh = "_pixeh_function";
sag = "_ssh_add_github";
shortcuts = "_fish_shortcuts";
Expand Down Expand Up @@ -215,6 +217,8 @@
"_ocxeh_function"
"_ocxelh_function"
"_pixe_function"
"_pixel_function"
"_pixelh_function"
"_pixeh_function"
"_ssh_add_github"
"_tdo_function"
Expand Down
8 changes: 4 additions & 4 deletions home-manager/programs/fish/functions/_pixe_function.fish
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
function _pixe_function --description "Run Pi agent with a free-form prompt"
# Run Pi agent with a free-form prompt (spaces allowed)
function _pixe_function --description "Run Pi with a free-form prompt"
# Run Pi with a free-form prompt (spaces allowed)
# Usage: pixe [<prompt words...>]

if test (count $argv) -eq 0
pi-agent -m 'openrouter-preset/@preset/glm-4-7'
pi --model 'cliproxyapi/glm-4.7'
else
set -l prompt (string join " " -- $argv)
pi-agent "$prompt" -m 'openrouter-preset/@preset/glm-4-7'
pi --model 'cliproxyapi/glm-4.7' "$prompt"
end
end
8 changes: 4 additions & 4 deletions home-manager/programs/fish/functions/_pixe_function.tpl.fish
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
function _pixe_function --description "Run Pi agent with a free-form prompt"
# Run Pi agent with a free-form prompt (spaces allowed)
function _pixe_function --description "Run Pi with a free-form prompt"
# Run Pi with a free-form prompt (spaces allowed)
# Usage: pixe [<prompt words...>]

if test (count $argv) -eq 0
pi-agent -m 'openrouter-preset/@preset/__GLM_NONDOT__'
pi --model 'cliproxyapi/__GLM__'
else
set -l prompt (string join " " -- $argv)
pi-agent "$prompt" -m 'openrouter-preset/@preset/__GLM_NONDOT__'
pi --model 'cliproxyapi/__GLM__' "$prompt"
end
end
6 changes: 3 additions & 3 deletions home-manager/programs/fish/functions/_pixeh_function.fish
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function _pixeh_function --description "Run Pi agent headlessly with a prompted input"
# Prompt for input and run Pi agent
function _pixeh_function --description "Run Pi headlessly with a prompted input"
# Prompt for input and run Pi in print mode
# Usage: pixeh

read -P "Prompt: " prompt
Expand All @@ -8,5 +8,5 @@ function _pixeh_function --description "Run Pi agent headlessly with a prompted
return 1
end

pi-agent "$prompt" -m 'openrouter-preset/@preset/glm-4-7'
pi --model 'cliproxyapi/glm-4.7' -p "$prompt"
end
6 changes: 3 additions & 3 deletions home-manager/programs/fish/functions/_pixeh_function.tpl.fish
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function _pixeh_function --description "Run Pi agent headlessly with a prompted input"
# Prompt for input and run Pi agent
function _pixeh_function --description "Run Pi headlessly with a prompted input"
# Prompt for input and run Pi in print mode
# Usage: pixeh

read -P "Prompt: " prompt
Expand All @@ -8,5 +8,5 @@ function _pixeh_function --description "Run Pi agent headlessly with a prompted
return 1
end

pi-agent "$prompt" -m 'openrouter-preset/@preset/__GLM_NONDOT__'
pi --model 'cliproxyapi/__GLM__' -p "$prompt"
end
11 changes: 11 additions & 0 deletions home-manager/programs/fish/functions/_pixel_function.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function _pixel_function --description "Run Pi with a free-form prompt using the local Qwen model"
# Run Pi with a free-form prompt (spaces allowed) using the local Qwen model
# Usage: pixel [<prompt words...>]

if test (count $argv) -eq 0
pi --model 'lmstudio/qwen/qwen3.5-9b'
else
set -l prompt (string join " " -- $argv)
pi --model 'lmstudio/qwen/qwen3.5-9b' "$prompt"
end
end
Comment on lines +1 to +11

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This function is almost identical to _pixe_function, with the only difference being the model string. Similarly, the new _pixelh_function is very similar to _pixeh_function. This introduces code duplication. To improve maintainability, consider creating helper functions.

For example, you could have a helper for interactive prompts:

# in a new helper function, e.g. _pi_interactive_wrapper.fish
function _pi_interactive_wrapper
    set -l model $argv[1]
    set -l prompt_args $argv[2..-1]

    if test (count $prompt_args) -eq 0
        pi --model "$model"
    else
        set -l prompt (string join " " -- $prompt_args)
        pi --model "$model" "$prompt"
    end
end

Then _pixel_function could be simplified to:

function _pixel_function --description "Run Pi with a free-form prompt using the local Qwen model"
    _pi_interactive_wrapper 'lmstudio/qwen/qwen3.5-9b' $argv
end

A similar helper could be created for the headless (-h) functions. This would make the code DRYer and easier to manage when adding more model wrappers in the future.

11 changes: 11 additions & 0 deletions home-manager/programs/fish/functions/_pixel_function.tpl.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function _pixel_function --description "Run Pi with a free-form prompt using the local Qwen model"
# Run Pi with a free-form prompt (spaces allowed) using the local Qwen model
# Usage: pixel [<prompt words...>]

if test (count $argv) -eq 0
pi --model 'lmstudio/__QWEN_LOCAL__'
else
set -l prompt (string join " " -- $argv)
pi --model 'lmstudio/__QWEN_LOCAL__' "$prompt"
end
end
12 changes: 12 additions & 0 deletions home-manager/programs/fish/functions/_pixelh_function.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function _pixelh_function --description "Run Pi headlessly with the local Qwen model"
# Prompt for input and run Pi in print mode with the local Qwen model
# Usage: pixelh

read -P "Prompt: " prompt
if test -z "$prompt"
echo "No prompt provided, aborting." >&2
return 1
end

pi --model 'lmstudio/qwen/qwen3.5-9b' -p "$prompt"
end
12 changes: 12 additions & 0 deletions home-manager/programs/fish/functions/_pixelh_function.tpl.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function _pixelh_function --description "Run Pi headlessly with the local Qwen model"
# Prompt for input and run Pi in print mode with the local Qwen model
# Usage: pixelh

read -P "Prompt: " prompt
if test -z "$prompt"
echo "No prompt provided, aborting." >&2
return 1
end

pi --model 'lmstudio/__QWEN_LOCAL__' -p "$prompt"
end
2 changes: 2 additions & 0 deletions scripts/llm-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ declare -A TEMPLATES=(
["home-manager/programs/fish/functions/_ocxeh_function.tpl.fish"]=home-manager/programs/fish/functions/_ocxeh_function.fish
["home-manager/programs/fish/functions/_ocxelh_function.tpl.fish"]=home-manager/programs/fish/functions/_ocxelh_function.fish
["home-manager/programs/fish/functions/_pixe_function.tpl.fish"]=home-manager/programs/fish/functions/_pixe_function.fish
["home-manager/programs/fish/functions/_pixel_function.tpl.fish"]=home-manager/programs/fish/functions/_pixel_function.fish
["home-manager/programs/fish/functions/_pixelh_function.tpl.fish"]=home-manager/programs/fish/functions/_pixelh_function.fish
["home-manager/programs/fish/functions/_pixeh_function.tpl.fish"]=home-manager/programs/fish/functions/_pixeh_function.fish
)

Expand Down
7 changes: 4 additions & 3 deletions spec/fish/_pixe_function.tpl_test.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ source $fn/_pixe_function.tpl.fish

# ── no args: interactive mode ─────────────────────────────
set log1 (mktemp)
function pi-agent; echo $argv >> $log1; end
function pi; echo $argv >> $log1; end

_pixe_function

@test "no args calls pi-agent with templated preset" (grep -c "openrouter-preset/@preset/__GLM_NONDOT__" $log1) -ge 1
@test "no args calls pi with templated cliproxyapi model" (grep -c "cliproxyapi/__GLM__" $log1) -ge 1

# ── with args: builds prompt ──────────────────────────────
set log2 (mktemp)
function pi-agent; echo $argv >> $log2; end
function pi; echo $argv >> $log2; end

_pixe_function hello world

@test "with args builds prompt" (grep -c "hello world" $log2) -ge 1
@test "with args uses templated cliproxyapi model" (grep -c "cliproxyapi/__GLM__" $log2) -ge 1

rm -f $log1 $log2
7 changes: 4 additions & 3 deletions spec/fish/_pixe_function_test.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ source $fn/_pixe_function.fish

# ── no args: interactive mode ─────────────────────────────
set log1 (mktemp)
function pi-agent; echo $argv >> $log1; end
function pi; echo $argv >> $log1; end

_pixe_function

@test "no args calls pi-agent with model" (grep -c "openrouter-preset" $log1) -ge 1
@test "no args calls pi with cliproxyapi model" (grep -c "cliproxyapi/glm-4.7" $log1) -ge 1

# ── with args: builds prompt ──────────────────────────────
set log2 (mktemp)
function pi-agent; echo $argv >> $log2; end
function pi; echo $argv >> $log2; end

_pixe_function hello world

@test "with args builds prompt" (grep -c "hello world" $log2) -ge 1
@test "with args uses cliproxyapi model" (grep -c "cliproxyapi/glm-4.7" $log2) -ge 1

rm -f $log1 $log2
11 changes: 11 additions & 0 deletions spec/fish/_pixeh_function.tpl_test.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@ source $fn/_pixeh_function.tpl.fish

@test "empty prompt rejects" (echo "" | _pixeh_function 2>&1) = "No prompt provided, aborting."
@test "empty prompt returns 1" (echo "" | _pixeh_function 2>/dev/null; echo $status) = 1

set log1 (mktemp)
function pi; echo $argv >> $log1; end

echo "hello world" | _pixeh_function

@test "non-empty prompt builds prompt" (grep -c "hello world" $log1) -ge 1
@test "non-empty prompt uses templated cliproxyapi model" (grep -c "cliproxyapi/__GLM__" $log1) -ge 1
@test "non-empty prompt uses print mode" (grep -c -- "-p" $log1) -ge 1

rm -f $log1
11 changes: 11 additions & 0 deletions spec/fish/_pixeh_function_test.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@ source $fn/_pixeh_function.fish

@test "empty prompt rejects" (echo "" | _pixeh_function 2>&1) = "No prompt provided, aborting."
@test "empty prompt returns 1" (echo "" | _pixeh_function 2>/dev/null; echo $status) = 1

set log1 (mktemp)
function pi; echo $argv >> $log1; end

echo "hello world" | _pixeh_function

@test "non-empty prompt builds prompt" (grep -c "hello world" $log1) -ge 1
@test "non-empty prompt uses cliproxyapi model" (grep -c "cliproxyapi/glm-4.7" $log1) -ge 1
@test "non-empty prompt uses print mode" (grep -c -- "-p" $log1) -ge 1

rm -f $log1
21 changes: 21 additions & 0 deletions spec/fish/_pixel_function.tpl_test.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
set fn (status dirname)/../../home-manager/programs/fish/functions
source $fn/_pixel_function.tpl.fish

# ── no args: interactive mode ─────────────────────────────
set log1 (mktemp)
function pi; echo $argv >> $log1; end

_pixel_function

@test "no args calls pi with templated local Qwen model" (grep -c "lmstudio/__QWEN_LOCAL__" $log1) -ge 1

# ── with args: builds prompt ──────────────────────────────
set log2 (mktemp)
function pi; echo $argv >> $log2; end

_pixel_function hello world

@test "with args builds prompt" (grep -c "hello world" $log2) -ge 1
@test "with args uses templated local Qwen model" (grep -c "lmstudio/__QWEN_LOCAL__" $log2) -ge 1

rm -f $log1 $log2
21 changes: 21 additions & 0 deletions spec/fish/_pixel_function_test.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
set fn (status dirname)/../../home-manager/programs/fish/functions
source $fn/_pixel_function.fish

# ── no args: interactive mode ─────────────────────────────
set log1 (mktemp)
function pi; echo $argv >> $log1; end

_pixel_function

@test "no args calls pi with local Qwen model" (grep -c "lmstudio/qwen/qwen3.5-9b" $log1) -ge 1

# ── with args: builds prompt ──────────────────────────────
set log2 (mktemp)
function pi; echo $argv >> $log2; end

_pixel_function hello world

@test "with args builds prompt" (grep -c "hello world" $log2) -ge 1
@test "with args uses local Qwen model" (grep -c "lmstudio/qwen/qwen3.5-9b" $log2) -ge 1

rm -f $log1 $log2
Loading
Loading