Skip to content

Commit f1d9a21

Browse files
committed
chore: optimize AI agent context and implement CI cost controls
- Modularize `AGENTS.md` by relocating detailed rules to the `.skills/` directory. - Add `scripts/sort-strings.py` and `strings-index.txt` to organize and index string resources. - Introduce CI cost control guidelines and a pre-commit `ai-guardrail.sh` to prevent binary and log leaks. - Expand `.copilotignore`, `.aiexclude`, and `.gitattributes` to reduce context window usage and indexing costs. - Establish `.agent_memory/session_context.md` for persistent task tracking and project state. - Update `SKILL.md` for code reviews with specific Git and PR hygiene requirements.
1 parent 92b8f0d commit f1d9a21

11 files changed

Lines changed: 2838 additions & 1324 deletions

File tree

.agent_memory/session_context.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Agent Session Context - Meshtastic Android
2+
3+
## Current Project State
4+
- **Token Mitigation (Phase 1-3):** COMPLETE.
5+
- **Ignore Rules:** Stricter `.copilotignore` and `.aiexclude` are active.
6+
- **Instruction Optimization:** `AGENTS.md` is modularized (~3KB base).
7+
- **Cleanup:** 1.5GB of stale build artifacts and logs purged.
8+
- **Guardrails:** Pre-commit AI guardrail script installed in `scripts/`. CI Cost Control skill active.
9+
10+
## Active Task History
11+
- **Task:** Mitigate astronomical Copilot token costs.
12+
- **Outcome:** Significantly reduced context tax by moving detailed rules to `.skills/` and ignoring binary/log artifacts.
13+
- **Next Steps:** None. Mitigation project finalized.
14+
15+
## Golden Context
16+
- Always check `.skills/compose-ui/strings-index.txt` before reading `strings.xml`.
17+
- Run `python3 scripts/sort-strings.py` after adding strings to keep the index and file organized.
18+
- Always check `gh run list` before pushing.
19+
- Pre-commit hook `scripts/ai-guardrail.sh` protects against binary leaks.

.aiexclude

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Standard AI exclusion list for Cursor, Windsurf, etc.
2+
# Mirroring .copilotignore for project-wide token discipline
3+
4+
# Build & Generated
5+
**/build/**
6+
.gradle/
7+
.kotlin/
8+
**/generated/**
9+
10+
# Agent Artifacts
11+
.agent_artifacts/
12+
.agent_refs/
13+
tmp/
14+
*.log
15+
16+
# Media & Binaries
17+
**/*.png
18+
**/*.jpg
19+
**/*.jpeg
20+
**/*.webp
21+
**/*.svg
22+
**/*.ico
23+
**/*.gif
24+
**/*.mp3
25+
**/*.wav
26+
**/*.ogg
27+
**/*.pdf
28+
**/*.ttf
29+
**/*.otf
30+
**/*.jar
31+
**/*.aar
32+
**/*.apk
33+
34+
# Resources (Indexing non-English strings is a token sink)
35+
**/values-*/strings.xml
36+
**/composeResources/**/values*/*.xml

.copilotignore

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,54 @@
1-
# Ignore build artifacts and generated files from Copilot indexing
1+
# Meshtastic Android - GitHub Copilot Ignore List
22
# This saves context window tokens and prevents Copilot from hallucinating off of minified code.
33

4-
# Build directories
4+
# ── Build & Generated ─────────────────────────────────────────────────────────
55
**/build/**
66
.gradle/
7-
.idea/
8-
9-
# Android generated files
7+
.kotlin/
108
**/generated/**
119
.cxx/
1210
.externalNativeBuild/
1311

14-
# Git history & worktrees
15-
.git/
16-
.worktrees/
17-
18-
# Protobuf (Prevents Copilot from suggesting raw protobuf byte buffers)
19-
core/proto/
20-
21-
# Environment and secrets
12+
# ── IDE & Environment ─────────────────────────────────────────────────────────
13+
.idea/
14+
.run/
15+
.claude/
16+
.gemini/
17+
.jdk
2218
local.properties
2319
secrets.properties
2420
*.jks
21+
.DS_Store
2522

26-
# Agent References (Prevents pollution of project space with external code)
23+
# ── Agent Artifacts (Large volumes of logs/images) ───────────────────────────
24+
.agent_artifacts/
25+
# Note: .agent_plans/ is NOT ignored to maintain implementation context.
2726
.agent_refs/
27+
tmp/
28+
*.log
29+
30+
# ── Binary Assets & Media ─────────────────────────────────────────────────────
31+
**/*.png
32+
**/*.jpg
33+
**/*.jpeg
34+
**/*.webp
35+
**/*.svg
36+
**/*.ico
37+
**/*.gif
38+
**/*.mp3
39+
**/*.wav
40+
**/*.ogg
41+
**/*.pdf
42+
**/*.ttf
43+
**/*.otf
44+
**/*.jar
45+
**/*.aar
46+
**/*.apk
47+
48+
# ── External & Submodules ─────────────────────────────────────────────────────
49+
core/proto/
50+
51+
# ── Resources ────────────────────────────────────────────────────────────────
52+
# Ignore translations (reduces churn and indexing tokens)
53+
**/values-*/strings.xml
54+
**/composeResources/**/values*/*.xml

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Mark resources as generated to reduce Copilot PR summary costs
2+
**/src/main/res/**/*.xml linguist-generated=true
3+
**/composeResources/**/*.xml linguist-generated=true
4+
**/strings.xml linguist-generated=true
5+
*.json linguist-generated=true
6+
7+
# Ensure assets are treated as binary
8+
*.png binary
9+
*.jpg binary
10+
*.webp binary
11+
*.mp3 binary
12+
*.wav binary
13+
*.ogg binary

.skills/ci-cost-control/SKILL.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Skill: CI Cost Control & Monitoring
2+
3+
## Description
4+
Guidelines for agents to minimize GitHub Actions compute waste and prevent redundant or failing CI runs.
5+
6+
## Rules
7+
8+
### 1. Check Before You Kick
9+
Before pushing code that triggers a CI workflow, you **MUST** check if a relevant run is already in progress:
10+
```bash
11+
gh run list --branch $(git branch --show-current) --limit 5
12+
```
13+
- If a run is pending/running for your current state, **DO NOT** push again unless you are fixing a specific CI failure.
14+
- Cancel redundant runs if your new push supersedes them: `gh run cancel <run_id>`.
15+
16+
### 2. Local First
17+
NEVER use CI as a "remote compiler."
18+
- You must run `./gradlew spotlessCheck detekt test` locally before pushing.
19+
- If local tests fail, CI **will** fail. Do not waste the tokens or the compute.
20+
21+
### 3. Modular CI Invocations
22+
When using the `/delegate` or autonomous PR tools, explicitly limit the scope of the CI check if the tool supports it. Avoid running the full multi-OS desktop matrix for a simple documentation fix.
23+
24+
## Monitoring
25+
Use `gh run view <run_id>` to inspect failures. Do not re-run a whole suite if only one shard failed due to a known flake; use `gh run rerun --failed`.

.skills/code-review/SKILL.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,8 @@ When reviewing code, meticulously verify the following categories. Flag any devi
6464
2. **Reference the Docs:** Cite `AGENTS.md` and project architecture playbooks to justify change requests (e.g., "Per AGENTS.md, `java.io.*` cannot be used in `commonMain`; please migrate to Okio").
6565
3. **Enforce Build Health:** Remind authors to run `./gradlew test allTests` locally to verify changes, especially since KMP `test` tasks are ambiguous.
6666
4. **Praise Good Patterns:** Acknowledge correct usage of complex architecture requirements, like proper Navigation 3 scene transitions or elegant `commonMain` helper extractions.
67+
68+
## Git & PR Hygiene Rules
69+
- **Commit Hygiene:** Squash fixup/polish/review-feedback commits before opening a PR. Each commit should represent a logical, self-contained unit of work — not a back-and-forth conversation.
70+
- **PR Descriptions:** Keep PR descriptions concise and scannable. State *what changed* and *why*, not a per-commit play-by-play. Use a short summary paragraph followed by a bullet list of changes. Avoid tables, headers-per-commit, or verbose breakdowns. Reference the `meshtastic/firmware` repo PRs for tone and style.
71+
- **PR Titles:** Use conventional commit format: `feat(scope):`, `fix(scope):`, `refactor(scope):`, `chore(scope):`. Keep titles under ~72 characters.

0 commit comments

Comments
 (0)