コミットするごとにテスト実行・ドキュメント生成・AGENTS.md の自動更新を行うパイプライン
Project description
agents-docs-sync
コミットごとに自動でテスト実行・ドキュメント生成・AGENTS.md 更新を行うパイプラインです。
Python とシェルスクリプトの組み合わせで構成され、CLI エントリポイント agents_docs_sync(pyproject.toml の [project.scripts] から提供)により以下の処理が実装されています。
-
テストとカバレッジ
pytest,pytest-covを使用し単体・統合テストを走らせ、結果は CI で利用できる形式(JUnit XML 等)へ出力。
-
ドキュメント生成
- Jinja2 テンプレートと Outline の組み合わせにより Markdown ドキュメントを構造化して作成。
docgen/models/agents.pyに定義された Pydantic モデル(ProjectOverview,AgentsConfigSection,AgentsGenerationConfig,AgentsDocument等)から設定情報とメタデータを取得し、テンプレートへ注入します。
-
AGENTS.md 自動更新
- コードベースに埋め込まれたエージェント定義(関数・クラスの docstring や
AgentsConfigによる宣言)を解析し、構造化データとしてまとめます。 - この情報は Jinja2 テンプレートで整形され、AGENTS.md が最新版へ差分更新されます。
- コードベースに埋め込まれたエージェント定義(関数・クラスの docstring や
-
アーキテクチャ図自動生成(LLM 不使用)
- プロジェクト構造とエージェント間の依存関係を静的解析し、Mermaid / PlantUML 用に描画指令を書き出します。
docgen内で実装された分析モジュールがhnswlib,sentence-transformers,torchを活用してクラス・メソッド間の類似性を判定し、視覚化可能な図にまとめます。
-
CLI とフック
# ヘルプ表示 agents_docs_sync --help # Git フックスクリプトをインストール(pre‑commit 等) agents_docs_sync hook install
hook installはリポジトリ内にシェルスクリプトを書き込み、コミット前または push 時点で自動実行されるよう設定します。
-
依存ライブラリ
- anthropic, openai(必要時 LLM 呼び出し)、httpx(API 通信)
- jinja2 (テンプレート)、outlines (ドキュメント生成ロジック)
- pydantic、pyyaml(設定ファイル解析)
- ruff(静的コードチェック)
-
CI / GitHub Actions
agents_docs_syncをジョブの一部として組み込み、プッシュ時に自動実行。テスト失敗やドキュメント差分がある場合はビルドを失敗させることで品質保証します。
-
設定ファイル構造
agents.yaml(または.yml) に全体のプロジェクト情報と各エージェント固有設定 (AgentsConfigSection,AgentsGenerationConfig) を記述。- YAML は Pydantic モデルでバリデートされ、型安全な構成管理が可能です。
このパイプラインにより、コード変更ごとのドキュメント整合性を保証しつつ、人手による更新作業の負担を大幅に削減します。
graph TB
%% Auto-generated architecture diagram
subgraph agents_docs_sync [fa:fa-python agents-docs-sync]
direction TB
subgraph docgen [docgen]
direction TB
docgen_collectors["collectors"]:::moduleStyle
subgraph docgen_utils [utils]
direction TB
docgen_utils_llm["llm"]:::moduleStyle
end
class docgen_utils moduleStyle
docgen_models["models"]:::moduleStyle
subgraph docgen_archgen [archgen]
direction TB
docgen_archgen_detectors["detectors"]:::moduleStyle
docgen_archgen_generators["generators"]:::moduleStyle
end
class docgen_archgen moduleStyle
docgen_detectors["detectors"]:::moduleStyle
subgraph docgen_generators [generators]
direction TB
docgen_generators_parsers["parsers"]:::moduleStyle
docgen_generators_mixins["mixins"]:::moduleStyle
end
class docgen_generators moduleStyle
subgraph docgen_rag [rag]
direction TB
docgen_rag_strategies["strategies"]:::moduleStyle
end
class docgen_rag moduleStyle
end
class docgen moduleStyle
end
docgen_collectors --> docgen_models
docgen_collectors --> docgen_utils
docgen_utils --> docgen_models
docgen_utils_llm --> docgen_models
docgen_archgen --> docgen_detectors
docgen_archgen --> docgen_generators
docgen_archgen --> docgen_models
docgen_archgen --> docgen_utils
docgen_archgen_detectors --> docgen_models
docgen_archgen_generators --> docgen_models
docgen_detectors --> docgen_utils
docgen_generators --> docgen_archgen
docgen_generators --> docgen_collectors
docgen_generators --> docgen_detectors
docgen_generators --> docgen_models
docgen_generators --> docgen_utils
docgen_generators_parsers --> docgen_detectors
docgen_generators_parsers --> docgen_models
docgen_generators_parsers --> docgen_utils
docgen_generators_mixins --> docgen_utils
docgen_rag --> docgen_utils
docgen_rag_strategies --> docgen_utils
classDef pythonStyle fill:#3776ab,stroke:#ffd43b,stroke-width:2px,color:#fff
classDef dockerStyle fill:#2496ed,stroke:#1d63ed,stroke-width:2px,color:#fff
classDef dbStyle fill:#336791,stroke:#6b9cd6,stroke-width:2px,color:#fff
classDef moduleStyle fill:#f9f9f9,stroke:#333,stroke-width:2px
Services
agents-docs-sync
- Type: python
- Description: コミットするごとにテスト実行・ドキュメント生成・AGENTS.md の自動更新を行うパイプライン
- Dependencies: anthropic, hnswlib, httpx, jinja2, openai, outlines, pydantic, pytest, pytest-cov, pytest-mock, pyyaml, ruff, sentence-transformers, torch
使用技術
- Python
- Shell
依存関係
- Python:
pyproject.tomlまたはrequirements.txtを参照
セットアップ
前提条件
- Python 3.12以上
インストール
Python
# uvを使用する場合
uv sync
LLM環境のセットアップ
APIを使用する場合
-
APIキーの取得と設定
- OpenAI APIキーを取得: https://platform.openai.com/api-keys
- 環境変数に設定:
export OPENAI_API_KEY=your-api-key-here
-
API使用時の注意事項
- APIレート制限に注意してください
- コスト管理のために使用量を監視してください
ローカルLLMを使用する場合
-
ローカルLLMのインストール
- Ollamaをインストール: https://ollama.ai/
- モデルをダウンロード:
ollama pull llama3 - サービスを起動:
ollama serve
-
ローカルLLM使用時の注意事項
- モデルが起動していることを確認してください
- ローカルリソース(メモリ、CPU)を監視してください
ビルドおよびテスト
ビルド
uv sync
uv build
uv run python3 docgen/docgen.py
テスト
uv run pytest tests/ -v --tb=short
コマンド
プロジェクトで利用可能なスクリプト:
| コマンド | 説明 |
|---|
| agents_docs_sync | 汎用ドキュメント自動生成システム |
agents_docs_sync のオプション
| オプション | 説明 |
|---|
| --config | 設定ファイルのパス |
| --detect-only | 言語検出のみ実行 |
| --no-api-doc | APIドキュメントを生成しない |
| --no-readme | READMEを更新しない |
| --build-index | RAGインデックスをビルド |
| --use-rag | RAGを使用してドキュメント生成 |
| --generate-arch | アーキテクチャ図を生成(Mermaid形式) |
| hook_name | フック名(指定しない場合は全て) |
| hook_name | フック名(指定しない場合は全て) |
| hook_name | 実行するフック名 |
| hook_args | フック引数 |
| --force | 既存ファイルを強制上書き |
このREADME.mdは自動生成されています。最終更新: 2025-12-02 19:07:04
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agents_docs_sync-0.1.4.tar.gz.
File metadata
- Download URL: agents_docs_sync-0.1.4.tar.gz
- Upload date:
- Size: 308.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fa59327106d8ea31ad1f1ecf9846f47cbaa3098e8b34e519c4a2752fe27f8a0
|
|
| MD5 |
8f4a7b939ede6c0e881e17cf6a1d061b
|
|
| BLAKE2b-256 |
2f59e5ca5242c41262f02ca1e1272873ac8d9798a8142b50bbe2ce79ae87f9ce
|
File details
Details for the file agents_docs_sync-0.1.4-py3-none-any.whl.
File metadata
- Download URL: agents_docs_sync-0.1.4-py3-none-any.whl
- Upload date:
- Size: 164.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8a77e4fc10469b15fe6970e93f6bb68472d5957db605725a5c32818b9d4d456
|
|
| MD5 |
cb23b2a9b97c80412688f3ae09efa874
|
|
| BLAKE2b-256 |
cb70769a80970b6566fb1cfb2ee97989cf531794e53ff4ead13962862daf4559
|