### Check Swift version Source: https://github.com/alterhq/openpetskit/blob/main/CONTRIBUTING.md Verify that Swift 6.0 or later is installed before building or testing. ```sh swift --version ``` -------------------------------- ### Run the full test suite Source: https://github.com/alterhq/openpetskit/blob/main/CONTRIBUTING.md Execute all unit tests before making changes or opening a pull request. ```sh swift test ``` -------------------------------- ### Build OpenPetsKit with Swift Package Manager Source: https://github.com/alterhq/openpetskit/blob/main/CONTRIBUTING.md Fetch dependencies and compile the package from a local checkout. ```sh cd OpenPetsKit swift build ``` -------------------------------- ### Check if the shared pet is running Source: https://github.com/alterhq/openpetskit/blob/main/docs/shared-pet-system.md Check whether the shared pet is already running before deciding to start your own host. If running, play a waving animation; otherwise start or prompt for the user's preferred host. ```swift let client = OpenPetsClient() if client.isPetRunning() { try client.send(.playAnimation(name: .waving)) } else { // Start or prompt for the user's preferred OpenPets host. } ``` -------------------------------- ### Run targeted tests for bundled pet and IPC framing Source: https://github.com/alterhq/openpetskit/blob/main/CONTRIBUTING.md Useful manual checks for specific test cases: BundledStarcornPetLoads and UnixSocketClientServerFraming. ```sh swift test --filter BundledStarcornPetLoads ``` ```sh swift test --filter UnixSocketClientServerFraming ``` -------------------------------- ### CLI host and notify with custom socket Source: https://github.com/alterhq/openpetskit/blob/main/docs/shared-pet-system.md Run a pet host and send a notification to a custom socket for isolation, such as integration tests or a second pet host. The first command starts the host, the second sends a message to the dev socket. ```sh swift run openpets run --pet /path/to/starcorn --socket /tmp/openpets-dev.sock swift run openpets notify --socket /tmp/openpets-dev.sock --title "Dev Pet" --status message --text "This targets the dev socket." ``` -------------------------------- ### Load configuration and create client with custom socket path Source: https://github.com/alterhq/openpetskit/blob/main/docs/shared-pet-system.md Honor the user's configured socket by loading `~/.config/openpets/config.json` and passing the socket path to the client. ```swift let configuration = try OpenPetsConfiguration.loadOrCreateDefault() let client = OpenPetsClient(socketPath: configuration.socketPath) ``` -------------------------------- ### Swift client with custom socket path Source: https://github.com/alterhq/openpetskit/blob/main/docs/shared-pet-system.md Create an OpenPetsClient that connects to a custom socket, useful for isolation. Use only when intentionally targeting a different pet host. ```swift let client = OpenPetsClient(socketPath: "/tmp/openpets-dev.sock") ``` -------------------------------- ### Send a pet notification with OpenPetsClient Source: https://github.com/alterhq/openpetskit/blob/main/README.md Creates an OpenPetsClient, sends a .notify command with a PetNotification, and prints the response threadId. ```swift import OpenPetsKit let client = OpenPetsClient() let response = try client.send(.notify(PetNotification( title: "Export Complete", text: "The customer report is ready.", status: "done" ))) print(response.threadId ?? "") ``` -------------------------------- ### Add OpenPetsKit product to target dependencies Source: https://github.com/alterhq/openpetskit/blob/main/README.md Adds the OpenPetsKit library product to a target's dependencies in a Swift package manifest. ```swift .target( name: "YourApp", dependencies: [ .product(name: "OpenPetsKit", package: "OpenPetsKit") ] ) ``` -------------------------------- ### Send a notification with the default client Source: https://github.com/alterhq/openpetskit/blob/main/docs/shared-pet-system.md Use the built-in default client to participate in the user's shared OpenPets companion without custom configuration. The response provides a threadId for later updates. ```swift import OpenPetsKit let client = OpenPetsClient() let response = try client.send(.notify(PetNotification( title: "Export Running", text: "Generating the customer report.", status: "running" ))) let threadId = response.threadId ``` -------------------------------- ### Load bundled Starcorn pet Source: https://github.com/alterhq/openpetskit/blob/main/README.md Loads the bundled Starcorn pet from OpenPetsBundledPets.starcornURL using PetBundle.load. ```swift import OpenPetsKit let petURL = OpenPetsBundledPets.starcornURL let petBundle = try PetBundle.load(from: petURL) ``` -------------------------------- ### Add OpenPetsKit package dependency Source: https://github.com/alterhq/openpetskit/blob/main/README.md Adds the OpenPetsKit package from the main branch to a Swift package manifest. ```swift .package(url: "https://github.com/alterhq/OpenPetsKit.git", branch: "main") ``` -------------------------------- ### Update a notification with the same threadId Source: https://github.com/alterhq/openpetskit/blob/main/docs/shared-pet-system.md Reuse the returned threadId to update the same operation's bubble in place. Omitting threadId for every update creates separate bubbles for each task. ```swift try client.send(.notify(PetNotification( title: "Export Complete", text: "The customer report is ready.", status: "done", threadId: threadId ))) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.