mcpField
M
moon

moon

github.com/hyperb1iss開発780 回インストール39 週間前に更新
リポジトリ

moon について

moon は、複数言語のモノレポ向けリポジトリ管理・ビルドシステムです。開発チームが依存関係に基づくタスク実行、成果物のキャッシュ、ツールチェーン管理を行えます。

主な機能

  1. 01依存関係に基づくタスク実行
  2. 02ビルド成果物のキャッシュ
  3. 03ツールチェーンのバージョン管理
  4. 04プロジェクトと依存関係のグラフ生成
  5. 05影響を受けるプロジェクトの検出

活用シーン

  1. 01依存プロジェクトをまたぐテスト実行
  2. 02CI とローカルでの再ビルド削減
  3. 03モノレポ内の言語バージョン管理

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/hyperb1iss/moonrepo-skill --skill moon

インストール後、Claude Code で/moonを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

examples/
ci-workflow.yml
moon.yml
workspace.yml
references/
cli-reference.md
task-config.md
v2-migration.md
workspace-config.md

詳細

moon - ポリグロットモノレポのビルドシステム

moon は、ポリグロットモノレポ向けの、Rust ベースのリポジトリ管理、タスクオーケストレーション、ビルドシステムです。スマートキャッシュ、依存関係を考慮したタスク実行、統一されたツールチェーン管理を提供します。

moon v2 が利用可能になりました。 移行するには moon migrate v2 を実行してください。破壊的変更については references/v2-migration.md を参照してください。

moon を使う場面

  • 複数のプロジェクト/パッケージを含むモノレポの管理
  • 依存関係のあるプロジェクト間でのタスクのオーケストレーション
  • CI/ローカルビルドを高速化するためのビルド出力のキャッシュ
  • ツールチェーンのバージョン管理(Node.js、Rust、Python、Go など)
  • プロジェクトグラフとアクショングラフの生成

クイックリファレンス

主なコマンド
moon run <target>          # Run task(s)
moon run :lint             # Run in all projects
moon run '#tag:test'       # Run by tag
moon ci                    # CI-optimized execution
moon check --all           # Run all build/test tasks
moon query projects        # List projects
moon project-graph         # Visualize dependencies
ターゲット構文
パターン説明
project:task特定のプロジェクトとタスク
:taskこのタスクを持つすべてのプロジェクト
#tag:taskタグを持つプロジェクト
^:task上流の依存関係(deps 内)
~:task現在のプロジェクト(configs 内)
設定ファイル
ファイル用途
.moon/workspace.ymlワークスペース設定、プロジェクトの検出
.moon/toolchains.yml言語のバージョン、パッケージマネージャー(v2)
.moon/tasks/*.ymlグローバルに継承されるタスク(v2)
moon.ymlプロジェクトレベルの設定とタスク

v2 に関する注意: .moon/toolchain.yml → .moon/toolchains.yml(複数形)、.moon/tasks.yml → .moon/tasks/*.yml

ワークスペース設定

# .moon/workspace.yml
$schema: "https://moonrepo.dev/schemas/workspace.json"

projects:
  - "apps/*"
  - "packages/*"

vcs:
  client: "git"
  defaultBranch: "main"

pipeline:
  archivableTargets:
    - ":build"
  cacheLifetime: "7 days"

プロジェクト設定

# moon.yml
$schema: "https://moonrepo.dev/schemas/project.json"

language: "typescript"
layer: "application" # v2: 'type' renamed to 'layer'
stack: "frontend"
tags: ["react", "graphql"]

dependsOn:
  - "shared-utils"
  - id: "api-client"
    scope: "production"

fileGroups:
  sources:
    - "src/**/*"
  tests:
    - "tests/**/*"

tasks:
  build:
    command: "vite build"
    inputs:
      - "@group(sources)"
    outputs:
      - "dist"
    deps:
      - "^:build"

  dev:
    command: "vite dev"
    preset: "server"

  # v2: Use 'script' for shell features (pipes, redirects)
  lint:
    script: "eslint . && prettier --check ."

  test:
    command: "vitest run"
    inputs:
      - "@group(sources)"
      - "@group(tests)"
レイヤーの種類(v2)
レイヤー説明
applicationアプリ、サービス
library共有可能なコード
toolCLI、スクリプト
automationE2E/統合テスト
scaffoldingテンプレート、ジェネレーター
configurationインフラ、設定

タスク設定

タスクのフィールド
フィールド説明
command実行するコマンド(文字列または配列)
args追加の引数
depsタスクの依存関係
inputsキャッシュのハッシュ計算対象となるファイル
outputsキャッシュするファイル
env環境変数
extends別のタスクから継承
presetserver または utility
タスクの継承

.moon/tasks/*.yml を介して、タスクをグローバルに継承できます。

# .moon/tasks/node.yml
inheritedBy:
  toolchains: ["javascript", "typescript"]

fileGroups:
  sources: ["src/**/*"]

tasks:
  lint:
    command: "eslint ."
    inputs: ["@group(sources)"]

プロジェクト側で継承を制御します。

# moon.yml
workspace:
  inheritedTasks:
    include: ["lint", "test"]
    exclude: ["deploy"]
    rename:
      buildApp: "build"
タスクのオプション
tasks:
  example:
    command: "cmd"
    options:
      cache: true # Enable caching
      runInCI: "affected" # affected, always, only, false
      persistent: true # Long-running process
      retryCount: 2 # Retry on failure
      timeout: 300 # Seconds
      mutex: "resource" # Exclusive lock
      priority: "high" # critical, high, normal, low
入力トークン
inputs:
  - "@group(sources)" # File group
  - "@globs(tests)" # Glob patterns
  - "/tsconfig.base.json" # Workspace root file
  - "$NODE_ENV" # Environment variable

ツールチェーン設定

# .moon/toolchains.yml (v2: plural)
$schema: "https://moonrepo.dev/schemas/toolchains.json"

# JavaScript ecosystem (v2: required for node/bun/deno)
javascript:
  packageManager: "pnpm"
  inferTasksFromScripts: false

node:
  version: "20.10.0"

pnpm:
  version: "8.12.0"

# Alternative runtimes
bun:
  version: "1.0.0"

deno:
  version: "1.40.0"

typescript:
  syncProjectReferences: true
  routeOutDirToCache: true

rust:
  version: "1.75.0"
  bins: ["cargo-nextest", "cargo-llvm-cov"]

go:
  version: "1.21.0"

python:
  version: "3.12.0"
ツールチェーンのティア
ティア説明例
3完全な管理Node.js、Bun、Deno、Rust、Go、Python
2エコシステムとの統合PHP、Ruby
1プロジェクトの分類Bash、Batch
0システムによる実行カスタムツール

CI との統合

# GitHub Actions
- uses: actions/checkout@v4
  with:
    fetch-depth: 0 # Required for affected detection

- uses: moonrepo/setup-toolchain@v0
  with:
    auto-install: true

- run: moon ci :build :test

- uses: moonrepo/run-report-action@v1
  if: success() || failure()
  with:
    access-token: ${{ secrets.GITHUB_TOKEN }}
マトリックスによる並列化
strategy:
  matrix:
    shard: [0, 1, 2, 3]

steps:
  - run: moon ci --job ${{ matrix.shard }} --job-total 4
影響を受けるプロジェクトの検出
moon run :test --affected             # Only affected projects
moon run :lint --affected --status staged  # Only staged files
moon ci :test --base origin/main      # Compare against base
moon query changed-files              # v2: renamed from touched-files

Docker のサポート

moon docker scaffold <project>     # Generate Docker layers
moon docker setup                  # Install toolchain in Docker
moon docker prune                  # Prune for production
moon docker file <project>         # Generate Dockerfile

Moon クエリ言語(MQL)

# Filter projects
moon query projects "language=typescript && projectType=library"
moon run :build --query "tag=react"

# Operators: =, !=, ~, !~, &&, ||
# Fields: project, language, stack, tag, task, taskType

参考資料

設定オプションの詳細については、以下を参照してください。

  • references/workspace-config.md - workspace.yml の完全なリファレンス
  • references/task-config.md - タスク設定と継承パターン
  • references/v2-migration.md - v1 から v2 への移行ガイド
  • references/cli-reference.md - CLI コマンドの完全なリファレンス
例
  • examples/workspace.yml - ワークスペースの完全な設定
  • examples/moon.yml - プロジェクトの完全な設定
  • examples/ci-workflow.yml - GitHub Actions の CI ワークフロー

コメント