Repo-local guidance for maintaining SwiftASB, a Swift Package Manager library that wraps the local Codex app-server for Swift and SwiftUI clients.
- Use this file for all work at the SwiftASB repository root.
- Treat this package as a library first: public API should be deliberate, documented, and tested.
- Use Swift Package Manager as the source of truth for package structure, dependencies, products, targets, resources, and Swift language mode.
- Treat the bundled Codex app-server v2 schema as the primary generated-wire source of truth.
- Treat the generated wire layer as internal scaffolding, not the final public Swift API.
- Start with
Package.swiftfor package graph, target, dependency, platform, and Swift language mode changes. - Use
Sources/SwiftASB/Public/for public API shape andSources/SwiftASB/Protocol/,Sources/SwiftASB/Transport/, andSources/SwiftASB/History/for the main internal runtime surfaces. - Use
Sources/SwiftASB/Generated/CodexWire/Latest/for the promoted generated v2 wire snapshot. - Use
Tests/SwiftASBTests/for Swift Testing coverage. - Use
scripts/generate-wire-types.shfor Codex schema-derived wire refreshes. - Use
scripts/repo-maintenance/for repo-owned validation, shared sync, and release entrypoints. - Use
README.md,CONTRIBUTING.md,ROADMAP.md, anddocs/maintainers/for shipped behavior, contributor workflow, planned work, and durable design decisions.
- Prefer the simplest correct Swift that is easiest to read, reason about, and maintain.
- Prefer value types for domain modeling.
- Prefer concrete types internally and reserve protocols for real seams.
- Mark classes
finalby default when reference semantics are required. - Keep dependency flow unidirectional and ownership obvious.
- Prefer explicit, consistent, and unambiguous names.
- Prefer synthesized conformances and memberwise initialization whenever they satisfy the real need.
- Avoid ceremony, wrappers, or extra abstraction layers unless they solve a concrete package problem.
- Keep operator-facing errors, warnings, and log strings descriptive and human-readable.
- Prefer
swift packageCLI commands for structural changes whenever the command exists. - Use
swift package add-dependencyto add dependencies instead of hand-editing package graphs. - Use
swift package add-targetto add library, executable, or test targets. - For package configuration not covered by CLI commands, update
Package.swiftintentionally and keep edits minimal. - Keep package graph updates together in the same change when structure changes.
- Keep
Package.swiftexplicit about its package-wide Swift language mode; preferswiftLanguageModes: [.v6]on current Swift 6-era manifests. - Treat
Package.resolvedand similar package-manager outputs as generated files; do not hand-edit them. - Keep package resources under the owning target tree, declare them intentionally, and load bundled resources through
Bundle.module.
- Keep the README product-facing and approachable for package users and their agents.
- Keep contributor setup, validation, generated-wire refreshes, DocC checks, live test flags, release prep, and PR expectations in
CONTRIBUTING.md. - Keep Codex-facing maintainer instructions in this file or a more specific nested
AGENTS.md. - SwiftASB-specific adoption guidance for external agents lives in the
swiftasb-skillsplugin insocket, not in this package. Update that plugin separately when public API changes would make those skills stale.
- For Swift, Apple-framework, Apple-platform, or Xcode-related tasks, read the relevant Apple or Swift documentation first before proposing or making changes.
- If a public API change, generated-wire promotion, new dependency, or ownership change starts widening beyond the requested scope, surface that before implementing it.
- If SwiftPM guidance drifts, use
sync-swift-package-guidanceto refresh or merge the package workflow baseline. - Use
bootstrap-swift-packageonly when a new Swift package repo still needs to be created from scratch. - Use
swift-package-build-run-workflowfor manifest, dependency, resource, build, and run work whenPackage.swiftis the source of truth. - Use
swift-package-testing-workflowfor Swift Testing, XCTest holdouts, fixtures, package test diagnosis, and package test-plan work. - Prefer
xcode-build-run-workfloworxcode-testing-workflowonly when package work needs Xcode-managed SDK, toolchain, DocC, or test behavior. - Re-run
sync-swift-package-guidanceafter substantial package-workflow or plugin updates so local guidance stays aligned.
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.
swift package resolveRun the package checks before committing package changes:
swift build
swift testRun the repo-maintenance validation before release or maintainer-surface changes:
bash scripts/repo-maintenance/validate-all.shCheck whitespace before staging:
git diff --checkRefresh generated Codex wire types through the maintainer entrypoint:
scripts/generate-wire-types.shRun the repo-maintenance shared sync entrypoint:
bash scripts/repo-maintenance/sync-shared.shStart a standard release from a feature branch with a clean committed worktree:
bash scripts/repo-maintenance/release.sh --mode standard --version vX.Y.ZValidate DocC through Xcode when documentation changes:
xcodebuild docbuild -scheme SwiftASB -destination generic/platform=macOS -derivedDataPath tmp/xcode-docc/DerivedData- Keep package, docs, tests, and generated-wire surfaces aligned in the same branch when one change affects more than one of them.
- 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.
- Keep README product-facing. Keep contributor workflow, local validation, live test flags, schema generation, DocC build commands, and release-prep details in
CONTRIBUTING.mdunless the README user needs them to consume the package. - PRs should identify the changed surface, explain any public API or docs boundary decision, and list the validation commands that ran.
swift buildandswift testpass for package changes unless the task is explicitly docs-only and no package behavior changed.bash scripts/repo-maintenance/validate-all.shpasses for maintainer guidance, repo tooling, CI wrapper, or release setup changes.- Documentation reflects the actual shipped behavior, not aspirational API.
- Live Codex runtime probes are described as observational when runtime behavior is nondeterministic.
- Do not hand-edit
Package.resolved. - Do not hand-edit the promoted generated wire snapshot in
Sources/SwiftASB/Generated/CodexWire/Latest/; usescripts/generate-wire-types.sh. - Do not reintroduce a promoted generated v1 batch unless Gale explicitly asks for that compatibility surface again.
- Do not commit dumped local schema artifacts under
codex-schemas/unless Gale explicitly asks to commit them. - Do not commit temporary derived schemas or raw or patched quicktype staging output under
tmp/. - Do not treat the generated wire layer as public Swift API.
- Do not use
xcodebuildas the default package validation path when plain SwiftPM validation is enough.
- Ask before changing the public API ownership model, release boundary, licensing terms, or Codex CLI compatibility window.
- Ask before adding dependencies that are not first-party or top-tier Swift ecosystem packages.
- Ask before changing the shape of promoted generated-wire output.
- Ask before committing local schema dumps or temporary generated artifacts that are normally untracked.
- No nested
AGENTS.mdfiles are currently present below the repository root. - If a more specific
AGENTS.mdis added later, follow the closer file for its subtree while keeping this root guidance as the package-wide baseline.
- Treat the bundled Codex app-server v2 schema as the primary generated-wire source of truth.
- Use
scripts/generate-wire-types.shas the maintainer entrypoint for schema derivation, quicktype generation, dynamic-JSON patching, and staged Swift validation. - Keep dumped local schema artifacts under
codex-schemas/untracked unless Gale explicitly asks to commit them. - Keep temporary derived schemas and raw or patched quicktype staging output under
tmp/untracked. - Promote only the generated v2 wire snapshot into
Sources/SwiftASB/Generated/CodexWire/Latest/unless Gale explicitly asks for a different promotion shape. - The current generated promoted file is
CodexLifecycleV2Batch+JSONValue.swift. - Keep
CodexWireInitializeResponsehand-owned in its own dedicated Swift file next to the promoted generated v2 snapshot until the upstream v2 schema exposes that type directly. - Do not reintroduce a promoted generated v1 batch unless Gale explicitly asks for that compatibility surface again.
- Treat the generated wire layer as an internal scaffolding surface, not the final public Swift API.
- Use
swift buildandswift testas the default first-pass validation commands for this package. - Use
bootstrap-swift-packagewhen a new Swift package repo still needs to be created from scratch. - Use
sync-swift-package-guidancewhen the repo guidance for this package drifts and needs to be refreshed or merged forward. - Re-run
sync-swift-package-guidanceafter substantial package-workflow or plugin updates so local guidance stays aligned. - Use
swift-package-build-run-workflowfor manifest, dependency, plugin, resource, Metal-distribution, build, and run work whenPackage.swiftis the source of truth. - Use
swift-package-testing-workflowfor Swift Testing, XCTest holdouts,.xctestplan, fixtures, and package test diagnosis. - Use
scripts/repo-maintenance/validate-all.shfor local maintainer validation andscripts/repo-maintenance/sync-shared.shfor repo-local sync steps. - Use
scripts/repo-maintenance/release.sh --mode standard --version vX.Y.Zfrom a feature branch or worktree only when the task is actually a protected-main release, publish, merge, tag, or release-PR preparation. - Do not run the standard release workflow from
main; when a protected-main release is explicitly requested, let it validate, bump versions, tag, push the branch and tag, open the release PR, watch CI, address valid PR comments or record out-of-scope concerns inROADMAP.md, merge to protectedmain, fast-forward localmain, and clean up stale branches. - Treat
scripts/repo-maintenance/config/profile.envas the installedmaintain-project-repoprofile marker, and keep it on theswift-packageprofile for plain package repos. - Read relevant SwiftPM, Swift, and Apple documentation before proposing package-structure, dependency, manifest, concurrency, or architecture changes.
- Prefer Dash or local Swift docs first, then official Swift or Apple docs when local docs are insufficient.
- When SwiftPM behavior, manifest syntax, package plugins, resources, products, targets, or dependency rules matter, prefer the Dash.app docset workflow with the
swiftlang/swift-package-managerdocset first; fall back to the canonicalswiftlang/swift-package-managerGitHub repository only when the local docset is unavailable or insufficient. - Prefer the simplest correct Swift that is easiest to read and reason about.
- Prefer synthesized and framework-provided behavior over extra wrappers and boilerplate.
- For public Swift APIs, treat streamlined, compact, ergonomic call sites as the only acceptable default; prefer optional parameters with explicit default values over additional methods or overloads when the difference is optional behavior on the same operation.
- When a public function, initializer, or method reaches four or more arguments or parameters, strongly prefer a named typed
structrequest, options, or configuration value so call sites stay readable and future additions do not multiply overloads. - Prefer enums, enum cases with associated values, and narrow typed values over strings, booleans, sentinel values, or parallel parameters whenever the domain has a closed or meaningful set of choices.
- Keep data flow straight and dependency direction unidirectional.
- Treat
Package.swiftas the source of truth for package structure, targets, products, and dependencies. - Prefer
swift packagesubcommands for structural package edits before manually editingPackage.swift. - Edit
Package.swiftintentionally and keep it readable; agents may modify it when package structure, targets, products, or dependencies need to change, and should try to keep package graph updates consolidated in one change when possible. - Keep
Package.swiftexplicit about its package-wide Swift language mode. On current Swift 6-era manifests, preferswiftLanguageModes: [.v6]as the default declaration, treatswiftLanguageVersionsas a legacy alias used only when an older manifest surface requires it, and keep the supported Swift toolchain window focused on the latest stable minor and previous stable minor. Treat Swift6.2as the current minimum floor for trait-enabled manifests, not as a ceiling; use newer stable Swift toolchains when available and validated, and refresh this guidance when the maintained floor or window changes. Do not lower// swift-tools-version:below6.2without an explicit repo policy and a matching guidance update. - Keep
swift-configurationas the default configuration dependency for Swift packages unless the package has a concrete reason to remove it. The preferred manifest shape depends onhttps://github.com/apple/swift-configurationfrom1.2.0, enables the.defaults,Reloading,YAML, andCommandLineArgumentspackage traits, and adds theConfigurationproduct to the primary target. Add thePropertyListtrait when the package should parse property-list configuration, and add theLoggingtrait when configuration access should integrate withSwiftLog.Logger. - Keep dependency provenance concise but explicit enough for another contributor to fetch the same package: use package-manager, package-registry, GitHub URL, or other real remote repository requirements, and do not commit machine-local dependency paths such as
/Users/...,~/...,../..., local worktrees, or private checkout paths. Avoid branch- or revision-based requirements unless the user explicitly asks for that level of control. - Treat
Package.resolvedand similar package-manager outputs as generated files; do not hand-edit them. - Prefer Swift Testing by default unless an external constraint requires XCTest.
- Use
apple-ui-accessibility-workflowwhen the package work crosses into SwiftUI accessibility semantics, Apple UI accessibility review, or UIKit/AppKit accessibility bridge behavior. - Keep package resources under the owning target tree, declare them intentionally with
Resource.process(...),Resource.copy(...),Resource.embedInCode(...), and load them throughBundle.module. - Keep test fixtures as test-target resources instead of relying on the working directory.
- Bundle precompiled Metal artifacts such as
.metallibfiles as explicit resources when they ship with the package, and preferxcode-build-run-workflowwhen shader compilation or Apple-managed Metal toolchain behavior matters. - Prefer normal SwiftPM parallel test execution for ordinary Swift Testing and XCTest runs. Do not serialize regular package tests just because they use Swift, XCTest, async tests, fixtures, or test plans.
- Treat tests that load large local AI or ML models, especially models over 500 million parameters, as heavy system-resource tests. Run those tests sequentially, one at a time, and call
unload_modelson Gale's live TTS service before the heavy run andreload_modelsafter it ends, even when the run fails or is interrupted. - Validate both Debug and Release paths when optimization or packaging differences matter, and treat tagged releases as a cue to verify the Release artifact path before publishing.
- Prefer
xcode-build-run-workfloworxcode-testing-workflowonly when package work needs Xcode-managed SDK, toolchain, or test behavior. - Keep runtime UI accessibility verification and XCUITest follow-through in
xcode-testing-workflowrather than treating package-side testing as a substitute for live UI verification.