| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Site: https://annotkit.gpu-cli.sh
A Swift package for native in-app annotation, built for AI coding agents. Click a UI element in your own macOS or iOS app, or drag a frame around it, attach a note, and emit an agent-readable, code-locating annotation. The native analogue of the web Agentation tool.
The gesture becomes a stable selector, an element path, the element's role and text, and your comment, so an AI coding agent can locate the exact view instead of guessing from a verbal description.
Requirements: Swift 6.1 toolchain (Xcode 16.3 or later), macOS 15+ or iOS 17+. The package is Swift 6 language mode with strict concurrency. It has no dependencies.
Xcode: File ▸ Add Package Dependencies…, paste https://github.com/gpu-cli/annotkit, choose the version rule Up to Next Major from 0.8.0, and add the AnnotKit library to your app target. Leave AnnotKitMCP unchecked unless you want the agent bridge; the toolbar does not need it.
Package.swift:
dependencies: [
.package(url: "https://github.com/gpu-cli/annotkit", from: "0.8.0")
],
targets: [
.executableTarget(
name: "MyApp",
dependencies: [.product(name: "AnnotKit", package: "annotkit")]
)
]AppKit (macOS): in applicationDidFinishLaunching, after your main window is up:
import AnnotKit
func applicationDidFinishLaunching(_ notification: Notification) {
// ... make and show your window ...
#if DEBUG
Annotation.install() // floating toolbar; click a view, type a note
#endif
}If several windows are open at launch, name the one to annotate instead of letting AnnotKit pick: Annotation.install(on: window).
SwiftUI (macOS): call it from the root view's .onAppear or from an NSApplicationDelegateAdaptor:
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.onAppear {
#if DEBUG
Annotation.install()
#endif
}
}
}
}SwiftUI (iOS): attach it to the root view:
ContentView()
#if DEBUG
.installAnnotation()
#endifUIKit iOS hosts call Annotation.install() from the scene delegate once the window is key.
install() is a no-op in release builds unless the ANNOTKIT_ENABLE environment variable is set, and a no-op in debug builds when ANNOTKIT_DISABLE is set, so the #if DEBUG above is belt and braces: the toolbar never appears in a normal shipping build either way.
By default notes are written to ANNOTKIT_NOTES.md in the process's current working directory. For an app launched from Xcode that is usually not your project folder. Either set the working directory in the scheme (Edit Scheme ▸ Run ▸ Options ▸ Working Directory), point the path at the repo through the scheme's environment variables (ANNOTKIT_NOTES_MD=/path/to/repo/ANNOTKIT_NOTES.md), or pass a sink with an explicit path:
Annotation.install(sink: NotesFileSink(path: "/path/to/repo/ANNOTKIT_NOTES.md"))Other sinks: ClipboardSink(format: .markdown | .json) copies instead of writing, JSONFileSink writes the JSON store the MCP bridge reads, and MultiSink fans out to several.
Annotation.install(sink: ClipboardSink(format: .json))Selectors anchor to the nearest accessibilityIdentifier (#Settings.Models >> @Save). Views with no identifier anywhere above them still get a resolvable selector, but it is built from roles and indices and is fragile across layout changes. Put .accessibilityIdentifier("Settings.Models") on the components you expect to annotate and the notes will point an agent straight at that code.
Register a world-context provider and every captured note snapshots it, so an agent can put back the world the note was made in instead of guessing:
Annotation.install(
context: { ["persona": currentPersona, "appearance": appearanceName] }
)Press Annotate on the floating pill, click a control (or switch to the frame tool and drag around a card), type a note, and save. Export writes every pending note through the sink. Run swift run AnnotKitDemo in this repo to try the whole loop in a sample app first.
Write notes as JSON (JSONFileSink) and run the MCP server so an agent can query pending annotations over the Model Context Protocol:
swift run annotkit-mcp path/to/ANNOTKIT_NOTES.jsonTools: annotation_get_pending, annotation_resolve.
A host that launches many isolated instances of one binary — a design loop with an HMR session per branch, a gallery, an inspect window per persona — configures each of them from the launch environment alone, with no change to the app's call site:
ANNOTKIT_NOTES_MD=$WORLD/notes.md \
ANNOTKIT_NOTES=$WORLD/notes.json \
ANNOTKIT_EVENTS=$WORLD/events.jsonl \
ANNOTKIT_CONTEXT_PERSONA=ada \
./MyAppANNOTKIT_EVENTS adds an append-only JSONL log beside the snapshot — one line per capture, edit and delete — because the snapshot itself is written atomically and so cannot be followed with tail -f. An agent watches the stream and reads the snapshot the line names:
tail -F "$WORLD/events.jsonl" | while read -r line; do … doneFull contract, including how launcher context and the in-app provider merge: docs/embedding.md.
swift build
swift test
swift run AnnotKitProbe # live macOS smoke test
swift run AnnotKitDemo # interactive demo app (overlay mounted; good for recordings)
swift run AnnotKitEnvProbe # one env-configured embedding host, driven in codeSwift 6 (strict concurrency), macOS 15+, iOS 17+. Cross-compile for the iOS simulator with the command in CONTRIBUTING.md.
MIT. See LICENSE. The note format is a clean-room reimplementation of Agentation's AGENTATION_NOTES.md, written to ANNOTKIT_NOTES.md; this project contains no Agentation source.
| Back | FazBrowse Home | New Git URL |