-
Notifications
You must be signed in to change notification settings - Fork 884
Add AGENTS.md, code review guidelines, and architecture docs #9847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MostCromulent
wants to merge
3
commits into
Card-Forge:master
Choose a base branch
from
MostCromulent:agents
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+467
−0
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| # Forge - AI Coding Agent Configuration | ||
|
|
||
| ## Project Overview | ||
|
|
||
| Forge is an open-source, cross-platform Magic: The Gathering rules engine written in Java. Started in 2007, it provides a complete MTG game experience with AI opponents, multiple game modes, and network play support. | ||
|
|
||
| **License:** GPL-3.0 | **Repository:** https://github.com/Card-Forge/forge | ||
|
|
||
| Forge is maintained by a small group of part-time volunteers. Contributions should be well-documented, self-contained, and respectful of reviewer time: small PRs, minimal diffs, and clear descriptions. | ||
|
|
||
| ## Tech Stack | ||
|
|
||
| - **Language:** Java 17+ | **Build:** Maven 3.8.1+ | **Testing:** TestNG | ||
| - **GUI:** Java Swing (desktop), Libgdx (mobile) | ||
| - **Libraries:** Guava, JGraphT, Sentry | ||
|
|
||
| ## Project Structure | ||
|
|
||
| ``` | ||
| forge/ | ||
| ├── forge-core/ # Core engine: card definitions, utilities | ||
| ├── forge-game/ # Rules engine: combat, mana, zones, phases | ||
| ├── forge-ai/ # AI opponent: decision algorithms | ||
| ├── forge-gui/ # Shared GUI and resources (platform-neutral) | ||
| ├── forge-gui-desktop/ # Desktop GUI (Swing) | ||
| ├── forge-gui-mobile/ # Mobile GUI (Libgdx) | ||
| ├── forge-gui-android/ # Android backend (Libgdx) | ||
| ├── forge-gui-ios/ # iOS backend (Libgdx) | ||
| └── docs/ # Project documentation | ||
| └── Development/ | ||
| ├── Guidelines.md # Code review guidelines | ||
| └── Architecture.md # GUI and network architecture reference | ||
| ``` | ||
|
|
||
| For detailed architecture documentation (GUI hierarchy, layer responsibilities, network infrastructure), see [docs/Development/Architecture.md](docs/Development/Architecture.md). | ||
|
|
||
| **Card scripting:** Card definitions use a text-based scripting DSL and live in `forge-gui/res/cardsfolder/`. See the [Card Scripting API](https://github.com/Card-Forge/forge/wiki/Card-scripting-API) wiki for reference. | ||
|
|
||
| ## Before Making Changes | ||
|
|
||
| You MUST read and follow these documents before writing or planning code: | ||
|
|
||
| - **[docs/Development/Guidelines.md](docs/Development/Guidelines.md)** — Code review guidelines distilled from PR feedback. These are the most common cause of PR rejection when violated. Covers general principles, code style, architecture rules, network patterns, and testing requirements. | ||
| - **[docs/Development/Architecture.md](docs/Development/Architecture.md)** — GUI inheritance hierarchy, layer responsibilities, and network infrastructure. Read before modifying any GUI or network code. | ||
|
|
||
| Do not treat these as optional reference material. Review the relevant sections before designing an approach, and verify your implementation against them before submitting. | ||
|
|
||
| ## Build & Test Commands | ||
|
|
||
| ```bash | ||
| # Incremental build (default for iterative development) | ||
| mvn -pl forge-gui -am install -DskipTests | ||
|
|
||
| # Desktop build (for testing) | ||
| mvn -pl forge-gui-desktop -am install -DskipTests | ||
|
|
||
| # Quick compile check (fastest, syntax checking only) | ||
| mvn -pl forge-gui -am compile | ||
|
|
||
| # Compile a single module (fastest feedback loop) | ||
| mvn -pl forge-game compile | ||
|
|
||
| # Run a single test (IMPORTANT: use verify, not test) | ||
| mvn -pl forge-gui-desktop -am verify -Dtest="TestClassName#methodName" -Dsurefire.failIfNoSpecifiedTests=false | ||
|
|
||
| # Checkstyle (checks RedundantImport and UnusedImports only) | ||
| mvn checkstyle:check | ||
|
|
||
| # Install dependencies (also happens implicitly during compile/install) | ||
| mvn dependency:resolve | ||
|
|
||
| # Full distributable installer (Windows/Linux) | ||
| mvn -U -B clean -P windows-linux install -DskipTests | ||
|
|
||
| # Full distributable installer (Mac) | ||
| mvn -U -B clean -P osx install -DskipTests | ||
| ``` | ||
|
|
||
| **Key notes:** | ||
| - Always use incremental builds (`-pl forge-gui -am`) for development iteration. Full installer builds are slow. | ||
| - Use `-pl <module>` to scope commands to a single module for faster feedback. | ||
| - Use `verify` (not `test`) when running individual tests. | ||
| - Desktop GUI tests require a display. CI uses Xvfb for headless testing. | ||
|
|
||
| ## CI Environment | ||
|
|
||
| **Workflow:** `.github/workflows/test-build.yaml` runs on `ubuntu-latest` with Java 17 and 21 (Temurin), Xvfb virtual framebuffer, on every push and pull request. | ||
|
|
||
| **CI command:** `mvn -U -B clean test` | ||
|
|
||
| **What CI checks:** | ||
| - Unit tests (`testDeckLoaderHasPrecons`, `testGameResultInitialization`, `testConfigurationParsing`, etc.) | ||
| - Checkstyle: `RedundantImport` and `UnusedImports` only (see `checkstyle.xml`) | ||
|
|
||
| **Note:** Fork PRs require maintainer approval before CI workflows run. This is a GitHub Actions security feature, not a test failure. | ||
|
|
||
| ## Development Principles | ||
|
|
||
| These are the most critical principles. See [docs/Development/Guidelines.md](docs/Development/Guidelines.md) for the complete set. | ||
|
|
||
| 1. **Ask clarifying questions before starting work.** When a task has ambiguities in scope, approach, or trade-offs, surface options and let the maintainers decide before proceeding. | ||
| 2. **Search for existing code before creating new functionality.** Before implementing, search the codebase for existing mechanisms that solve the same or similar problem. Enhance existing code rather than creating parallel implementations. | ||
| 3. **Avoid over-engineering.** Solve the problem with the simplest approach that works. Don't introduce new classes, event types, or abstractions when existing infrastructure can be reused. Prefer modifying 3 files over creating 10 new ones. | ||
| 4. **Prototype the minimal version.** Before building new infrastructure, ask: "Can this be done by composing existing methods with a few lines at the call site?" If yes, do that. | ||
| 5. **Read code before modifying it.** Understand existing code before suggesting changes. Search for all callers of a method before changing its behavior. | ||
| 6. **Trace execution contexts.** Before implementing, enumerate the runtime contexts where the affected code will execute: local single-player, local multiplayer, network host, network client, AI opponent. Verify the change is appropriate in each. | ||
| 7. **Minimal diff.** Prefer small, focused changes. Do not make cosmetic fixes (whitespace, formatting, style) to code that isn't otherwise being changed for functional reasons. | ||
|
|
||
| ## Code Review Guidelines | ||
|
|
||
| See [docs/Development/Guidelines.md](docs/Development/Guidelines.md) for the complete code review guidelines. These are distilled from PR reviewer feedback and cover general principles, code style, architecture rules, network-specific patterns, and testing requirements. Following them avoids the most common causes of PR rejection. | ||
|
|
||
| ## Git Conventions | ||
|
|
||
| - Do not commit files listed in `.gitignore`. | ||
| - Write focused commits with clear, descriptive messages. | ||
| - Fork PRs require maintainer approval before CI workflows run. This is a GitHub Actions security feature, not a test failure. | ||
|
|
||
| ## Further Reading | ||
|
|
||
| - **[docs/Development/Guidelines.md](docs/Development/Guidelines.md)** - Complete code review guidelines distilled from PR feedback | ||
| - **[docs/Development/Architecture.md](docs/Development/Architecture.md)** - GUI hierarchy, layer responsibilities, and network architecture | ||
| - **[CONTRIBUTING.md](CONTRIBUTING.md)** - Contributor setup guide (IDE, SDK, platform builds) | ||
| - **[Card Scripting API](https://github.com/Card-Forge/forge/wiki/Card-scripting-API)** - Card scripting reference |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.