|
1 | 1 | # AGENTS.md |
2 | 2 |
|
3 | | -## Repository Expectations |
| 3 | +Repo-local guidance for maintaining SwiftASB, a Swift Package Manager library that wraps the local Codex app-server for Swift and SwiftUI clients. |
| 4 | + |
| 5 | +## Repository Scope |
| 6 | + |
| 7 | +### What This File Covers |
| 8 | + |
| 9 | +- Use this file for all work at the SwiftASB repository root. |
| 10 | +- Treat this package as a library first: public API should be deliberate, documented, and tested. |
| 11 | +- Use Swift Package Manager as the source of truth for package structure, dependencies, products, targets, resources, and Swift language mode. |
| 12 | +- Treat the bundled Codex app-server v2 schema as the primary generated-wire source of truth. |
| 13 | +- Treat the generated wire layer as internal scaffolding, not the final public Swift API. |
| 14 | + |
| 15 | +### Where To Look First |
| 16 | + |
| 17 | +- Start with `Package.swift` for package graph, target, dependency, platform, and Swift language mode changes. |
| 18 | +- Use `Sources/SwiftASB/Public/` for public API shape and `Sources/SwiftASB/Protocol/`, `Sources/SwiftASB/Transport/`, and `Sources/SwiftASB/History/` for the main internal runtime surfaces. |
| 19 | +- Use `Sources/SwiftASB/Generated/CodexWire/Latest/` for the promoted generated v2 wire snapshot. |
| 20 | +- Use `Tests/SwiftASBTests/` for Swift Testing coverage. |
| 21 | +- Use `scripts/generate-wire-types.sh` for Codex schema-derived wire refreshes. |
| 22 | +- Use `scripts/repo-maintenance/` for repo-owned validation, shared sync, and release entrypoints. |
| 23 | +- Use `README.md`, `CONTRIBUTING.md`, `ROADMAP.md`, and `docs/maintainers/` for shipped behavior, contributor workflow, planned work, and durable design decisions. |
| 24 | + |
| 25 | +## Working Rules |
| 26 | + |
| 27 | +### Change Scope |
| 28 | + |
| 29 | +- Prefer the simplest correct Swift that is easiest to read, reason about, and maintain. |
| 30 | +- Prefer value types for domain modeling. |
| 31 | +- Prefer concrete types internally and reserve protocols for real seams. |
| 32 | +- Mark classes `final` by default when reference semantics are required. |
| 33 | +- Keep dependency flow unidirectional and ownership obvious. |
| 34 | +- Prefer explicit, consistent, and unambiguous names. |
| 35 | +- Prefer synthesized conformances and memberwise initialization whenever they satisfy the real need. |
| 36 | +- Avoid ceremony, wrappers, or extra abstraction layers unless they solve a concrete package problem. |
| 37 | +- Keep operator-facing errors, warnings, and log strings descriptive and human-readable. |
| 38 | + |
| 39 | +### Source of Truth |
4 | 40 |
|
5 | | -- Use Swift Package Manager as the source of truth for package structure and dependencies. |
6 | 41 | - Prefer `swift package` CLI commands for structural changes whenever the command exists. |
7 | 42 | - Use `swift package add-dependency` to add dependencies instead of hand-editing package graphs. |
8 | 43 | - Use `swift package add-target` to add library, executable, or test targets. |
9 | 44 | - For package configuration not covered by CLI commands, update `Package.swift` intentionally and keep edits minimal. |
10 | 45 | - Keep package graph updates together in the same change when structure changes. |
11 | | -- Validate package changes with: |
12 | | - - `swift build` |
13 | | - - `swift test` |
| 46 | +- Keep `Package.swift` explicit about its package-wide Swift language mode; prefer `swiftLanguageModes: [.v6]` on current Swift 6-era manifests. |
| 47 | +- Treat `Package.resolved` and similar package-manager outputs as generated files; do not hand-edit them. |
| 48 | +- Keep package resources under the owning target tree, declare them intentionally, and load bundled resources through `Bundle.module`. |
14 | 49 |
|
15 | | -## Swift Package Workflow |
| 50 | +### Communication and Escalation |
16 | 51 |
|
| 52 | +- For Swift, Apple-framework, Apple-platform, or Xcode-related tasks, read the relevant Apple or Swift documentation first before proposing or making changes. |
| 53 | +- If a public API change, generated-wire promotion, new dependency, or ownership change starts widening beyond the requested scope, surface that before implementing it. |
| 54 | +- If SwiftPM guidance drifts, use `sync-swift-package-guidance` to refresh or merge the package workflow baseline. |
17 | 55 | - Use `bootstrap-swift-package` only when a new Swift package repo still needs to be created from scratch. |
18 | | -- Use `sync-swift-package-guidance` when repo guidance for this package drifts and needs to be refreshed or merged forward. |
19 | | -- Re-run `sync-swift-package-guidance` after substantial package-workflow or plugin updates so local guidance stays aligned. |
20 | 56 | - Use `swift-package-build-run-workflow` for manifest, dependency, resource, build, and run work when `Package.swift` is the source of truth. |
21 | 57 | - Use `swift-package-testing-workflow` for Swift Testing, XCTest holdouts, fixtures, package test diagnosis, and package test-plan work. |
22 | 58 | - Prefer `xcode-build-run-workflow` or `xcode-testing-workflow` only when package work needs Xcode-managed SDK, toolchain, DocC, or test behavior. |
23 | | -- Keep `Package.swift` explicit about its package-wide Swift language mode; prefer `swiftLanguageModes: [.v6]` on current Swift 6-era manifests. |
24 | | -- Treat `Package.resolved` and similar package-manager outputs as generated files; do not hand-edit them. |
25 | | -- Keep package resources under the owning target tree, declare them intentionally, and load bundled resources through `Bundle.module`. |
| 59 | +- Re-run `sync-swift-package-guidance` after substantial package-workflow or plugin updates so local guidance stays aligned. |
26 | 60 |
|
27 | | -## Swift Baseline |
| 61 | +## Commands |
28 | 62 |
|
29 | | -- For Swift, Apple-framework, Apple-platform, or Xcode-related tasks, read the relevant Apple or Swift documentation first before proposing or making changes. |
30 | | -- Prefer the simplest correct Swift that is easiest to read, reason about, and maintain. |
31 | | -- Prefer explicit, consistent, and unambiguous names. |
32 | | -- Prefer synthesized conformances and memberwise initialization whenever they satisfy the real need. |
33 | | -- Avoid ceremony, wrappers, or extra abstraction layers unless they solve a concrete package problem. |
34 | | -- Keep operator-facing errors, warnings, and log strings descriptive and human-readable. |
| 63 | +### Setup |
35 | 64 |
|
36 | | -## Types and Architecture |
| 65 | +Use Swift 6.3 or newer on macOS 15 or newer. SwiftASB discovers the local Codex CLI from `PATH`, common Homebrew locations, or the npm global prefix. |
37 | 66 |
|
38 | | -- Prefer value types for domain modeling. |
39 | | -- Prefer concrete types internally and reserve protocols for real seams. |
40 | | -- Mark classes `final` by default when reference semantics are required. |
41 | | -- Keep dependency flow unidirectional and ownership obvious. |
42 | | -- Treat this package as a library first: public API should be deliberate, documented, and tested. |
| 67 | +```bash |
| 68 | +swift package resolve |
| 69 | +``` |
| 70 | + |
| 71 | +### Validation |
| 72 | + |
| 73 | +Run the package checks before committing package changes: |
| 74 | + |
| 75 | +```bash |
| 76 | +swift build |
| 77 | +swift test |
| 78 | +``` |
| 79 | + |
| 80 | +Run the repo-maintenance validation before release or maintainer-surface changes: |
| 81 | + |
| 82 | +```bash |
| 83 | +bash scripts/repo-maintenance/validate-all.sh |
| 84 | +``` |
| 85 | + |
| 86 | +Check whitespace before staging: |
| 87 | + |
| 88 | +```bash |
| 89 | +git diff --check |
| 90 | +``` |
| 91 | + |
| 92 | +### Optional Project Commands |
| 93 | + |
| 94 | +Refresh generated Codex wire types through the maintainer entrypoint: |
| 95 | + |
| 96 | +```bash |
| 97 | +scripts/generate-wire-types.sh |
| 98 | +``` |
| 99 | + |
| 100 | +Run the repo-maintenance shared sync entrypoint: |
| 101 | + |
| 102 | +```bash |
| 103 | +bash scripts/repo-maintenance/sync-shared.sh |
| 104 | +``` |
| 105 | + |
| 106 | +Start a standard release from a feature branch with a clean committed worktree: |
| 107 | + |
| 108 | +```bash |
| 109 | +bash scripts/repo-maintenance/release.sh --mode standard --version vX.Y.Z |
| 110 | +``` |
| 111 | + |
| 112 | +Validate DocC through Xcode when documentation changes: |
| 113 | + |
| 114 | +```bash |
| 115 | +xcodebuild docbuild -scheme SwiftASB -destination generic/platform=macOS -derivedDataPath tmp/xcode-docc/DerivedData |
| 116 | +``` |
| 117 | + |
| 118 | +## Review and Delivery |
| 119 | + |
| 120 | +### Review Expectations |
| 121 | + |
| 122 | +- Keep package, docs, tests, and generated-wire surfaces aligned in the same branch when one change affects more than one of them. |
| 123 | +- Do not promote generated schema additions to public API just because they exist upstream; classify them as public now, observable-only for now, or internal-only before exposing them. |
| 124 | +- Keep README product-facing. Keep contributor workflow, local validation, live test flags, schema generation, DocC build commands, and release-prep details in `CONTRIBUTING.md` unless the README user needs them to consume the package. |
| 125 | +- PRs should identify the changed surface, explain any public API or docs boundary decision, and list the validation commands that ran. |
| 126 | + |
| 127 | +### Definition of Done |
| 128 | + |
| 129 | +- `swift build` and `swift test` pass for package changes unless the task is explicitly docs-only and no package behavior changed. |
| 130 | +- `bash scripts/repo-maintenance/validate-all.sh` passes for maintainer guidance, repo tooling, CI wrapper, or release setup changes. |
| 131 | +- Documentation reflects the actual shipped behavior, not aspirational API. |
| 132 | +- Live Codex runtime probes are described as observational when runtime behavior is nondeterministic. |
| 133 | + |
| 134 | +## Safety Boundaries |
| 135 | + |
| 136 | +### Never Do |
| 137 | + |
| 138 | +- Do not hand-edit `Package.resolved`. |
| 139 | +- Do not hand-edit the promoted generated wire snapshot in `Sources/SwiftASB/Generated/CodexWire/Latest/`; use `scripts/generate-wire-types.sh`. |
| 140 | +- Do not reintroduce a promoted generated v1 batch unless Gale explicitly asks for that compatibility surface again. |
| 141 | +- Do not commit dumped local schema artifacts under `codex-schemas/` unless Gale explicitly asks to commit them. |
| 142 | +- Do not commit temporary derived schemas or raw or patched quicktype staging output under `tmp/`. |
| 143 | +- Do not treat the generated wire layer as public Swift API. |
| 144 | +- Do not use `xcodebuild` as the default package validation path when plain SwiftPM validation is enough. |
| 145 | + |
| 146 | +### Ask Before |
| 147 | + |
| 148 | +- Ask before changing the public API ownership model, release boundary, licensing terms, or Codex CLI compatibility window. |
| 149 | +- Ask before adding dependencies that are not first-party or top-tier Swift ecosystem packages. |
| 150 | +- Ask before changing the shape of promoted generated-wire output. |
| 151 | +- Ask before committing local schema dumps or temporary generated artifacts that are normally untracked. |
| 152 | + |
| 153 | +## Local Overrides |
| 154 | + |
| 155 | +- No nested `AGENTS.md` files are currently present below the repository root. |
| 156 | +- If a more specific `AGENTS.md` is added later, follow the closer file for its subtree while keeping this root guidance as the package-wide baseline. |
43 | 157 |
|
44 | 158 | ## Codex App-Server Wire Workflow |
45 | 159 |
|
|
52 | 166 | - Keep `CodexWireInitializeResponse` hand-owned in its own dedicated Swift file next to the promoted generated v2 snapshot until the upstream v2 schema exposes that type directly. |
53 | 167 | - Do not reintroduce a promoted generated v1 batch unless Gale explicitly asks for that compatibility surface again. |
54 | 168 | - Treat the generated wire layer as an internal scaffolding surface, not the final public Swift API. |
55 | | - |
56 | | -## Testing and Tooling |
57 | | - |
58 | | -- Use Swift Testing as the default test framework. |
59 | | -- Avoid XCTest unless an external constraint requires it. |
60 | | -- Use `swift build` and `swift test` as the default first-pass validation commands. |
61 | | -- Use `xcodebuild` only when Apple-platform integration details need validation beyond plain SwiftPM. |
|
0 commit comments