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
42 changes: 42 additions & 0 deletions .claude/worktrees/agent-a84e8640/.github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Linux

on:
push:
branches: [main]
pull_request:

jobs:
build-and-test:
name: Swift ${{ matrix.swift }} on Linux
runs-on: ubuntu-latest
strategy:
matrix:
swift: ["6.2"]
container: swift:${{ matrix.swift }}

steps:
- uses: actions/checkout@v4

- name: Build DaggerheartModels
run: swift build --target DaggerheartModels

- name: Build validate-dhpack
run: swift build --target validate-dhpack

- name: Test DaggerheartModels
run: swift test --filter DaggerheartModelsTests

swift-format:
name: swift-format lint
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
container: swift:6.2

steps:
- uses: actions/checkout@v4

- name: Mark workspace as safe for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"

- name: Lint
run: git ls-files -z '*.swift' | xargs -0 swift-format lint --strict --parallel
37 changes: 37 additions & 0 deletions .claude/worktrees/agent-a84e8640/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Xcode
*.xcodeproj/xcuserdata/
*.xcworkspace/xcuserdata/
*.xcworkspace/contents.xcworkspacedata
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

# Swift Package Manager
.build/
.swiftpm/
*.resolved

# macOS
.DS_Store
.AppleDouble
.LSOverride
._*
.Spotlight-V100
.Trashes

# Test results
TestResults.xcresult

# Claude Code (local settings — machine-specific)
.claude/settings.local.json
4 changes: 4 additions & 0 deletions .claude/worktrees/agent-a84e8640/.spi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: 1
builder:
configs:
- documentation_targets: [DaggerheartModels, DaggerheartKit]
75 changes: 75 additions & 0 deletions .claude/worktrees/agent-a84e8640/.swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"fileScopedDeclarationPrivacy" : {
"accessLevel" : "private"
},
"indentConditionalCompilationBlocks" : true,
"indentSwitchCaseLabels" : false,
"indentation" : {
"spaces" : 2
},
"lineBreakAroundMultilineExpressionChainComponents" : false,
"lineBreakBeforeControlFlowKeywords" : false,
"lineBreakBeforeEachArgument" : false,
"lineBreakBeforeEachGenericRequirement" : false,
"lineBreakBetweenDeclarationAttributes" : false,
"lineLength" : 100,
"maximumBlankLines" : 1,
"multiElementCollectionTrailingCommas" : true,
"noAssignmentInExpressions" : {
"allowedFunctions" : [
"XCTAssertNoThrow"
]
},
"prioritizeKeepingFunctionOutputTogether" : false,
"reflowMultilineStringLiterals" : "never",
"respectsExistingLineBreaks" : true,
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : false,
"AlwaysUseLiteralForEmptyCollectionInit" : false,
"AlwaysUseLowerCamelCase" : true,
"AmbiguousTrailingClosureOverload" : true,
"AvoidRetroactiveConformances" : true,
"BeginDocumentationCommentWithOneLineSummary" : false,
"DoNotUseSemicolons" : true,
"DontRepeatTypeInStaticProperties" : true,
"FileScopedDeclarationPrivacy" : true,
"FullyIndirectEnum" : true,
"GroupNumericLiterals" : true,
"IdentifiersMustBeASCII" : true,
"NeverForceUnwrap" : false,
"NeverUseForceTry" : false,
"NeverUseImplicitlyUnwrappedOptionals" : false,
"NoAccessLevelOnExtensionDeclaration" : true,
"NoAssignmentInExpressions" : true,
"NoBlockComments" : true,
"NoCasesWithOnlyFallthrough" : true,
"NoEmptyLinesOpeningClosingBraces" : false,
"NoEmptyTrailingClosureParentheses" : true,
"NoLabelsInCasePatterns" : true,
"NoLeadingUnderscores" : false,
"NoParensAroundConditions" : true,
"NoPlaygroundLiterals" : true,
"NoVoidReturnOnFunctionSignature" : true,
"OmitExplicitReturns" : false,
"OneCasePerLine" : true,
"OneVariableDeclarationPerLine" : true,
"OnlyOneTrailingClosureArgument" : true,
"OrderedImports" : true,
"ReplaceForEachWithForLoop" : true,
"ReturnVoidInsteadOfEmptyTuple" : true,
"TypeNamesShouldBeCapitalized" : true,
"UseEarlyExits" : false,
"UseExplicitNilCheckInConditions" : true,
"UseLetInEveryBoundCaseVariable" : true,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : true,
"UseSynthesizedInitializer" : true,
"UseTripleSlashForDocumentationComments" : true,
"UseWhereClausesInForLoops" : false,
"ValidateDocumentationComments" : false
},
"spacesAroundRangeFormationOperators" : false,
"spacesBeforeEndOfLineComments" : 2,
"tabWidth" : 8,
"version" : 1
}
145 changes: 145 additions & 0 deletions .claude/worktrees/agent-a84e8640/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# DaggerheartModels — Claude Code Context

Swift Package containing the Daggerheart model layer.
Two targets: `DaggerheartModels` (Linux-safe value types) and `DaggerheartKit`
(Apple-platform `@Observable` stores). A `validate-dhpack` CLI validates content packs.

---

## Package structure

```
DaggerheartModels/
├── Sources/
│ ├── DaggerheartModels/ # Foundation-only; no Apple-only frameworks
│ ├── DaggerheartKit/
│ │ └── Resources/ # adversaries.json, environments.json (SRD data)
│ └── validate-dhpack/
├── Tests/
│ ├── DaggerheartModelsTests/ # Linux-compatible; runs in Linux CI
│ │ └── Fixtures/ # adversaries.json, environments.json, sample-homebrew.dhpack
│ └── DaggerheartKitTests/ # Apple-platform only
├── schemas/ # dhpack.schema.json (JSON Schema for .dhpack files)
├── Package.swift
├── .swift-format # Formatting rules (matches gwillish/encounter)
└── Scripts/format.sh # Format all tracked Swift files
```

---

## Build configuration

- **Swift:** 6.2, `.swiftLanguageMode(.v6)`
- **Platforms:** iOS 17, macOS 14, tvOS 17, watchOS 10 (DaggerheartKit); unrestricted (DaggerheartModels)
- **Swift settings active on all targets:**
- `.enableUpcomingFeature("MemberImportVisibility")` — members from transitive
dependencies are not visible without an explicit import
- **DaggerheartKit additionally:**
- `.defaultIsolation(MainActor.self)` — all non-isolated code defaults to `@MainActor`

### Implication of MemberImportVisibility

Any file that uses types from `DaggerheartModels` (even through `DaggerheartKit`)
must explicitly `import DaggerheartModels`. This applies to test files too.

---

## Building

```bash
# Build both libraries
swift build

# Build a specific target
swift build --target DaggerheartModels
swift build --target DaggerheartKit
swift build --target validate-dhpack
```

---

## Testing

```bash
# Run all tests
swift test

# Linux-safe model tests only (also what the Linux CI runs)
swift test --filter DaggerheartModelsTests

# Kit tests (Apple-platform only)
swift test --filter DaggerheartKitTests
```

Tests use **Swift Testing** (`import Testing`), not XCTest.

`DaggerheartModelsTests` must stay Linux-compatible: no `@Observable`, no
`Compendium`, no `EncounterStore`. Anything using Apple-platform-only types
belongs in `DaggerheartKitTests`.

---

## Formatting

Run before every commit:

```bash
./Scripts/format.sh
```

The script formats and lints all tracked Swift files:

```bash
git ls-files -z '*.swift' | xargs -0 swift-format format --parallel --in-place
git ls-files -z '*.swift' | xargs -0 swift-format lint --strict --parallel
```

---

## CI

`.github/workflows/linux.yml`:

- **Build + test on Linux** — Swift 6.1 and 6.2 on `ubuntu-latest`; runs
`swift build --target DaggerheartModels`, `swift build --target validate-dhpack`,
and `swift test --filter DaggerheartModelsTests`
- **swift-format lint** — runs on pull requests only; container `swift:6.2`

`DaggerheartKitTests` is intentionally excluded from Linux CI because
`DaggerheartKit` depends on `Observation`, which requires Apple platforms.

---

## Adding new model types

1. Add the `.swift` file to `Sources/DaggerheartModels/` if the type is
Foundation-only, or to `Sources/DaggerheartKit/` if it needs `@Observable`
or Apple-only frameworks.
2. Make it `public`.
3. Add `Codable` conformance if it will appear in `.dhpack` or JSON files.
4. Write tests in `DaggerheartModelsTests` (for model types) or `DaggerheartKitTests`
(for observable stores). Follow red-green TDD.
5. Run `./Scripts/format.sh` before committing.

---

## Key conventions

- **No force-unwrap** in any source or test file.
- **Daggerheart naming:** use game terms as-is (`hp`, `stress`, `fear`, `hope`,
`difficulty`, `thresholds`) — do not rename to generic equivalents.
- **Bundle resources:** `DaggerheartKit` resources (SRD JSON) are accessed via
`Bundle.module`, which is internal — it cannot appear in a `public` default
argument. Use `bundle: Bundle? = nil` and resolve as `bundle ?? .module` inside
the function body.
- **Test fixtures:** place JSON fixtures in `Tests/DaggerheartModelsTests/Fixtures/`
and declare them as `.copy("Fixtures")` in Package.swift. Access via
`Bundle.module.url(forResource:withExtension:subdirectory:)` with
`subdirectory: "Fixtures"`.

---

## Git

- **Never commit on behalf of the user.** Wait for an explicit request.
- **No Claude attribution** in commit messages.
Loading
Loading