opencodekit 0.16.15 → 0.16.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -242
- package/dist/index.js +19 -6
- package/dist/template/.opencode/AGENTS.md +72 -236
- package/dist/template/.opencode/README.md +49 -482
- package/dist/template/.opencode/agent/build.md +71 -345
- package/dist/template/.opencode/agent/explore.md +47 -139
- package/dist/template/.opencode/agent/general.md +61 -172
- package/dist/template/.opencode/agent/looker.md +65 -161
- package/dist/template/.opencode/agent/painter.md +46 -200
- package/dist/template/.opencode/agent/plan.md +37 -220
- package/dist/template/.opencode/agent/review.md +72 -153
- package/dist/template/.opencode/agent/scout.md +44 -486
- package/dist/template/.opencode/agent/vision.md +63 -178
- package/dist/template/.opencode/command/create.md +75 -307
- package/dist/template/.opencode/command/design.md +53 -589
- package/dist/template/.opencode/command/handoff.md +76 -180
- package/dist/template/.opencode/command/init.md +45 -211
- package/dist/template/.opencode/command/plan.md +62 -514
- package/dist/template/.opencode/command/pr.md +56 -226
- package/dist/template/.opencode/command/research.md +55 -266
- package/dist/template/.opencode/command/resume.md +33 -138
- package/dist/template/.opencode/command/review-codebase.md +54 -202
- package/dist/template/.opencode/command/ship.md +78 -127
- package/dist/template/.opencode/command/start.md +47 -577
- package/dist/template/.opencode/command/status.md +60 -353
- package/dist/template/.opencode/command/ui-review.md +52 -298
- package/dist/template/.opencode/command/verify.md +36 -250
- package/dist/template/.opencode/memory.db-shm +0 -0
- package/dist/template/.opencode/memory.db-wal +0 -0
- package/dist/template/.opencode/opencode.json +133 -35
- package/dist/template/.opencode/plugin/README.md +40 -166
- package/dist/template/.opencode/plugin/compaction.ts +162 -131
- package/dist/template/.opencode/plugin/lib/memory-db.ts +112 -0
- package/dist/template/.opencode/plugin/swarm-enforcer.ts +182 -27
- package/dist/template/.opencode/skill/augment-context-engine/SKILL.md +112 -0
- package/dist/template/.opencode/skill/augment-context-engine/mcp.json +6 -0
- package/dist/template/.opencode/skill/core-data-expert/SKILL.md +82 -0
- package/dist/template/.opencode/skill/core-data-expert/references/batch-operations.md +543 -0
- package/dist/template/.opencode/skill/core-data-expert/references/cloudkit-integration.md +259 -0
- package/dist/template/.opencode/skill/core-data-expert/references/concurrency.md +522 -0
- package/dist/template/.opencode/skill/core-data-expert/references/fetch-requests.md +643 -0
- package/dist/template/.opencode/skill/core-data-expert/references/glossary.md +233 -0
- package/dist/template/.opencode/skill/core-data-expert/references/migration.md +393 -0
- package/dist/template/.opencode/skill/core-data-expert/references/model-configuration.md +597 -0
- package/dist/template/.opencode/skill/core-data-expert/references/performance.md +300 -0
- package/dist/template/.opencode/skill/core-data-expert/references/persistent-history.md +553 -0
- package/dist/template/.opencode/skill/core-data-expert/references/project-audit.md +60 -0
- package/dist/template/.opencode/skill/core-data-expert/references/saving.md +574 -0
- package/dist/template/.opencode/skill/core-data-expert/references/stack-setup.md +625 -0
- package/dist/template/.opencode/skill/core-data-expert/references/testing.md +300 -0
- package/dist/template/.opencode/skill/core-data-expert/references/threading.md +589 -0
- package/dist/template/.opencode/skill/swift-concurrency/SKILL.md +246 -0
- package/dist/template/.opencode/skill/swift-concurrency/references/actors.md +640 -0
- package/dist/template/.opencode/skill/swift-concurrency/references/async-algorithms.md +822 -0
- package/dist/template/.opencode/skill/swift-concurrency/references/async-await-basics.md +249 -0
- package/dist/template/.opencode/skill/swift-concurrency/references/async-sequences.md +670 -0
- package/dist/template/.opencode/skill/swift-concurrency/references/core-data.md +533 -0
- package/dist/template/.opencode/skill/swift-concurrency/references/glossary.md +128 -0
- package/dist/template/.opencode/skill/swift-concurrency/references/linting.md +142 -0
- package/dist/template/.opencode/skill/swift-concurrency/references/memory-management.md +542 -0
- package/dist/template/.opencode/skill/swift-concurrency/references/migration.md +1076 -0
- package/dist/template/.opencode/skill/swift-concurrency/references/performance.md +574 -0
- package/dist/template/.opencode/skill/swift-concurrency/references/sendable.md +578 -0
- package/dist/template/.opencode/skill/swift-concurrency/references/tasks.md +604 -0
- package/dist/template/.opencode/skill/swift-concurrency/references/testing.md +565 -0
- package/dist/template/.opencode/skill/swift-concurrency/references/threading.md +452 -0
- package/dist/template/.opencode/skill/swiftui-expert-skill/SKILL.md +290 -0
- package/dist/template/.opencode/skill/swiftui-expert-skill/references/animation-advanced.md +351 -0
- package/dist/template/.opencode/skill/swiftui-expert-skill/references/animation-basics.md +284 -0
- package/dist/template/.opencode/skill/swiftui-expert-skill/references/animation-transitions.md +326 -0
- package/dist/template/.opencode/skill/swiftui-expert-skill/references/image-optimization.md +286 -0
- package/dist/template/.opencode/skill/swiftui-expert-skill/references/layout-best-practices.md +312 -0
- package/dist/template/.opencode/skill/swiftui-expert-skill/references/liquid-glass.md +377 -0
- package/dist/template/.opencode/skill/swiftui-expert-skill/references/list-patterns.md +153 -0
- package/dist/template/.opencode/skill/swiftui-expert-skill/references/modern-apis.md +400 -0
- package/dist/template/.opencode/skill/swiftui-expert-skill/references/performance-patterns.md +377 -0
- package/dist/template/.opencode/skill/swiftui-expert-skill/references/scroll-patterns.md +305 -0
- package/dist/template/.opencode/skill/swiftui-expert-skill/references/sheet-navigation-patterns.md +292 -0
- package/dist/template/.opencode/skill/swiftui-expert-skill/references/state-management.md +447 -0
- package/dist/template/.opencode/skill/swiftui-expert-skill/references/text-formatting.md +285 -0
- package/dist/template/.opencode/skill/swiftui-expert-skill/references/view-structure.md +276 -0
- package/dist/template/.opencode/tool/action-queue.ts +308 -0
- package/dist/template/.opencode/tool/swarm.ts +65 -40
- package/package.json +16 -3
- package/dist/template/.opencode/.agents/skills/context7/SKILL.md +0 -88
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# CloudKit Integration
|
|
2
|
+
|
|
3
|
+
`NSPersistentCloudKitContainer` syncs Core Data with CloudKit, enabling seamless data synchronization across devices.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
### Basic Setup
|
|
8
|
+
|
|
9
|
+
```swift
|
|
10
|
+
import CoreData
|
|
11
|
+
import CloudKit
|
|
12
|
+
|
|
13
|
+
let container = NSPersistentCloudKitContainer(name: "Model")
|
|
14
|
+
|
|
15
|
+
container.loadPersistentStores { description, error in
|
|
16
|
+
if let error = error {
|
|
17
|
+
fatalError("Failed to load store: \(error)")
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Configure CloudKit Container
|
|
23
|
+
|
|
24
|
+
In Xcode:
|
|
25
|
+
1. Add CloudKit capability
|
|
26
|
+
2. Select or create CloudKit container
|
|
27
|
+
3. Enable "Use CloudKit" in Core Data model
|
|
28
|
+
|
|
29
|
+
### Schema Design Limitations
|
|
30
|
+
|
|
31
|
+
CloudKit has restrictions Core Data doesn't:
|
|
32
|
+
|
|
33
|
+
**Not Supported:**
|
|
34
|
+
- Unique constraints on entities
|
|
35
|
+
- `Undefined` attribute type
|
|
36
|
+
- `ObjectID` attribute type
|
|
37
|
+
- Non-optional relationships (must be optional)
|
|
38
|
+
- Relationships without inverse
|
|
39
|
+
- Deny deletion rule
|
|
40
|
+
|
|
41
|
+
**Supported:**
|
|
42
|
+
- Adding new fields to record types
|
|
43
|
+
- Adding new record types
|
|
44
|
+
|
|
45
|
+
**Important:** Production schema is **immutable**. Plan carefully!
|
|
46
|
+
|
|
47
|
+
## Schema Initialization
|
|
48
|
+
|
|
49
|
+
### Development Environment
|
|
50
|
+
|
|
51
|
+
```swift
|
|
52
|
+
// First run initializes schema in Development
|
|
53
|
+
container.loadPersistentStores { description, error in
|
|
54
|
+
// Schema created automatically
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Promoting to Production
|
|
59
|
+
|
|
60
|
+
1. Test thoroughly in Development
|
|
61
|
+
2. Open CloudKit Dashboard
|
|
62
|
+
3. Deploy schema to Production
|
|
63
|
+
4. **Cannot modify after deployment!**
|
|
64
|
+
|
|
65
|
+
## Monitoring Sync
|
|
66
|
+
|
|
67
|
+
### Observe Events
|
|
68
|
+
|
|
69
|
+
```swift
|
|
70
|
+
NotificationCenter.default.addObserver(
|
|
71
|
+
self,
|
|
72
|
+
selector: #selector(storeDidChange),
|
|
73
|
+
name: NSPersistentCloudKitContainer.eventChangedNotification,
|
|
74
|
+
object: container
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
@objc func storeDidChange(_ notification: Notification) {
|
|
78
|
+
guard let event = notification.userInfo?[NSPersistentCloudKitContainer.eventNotificationUserInfoKey]
|
|
79
|
+
as? NSPersistentCloudKitContainer.Event else {
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
switch event.type {
|
|
84
|
+
case .setup:
|
|
85
|
+
print("Setup: \(event.succeeded ? "succeeded" : "failed")")
|
|
86
|
+
case .import:
|
|
87
|
+
print("Import: \(event.succeeded ? "succeeded" : "failed")")
|
|
88
|
+
case .export:
|
|
89
|
+
print("Export: \(event.succeeded ? "succeeded" : "failed")")
|
|
90
|
+
@unknown default:
|
|
91
|
+
break
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if let error = event.error {
|
|
95
|
+
print("Error: \(error)")
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Testing Sync
|
|
101
|
+
|
|
102
|
+
```swift
|
|
103
|
+
func testSync() {
|
|
104
|
+
let expectation = XCTestExpectation(description: "Export")
|
|
105
|
+
|
|
106
|
+
// Create expectation for export
|
|
107
|
+
let observer = NotificationCenter.default.addObserver(
|
|
108
|
+
forName: NSPersistentCloudKitContainer.eventChangedNotification,
|
|
109
|
+
object: container,
|
|
110
|
+
queue: nil
|
|
111
|
+
) { notification in
|
|
112
|
+
guard let event = notification.userInfo?[NSPersistentCloudKitContainer.eventNotificationUserInfoKey]
|
|
113
|
+
as? NSPersistentCloudKitContainer.Event else {
|
|
114
|
+
return
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if event.type == .export && event.endDate != nil {
|
|
118
|
+
expectation.fulfill()
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Make changes
|
|
123
|
+
let article = Article(context: container.viewContext)
|
|
124
|
+
article.name = "Test"
|
|
125
|
+
try? container.viewContext.save()
|
|
126
|
+
|
|
127
|
+
wait(for: [expectation], timeout: 60)
|
|
128
|
+
NotificationCenter.default.removeObserver(observer)
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Cross-Version Compatibility
|
|
133
|
+
|
|
134
|
+
### Strategy 1: Incremental Fields
|
|
135
|
+
|
|
136
|
+
Add new fields, keep old ones:
|
|
137
|
+
|
|
138
|
+
```swift
|
|
139
|
+
// V1: name
|
|
140
|
+
// V2: name, subtitle (new)
|
|
141
|
+
// Old versions see records but not subtitle
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Strategy 2: Version Attribute
|
|
145
|
+
|
|
146
|
+
```swift
|
|
147
|
+
// Add version attribute
|
|
148
|
+
article.schemaVersion = 2
|
|
149
|
+
|
|
150
|
+
// Filter in fetch requests
|
|
151
|
+
fetchRequest.predicate = NSPredicate(format: "schemaVersion <= %d", currentVersion)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Strategy 3: New Container
|
|
155
|
+
|
|
156
|
+
```swift
|
|
157
|
+
let options = NSPersistentCloudKitContainerOptions(
|
|
158
|
+
containerIdentifier: "iCloud.com.example.app.v2"
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
let description = NSPersistentStoreDescription(url: storeURL)
|
|
162
|
+
description.cloudKitContainerOptions = options
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Caution:** Large datasets take time to upload.
|
|
166
|
+
|
|
167
|
+
## Debugging
|
|
168
|
+
|
|
169
|
+
### System Logs
|
|
170
|
+
|
|
171
|
+
Monitor these processes:
|
|
172
|
+
- **Application** - Core Data activity
|
|
173
|
+
- **dasd** - Scheduling decisions
|
|
174
|
+
- **cloudd** - CloudKit operations
|
|
175
|
+
- **apsd** - Push notifications
|
|
176
|
+
|
|
177
|
+
### Using log stream
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Application logs
|
|
181
|
+
log stream --predicate 'process == "YourApp"'
|
|
182
|
+
|
|
183
|
+
# CloudKit logs
|
|
184
|
+
log stream --predicate 'process == "cloudd" AND message CONTAINS "your.container.id"'
|
|
185
|
+
|
|
186
|
+
# Push notifications
|
|
187
|
+
log stream --predicate 'process == "apsd"'
|
|
188
|
+
|
|
189
|
+
# Scheduling
|
|
190
|
+
log stream --predicate 'process == "dasd" AND message CONTAINS "YourApp"'
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### CloudKit Logging Profile
|
|
194
|
+
|
|
195
|
+
1. Download from [Apple Developer Portal](https://developer.apple.com/bug-reporting/profiles-and-logs/)
|
|
196
|
+
2. Install on device
|
|
197
|
+
3. Reboot device
|
|
198
|
+
4. Reproduce issue
|
|
199
|
+
5. Collect sysdiagnose
|
|
200
|
+
|
|
201
|
+
### Collecting Diagnostics
|
|
202
|
+
|
|
203
|
+
**sysdiagnose:**
|
|
204
|
+
- iOS: Volume Up + Volume Down + Power (hold)
|
|
205
|
+
- macOS: Shift + Control + Option + Command + Period
|
|
206
|
+
|
|
207
|
+
## Common Issues
|
|
208
|
+
|
|
209
|
+
### Schema Mismatch
|
|
210
|
+
|
|
211
|
+
**Problem:** Local schema doesn't match CloudKit schema.
|
|
212
|
+
|
|
213
|
+
**Solution:**
|
|
214
|
+
1. Delete app
|
|
215
|
+
2. Reinstall
|
|
216
|
+
3. Let schema reinitialize
|
|
217
|
+
|
|
218
|
+
### Sync Not Working
|
|
219
|
+
|
|
220
|
+
**Checklist:**
|
|
221
|
+
- [ ] CloudKit capability enabled
|
|
222
|
+
- [ ] Signed in to iCloud
|
|
223
|
+
- [ ] Network connection available
|
|
224
|
+
- [ ] CloudKit container configured
|
|
225
|
+
- [ ] Schema initialized in Development
|
|
226
|
+
- [ ] Schema promoted to Production
|
|
227
|
+
|
|
228
|
+
### Large Initial Sync
|
|
229
|
+
|
|
230
|
+
**Problem:** First sync takes too long.
|
|
231
|
+
|
|
232
|
+
**Solutions:**
|
|
233
|
+
- Use background fetch
|
|
234
|
+
- Show progress indicator
|
|
235
|
+
- Implement data generators for testing
|
|
236
|
+
|
|
237
|
+
## Best Practices
|
|
238
|
+
|
|
239
|
+
1. **Test in Development first** - Schema is mutable
|
|
240
|
+
2. **Plan schema carefully** - Production is immutable
|
|
241
|
+
3. **Make relationships optional** - Required by CloudKit
|
|
242
|
+
4. **Add inverse relationships** - Required by CloudKit
|
|
243
|
+
5. **Version your data** - For cross-version compatibility
|
|
244
|
+
6. **Monitor sync events** - Detect and handle errors
|
|
245
|
+
7. **Test with multiple devices** - Verify sync behavior
|
|
246
|
+
8. **Handle conflicts** - Use appropriate merge policy
|
|
247
|
+
9. **Collect diagnostics** - For debugging sync issues
|
|
248
|
+
10. **Consider data size** - Large datasets take time to sync
|
|
249
|
+
|
|
250
|
+
## Summary
|
|
251
|
+
|
|
252
|
+
- Use `NSPersistentCloudKitContainer` for CloudKit sync
|
|
253
|
+
- Schema has limitations (optional relationships, no constraints)
|
|
254
|
+
- Production schema is immutable
|
|
255
|
+
- Monitor sync with event notifications
|
|
256
|
+
- Test thoroughly in Development before promoting
|
|
257
|
+
- Plan for cross-version compatibility
|
|
258
|
+
- Use system logs for debugging
|
|
259
|
+
- Collect sysdiagnose for complex issues
|