|
| 1 | +# SwiftGit public API inventory |
| 2 | + |
| 3 | +This document catalogs the public API surface of the SwiftGit package and provides focused documentation and usage examples for automated agents and human readers. It is intended to be consumed by agents to generate actionable SKILL content for each API area. |
| 4 | + |
| 5 | +Structure |
| 6 | +- Classes & types: short descriptions and top-level public members |
| 7 | +- Models: commonly used value types and their important properties |
| 8 | +- Options: ExpressibleByStringLiteral option types used as argument helpers |
| 9 | +- Commands: repository/command helpers exposed as public extensions |
| 10 | +- Tests: reference to tests that target the public API |
| 11 | + |
| 12 | +Primary public types |
| 13 | + |
| 14 | +1) Git (class) |
| 15 | +- Location: Sources/SwiftGit/Custom/Git.swift |
| 16 | +- Summary: High-level entrypoint for running git commands via the package. Holds a GitEnvironment and a Shell.Instance for process execution. |
| 17 | +- Important public members (selection): |
| 18 | + - public static var shared: Git { get throws } |
| 19 | + - public init(environment: GitEnvironment) |
| 20 | + - public func data(_ commands: [String], context: Shell.Context? = nil) async throws -> Data |
| 21 | + - public func run(_ commands: [String], context: Shell.Context? = nil) async throws -> String |
| 22 | + - public func run(_ cmd: String, context: Shell.Context? = nil) async throws -> String |
| 23 | + - public func data(_ commands: [String], context: Shell.Context? = nil) throws -> Data |
| 24 | + - public func run(_ commands: [String], context: Shell.Context? = nil) throws -> String |
| 25 | + - public func repository(at url: URL) -> Repository |
| 26 | + - public func repository(at path: String) -> Repository |
| 27 | + |
| 28 | +2) GitEnvironment (class & nested types) |
| 29 | +- Location: Sources/SwiftGit/Custom/GitEnvironment.swift |
| 30 | +- Summary: Represents a configured git runtime (embedded, system, or custom). Encapsulates resource (executable), environment variables, and triggers. |
| 31 | +- Important public members: |
| 32 | + - public enum Style { case embed, system, custom(_ url: URL), auto } |
| 33 | + - public struct Resource { public let executableURL: URL; public let envExecPath: String? } |
| 34 | + - public struct Variable { factory helpers: execPath(_:), home(_:), prefix(_:), configNoSystem(_:), etc. } |
| 35 | + - public init(resource: Resource, variables: [Variable], triggers: [GitTrigger]) |
| 36 | + - public static var shared: GitEnvironment { get } |
| 37 | + |
| 38 | +3) Repository (struct) |
| 39 | +- Location: Sources/SwiftGit/Custom/Repository.swift |
| 40 | +- Summary: Convenience repository-scoped helpers backed by a Git instance. Provides many sub-APIs for common git workflows. |
| 41 | +- Important public members (selection): |
| 42 | + - public init(git: Git, url: URL) |
| 43 | + - public init(git: Git, path: String) |
| 44 | + - public extension Repository { many repository helpers live in extensions (clone, commit, push, status, tag, stash, etc.) } |
| 45 | + |
| 46 | +4) Shell (structs & Instance) |
| 47 | +- Location: Sources/SwiftGit/Custom/Shell.swift |
| 48 | +- Summary: Centralized process execution utilities (sync/async + Combine publishers). Prefer these helpers when invoking git. |
| 49 | +- Important public types & members: |
| 50 | + - public struct Context { public var environment: [String: String]; public var currentDirectory: URL?; public let standardOutput: PassthroughSubject<Data, Never>? } |
| 51 | + - public struct Arguments / ShellArguments |
| 52 | + - public struct Instance { public var changedArgsBeforeRun: ((_ args: inout Arguments) -> Void)?; public func data(_ args: Shell.Arguments) async throws -> Data; public func string(_ args: Shell.Arguments) async throws -> String } |
| 53 | + - convenience static helpers: Shell.zsh(...), Shell.data(...), Shell.string(...) |
| 54 | + |
| 55 | +5) GitTrigger (struct) |
| 56 | +- Location: Sources/SwiftGit/Custom/GitTrigger.swift |
| 57 | +- Summary: Small callback/event primitive used by GitEnvironment to trigger hooks on events. |
| 58 | +- Important public members: |
| 59 | + - public enum Event: Int { case beforeRun, afterRun } |
| 60 | + - public struct Content { public let commands: [String]; public let data: Data } |
| 61 | + - public init(on event: Event, action: @escaping (_ result: Result<Content, Error>) -> Void) |
| 62 | + - public static func failure(on:event, action: ...) and success(on:event, action: ...) |
| 63 | + |
| 64 | +Models (examples) |
| 65 | +- GitStatus (Sources/SwiftGit/Custom/models/GitStatus.swift): public struct GitStatus with properties branch, changed, renamedCopied, unmerged, untracked. Several nested types represent entries and styles. |
| 66 | +- Commit / Commit enums: Sources/SwiftGit/Custom/models/Commit.swift |
| 67 | +- Reference types: Sources/SwiftGit/Custom/models/Reference.swift (protocol ReferenceType, structs Branch, Tag) |
| 68 | +- Pathspec: ExpressibleByStringLiteral helper, value wrapper |
| 69 | + |
| 70 | +Options |
| 71 | +- Many option types are defined as small structs conforming to ExpressibleByStringLiteral for convenient API composition. Examples: |
| 72 | + - AddOptions, ResetOptions, CloneOptions, CommitOptions, PushOptions, FetchOptions, StatusOptions, etc. (see Sources/SwiftGit/options/) |
| 73 | + |
| 74 | +Commands & repository extensions |
| 75 | +- Most git subcommands are exposed as public extensions on Git or Repository under Sources/SwiftGit/Custom/commands/*. Each file shapes a coherent sub-API (clone, commit, push, fetch, log, status, tag, stash, etc.). |
| 76 | + |
| 77 | +Tests that reference public APIs |
| 78 | +- Tests live under Tests/SwiftGitTests. Key files that exercise public APIs include: |
| 79 | + - Tests/SwiftGitTests/IntegrationTests.swift |
| 80 | + - Tests/SwiftGitTests/ParseTests.swift |
| 81 | + - Tests/SwiftGitTests/CloneCommandTests.swift |
| 82 | + - Tests/SwiftGitTests/ShowCommitResultTests.swift |
| 83 | + |
| 84 | +How this inventory will be used |
| 85 | +- The next step is to generate per-API skill documentation files that include: |
| 86 | + - The declaration/signature |
| 87 | + - Short description |
| 88 | + - Examples of usage (non-executable snippets) |
| 89 | + - Tests referencing the API |
| 90 | + |
| 91 | +Follow-up files to generate (I will create when you approve): |
| 92 | +- references/apis/Git.md |
| 93 | +- references/apis/GitEnvironment.md |
| 94 | +- references/apis/Repository.md |
| 95 | +- references/apis/Shell.md |
| 96 | +- references/apis/GitTrigger.md |
| 97 | +- references/apis/Models.md |
| 98 | +- references/apis/Options.md |
| 99 | +- references/apis/Commands.md |
0 commit comments