@weave-os/router 0.2.29 → 0.2.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -16
- package/bin.js +53 -10
- package/cc-statusline.sh +269 -56
- package/codex-skills/force-parent/SKILL.md +23 -0
- package/codex-skills/force-parent/scripts/emit.sh +7 -0
- package/codex-skills/router-models/SKILL.md +1 -1
- package/codex-status.sh +312 -48
- package/codex-toggle.sh +1 -1
- package/commands/force-parent.md +6 -0
- package/commands/models.md +1 -1
- package/commands/router-models.md +1 -1
- package/directives.tsv +1 -0
- package/install.sh +1566 -218
- package/package.json +8 -2
- package/pi-router/README.md +4 -2
- package/pi-router/src/force-model.ts +109 -38
- package/pi-router/src/pricing.generated.ts +8 -3
- package/pi-router/src/routed-model.ts +51 -7
- package/pi-router/src/ui.ts +3 -3
- package/uninstall.sh +167 -9
- package/windows.js +545 -0
package/uninstall.sh
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
#
|
|
3
|
-
# Weave Router uninstaller for Claude Code, Codex, opencode, and
|
|
3
|
+
# Weave Router uninstaller for Claude Code, Codex, opencode, pi, and GitHub Copilot CLI.
|
|
4
4
|
#
|
|
5
|
-
#
|
|
5
|
+
# Without a client flag, every client with Weave Router config is uninstalled
|
|
6
|
+
# in turn. --claude removes the env vars, statusLine, and local
|
|
6
7
|
# router auth that install.sh added; leaves the rest of settings.json
|
|
7
8
|
# untouched. Pass --codex to strip the managed [model_providers.weave]
|
|
8
9
|
# block (and the matching top-level `model_provider`) from Codex's
|
|
@@ -14,10 +15,12 @@
|
|
|
14
15
|
# weave defaults, and remove the router key file.
|
|
15
16
|
#
|
|
16
17
|
# Usage:
|
|
17
|
-
# npx @workweave/router --uninstall #
|
|
18
|
+
# npx @workweave/router --uninstall # every configured client, user scope
|
|
19
|
+
# npx @workweave/router --uninstall --claude # Claude Code only
|
|
18
20
|
# npx @workweave/router --uninstall --codex # Codex, user scope
|
|
19
21
|
# npx @workweave/router --uninstall --opencode # opencode, user scope
|
|
20
22
|
# npx @workweave/router --uninstall --pi # pi, user scope
|
|
23
|
+
# npx @workweave/router --uninstall --copilot # GitHub Copilot CLI (providers.json, skills)
|
|
21
24
|
# npx @workweave/router --uninstall --scope project # run inside the repo
|
|
22
25
|
# npx @workweave/router --uninstall --dir /tmp/test # --dir alone (user scope, .weave/)
|
|
23
26
|
# npx @workweave/router --uninstall --scope project --dir /tmp # --dir + project scope (.claude/)
|
|
@@ -44,6 +47,7 @@ WEAVE_REGISTRY_DATA=$(cat <<'WEAVE_REGISTRY_EOF'
|
|
|
44
47
|
# canonical|aliases|capability|claude|codex|opencode|pi|cursor|adapter
|
|
45
48
|
# aliases are comma-separated; client columns are yes/no. adapter is the native asset kind.
|
|
46
49
|
force-model|fm|prompt|yes|yes|yes|yes|manual|command,skill
|
|
50
|
+
force-parent||prompt|yes|yes|yes|yes|manual|command,skill
|
|
47
51
|
unforce-model|ufm|prompt|yes|yes|yes|yes|manual|command,skill
|
|
48
52
|
router-feedback|rf|prompt|yes|yes|yes|no|manual|command,skill
|
|
49
53
|
router-off||local-toggle|yes|yes|no|no|manual|command,skill
|
|
@@ -204,6 +208,17 @@ weave_command_router_owned() {
|
|
|
204
208
|
return 1
|
|
205
209
|
}
|
|
206
210
|
|
|
211
|
+
# Git Bash rewrites $HOME's /c/... form to C:/... in arguments to native
|
|
212
|
+
# executables such as jq.exe, so the stored command can use either form.
|
|
213
|
+
statusline_commands_match() {
|
|
214
|
+
local first_mixed second_mixed
|
|
215
|
+
[ "$1" = "$2" ] && return 0
|
|
216
|
+
command -v cygpath >/dev/null 2>&1 || return 1
|
|
217
|
+
first_mixed="$(cygpath -m -- "$1" 2>/dev/null)" && [ -n "$first_mixed" ] || return 1
|
|
218
|
+
second_mixed="$(cygpath -m -- "$2" 2>/dev/null)" && [ -n "$second_mixed" ] || return 1
|
|
219
|
+
[ "$first_mixed" = "$second_mixed" ]
|
|
220
|
+
}
|
|
221
|
+
|
|
207
222
|
# claude_statusline_router_owned reports whether a settings entry points at the
|
|
208
223
|
# router's statusline. Existing scripts prove ownership with the marker; when a
|
|
209
224
|
# script is missing, the adjacent ownership marker proves that the router wrote
|
|
@@ -212,7 +227,7 @@ claude_statusline_router_owned() {
|
|
|
212
227
|
local settings_path="$1" expected_command="$2" script_path="$3" ownership_marker_path="$4" configured_command
|
|
213
228
|
[ -f "$settings_path" ] || return 1
|
|
214
229
|
configured_command="$(jq -r '.statusLine.command // empty' "$settings_path" 2>/dev/null || true)"
|
|
215
|
-
|
|
230
|
+
statusline_commands_match "$configured_command" "$expected_command" || return 1
|
|
216
231
|
if [ -f "$script_path" ]; then
|
|
217
232
|
if grep -Fq "$CLAUDE_STATUSLINE_MARKER" "$script_path" 2>/dev/null; then
|
|
218
233
|
return 0
|
|
@@ -223,6 +238,8 @@ claude_statusline_router_owned() {
|
|
|
223
238
|
&& grep -Fq "$CLAUDE_STATUSLINE_MARKER" "$ownership_marker_path"
|
|
224
239
|
}
|
|
225
240
|
|
|
241
|
+
uninstall_args=("$@")
|
|
242
|
+
target_explicit="false"
|
|
226
243
|
while [ $# -gt 0 ]; do
|
|
227
244
|
case "$1" in
|
|
228
245
|
--scope)
|
|
@@ -235,20 +252,23 @@ while [ $# -gt 0 ]; do
|
|
|
235
252
|
[ -n "$install_dir" ] || { err "--dir requires a path."; exit 2; }
|
|
236
253
|
;;
|
|
237
254
|
--codex)
|
|
238
|
-
target="codex"; shift
|
|
255
|
+
target="codex"; target_explicit="true"; shift
|
|
239
256
|
;;
|
|
240
257
|
--opencode)
|
|
241
|
-
target="opencode"; shift
|
|
258
|
+
target="opencode"; target_explicit="true"; shift
|
|
242
259
|
;;
|
|
243
260
|
--pi)
|
|
244
|
-
target="pi"; shift
|
|
261
|
+
target="pi"; target_explicit="true"; shift
|
|
262
|
+
;;
|
|
263
|
+
--copilot)
|
|
264
|
+
target="copilot"; target_explicit="true"; shift
|
|
245
265
|
;;
|
|
246
266
|
--claude)
|
|
247
267
|
# No-op selector for symmetry with --codex / --opencode and install.sh's
|
|
248
268
|
# --claude. Lets `./install.sh --uninstall --claude` (which forwards
|
|
249
269
|
# remaining args here) succeed instead of hitting the unknown-flag
|
|
250
270
|
# catch-all.
|
|
251
|
-
target="claude"; shift
|
|
271
|
+
target="claude"; target_explicit="true"; shift
|
|
252
272
|
;;
|
|
253
273
|
-h|--help)
|
|
254
274
|
# awk avoids GNU `head -n -<N>` (rejected by BSD head on macOS).
|
|
@@ -261,7 +281,66 @@ while [ $# -gt 0 ]; do
|
|
|
261
281
|
esac
|
|
262
282
|
done
|
|
263
283
|
|
|
264
|
-
|
|
284
|
+
# skip_if_not_installed ends a child of a bare --uninstall quietly (exit 3)
|
|
285
|
+
# unless config $1 has a line matching ERE $2 or any further path exists. A
|
|
286
|
+
# client that is installed still needs jq, checked here rather than up front.
|
|
287
|
+
skip_if_not_installed() {
|
|
288
|
+
[ -n "${WEAVE_UNINSTALL_ALL_CHILD:-}" ] || return 0
|
|
289
|
+
local config="$1" pattern="$2" installed="false" extra
|
|
290
|
+
shift 2
|
|
291
|
+
[ -f "$config" ] && grep -Eq -- "$pattern" "$config" && installed="true"
|
|
292
|
+
for extra in "$@"; do [ -e "$extra" ] && installed="true"; done
|
|
293
|
+
[ "$installed" = "true" ] || exit 3
|
|
294
|
+
[ "$target" = "codex" ] || command -v jq >/dev/null 2>&1 || { err "jq is required for the $target uninstall path."; exit 1; }
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
client_label() {
|
|
298
|
+
case "$1" in
|
|
299
|
+
claude) printf 'Claude Code' ;;
|
|
300
|
+
codex) printf 'Codex' ;;
|
|
301
|
+
copilot) printf 'Copilot CLI' ;;
|
|
302
|
+
*) printf '%s' "$1" ;;
|
|
303
|
+
esac
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
# A bare --uninstall removes Weave Router from every client it configured. Each
|
|
307
|
+
# client runs as its own child so its path stays exactly the --<client> one. A
|
|
308
|
+
# piped run with no recoverable source keeps the old Claude Code-only default.
|
|
309
|
+
uninstall_self="$0"
|
|
310
|
+
[ -f "$uninstall_self" ] || uninstall_self=""
|
|
311
|
+
if [ "$target_explicit" = "false" ] && [ -z "${WEAVE_UNINSTALL_ALL_CHILD:-}" ] \
|
|
312
|
+
&& { [ -n "$uninstall_self" ] || [ -n "${BASH_EXECUTION_STRING:-}" ]; }; then
|
|
313
|
+
uninstall_self_tmp=""
|
|
314
|
+
if [ -z "$uninstall_self" ]; then
|
|
315
|
+
uninstall_self_tmp="$(mktemp -t weave-uninstall.XXXXXX)"
|
|
316
|
+
printf '%s\n' "$BASH_EXECUTION_STRING" >"$uninstall_self_tmp"
|
|
317
|
+
uninstall_self="$uninstall_self_tmp"
|
|
318
|
+
fi
|
|
319
|
+
removed=""
|
|
320
|
+
failed=""
|
|
321
|
+
for client in claude codex opencode pi copilot; do
|
|
322
|
+
child_status=0
|
|
323
|
+
WEAVE_UNINSTALL_ALL_CHILD=1 bash "$uninstall_self" "${uninstall_args[@]+"${uninstall_args[@]}"}" "--$client" || child_status=$?
|
|
324
|
+
case "$child_status" in
|
|
325
|
+
0) removed="${removed:+$removed, }$(client_label "$client")" ;;
|
|
326
|
+
3) ;;
|
|
327
|
+
*) failed="${failed:+$failed, }$(client_label "$client")" ;;
|
|
328
|
+
esac
|
|
329
|
+
done
|
|
330
|
+
[ -z "$uninstall_self_tmp" ] || rm -f "$uninstall_self_tmp"
|
|
331
|
+
printf '\n'
|
|
332
|
+
if [ -z "$removed" ] && [ -z "$failed" ]; then
|
|
333
|
+
info "Weave Router isn't configured for Claude Code, Codex, opencode, pi or Copilot CLI here (scope=$scope); nothing to remove."
|
|
334
|
+
fi
|
|
335
|
+
[ -z "$removed" ] || ok "Removed Weave Router from: $removed."
|
|
336
|
+
if [ -n "$failed" ]; then
|
|
337
|
+
err "Weave Router may still be routing: $failed. See the errors above."
|
|
338
|
+
exit 1
|
|
339
|
+
fi
|
|
340
|
+
exit 0
|
|
341
|
+
fi
|
|
342
|
+
|
|
343
|
+
if [ -z "${WEAVE_UNINSTALL_ALL_CHILD:-}" ] && { [ "$target" = "claude" ] || [ "$target" = "opencode" ] || [ "$target" = "pi" ] || [ "$target" = "copilot" ]; } && ! command -v jq >/dev/null 2>&1; then
|
|
265
344
|
err "jq is required for the $target uninstall path."
|
|
266
345
|
exit 1
|
|
267
346
|
fi
|
|
@@ -657,6 +736,7 @@ if [ "$target" = "opencode" ]; then
|
|
|
657
736
|
refuse_if_symlink "$opencode_dir"
|
|
658
737
|
fi
|
|
659
738
|
opencode_config_file="$opencode_dir/opencode.json"
|
|
739
|
+
skip_if_not_installed "$opencode_config_file" '"weave(-claude|-codex)?"' "$opencode_dir/.weave-parked.json"
|
|
660
740
|
opencode_parked="$opencode_dir/.weave-parked.json"
|
|
661
741
|
opencode_direct_model=""
|
|
662
742
|
refuse_if_symlink "$opencode_config_file"
|
|
@@ -786,6 +866,74 @@ EOF
|
|
|
786
866
|
exit 0
|
|
787
867
|
fi
|
|
788
868
|
|
|
869
|
+
# ---------- copilot uninstall path ----------
|
|
870
|
+
|
|
871
|
+
if [ "$target" = "copilot" ]; then
|
|
872
|
+
# Mirrors install.sh: user scope only; --dir is a throwaway COPILOT_HOME.
|
|
873
|
+
if [ -n "$install_dir" ]; then
|
|
874
|
+
install_dir="$(cd "$install_dir" 2>/dev/null && pwd || echo "$install_dir")"
|
|
875
|
+
copilot_dir="$install_dir/.copilot"
|
|
876
|
+
else
|
|
877
|
+
copilot_dir="${COPILOT_HOME:-$HOME/.copilot}"
|
|
878
|
+
fi
|
|
879
|
+
copilot_providers_file="$copilot_dir/providers.json"
|
|
880
|
+
copilot_settings_file="$copilot_dir/settings.json"
|
|
881
|
+
copilot_parked_file="$copilot_dir/.weave-parked.json"
|
|
882
|
+
for path in "$copilot_dir" "$copilot_providers_file" "$copilot_settings_file" "$copilot_parked_file"; do
|
|
883
|
+
refuse_if_symlink "$path"
|
|
884
|
+
done
|
|
885
|
+
skip_if_not_installed "$copilot_providers_file" '"name": *"weave"' "$copilot_parked_file"
|
|
886
|
+
|
|
887
|
+
if [ -f "$copilot_providers_file" ]; then
|
|
888
|
+
report_uninstall_event copilot \
|
|
889
|
+
"$(jq -r '[(.providers // [])[] | select(.name == "weave") | .baseUrl // empty][0] // empty' "$copilot_providers_file" 2>/dev/null | sed 's#/v1$##')" \
|
|
890
|
+
"$(jq -r '[(.providers // [])[] | select(.name == "weave") | .headers["X-Weave-Router-Key"] // empty][0] // empty' "$copilot_providers_file" 2>/dev/null)" || true
|
|
891
|
+
cleaned="$(jq '
|
|
892
|
+
.providers = [(.providers // [])[] | select(.name != "weave")]
|
|
893
|
+
| .models = [(.models // [])[] | select(.provider != "weave")]
|
|
894
|
+
' "$copilot_providers_file")"
|
|
895
|
+
if [ "$(printf '%s' "$cleaned" | jq '(.providers | length) + (.models | length) + (del(.providers, .models) | length)')" = "0" ]; then
|
|
896
|
+
rm -f "$copilot_providers_file"
|
|
897
|
+
ok "Removed empty $copilot_providers_file"
|
|
898
|
+
else
|
|
899
|
+
printf '%s\n' "$cleaned" >"$copilot_providers_file"
|
|
900
|
+
chmod 600 "$copilot_providers_file"
|
|
901
|
+
ok "Removed the weave provider from $copilot_providers_file"
|
|
902
|
+
fi
|
|
903
|
+
else
|
|
904
|
+
info "No Copilot CLI providers.json at $copilot_providers_file (already uninstalled?)"
|
|
905
|
+
fi
|
|
906
|
+
|
|
907
|
+
if [ -f "$copilot_settings_file" ]; then
|
|
908
|
+
direct_model=""
|
|
909
|
+
[ -f "$copilot_parked_file" ] && direct_model="$(jq -r '.direct_model // empty' "$copilot_parked_file" 2>/dev/null || true)"
|
|
910
|
+
cleaned="$(jq --arg direct "$direct_model" '
|
|
911
|
+
if ((.model // "") | startswith("weave/"))
|
|
912
|
+
then (if $direct != "" then .model = $direct else del(.model) end)
|
|
913
|
+
else . end
|
|
914
|
+
' "$copilot_settings_file")"
|
|
915
|
+
printf '%s\n' "$cleaned" >"$copilot_settings_file"
|
|
916
|
+
ok "Restored Copilot CLI default model in $copilot_settings_file${direct_model:+ ($direct_model)}"
|
|
917
|
+
fi
|
|
918
|
+
rm -f "$copilot_parked_file"
|
|
919
|
+
|
|
920
|
+
# Only remove skills that still carry our ownership marker.
|
|
921
|
+
if [ -d "$copilot_dir/skills" ] && [ ! -L "$copilot_dir/skills" ]; then
|
|
922
|
+
for skill_dir in "$copilot_dir"/skills/*/; do
|
|
923
|
+
[ -d "$skill_dir" ] || continue
|
|
924
|
+
skill_dir="${skill_dir%/}"
|
|
925
|
+
name="${skill_dir##*/}"
|
|
926
|
+
[ -L "$skill_dir" ] && continue
|
|
927
|
+
if [ ! -f "$skill_dir/SKILL.md" ] || [ -L "$skill_dir/SKILL.md" ]; then continue; fi
|
|
928
|
+
grep -Fq "<!-- weave-router managed $name skill -->" "$skill_dir/SKILL.md" || continue
|
|
929
|
+
rm -rf "$skill_dir"
|
|
930
|
+
done
|
|
931
|
+
rmdir "$copilot_dir/skills" 2>/dev/null || true
|
|
932
|
+
ok "Removed Weave Router Copilot skills"
|
|
933
|
+
fi
|
|
934
|
+
exit 0
|
|
935
|
+
fi
|
|
936
|
+
|
|
789
937
|
# ---------- pi uninstall path ----------
|
|
790
938
|
|
|
791
939
|
if [ "$target" = "pi" ]; then
|
|
@@ -837,6 +985,7 @@ if [ "$target" = "pi" ]; then
|
|
|
837
985
|
refuse_if_symlink "$pi_settings_file"
|
|
838
986
|
refuse_if_symlink "$pi_key_file"
|
|
839
987
|
|
|
988
|
+
skip_if_not_installed "$pi_models_file" '"weave"'
|
|
840
989
|
report_pi_uninstall_event "$pi_models_file" "$pi_key_file" || true
|
|
841
990
|
# models.json: drop provider.weave; remove the file if nothing else remains.
|
|
842
991
|
# Other providers/models the user added are preserved.
|
|
@@ -954,6 +1103,7 @@ if [ "$target" = "codex" ]; then
|
|
|
954
1103
|
# exits before strip_codex_block, so one symlinked helper left the config
|
|
955
1104
|
# wired to a router the uninstall had just been asked to remove.
|
|
956
1105
|
|
|
1106
|
+
skip_if_not_installed "$codex_config_file" 'model_providers.weave'
|
|
957
1107
|
report_codex_uninstall_event "$codex_config_file" || true
|
|
958
1108
|
if [ -f "$codex_config_file" ]; then
|
|
959
1109
|
strip_codex_block "$codex_config_file"
|
|
@@ -1147,6 +1297,8 @@ else
|
|
|
1147
1297
|
refuse_if_symlink "$statusline_ownership_file"
|
|
1148
1298
|
fi
|
|
1149
1299
|
|
|
1300
|
+
skip_if_not_installed "$settings_file" 'ANTHROPIC_BASE_URL|Weave Router|cc-statusline' \
|
|
1301
|
+
"$(dirname "$settings_file")/.weave-parked.json" "$(dirname "$settings_file")/.weave-context-window.json" "$statusline_file"
|
|
1150
1302
|
statusline_file_owned="false"
|
|
1151
1303
|
statusline_setting_owned="false"
|
|
1152
1304
|
context_state_file="$(dirname "$settings_file")/.weave-context-window.json"
|
|
@@ -1176,6 +1328,7 @@ fi
|
|
|
1176
1328
|
|
|
1177
1329
|
report_claude_uninstall_event || true
|
|
1178
1330
|
|
|
1331
|
+
|
|
1179
1332
|
if [ -f "$settings_file" ]; then
|
|
1180
1333
|
# Only remove keys we actually installed: scrub our env vars, and only
|
|
1181
1334
|
# delete `statusLine` / `apiKeyHelper` when they point at scripts this
|
|
@@ -1187,6 +1340,11 @@ if [ -f "$settings_file" ]; then
|
|
|
1187
1340
|
| (if (.env | length) == 0 then del(.env) else . end)
|
|
1188
1341
|
else . end
|
|
1189
1342
|
| (if $statusline_setting_owned == "true" then del(.statusLine) else . end)
|
|
1343
|
+
| (if (.hooks.UserPromptSubmit | type) == "array" then
|
|
1344
|
+
.hooks.UserPromptSubmit |= (map(if (.hooks | type) == "array" then .hooks |= map(select((.command // "" | tostring | test("cc-statusline\\.sh\"? --prompt-hook( |$)")) | not)) else . end) | map(select((.hooks | type) != "array" or (.hooks | length) > 0)))
|
|
1345
|
+
| (if (.hooks.UserPromptSubmit | length) == 0 then del(.hooks.UserPromptSubmit) else . end)
|
|
1346
|
+
| (if (.hooks | length) == 0 then del(.hooks) else . end)
|
|
1347
|
+
else . end)
|
|
1190
1348
|
| (if (.apiKeyHelper // "" | tostring | endswith("weave-key.sh"))
|
|
1191
1349
|
then del(.apiKeyHelper) else . end)
|
|
1192
1350
|
| (if ((.attribution.commit == "Co-Authored-By: Weave Router <router@weaveos.com>"
|