Skip to content

Python stdlib only, zero dependencies な local-cli #98

@satokaz

Description

@satokaz

https://github.com/lutelute/local-cli

  • Local-first AI coding agent CLI powered by Ollama (Python stdlib only, zero dependencies)

git clone して、python -m local_cli で改修しなくても Solaris でも動いた。が、ollama 依存なので fake-olama で LiteLLM へ流してみる。
ひとまず、お前 Solaris で動いてるけど、どうなん?って聞いた結果:

local-cli を走らせてみた

$ python -m local_cli
✓ Ollama: Connected (v0.5.0)
⚠ Model: Model 'qwen3:8b' not found. Available: openai.gpt-oss-120b, github_copilot/gpt-4.1, github_copilot/raptor-mini, github_copilot/gpt-5-mini, text-embedding-ada-002, text-embedding-3-small, text-embedding-3-small-inference, claude-sonnet-4.6
✓ Disk space: 188.9 GB free
local-cli v0.7.3 | model: qwen3:8b
Tools: bash, read, write, edit, glob, grep, web_fetch, ask_user, agent
Provider: ollama
Type /help for commands, /exit to quit.

You> /model claude-sonnet-4.6
Switched to model: claude-sonnet-4.6
You> hi
Hi there! How can I help you today? 😊
You> Soalris で動かすためのコードレビューをお願いします
もちろんです!Solaris 環境向けのコードレビューをお手伝いします。

レビューしたいコードを貼り付けていただくか、ファイルのパスを教えていただけますか?

また、以下の情報もあわせて教えていただけると、より的確なレビューができます:

  1. Solaris のバージョン (例: Solaris 10, Solaris 11 など)
  2. 使用言語 (C, C++, Shell, Python など)
  3. コンパイラ/ツール (Sun Studio, GCC など)
  4. 特に気になっている点 (移植性、パフォーマンス、セキュリティ など)

お気軽にどうぞ! 🙂
You> このレポジトリのコードです
リポジトリのパスを確認させてください!
Result: /export/home/opc/Gits/local-cli 合計 54 drwxr-xr-x 11 opc staff 18 3月 10 14:38 . drwxr-xr-x 15 opc staff 16 3月 10 14:41 .. drwxr-xr-x 3 opc staff 3 3月 10 14:38 .auto-claude drwxr-xr-x 3 o...
Result: ./.auto-claude/specs/007-extend-orchestration-feature-to-match-claude-code-/build-progress.txt ./.auto-claude/specs/007-extend-orchestration-feature-to-match-claude-code-/implementation_plan.json ./.c...
Result: """Cross-platform clipboard utility for local-cli. Provides clipboard write access using platform-native command-line tools: - macOS: pbcopy - Linux: xclip or xsel - Windows: clip Al...
Result: """Argument parsing and interactive REPL for local-cli. Provides :func:build_parser for CLI argument parsing using argparse, and :func:run_repl for the interactive read-eval-print loop. """ ...
Result: """Bash tool for executing shell commands. Runs shell commands via subprocess.run(), captures stdout and stderr, and integrates with the security module to block dangerous commands and sanitize t...
Result: """Security utilities for local-cli. Provides dangerous command detection, environment variable sanitization, Ollama host validation, and model name validation. """ import os import re from urllib.p...
Result: """Terminal spinner for visual feedback during long-running operations. Provides a threaded spinner that animates in the terminal while the main thread is blocked (e.g. waiting for LLM response or ex...
コードを一通り確認しました。Solaris 向けのレビューをまとめます。


Solaris 対応コードレビュー

🔴 Critical(動作しない可能性が高い)


1. clipboard.py — Solaris がサポートされていない

_CLIPBOARD_COMMANDS: dict[str, list[list[str]]] = {
    "Darwin": [["pbcopy"]],
    "Linux": [["xclip", ...], ["xsel", ...]],
    "Windows": [["clip"]],
}

platform.system() が Solaris では "SunOS" を返します。"Solaris" ではありません。そのため candidates = [] になり、クリップボードは常に unavailable 扱いになります。

修正案:

_CLIPBOARD_COMMANDS: dict[str, list[list[str]]] = {
    "Darwin": [["pbcopy"]],
    "Linux": [["xclip", "-selection", "clipboard"], ["xsel", "--clipboard", "--input"]],
    "SunOS": [["xclip", "-selection", "clipboard"], ["xsel", "--clipboard", "--input"]],  # 追加
    "Windows": [["clip"]],
}

2. system_info.py — Solaris の RAM 検出が未実装

elif system == "Linux":
    with open("/proc/meminfo") as f: ...

Solaris には /proc/meminfo が存在しません。Solaris で RAM を取得するには prtconf コマンドを使います。

修正案:

elif system == "SunOS":
    try:
        raw = subprocess.check_output(
            ["prtconf", "-m"], timeout=5,
        ).decode().strip()
        # 出力例: "Memory size: 8192 Megabytes"
        match = re.search(r"(\d+)", raw)
        if match:
            info["ram_gb"] = int(match.group(1)) // 1024
    except Exception:
        pass

3. cli.pyreadline モジュールが Solaris で利用できない場合がある

import readline  # noqa: F401 — imported for side-effect (line editing/history)

Solaris の Python ビルドによっては readline モジュールが含まれていません(GNU readline が別途必要)。ImportError でクラッシュします。

修正案:

try:
    import readline  # noqa: F401
except ImportError:
    pass  # Solaris 等で readline が使えなくても動作継続

4. spinner.py — Braille 文字が Solaris のターミナルで表示できない

_FRAMES = "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"

Solaris の旧来のターミナル(dtterm、xterm 等)や古い LANG 設定では UTF-8 の Braille 文字が文字化けします。

修正案:

import locale
if locale.getpreferredencoding(False).upper() in ("UTF-8", "UTF8"):
    _FRAMES = "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"
else:
    _FRAMES = "-\\|/"  # ASCII フォールバック

5. bash_tool.pybash がデフォルトパスにない

result = subprocess.run(
    ["bash", "-c", command],
    ...
)

Solaris では bash/usr/bin/bash ではなく /usr/local/bin/bash/opt/csw/bin/bash にインストールされている場合があります。PATH に含まれていなければ FileNotFoundError になります。

修正案:

import shutil
bash_path = shutil.which("bash") or "/usr/local/bin/bash"
result = subprocess.run([bash_path, "-c", command], ...)

🟡 Warning(動作するが問題が出る可能性)


6. scripts/local-cli.shdetect_os() が Solaris を未対応

detect_os() {
    case "$(uname -s)" in
        Darwin*)  printf 'macos' ;;
        Linux*)   printf 'linux' ;;
        *)        printf 'unknown' ;;  # ← Solaris (SunOS) はここに落ちる
    esac
}

Solaris は uname -sSunOS を返します。unknown になり Ollama の自動起動ができません。

修正案:

SunOS*)
    info "Starting Ollama via 'ollama serve'..."
    if command -v ollama >/dev/null 2>&1; then
        ollama serve >/dev/null 2>&1 &
    else
        error_exit "Ollama is not installed."
    fi
    ;;

7. scripts/install.sh{1..60} ブレース展開が /bin/sh (Solaris) で非対応

printf '=%.0s' {1..60}

Solaris の /bin/sh (旧来の Bourne shell) ではブレース展開がサポートされていません。ただし #!/usr/bin/env bash が指定されているので、bash が入っていれば問題ありませんが、動作前提として明示すべきです。


8. security.pyvalidate_ollama_host()"SunOS" は特に問題なし

これは URL バリデーションなので OS 非依存。問題なし ✅


9. Python バージョン要件 (pyproject.toml)

requires-python = ">=3.10"

Python 3.10+ の型アノテーション構文(list[str] | None など)を多用しています。Solaris にプリインストールされている Python は古い場合があるため、Python 3.10 以上が明示的にインストールされているか確認が必要です。


📋 修正サマリー

ファイル 問題 優先度
clipboard.py "SunOS" キーが未登録 🔴 High
system_info.py /proc/meminfo が存在しない 🔴 High
cli.py readline が ImportError になりうる 🔴 High
spinner.py Braille 文字が表示できない 🔴 High
bash_tool.py bash のパスが見つからない場合がある 🔴 High
scripts/local-cli.sh SunOSdetect_osunknown になる 🟡 Medium
scripts/install.sh Bourne sh との互換性 🟡 Medium

修正を実際に適用しましょうか?
You>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions