Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

pygenius-ai

Latest version: v0.3.25

Overview

Last scanned
23 Nov 2026
Published
23 Nov 2026
PyPI package Publisher: zhuao9
29 Versions
3.5K Downloads

Scan summary

pygenius-ai was last scanned on 23 Nov 2026 at version 0.3.25. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 29 versions; the latest 2 were published within 6 days (18–23 Nov 2026).
  • Findings: No rules fired in version 0.3.25.
  • Downloads: 3,528 downloads.

Versions

29 versions published
Versions and the rules that fired in each
VersionPublishedStatus
0.3.25 LATEST 23 Nov 2026 No rules fired
0.3.24 18 Nov 2026 No rules fired
0.3.23 11 Nov 2026 No rules fired
0.3.22 6 Nov 2026 Not shown
0.3.21 6 Nov 2026 Not shown

No rules fired in 0.3.25

Findings

Findings for v0.3.25. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 0.3.25; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

PyGenius

Production-grade Python code generation system with AST-aware context, layered defense, multi-agent orchestration, and pluggable LLM providers.

状态

Coverage E2E Score Ruff Python

设计原则

  1. AST 先行 — 用 ast 模块做精准上下文提取,绝不全文塞入 LLM
  2. 分层防线 — Ruff → pyright → mypy → pytest,快速反馈优先
  3. Plan 驱动 — Python 约定强,先规划再执行
  4. 异步感知 — Python 异步生态有坑,记忆必须沉淀经验
  5. 沙箱隔离 — 代码执行必须在 Docker 内
  6. 版本锁定 — 所有依赖 == 指定版本
  7. 测试即验证 — Debug 优先跑测试,不靠肉眼看
  8. 渐进上下文 — L1 签名 → L2 依赖链 → L3 全文,按需加载
  9. Provider 无关 — LLM 调用走抽象层,OpenAI/DeepSeek/Mock 都能插

项目结构

pygenius/
├── pyproject.toml                  # 项目配置 + ruff/mypy 规则
├── README.md
├── sandbox/Dockerfile              # Docker 沙箱镜像
├── examples/
│   └── demo_mock.py                # 端到端 demo(无需 API key)
├── src/pygenius/
│   ├── main.py                     # CLI 入口 (click)
│   ├── llm/                        # 🆕 LLM Provider 抽象层
│   │   ├── base.py                 #   LLMProvider 抽象类 + 数据模型
│   │   ├── mock.py                 #   MockLLMProvider(测试用)
│   │   ├── openai_provider.py      #   OpenAI 兼容后端
│   │   └── router.py               #   🆕 LLMRouter 多 provider 路由
│   ├── agents/                     # 多智能体
│   │   ├── base.py                 #   基类
│   │   ├── planner.py              #   Plan-and-Solve 架构师
│   │   ├── coder.py                #   ReAct 码农循环(LLM 驱动)
│   │   └── reviewer.py             #   Reflection 审查专家
│   ├── orchestrator/
│   │   └── orchestrator.py         # 协调器(项目经理)
│   ├── context/                    # AST 上下文
│   │   ├── extractor.py            #   L1/L2/L3 提取 + 缓存
│   │   ├── dependency.py           #   跨模块依赖图
│   │   └── assembler.py            #   上下文组装(预算+降级)
│   ├── memory/                     # 三层记忆
│   │   ├── short_term.py           #   会话记忆 + 反思触发
│   │   ├── long_term.py            #   持久记忆(TTL+冲突)
│   │   └── vector.py               #   向量记忆(ChromaDB)
│   ├── budget/                     # Token 预算
│   │   └── token_budget.py         #   全局+任务+Agent 三层限额
│   ├── events/
│   │   └── event_bus.py            # 事件总线(观察者模式)
│   ├── sandbox/
│   │   └── docker_sandbox.py       # Docker 沙箱
│   ├── tools/                      # 工具链
│   │   ├── file_ops.py             #   文件操作(路径穿越防护)
│   │   ├── command.py              #   命令执行(白名单)
│   │   ├── linter.py               #   ruff→pyright→mypy 分层
│   │   ├── tester.py               #   pytest + coverage
│   │   ├── quality_checker.py      #   AST 代码质量检查 🆕
│   │   ├── package_manager.py      #   pip/uv 安装 + pip-audit
│   │   ├── ast_engine.py           #   AST 分析工具
│   │   ├── git_ops.py              #   Git 操作
│   │   ├── security.py             #   命令分类 + 密钥扫描
│   │   └── registry.py             #   工具注册中心
│   ├── config/settings.py          # pydantic-settings 配置
│   └── models/                     # Pydantic 数据模型
│       ├── messages.py             #   Agent 消息
│       ├── tasks.py                #   任务模型
│       └── context.py              #   上下文模型
└── tests/                          # 1116 个测试
    ├── conftest.py
    ├── test_llm.py                 # 🆕 LLM provider 测试 (18)
    ├── test_coder.py               # 🆕 Coder ReAct 测试 (25)
    ├── test_coder_robustness.py    # 🆕 Coder 鲁棒性测试 (41)
    ├── test_coder_actions.py       # 🆕 Coder 动作执行测试 (15)
    ├── test_reviewer.py            # 🆕 Reviewer 测试 (10)
    ├── test_reviewer_quality.py    # 🆕 Reviewer 质量检查测试 (10)
    ├── test_orchestrator.py        # 🆕 Orchestrator 测试 (9)
    ├── test_orchestrator_edge_cases.py # 🆕 Orchestrator 边界测试 (14)
    ├── test_dependency.py          # 🆕 依赖图测试 (6)
    ├── test_dependency_comprehensive.py # 🆕 依赖图全面测试 (24)
    ├── test_command.py             # 🆕 命令执行测试 (13)
    ├── test_command_edge_cases.py  # 🆕 命令执行边界测试 (7)
    ├── test_linter.py              # 🆕 Linter 测试 (9)
    ├── test_linter_comprehensive.py # 🆕 Linter 解析边界测试 (12)
    ├── test_linter_edge_cases.py   # 🆕 Linter 边界测试 (5)
    ├── test_linter_fallback.py     # 🆕 Linter fallback 测试 (3)
    ├── test_linter_resolution.py   # 🆕 Linter 命令解析测试 (12)
    ├── test_tester.py              # 🆕 TestRunner 测试 (7)
    ├── test_tester_comprehensive.py # 🆕 TestRunner 全面测试 (8)
    ├── test_config.py              # 🆕 配置测试 (8)
    ├── test_ast_engine.py          # AST 引擎 (10)
    ├── test_ast_engine_comprehensive.py # 🆕 AST 引擎异常测试 (13)
    ├── test_ast_engine_edge_cases.py # 🆕 AST 引擎边界测试 (2)
    ├── test_context.py             # 上下文组装 (5)
    ├── test_assembler_comprehensive.py # 🆕 上下文组装全面测试 (19)
    ├── test_context_comprehensive.py # 🆕 上下文模块全面测试 (36)
    ├── test_tools.py               # 文件/安全 (15)
    ├── test_file_ops_comprehensive.py # 🆕 文件操作全面测试 (10)
    ├── test_memory.py              # 记忆系统 (12)
    ├── test_short_term_comprehensive.py # 🆕 STM 全面测试 (11)
    ├── test_long_term_comprehensive.py # 🆕 LTM 全面测试 (63,含去重/衰减/压实)
    ├── test_budget.py              # Token 预算 (7)
    ├── test_agents.py              # Planner/Plan (8)
    ├── test_base_agent.py          # 🆕 BaseAgent 基础设施测试 (11)
    ├── test_planner_comprehensive.py # 🆕 Planner 全面测试 (52)
    ├── test_events.py              # 事件总线 (5)
    ├── test_quality_checker.py     # 🆕 代码质量检查测试 (24)
    ├── test_codegen_mock_expansion.py # 🆕 多项目类型测试 (26)
    ├── test_main_helpers.py        # 🆕 CLI helper 全面测试 (27)
    ├── test_llm_base_helpers.py    # 🆕 LLM base + FakeClock 测试 (6)
    ├── test_llm_mock_extras.py     # 🆕 MockLLMProvider 扩展测试 (3)
    ├── test_vector_memory.py       # 🆕 向量记忆测试 (19)
    ├── test_openai_provider_extras.py # 🆕 OpenAI provider retry+embed 测试 (12)
    ├── test_git_ops_safety.py      # 🆕 Git hard_reset 安全测试 (3)
    ├── test_quality_checker_edge_cases.py # 🆕 质量检查边界测试 (6)
    ├── test_docker_sandbox_mocked.py # 🆕 Docker sandbox mock 测试 (25)
    ├── test_assembler_edge_cases.py # 🆕 上下文组装边界测试 (7)
    ├── test_command_docker_mocked.py # 🆕 Command Docker mock 测试 (10)
    ├── test_coder_parse_edge_cases.py # 🆕 Coder 解析边界测试 (9)
    ├── test_multi_turn_interaction.py # 🆕 多轮交互端到端测试 (5)
    ├── test_cli_callback_interaction.py # 🆕 CLI 回调交互测试 (7)
    ├── test_orchestrator_multi_turn.py # 🆕 Orchestrator 多轮路径测试 (4)
    ├── test_main_verbose.py           # 🆕 CLI verbose traceback 测试 (7)
    ├── test_parallelism_report.py     # 🆕 冲突可视化报告测试 (27)
    ├── test_ltm_maintenance.py        # 🆕 LTM 自动维护钩子测试 (17)
    ├── test_ltm_maintenance_surface.py # 🆕 LTM 维护表面接线测试 (19)
    ├── test_packaging.py              # 🆕 打包发布测试 (12)
    ├── test_assembler_remaining.py    # 🆕 上下文组装剩余分支测试 (2)
    ├── test_tool_calling.py           # 🆕 原生 tool calling 测试 (30)
    ├── test_openai_streaming.py       # 🆕 OpenAI streaming SSE 测试 (7)
    ├── test_openai_provider.py        # 🆕 OpenAI chat/embed/retry 测试 (30)
    ├── test_search_replace.py          # 🆕 search_replace 工具测试 (19)
    └── test_web_ops.py                # 🆕 web_search/fetch_url 工具测试 (37)

快速开始

运行测试
# 安装
python -m venv .venv
.venv/bin/pip install -e ".[dev]"

# 跑测试
.venv/bin/python -m pytest tests/ -v

# 跑覆盖率
.venv/bin/python -m pytest tests/ --cov=pygenius --cov-report=term

# 代码检查
.venv/bin/ruff check src/ tests/
.venv/bin/ruff format src/ tests/
端到端 Demo
# 无需 API key — 用 MockLLMProvider 跑通完整流程
.venv/bin/python examples/demo_mock.py

输出示例:

📋 === Step 1: Planning ===
   Project: user
   Tech stack: {'framework': 'FastAPI', 'database': 'PostgreSQL'}
   Subtasks: 7

🔧 === Step 2: Execute T1 (Initialize project) ===
   Status: completed
   Iterations: 2
   ✅ Created: pyproject.toml

🔍 === Step 3: Review ===
   Approved: True ✅
   Score: 100.0

📊 === Step 4: Final Status ===
   Tokens used: 14,424 / 500,000
   LLM calls: 3
   ReAct steps: 2
接入真实 LLM
from pygenius.llm.openai_provider import OpenAICompatibleProvider
from pygenius.orchestrator.orchestrator import Orchestrator
import os

# DeepSeek
provider = OpenAICompatibleProvider(
    api_key=os.environ["DEEPSEEK_API_KEY"],
    base_url="https://api.deepseek.com/v1",
    default_model="deepseek-chat",
)

orch = Orchestrator(project_dir="./my_project", llm=provider)
result = orch.execute("Create a FastAPI REST API for a todo app")

LLM Provider 抽象

所有 Agent 通过 LLMProvider 接口调用 LLM,可插拔:

Provider 用途 网络
MockLLMProvider 测试、demo、CI 否
OpenAICompatibleProvider 生产环境(OpenAI / DeepSeek / Together / vLLM / Ollama) 是
LLMRouter 🆕 多 provider 路由 + 自动 fallback + 成本统计 取决于子 provider

Mock provider 支持:

  • Scripted — 按顺序返回预设响应
  • Rule-based — 子串匹配返回响应
  • Regex — 正则匹配返回响应
  • fail_after — N 次后失败(重试测试)
  • call_log — 完整调用记录(断言用)
LLMRouter 多 provider 路由

按任务复杂度自动分流到不同模型,降低成本同时维持质量:

from pygenius.llm import LLMRouter, OpenAICompatibleProvider

strong = OpenAICompatibleProvider(default_model="gpt-4o")          # 规划/重构
balanced = OpenAICompatibleProvider(default_model="gpt-4o-mini")  # 日常编码
fast = OpenAICompatibleProvider(default_model="gpt-4o-nano")     # 简单编辑

router = LLMRouter(
    strong=strong,
    balanced=balanced,
    fast=fast,
    enable_fallback=True,  # 主 provider 失败自动切换
)

orch = Orchestrator(project_dir="./my_project", llm=router)

路由策略(基于关键词分类复杂度):

  • high(architect/design/refactor/security/performance/...)→ strong
  • medium(默认编码任务)→ balanced
  • low(rename/typo/format/comment/...)→ fast
  • tool calling → 必须用 strong/balanced(fast 不支持)

特性:

  • 自动 fallback:primary 失败 → 备用 provider 接管
  • 成本统计:每个 provider 单独累计 calls/failures/tokens
  • route() 方法可预测路由决策(不调用 LLM)
  • 透明:实现 LLMProvider 接口,agents 无感知

三层记忆

层 实现 用途 持久化
短期 ShortTermMemory 当前会话的 AST 索引、错误日志、连续失败计数 否
长期 LongTermMemory 跨会话的最佳实践、bug 教训、版本陷阱 JSON 文件
向量 VectorMemory ChromaDB 语义检索历史代码模式 ChromaDB

长期记忆的特性:

  • TTL 和淘汰机制
  • 置信度评分 + 时间衰减(decay():每闲置一个半衰期置信度减半,低于阈值自动剪枝;human 来源免疫;get/search/合并刷新存活时钟)
  • 重复观察自动合并(add() 三级判定:精确重复 → 置信度强化合并;近似重复(Jaccard≥0.8 或包含率≥0.95,标点/大小写不敏感)→ 合并标签并集;version_scope 特化 → 旧条目弃用+新条目插入)——不再静默覆盖、不再堆积近似重复
  • merge_duplicates():存量库一次性压实(旧格式数据迁移)
  • 版本范围限定
  • 冲突检测(新条目自动 deprecate 旧条目)

Token 预算

防止失控烧钱:

  • 全局预算上限(默认 50 万 token)
  • 单任务上限(默认 5 万)
  • 单 Agent 上限(默认 20 万)
  • 按 task/agent/model 多维度追踪

Coder ReAct 引擎

Coder 是核心代码生成 agent,使用 ReAct 范式(Thought → Action → Observation 循环):

可用 Actions:

  • write_file — 创建/覆盖文件,写完自动跑 ruff format
  • edit_file — 精确替换文件中的文本片段
  • read_file — 读取已有文件内容(LLM 可主动探索项目)
  • list_dir — 列出目录内容(LLM 可了解项目结构)
  • run_linter — 调用 ruff / pyright / mypy 检查代码
  • run_tests — 运行 pytest 并解析结果
  • ask_user — LLM 在遇到歧义时主动向用户提问
  • done — 声明任务完成

健壮性设计:

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • pypi-releases pygenius-ai

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Vulnerability Insights

Compromised Claude Code extensions (versions 2.1.312 & 2.1.313) in Cursor try to install a backdoor

PolinRider Returns
Research

PolinRider Returns: Hijacked npm Packages Use Ethereum Blockchain to Conceal Malware Infrastructure

Ethersphere Hijacked With Crypto Stealing Malware (1)
npm

Ethersphere Hijacked With Crypto Stealing Malware Via Github & npm

Frame 2085668439 (1)
Group 1261154229