Use this file for durable repo-local guidance that Codex should follow before changing code, docs, or project workflow surfaces in this repository.
This root AGENTS.md governs the whole SwiftlyFetch Swift package repository. It covers the retrieval package code in Sources/, the tests in Tests/, maintainer planning docs in docs/maintainers/, and the repo-maintenance scripts and workflow surfaces that keep the package healthy.
Check these surfaces before reading broadly:
Package.swiftfor the source-of-truth package layout, products, targets, platforms, and language mode.docs/maintainers/retrieval-package-plan.mdfor the intended product identity, architecture, and implementation sequence.ROADMAP.mdfor the currently committed milestone shape and what is still intentionally unfinished.Sources/RAGCore/andSources/RAGKit/for the current code surface.
Keep work retrieval-first and Apple-first. RAGKit/SwiftlyFetch semantic index persistence is an approved retrieval-state pattern; if a change starts pulling the repo toward answer generation, chat orchestration, agents, remote APIs, other persistence layers, or connector-heavy ingestion, stop and surface that scope change explicitly before implementing it.
Treat Package.swift as the package structure source of truth. Treat docs/maintainers/retrieval-package-plan.md and ROADMAP.md as the maintainer-facing architecture and planning sources of truth. When code and docs drift, reconcile them instead of silently following the newer-looking one.
Escalate before widening the public API surface, changing package naming, adding new module families, or introducing a new storage or backend layer that changes the repository’s near-term direction. If a task implies architectural drift, say what concrete behavior is forcing that change before proceeding.
swift buildswift test
scripts/repo-maintenance/validate-all.shscripts/repo-maintenance/release.sh --helpGround changes in the actual retrieval package plan and current code. When handing work back, call out behavior changes, verification run, and any roadmap or maintainer-doc updates that were required to keep the repo coherent. If a change leaves intentionally unfinished follow-up work, say exactly what is left and why it was not pulled into the same pass.
Work is done when the package still builds and tests cleanly, repo-maintenance validation passes, and nearby maintainer docs stay aligned with the code when the implementation meaningfully changes. For architecture-facing work, update docs/maintainers/ or ROADMAP.md when the repo’s intended direction or current milestone state changes.
- Never widen this package into generation, chat orchestration, agents, PDF ingestion, persistence layers beyond the approved RAGKit/SwiftlyFetch semantic index state, or remote provider APIs without explicit approval.
- Never make the main test suite depend on downloaded Apple embedding assets.
- Never add external dependencies for this v1 retrieval package without explicit approval.
- Never hand-edit generated package-manager outputs such as
Package.resolvedif they appear later.
- Ask before changing product naming in a way that affects the future
SwiftlyFetchumbrella direction. - Ask before adding a new module family beyond the current retrieval-focused
RAGCoreandRAGKitsplit. - Ask before changing the metadata-filter surface in a way that turns it into a larger query language.
There are no deeper AGENTS.md files in the current repository tree. If more specific guidance files are added later under subdirectories, they should refine this root file for work happening in that subtree.
- 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,scripts/repo-maintenance/sync-shared.shfor repo-local sync steps, andscripts/repo-maintenance/release.shfor releases. - 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.
- Prefer the simplest correct Swift that is easiest to read and reason about.
- Prefer synthesized and framework-provided behavior over extra wrappers and boilerplate.
- 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 remember that lowering the manifest's// swift-tools-version:from the bootstrap default is often appropriate when the package should support an older Swift 6 toolchain, but never below6.0. - Keep the shared Swift-package dependency baseline in mind when creating new Swift package repos or when this package's dependency policy is explicitly opened: the current baseline package is
swift-configurationfromhttps://github.com/apple/swift-configuration, with theConfigurationproduct and package traits.defaults,Reloading,YAML, andCommandLineArguments. The optionalPropertyListtrait is available when property-list parsing is needed, and the optionalLoggingtrait is available when configuration access should integrate withSwiftLog.Logger. This repository's v1 safety boundary still applies: do not add new external dependencies toSwiftlyFetchwithout explicit approval. - Avoid adding unnecessary dependency-provenance detail or switching to branch/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.
- Prefer a checked-in repo-root
.swiftformatfile as the Swift formatting source of truth. - Prefer a pre-commit hook such as
scripts/repo-maintenance/hooks/pre-commit.samplethat formats staged Swift sources and then verifies them withswiftformat --lintbefore commit. - Treat SwiftLint as an optional complementary signal layer for clarity, safety, and maintainability after SwiftFormat owns formatting shape.
- 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. - 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.