Skip to main content

mens

Agent framework with built-in tools, MCP integration, and CLI.

Install

pip install mens[all]

需要 Python 3.12+ 才能在 TUI 里显示图片(textual-image 的下界);3.10/3.11 上 图片降级成文本占位,其余功能不受影响。

本地开发

日常开发用 conda py12,它同时 editable 装了 mens 和 flexllm——改 flexllm 的代码 立刻在 mens 里生效,两个项目能联调(mens 的语音、多模态都依赖 flexllm 的新能力)。

conda activate py12
pip install -e ".[all,dev]"    # 只做一次
pytest -q                      # 500 passed

.venv(uv)只用于发版前验证,别拿它做日常开发:

uv sync && uv run pytest -q

两者测的不是同一件事:py12 里依赖是本地 editable 的,验证"我改的代码对不对";.venvuv.lock 装 PyPI 版本,验证"用户 pip install mens 拿到的组合能不能跑"—— flexllm>=0.9.0 这类下界是真是假,只有后者测得出来。CI(release.yml)跑的也是 uv。

代价是两套环境会漂移,而且症状是功能静默降级、不是报错:flexllm 本地加了新功能而 .venv 里还是 PyPI 旧版,两边版本号却一样。动手前先确认自己在哪个环境

python -c "import flexllm, mens; print(flexllm.__file__); print(mens.__file__)"
# 指向 ~/github/... = py12(可联调);指向 .venv/site-packages = 发布形态

Quick Start

from flexllm import LLMClient
from mens import AgentClient

llm = LLMClient(model="gpt-4o")
agent = AgentClient(llm)
result = await agent.run("读取 main.py 并分析")

CLI

mens run "查一下 cpu 使用率"          # 非交互执行(支持 stdin 管道)
mens run --tools code "读取 main.py"
mens chat                             # 交互式全屏 TUI
mens chat -c                          # 恢复最近会话
mens sessions list                    # 会话管理

程序 / AI Agent 调用

mens run 是给自动化用的入口:stdout 是结果、stderr 是过程,退出码表达成败。

mens info                                          # 自描述:工具/skill/退出码(JSON)
mens run "任务" --format json                       # 完整执行记录
mens run "任务" --format json || echo "失败: $?"    # 0 成功 / 2 参数错 / 5 未完成

跨调用多轮:--session <id> 新建会话、--resume <id> 续接(分开是为了让"撞上同名旧会话" 报错而不是静默接上陌生上下文)。

退出码与 JSON 字段的完整契约见 docs/agent-cli.md

给 Claude Code 等 AI agent 用时,先装 skill 让它一次拿到心智模型,不必逐层 --help 摸索:

mens install-skill        # → 软链到 ~/.claude/skills/mens/(重开会话后生效)

软链而非复制:升级 mens 后 skill 自动跟着更新,不必记得重装。

交互式 TUI(mens chat)

全屏终端界面:流式输出、工具调用卡片、斜杠命令(/help /clear /compact /model /resume …)、 Esc 中断当前任务、↑/↓ 输入历史、Tab @路径 补全(界面显示短路径,发给模型时展开成绝对路径)。

  • 权限:默认 default 模式(只读放行,写操作弹窗审批),Shift+Tab 随时轮转 default → acceptEdits → bypass(bypass = 不再询问);"总是允许"会把规则持久化到 .mens/settings.json(如 bash(git commit:*))。详见 docs/permissions.md
  • 会话:每轮自动持久化(flaxkv2),-c/--resume 或 TUI 内 /resume 恢复。详见 docs/sessions.md

完整文档见 docs/

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mens-0.1.5.tar.gz (461.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mens-0.1.5-py3-none-any.whl (161.8 kB view details)

Uploaded Python 3

File details

Details for the file mens-0.1.5.tar.gz.

File metadata

  • Download URL: mens-0.1.5.tar.gz
  • Upload date:
  • Size: 461.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mens-0.1.5.tar.gz
Algorithm Hash digest
SHA256 03dbff323725641ac76fbf3ccc0c3533f33e650836416baa48261bc08afb7c25
MD5 d4871bc7841d1426cb3be00c59a452b7
BLAKE2b-256 7d86134e994a6452e1ef09942245b9bd0818ea4cea2f37084615cef093dbb7dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for mens-0.1.5.tar.gz:

Publisher: release.yml on KenyonY/mens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mens-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: mens-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 161.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mens-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 42c97132f9534a541b06e0953f23ab22e22f81237de77e61e5592e34e0d96192
MD5 e70b31f65cac703ae487596cde340252
BLAKE2b-256 bc6339414b5d7c85ab46b47e07b11216256c935312a1b335b02f9d335cd0a255

See more details on using hashes here.

Provenance

The following attestation bundles were made for mens-0.1.5-py3-none-any.whl:

Publisher: release.yml on KenyonY/mens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page