Skip to content
Apothem
架构

源码布局

Apothem 为何使用 src/ 布局,以及源码树如何组织。

Apothem 采用了 PyPA src-layout,将所有可导入的 Python 代码放在 src/apothem/ 下。

为什么采用 src-layout

  • 导入隔离。 只有当 src/ 位于路径上时(引擎以 PYTHONPATH=src python -m apothem 运行),import apothem 才能解析,从而防止从无关目录意外导入工作树。
  • 自包含运行时。 Apothem 直接从检出运行,其依赖 vendored 在 src/apothem/_vendor/ 下——无需任何安装步骤。src-layout 使该可导入表面与仓库的工具链、测试和脚本清晰分离。
  • 干净的分发。 同一布局产出格式良好的 sdist 和 wheel(以及可选的 pip install -e . 可编辑安装),其内容与实际发布的内容完全一致,不会混入任何游离的顶层模块。

源码树结构

src/apothem/
    agents/         persistent agent definitions (*.md)
    audit/          inventory and provenance tools
    benchmarks/     performance benchmarks
    cli/            Click CLI (top-level commands listed below the tree)
    commands/       slash command definitions (*.md)
    conformity/     mechanical gate checkers (*_grep.py)
    harnesses/      one sub-package per harness adapter (17 adapters)
    hooks/          hook dispatcher + message files
    lib/            shared Python library
    output-styles/  output-style definitions (*.md)
    rules/          behavioral rules (*.md)
    schemas/        YAML/JSON schemas
    skills/         reusable skill templates (folder/SKILL.md)
    statuslines/    status-line config (*.json)
    templates/      reusable template artifacts

CLI 命令

下面的列表由 Click 命令树生成。

The cli/ package registers 14 top-level commands:

可导入工件与配置工件

src/apothem/ 下的许多条目是 Markdown 配置工件,而不是 Python 模块。可导入的 Python 表面是:

  • src/apothem/cli/(作为 apothem 入口点暴露的 Click CLI)
  • src/apothem/harnesses/(17 个工具适配器子包)
  • src/apothem/lib/(共享库:配置档案、注册表、物化器、传播)
  • src/apothem/hooks/(dispatch.py、lib/)
  • src/apothem/conformity/(机械 grep 脚本)
  • src/apothem/audit/(清点脚本)
  • src/apothem/benchmarks/(性能基准驱动程序)

On this page