diff --git a/.ctxcap.json b/.ctxcap.json new file mode 100644 index 0000000000..7a9b30d518 --- /dev/null +++ b/.ctxcap.json @@ -0,0 +1,3 @@ +{ + "include": ["AGENTS.md", "CLAUDE.md", "**/AGENTS.md", "**/CLAUDE.md"] +} diff --git a/.github/workflows/ctxcap.yml b/.github/workflows/ctxcap.yml new file mode 100644 index 0000000000..4a25ccf0c2 --- /dev/null +++ b/.github/workflows/ctxcap.yml @@ -0,0 +1,42 @@ +name: context budget + +# AGENTS.md and CLAUDE.md are loaded by every harness working in this repo, so +# their token cost is part of the repo's interface. This measures the delta a PR +# introduces against the merge base and fails when it grows. Nested per-crate +# AGENTS.md files are included, because a harness working in rust/crates/api is +# given that one and not the root file. The committed ctxcap-baseline.json is +# what the comparison uses; update it in the same PR as an intended increase. +on: + pull_request: + branches: [main] + paths: + - '**/AGENTS.md' # root, rust/, rust/crates/*/, and src/ + - '**/CLAUDE.md' + - '.ctxcap.json' # which files are in scope + - 'ctxcap-baseline.json' # what a PR is measured against + - '.github/workflows/ctxcap.yml' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ctxcap-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + context-budget: + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + pull-requests: write + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + with: + fetch-depth: 0 + persist-credentials: false + - uses: Naeha-S/ctxcap@v1 + with: + fail-on: increase + stale: true diff --git a/ctxcap-baseline.json b/ctxcap-baseline.json new file mode 100644 index 0000000000..ae5dae31dd --- /dev/null +++ b/ctxcap-baseline.json @@ -0,0 +1,13 @@ +{ + "AGENTS.md": 1643, + "CLAUDE.md": 250, + "rust/AGENTS.md": 1005, + "rust/CLAUDE.md": 226, + "rust/crates/api/AGENTS.md": 762, + "rust/crates/commands/AGENTS.md": 819, + "rust/crates/plugins/AGENTS.md": 652, + "rust/crates/runtime/AGENTS.md": 983, + "rust/crates/rusty-claude-cli/AGENTS.md": 1034, + "rust/crates/tools/AGENTS.md": 836, + "src/AGENTS.md": 798 +}