Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# AGENTS.md - WurstSetup / Grill Notes

This repo builds the Grill CLI and project setup tooling. The generated map-project agent notes live in `templates/AGENTS.md`; keep this root file focused on WurstSetup itself.

## Current Architecture

- Project config models come from `com.github.wurstscript:wurst-project-config`; do not reintroduce local DAO copies.
- Local helpers in `config/ProjectConfigModels.kt` should stay thin: typealiases plus immutable copy helpers for shared records.
- `YamlHelper.dumpProjectConfig` intentionally serializes a pruned YAML map instead of the shared records directly. This preserves the old user-facing `wurst.build` behavior by omitting null/default nested fields.
- `wbschema.json` should stay lenient and aligned with the shared config parser, especially for `scriptMode`, `wc3Patch`, and nullable legacy fields.

## WC3 Patch And Core JASS

- `CoreJassProvider.DEFAULT_PATCH` is `v2.0`.
- Core JASS is fetched from `wurstscript/jass-history`.
- Friendly patch targets must resolve through the shared parser / `Wc3PatchTarget` style rules:
- below `1.29` => pre-1.29 behavior and stdlib
- `1.29` through `1.31` => classic
- `1.32+`, `1.36`, `2.0`, and `Reforged-*` => Reforged
- Do not add alias hacks for broken jass-history folder names. Fix `wurstscript/jass-history` instead.
- Bundled core JASS fallbacks are patch-specific. Do not silently use the old `reforged` bundle as the `v2.0` fallback.
- Keep provenance in `_build/core-jass.properties`; mismatched cached `common.j` / `blizzard.j` should be refreshed.

## Generate Workflow

- `grill generate` should write a schema-valid minimal `wurst.build`.
- Keep `dependencies`, `scriptMode`, and `wc3Patch`.
- `buildMapData` should only seed known fields: `name`, `fileName`, and `author`. Do not emit nested default scaffolding like `scenarioData`, `optionsFlags`, `players: []`, `forces: []`, or `loadingScreen: null`.
- Generate supports `--wc3-path <dir>`. It should detect/show the Warcraft III client family and warn if it does not match the selected project patch target.
- The VS Code setting `wurst.wc3path` should only be written for a valid detected/selected WC3 folder.

## Install / Userdir

- Grill installs itself to `~/.wurst/grill-cli/grill.jar`.
- The Gradle task `make_for_userdir` must keep that jar refreshed for local testing.
- `remove wurstscript` must not delete the whole `~/.wurst` folder; it should remove compiler artifacts only and leave Grill/runtime state intact.
- Tests should not mutate the real user install. Use the `wurst.install.dir` system property override when testing installation/removal behavior.

## Compiler Interaction

- Build/typecheck should not require parsing the installed Warcraft executable when `wc3Patch` is pinned.
- Run/launch is different: the selected WC3 executable controls launch arguments. If the client family and project patch target differ, warn and allow choosing another WC3 folder.
- Keep compiler-facing patch behavior tested in the WurstScript repo as well; Grill and compiler can diverge if only one side is tested.

## Test Commands

Run the full WurstSetup suite before publishing:

```bash
./gradlew test
```

Useful focused checks:

```bash
./gradlew test --tests GenerateTests --tests YamlHelperTests --tests Wc3ClientDetectorTests
./gradlew test --tests CMDTests.testUnInstallCmd
./gradlew make_for_userdir
```

`git diff --check` should be clean apart from Windows CRLF warnings.
20 changes: 20 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'
implementation 'com.github.wurstscript:wurst-project-config:2c7ccd1a5f'
implementation 'com.github.Frotty:SimpleRegistry:f96dda96bd'
implementation 'org.jline:jline:3.30.13'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.17'
Expand Down Expand Up @@ -135,6 +136,25 @@ dist.dependsOn versionInfoFile

dist.archiveFileName = "WurstSetup.jar"

def fatJar = dist.archiveFile.map { it.asFile }
def wurstUserDir = "${System.properties['user.home']}/.wurst"
def grillCliDir = "${wurstUserDir}/grill-cli"

tasks.register('delete_legacy_userdir_grill_jar', Delete) {
delete "${wurstUserDir}/WurstSetup.jar"
}

tasks.register('make_for_userdir', Copy) {
dependsOn 'dist', 'delete_legacy_userdir_grill_jar'
from fatJar
into grillCliDir
rename { 'grill.jar' }
}

tasks.register('make_for_userdir_grill_cli') {
dependsOn 'make_for_userdir'
}

task copy_jar(type: Copy) {
mkdir("downloads/")
from 'build/libs/'
Expand Down
130 changes: 0 additions & 130 deletions src/main/kotlin/config/DAOs.kt

This file was deleted.

45 changes: 45 additions & 0 deletions src/main/kotlin/config/ProjectConfigModels.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package config

const val CONFIG_FILE_NAME = "wurst.build"

typealias ScriptMode = org.wurstscript.projectconfig.ScriptMode
typealias Race = org.wurstscript.projectconfig.Race
typealias Controller = org.wurstscript.projectconfig.Controller
Comment thread
Frotty marked this conversation as resolved.
typealias WurstProjectConfigData = org.wurstscript.projectconfig.WurstProjectConfigData
typealias WurstProjectBuildMapData = org.wurstscript.projectconfig.WurstProjectBuildMapData
typealias WurstProjectBuildScenarioData = org.wurstscript.projectconfig.WurstProjectBuildScenarioData
typealias WurstProjectBuildLoadingScreenData = org.wurstscript.projectconfig.WurstProjectBuildLoadingScreenData
typealias WurstProjectBuildOptionFlagsData = org.wurstscript.projectconfig.WurstProjectBuildOptionFlagsData
typealias WurstProjectBuildPlayer = org.wurstscript.projectconfig.WurstProjectBuildPlayer
typealias WurstProjectBuildForce = org.wurstscript.projectconfig.WurstProjectBuildForce
typealias WurstProjectBuildForceFlags = org.wurstscript.projectconfig.WurstProjectBuildForceFlags

fun newProjectConfig(
projectName: String = "unnamed",
dependencies: List<String> = emptyList(),
buildMapData: WurstProjectBuildMapData = WurstProjectBuildMapData.empty(),
scriptMode: ScriptMode? = null,
wc3Patch: String? = null
): WurstProjectConfigData {
return WurstProjectConfigData(projectName, dependencies, buildMapData, scriptMode, wc3Patch)
}

fun WurstProjectConfigData.withProjectName(projectName: String): WurstProjectConfigData {
return WurstProjectConfigData(projectName, dependencies(), buildMapData(), scriptMode(), wc3Patch())
}

fun WurstProjectConfigData.withWc3Patch(wc3Patch: String?): WurstProjectConfigData {
return WurstProjectConfigData(projectName(), dependencies(), buildMapData(), scriptMode(), wc3Patch)
}

fun WurstProjectConfigData.withDependencies(dependencies: List<String>): WurstProjectConfigData {
return WurstProjectConfigData(projectName(), dependencies, buildMapData(), scriptMode(), wc3Patch())
}

fun WurstProjectConfigData.withAddedDependency(dependency: String): WurstProjectConfigData {
return withDependencies(dependencies() + dependency)
}

fun WurstProjectConfigData.withRemovedDependency(dependency: String): WurstProjectConfigData {
return withDependencies(dependencies().filterNot { it == dependency })
}
8 changes: 5 additions & 3 deletions src/main/kotlin/config/WurstProjectConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ object WurstProjectConfig {
if (Files.exists(buildFile) && buildFile.fileName.toString().equals(CONFIG_FILE_NAME, ignoreCase = true)) {
val config = YamlHelper.loadProjectConfig(buildFile)
val projectRoot = buildFile.parent
if (config.projectName.isEmpty()) {
config.projectName = projectRoot?.fileName.toString()
saveProjectConfig(projectRoot, config)
if (config.projectName.isBlank()) {
val namedConfig = config.withProjectName(projectRoot?.fileName?.toString() ?: "unnamed")
saveProjectConfig(projectRoot, namedConfig)
Log.print("done\n")
return namedConfig
}
Log.print("done\n")
return config
Expand Down
6 changes: 6 additions & 0 deletions src/main/kotlin/file/CLICommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ enum class GlobalOptions(val optionName: String = "", val argCount: Int = 0) {
override fun runOption(setupMain: SetupMain, args: List<String>) {
setupMain.wc3Patch = CoreJassProvider.normalizePatchInput(args[0])
}
},
WC3_PATH("--wc3-path", 1) {
override fun runOption(setupMain: SetupMain, args: List<String>) {
setupMain.gamePath = java.nio.file.Paths.get(args[0])
setupMain.gamePathExplicit = true
}
};

abstract fun runOption(setupMain: SetupMain, args: List<String>)
Expand Down
Loading
Loading