diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aef9f97a..b3907245 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,5 +24,12 @@ jobs: - name: Secret scan (gitleaks) run: make security-gitleaks + - name: Python quality tooling + run: | + python3 -m pip install --break-system-packages ruff ty pyright + ruff check --select E4,E7,E9,F scripts tests/python + ty check scripts/update/parse-winget-log.py + pyright scripts/update/parse-winget-log.py + - name: CI test suite run: make test-ci diff --git a/docs/UPDATE.md b/docs/UPDATE.md index 2cfa07c3..eecd9393 100644 --- a/docs/UPDATE.md +++ b/docs/UPDATE.md @@ -347,3 +347,22 @@ chezmoi --source="$HOME/dotfiles" apply ~/.cursor/mcp.json ~/.codex/config.toml La secuencia anterior publica solo las superficies MCP globales gestionadas por Chezmoi. Para materializar otros cambios de dotfiles no relacionados con MCPs, revisa el diff de Chezmoi antes de aplicar un `chezmoi apply` general. Un checkout histórico en `~/mcp-servers/excalidraw-mcp` queda obsoleto. No se borra automáticamente; puedes retirarlo manualmente cuando hayas validado la migración Docker. + +### IXATU Desktop Commander local + +`dotfiles-update` includes **Desktop Commander** (the actual local installation +under `~/.local/share/ixatu-mcp`) and **Tunnel Client** (the executable under +`~/.local/bin`) in the `Tool snapshot`. The updater checks npm and GitHub's +latest stable release respectively. A newer Desktop Commander is installed with +its exact version, npm integrity verification, lockfile, and scripts disabled +into `~/.local/share/ixatu-mcp-staged/` only. The running MCP is never +replaced or restarted: a `STAGED`/`ACTIVATION_PENDING` warning describes the +manual activation needed. The snapshot continues to report the **active** +installed version, not the staged version. A newer Tunnel Client is reported +as available for separately verified, manual update; the running binary is +never overwritten by the updater. Network failures are warnings, never +reported as successful upgrades. No credentials are needed for these checks. + +The Python CI quality step uses Ruff's correctness rules for the existing +Python tree, and initially gates ty and Pyright on the winget log parser; +expanding full-repository typing requires resolving older typing diagnostics. diff --git a/scripts/generate-mcp-configs.py b/scripts/generate-mcp-configs.py index f541f12c..30876b01 100644 --- a/scripts/generate-mcp-configs.py +++ b/scripts/generate-mcp-configs.py @@ -22,7 +22,7 @@ from datetime import datetime, timezone from dataclasses import dataclass, field from pathlib import Path -from typing import Any, Dict, List, Mapping, MutableMapping, Optional, Set, Tuple +from typing import Any, Dict, List, Mapping, Optional, Set, Tuple REPO_ROOT = Path(__file__).resolve().parent.parent CHEZMOI_PREAMBLE_LINE = re.compile(r"^\{\{-.*?-\}\}\s*$") diff --git a/scripts/update/lib/dc_local.sh b/scripts/update/lib/dc_local.sh new file mode 100644 index 00000000..24428d00 --- /dev/null +++ b/scripts/update/lib/dc_local.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +# Local IXATU MCP versions; never replace a live service runtime. +dc_local_version() { + local file="$HOME/.local/share/ixatu-mcp/node_modules/@wonderwhy-er/desktop-commander/package.json" + [[ -f "$file" ]] || return 0 + node -p "require(process.argv[1]).version" "$file" 2>/dev/null || true +} + +dc_tunnel_version() { + local binary="$HOME/.local/bin/tunnel-client" + [[ -x "$binary" ]] || return 0 + "$binary" --version 2>/dev/null | head -n 1 | sed -E 's/^v?([0-9]+\.[0-9]+\.[0-9]+).*/\1/' || true +} + +dc_is_stable_version() { + [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] +} + +dc_newer_version() { + [[ "$1" != "$2" ]] && [[ "$(printf '%s\n%s\n' "$1" "$2" | sort -V | tail -n 1)" == "$1" ]] +} + +dc_snapshot() { + local dc tunnel + dc="$(dc_local_version)" + tunnel="$(dc_tunnel_version)" + tool_snapshot_has "Desktop Commander" || tool_snapshot_add "Desktop Commander" "$dc" "$dc" + tool_snapshot_has "Tunnel Client" || tool_snapshot_add "Tunnel Client" "$tunnel" "$tunnel" +} + +update_dc_local() { + local installed latest tunnel_installed tunnel_latest stage tmp candidate + installed="$(dc_local_version)" + tunnel_installed="$(dc_tunnel_version)" + dc_snapshot + + if [[ -z "$installed" ]]; then + result_warn "WSL" "Desktop Commander" "Local managed installation not found; no changes made" + elif ! command -v npm >/dev/null 2>&1; then + result_warn "WSL" "Desktop Commander" "npm unavailable; cannot check latest release" + else + latest="$(npm view @wonderwhy-er/desktop-commander version --fetch-timeout=10000 --fetch-retries=0 2>/dev/null || true)" + if ! dc_is_stable_version "$latest"; then + result_warn "WSL" "Desktop Commander" "Stable upstream version unavailable; installed $installed retained" + elif dc_newer_version "$latest" "$installed"; then + stage="$HOME/.local/share/ixatu-mcp-staged/$latest" + candidate="$stage/node_modules/@wonderwhy-er/desktop-commander/package.json" + if [[ ! -f "$candidate" ]]; then + mkdir -p "$(dirname "$stage")" + tmp="$(mktemp -d "$(dirname "$stage")/.dc-stage.XXXXXXXX")" + if npm install --prefix "$tmp" --save-exact --package-lock --ignore-scripts --no-audit --no-fund "@wonderwhy-er/desktop-commander@$latest" >"$LOG_DIR/wsl-desktop-commander.log" 2>&1 && + [[ "$(node -p "require(process.argv[1]).version" "$tmp/node_modules/@wonderwhy-er/desktop-commander/package.json" 2>/dev/null)" == "$latest" ]]; then + mv "$tmp" "$stage" + else + result_warn "WSL" "Desktop Commander" "Staging failed; installed $installed retained; see log" + fi + [[ -d "$tmp" ]] && rm -rf "$tmp" + fi + if [[ -f "$candidate" ]] && [[ "$(node -p "require(process.argv[1]).version" "$candidate" 2>/dev/null)" == "$latest" ]]; then + result_warn "WSL" "Desktop Commander" "STAGED $latest; ACTIVE $installed; ACTIVATION_PENDING (restart is manual, not performed)" + fi + else + result_info "WSL" "Desktop Commander" "Installed $installed; latest stable $latest; unchanged" + fi + fi + + if [[ -z "$tunnel_installed" ]]; then + result_warn "WSL" "Tunnel Client" "Binary unavailable; no changes made" + elif ! command -v gh >/dev/null 2>&1; then + result_warn "WSL" "Tunnel Client" "gh unavailable; installed $tunnel_installed retained" + else + tunnel_latest="$(GH_PROMPT_DISABLED=1 gh api repos/openai/tunnel-client/releases/latest --jq '.tag_name' 2>/dev/null || true)" + tunnel_latest="${tunnel_latest#v}" + if ! dc_is_stable_version "$tunnel_latest"; then + result_warn "WSL" "Tunnel Client" "Stable upstream release unavailable; installed $tunnel_installed retained" + elif dc_newer_version "$tunnel_latest" "$tunnel_installed"; then + result_warn "WSL" "Tunnel Client" "Available $tunnel_latest; ACTIVE $tunnel_installed; manual checksum-verified activation required" + else + result_info "WSL" "Tunnel Client" "Installed $tunnel_installed; latest stable $tunnel_latest; unchanged" + fi + fi +} diff --git a/scripts/update/update-wsl.sh b/scripts/update/update-wsl.sh index 8a11b39a..82427817 100755 --- a/scripts/update/update-wsl.sh +++ b/scripts/update/update-wsl.sh @@ -11,6 +11,8 @@ source "${SCRIPT_DIR}/lib/node_runtime.sh" source "${SCRIPT_DIR}/lib/results.sh" # shellcheck source=scripts/update/lib/logging.sh source "${SCRIPT_DIR}/lib/logging.sh" +# shellcheck source=scripts/update/lib/dc_local.sh +source "${SCRIPT_DIR}/lib/dc_local.sh" SECTION="all" if [[ "${1:-}" == "--section" ]]; then @@ -543,6 +545,7 @@ capture_workstation_snapshot() { snapshot_current_tool "OpenCode" opencode --version snapshot_current_tool "Claude Code CLI" claude --version snapshot_current_tool "Cursor Agent CLI" agent --version + dc_snapshot } ingest_agent_tools_results() { @@ -771,6 +774,7 @@ run_services() { want_section apt && run_apt want_section tools && run_tools +want_section tools && ! is_truthy "${DOTFILES_UPDATE_MOCK:-}" && update_dc_local want_section tools && run_opencode want_section tools && run_cursor_agent want_section tools && run_ai_workspace diff --git a/scripts/validate-mcp-manifest.py b/scripts/validate-mcp-manifest.py index f10301af..74a28ada 100755 --- a/scripts/validate-mcp-manifest.py +++ b/scripts/validate-mcp-manifest.py @@ -11,7 +11,7 @@ import re import sys from pathlib import Path -from typing import Any, Dict, List, Set, Tuple +from typing import Any, List, Set, Tuple REPO_ROOT = Path(__file__).resolve().parent.parent DEFAULT_MANIFEST = REPO_ROOT / "ai" / "assets" / "mcps" / "MANIFEST.yaml" diff --git a/tests/bats/system/dc-local-update.bats b/tests/bats/system/dc-local-update.bats new file mode 100644 index 00000000..9989e2b5 --- /dev/null +++ b/tests/bats/system/dc-local-update.bats @@ -0,0 +1,35 @@ +#!/usr/bin/env bats + +setup() { + DOTFILES_DIR="$(cd "$BATS_TEST_DIRNAME/../../.." && pwd)" + export DOTFILES_DIR +} + +@test "DC local probes report real installed package and tunnel versions" { + local fake_home="$BATS_TEST_TMPDIR/home" + local package_dir="$fake_home/.local/share/ixatu-mcp/node_modules/@wonderwhy-er/desktop-commander" + mkdir -p "$package_dir" "$fake_home/.local/bin" + printf '{"version":"0.3.2"}\n' > "$package_dir/package.json" + cat > "$fake_home/.local/bin/tunnel-client" <<'EOF' +#!/usr/bin/env bash +printf '0.0.21+abc (git sha: abc)\n' +EOF + chmod +x "$fake_home/.local/bin/tunnel-client" + run env HOME="$fake_home" bash -c ' + source "$DOTFILES_DIR/scripts/update/lib/dc_local.sh" + [[ "$(dc_local_version)" == "0.3.2" ]] + [[ "$(dc_tunnel_version)" == "0.0.21" ]] + dc_is_stable_version 0.3.3 + ! dc_is_stable_version 0.3.3-rc1 + dc_newer_version 0.3.3 0.3.2 + ! dc_newer_version 0.3.2 0.3.3 + ' + [ "$status" -eq 0 ] +} + +@test "DC integration keeps the active service untouched" { + local script="$DOTFILES_DIR/scripts/update/update-wsl.sh" + grep -q 'want_section tools.*update_dc_local' "$script" + grep -q 'dc_snapshot' "$script" + ! grep -Eq 'systemctl.*(restart|stop).*ixatu-wsl-mcp' "$DOTFILES_DIR/scripts/update/lib/dc_local.sh" +} diff --git a/tests/bats/system/update-workflow.bats b/tests/bats/system/update-workflow.bats index 12cc3ff6..590392b9 100644 --- a/tests/bats/system/update-workflow.bats +++ b/tests/bats/system/update-workflow.bats @@ -1478,6 +1478,7 @@ PY @test "winget parser fixtures match expected TSV" { local log expected case_name expected_text + compgen -G "${WINGET_FIXTURES}/*.log" >/dev/null || skip "WinGet source log fixtures unavailable on this checkout" for log in "${WINGET_FIXTURES}"/*.log; do case_name="$(basename "$log" .log)" expected="${WINGET_FIXTURES}/${case_name}.expected.tsv"