Skip to content

Commit 82a5da4

Browse files
committed
Add clone/pull progress callbacks and skill package
1 parent 5b91714 commit 82a5da4

18 files changed

Lines changed: 759 additions & 5 deletions

.skills/dist/swift-git.skill

43 KB
Binary file not shown.

.skills/swift-git/SKILL.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ description: "Repository-focused skill for building, testing, and agent-safe ope
88
Purpose
99
- Provide concise, actionable instructions and examples for automated agents and humans working with this repository.
1010
- Expose the small set of repository-specific commands and agent rules an automated worker needs so the runtime can make safe decisions without loading large docs.
11+
- Include the progress-callback APIs for clone/pull so agents can guide UI work and cancellation behavior.
1112

1213
When to use this skill (trigger examples)
1314
- "Build the package"
1415
- "Run tests"
1516
- "Run a single test"
1617
- "Where are the build/test commands"
1718
- "What agent rules should I follow for commits and CI"
19+
- "Add progress callbacks for clone or pull"
1820

1921
Quick commands (do not execute without user approval)
2022
- Build (debug):
@@ -27,6 +29,28 @@ Quick commands (do not execute without user approval)
2729
- swift test --filter ParseTests.testChangedEntryIndex_valid
2830
- swift test --filter test_format_date
2931

32+
Progress callbacks (clone/pull)
33+
- Types: `GitProgress`, `GitProgressStage`, `GitProgressAction` (Sources/SwiftGit/Custom/GitProgress.swift)
34+
- Clone overloads (Git):
35+
- `clone(... progress: (GitProgress) -> Void)` for simple progress updates
36+
- `clone(... progress: (GitProgress) -> GitProgressAction)` to allow cancellation (`.proceed` / `.cancel`)
37+
- Pull overloads (Repository):
38+
- `pull(... progress: (GitProgress) -> Void)`
39+
- `pull(... progress: (GitProgress) -> GitProgressAction)`
40+
- Callbacks are off-main; UI code should dispatch as needed.
41+
- Stage percent is per-stage and resets when stage changes.
42+
43+
Example (cancel at 50% network)
44+
```swift
45+
let git = try Git(environment: .shared)
46+
_ = try await git.clone([.progress], repository: url, directory: "/tmp/repo") { progress in
47+
if progress.stage == .network, (progress.stagePercent ?? 0) > 0.5 {
48+
return .cancel
49+
}
50+
return .proceed
51+
}
52+
```
53+
3054
Repository constraints (MUST follow)
3155
- Do NOT create commits or push to remote on behalf of a user unless explicitly authorized.
3256
- Do NOT modify the embedded git bundle at Sources/SwiftGit/Resource/git-instance.bundle.

.skills/swift-git/references/APIS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ Primary public types
6161
- public init(on event: Event, action: @escaping (_ result: Result<Content, Error>) -> Void)
6262
- public static func failure(on:event, action: ...) and success(on:event, action: ...)
6363

64+
6) GitProgress / GitProgressStage / GitProgressAction (struct + enums)
65+
- Location: Sources/SwiftGit/Custom/GitProgress.swift
66+
- Summary: Progress snapshot types for long-running clone/pull operations, plus the action enum for cancellable callbacks.
67+
- Important public members:
68+
- public struct GitProgress { receivedObjects, totalObjects, indexedObjects, receivedBytes, stage, stagePercent }
69+
- public enum GitProgressStage { case network, indexing, checkout, done }
70+
- public enum GitProgressAction { case proceed, cancel }
71+
6472
Models (examples)
6573
- GitStatus (Sources/SwiftGit/Custom/models/GitStatus.swift): public struct GitStatus with properties branch, changed, renamedCopied, unmerged, untracked. Several nested types represent entries and styles.
6674
- Commit / Commit enums: Sources/SwiftGit/Custom/models/Commit.swift
@@ -73,6 +81,7 @@ Options
7381

7482
Commands & repository extensions
7583
- 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.).
84+
- Clone and pull now have progress callback overloads (see git-commands-clone.swift and git-commands-pull.swift).
7685

7786
Tests that reference public APIs
7887
- Tests live under Tests/SwiftGitTests. Key files that exercise public APIs include:

.skills/swift-git/references/apis/Commands.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This section maps the command helper files in Sources/SwiftGit/Custom/commands/
44

55
Files & purpose (selection)
66
- git-commands-clone.swift — clone helpers and CloneOptions
7+
- git-commands-pull.swift — pull helpers and PullOptions (includes progress callbacks)
78
- git-commands-commit.swift — commit helpers and CommitOptions
89
- git-commands-status.swift — status helpers and StatusOptions
910
- git-commands-log.swift — log helpers and LogOptions

.skills/swift-git/references/apis/Models.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ GitStatus
66
- Location: Sources/SwiftGit/Custom/models/GitStatus.swift
77
- public struct GitStatus: Equatable with properties branch, changed, renamedCopied, unmerged, untracked and nested entry types.
88

9+
GitProgress
10+
- Location: Sources/SwiftGit/Custom/GitProgress.swift
11+
- public struct GitProgress with progress counters and stage; paired with GitProgressStage and GitProgressAction for clone/pull progress callbacks.
12+
913
Commit & User models
1014
- Sources/SwiftGit/Custom/models/Commit.swift
1115
- Sources/SwiftGit/Custom/results/LogResult.swift

.skills/swift-git/references/apis/Repository.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Public declaration highlights
77
- public init(git: Git, url: URL)
88
- public init(git: Git, path: String)
99
- Many repository-scoped command helpers are defined as public extensions across Sources/SwiftGit/Custom/commands/*. These include clone, commit, push, status, tag, stash, fetch, pull, merge, etc.
10+
- Pull includes progress callback overloads (GitProgress / GitProgressAction).
1011

1112
Summary
1213
Repository is a lightweight wrapper that provides convenience methods executing git commands within a repository directory using an associated Git instance.

.skills/swift-git/references/apis/zh/APIS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [GitEnvironment](symbols/GitEnvironment.md)(类) — Sources/SwiftGit/Custom/GitEnvironment.swift - Git 环境配置管理
1111
- [Shell](symbols/Shell.md)(工具) — Sources/SwiftGit/Custom/Shell.swift - 进程执行工具
1212
- [GitTrigger](symbols/GitTrigger.md)(结构体) — Sources/SwiftGit/Custom/GitTrigger.swift - 命令执行触发器
13+
- GitProgress / GitProgressStage / GitProgressAction(结构体/枚举) — Sources/SwiftGit/Custom/GitProgress.swift - 克隆/拉取进度回调类型与可取消动作
1314

1415
### 错误处理
1516
- [GitError](symbols/GitError.md)(枚举) — Sources/SwiftGit/Custom/GitError.swift - 统一的错误类型定义

.skills/swift-git/references/apis/zh/Commands.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
文件与职责
77
- git-commands-clone.swift — clone 相关 helper 与 CloneOptions
8+
- git-commands-pull.swift — pull helper 与 PullOptions(包含进度回调)
89
- git-commands-commit.swift — commit helper 与 CommitOptions
910
- git-commands-status.swift — status helper 与 StatusOptions
1011
- git-commands-log.swift — log helper 与 LogOptions

.skills/swift-git/references/apis/zh/Models.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ GitStatus
66
- 位置: Sources/SwiftGit/Custom/models/GitStatus.swift
77
- 说明: `public struct GitStatus` 包含分支信息、已更改文件、重命名/拷贝、未合并、未跟踪项等。许多嵌套类型用于表示不同的条目。
88

9+
GitProgress
10+
- 位置: Sources/SwiftGit/Custom/GitProgress.swift
11+
- 说明: 进度快照类型,包含 receivedObjects/totalObjects/indexedObjects/receivedBytes 与 stage;配合 GitProgressStage 与 GitProgressAction 用于 clone/pull 进度回调与取消控制。
12+
913
Commit
1014
- 位置: Sources/SwiftGit/Custom/models/Commit.swift
1115
- 说明: 包含 Commit enum(如 HEAD、mnemonics 等)用于表示引用定位。

.skills/swift-git/references/apis/zh/Repository.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
位置: Sources/SwiftGit/Custom/Repository.swift
44

55
概述
6-
- Repository 是对仓库目录里的 Git 操作的轻量封装,绑定在一个 Git 实例上,提供方便的方法来执行常见的 git 流程(commit、push、status、tag、stash 等)。
6+
- Repository 是对仓库目录里的 Git 操作的轻量封装,绑定在一个 Git 实例上,提供方便的方法来执行常见的 git 流程(commit、push、status、tag、stash、pull 等)。
7+
- pull 支持进度回调(GitProgress / GitProgressAction),适合 UI 展示与可取消操作。
78

89
主要公开成员(节选)
910
- public struct Repository

0 commit comments

Comments
 (0)