Repository navigation
Populate workspace todos from Claude's TaskCreate/TaskUpdate calls #9475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
6067028
ad73eaf
5c18a43
4e61c29
1d0c06a
86d8e26
07b8a65
dc04fd7
d0db71a
7995a11
e003e1c
a4594a1
6c1143d
14b2c2b
b78f7ab
9ebd6b0
9ea7999
58a1a93
a928107
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import Foundation | ||
| #if canImport(CryptoKit) | ||
| import CryptoKit | ||
| #endif | ||
|
|
||
| extension WorkstreamTaskTodo { | ||
| /// A stable workspace-checklist identity for this todo inside | ||
| /// `workstreamId`. | ||
| /// | ||
| /// Agent task ids are per-session counters (`"1"`, `"2"`, …) while the | ||
| /// workspace checklist is keyed by `UUID`, so the pair is hashed into a | ||
| /// deterministic UUID. Deriving it (instead of keeping a side table) means | ||
| /// the same task keeps its checklist row across app restarts and across | ||
| /// every entrypoint that syncs the list, and scoping it by workstream | ||
| /// keeps two concurrent agents in one workspace from colliding on the | ||
| /// shared `"1"`, `"2"` numbering. | ||
| /// | ||
| /// - Parameter workstreamId: The owning workstream (agent session) id. | ||
| /// - Returns: A deterministic RFC 4122 UUID for this `(workstream, task)`. | ||
| public func stableChecklistItemId(workstreamId: String) -> UUID { | ||
| workstreamChecklistItemId(workstreamId: workstreamId, taskId: id) | ||
| } | ||
| } | ||
|
|
||
| /// The deterministic checklist identity for one agent task id. | ||
| /// | ||
| /// Exposed separately from ``WorkstreamTaskTodo/stableChecklistItemId(workstreamId:)`` | ||
| /// so callers can derive the identity of a task they no longer hold (for | ||
| /// example, retiring rows for tasks the agent has deleted). | ||
| /// | ||
| /// - Parameters: | ||
| /// - workstreamId: The owning workstream (agent session) id. | ||
| /// - taskId: The agent's task id. | ||
| /// - Returns: A deterministic RFC 4122 UUID for this `(workstream, task)`. | ||
| public func workstreamChecklistItemId(workstreamId: String, taskId: String) -> UUID { | ||
| derivedChecklistUUID(from: "cmux.workstream.todo\u{0}\(workstreamId)\u{0}\(taskId)") | ||
| } | ||
|
|
||
| private func derivedChecklistUUID(from seed: String) -> UUID { | ||
| let data = Data(seed.utf8) | ||
| var bytes: [UInt8] | ||
| #if canImport(CryptoKit) | ||
| bytes = Array(SHA256.hash(data: data).prefix(16)) | ||
| #else | ||
| bytes = Array(repeating: 0, count: 16) | ||
| for (index, byte) in data.enumerated() { | ||
| bytes[index % 16] = bytes[index % 16] &+ byte &+ UInt8(truncatingIfNeeded: index) | ||
| } | ||
| #endif | ||
|
Comment on lines
+39
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win Drop the non-CryptoKit fallback instead of keeping a weak digest. This package lives under 🤖 Prompt for AI Agents |
||
| // RFC 4122 version 4 / variant bits so the value is a well-formed UUID. | ||
| bytes[6] = (bytes[6] & 0x0F) | 0x40 | ||
| bytes[8] = (bytes[8] & 0x3F) | 0x80 | ||
| return UUID(uuid: ( | ||
| bytes[0], bytes[1], bytes[2], bytes[3], | ||
| bytes[4], bytes[5], bytes[6], bytes[7], | ||
| bytes[8], bytes[9], bytes[10], bytes[11], | ||
| bytes[12], bytes[13], bytes[14], bytes[15] | ||
| )) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import Foundation | ||
|
|
||
| /// The outcome of feeding one task-tool call to ``WorkstreamTaskToolTodos``. | ||
| /// | ||
| /// Distinguishing ``ignored`` from an empty ``list(_:)`` matters: deleting the | ||
| /// agent's last task is a real empty-list transition that must retire its | ||
| /// checklist rows, while an unparseable payload must fall through to ordinary | ||
| /// tool telemetry and leave the checklist alone. | ||
| enum WorkstreamTaskToolOutcome: Equatable { | ||
| /// The payload carried nothing usable; the caller should fall back to | ||
| /// plain tool-use telemetry. | ||
| case ignored | ||
| /// The workstream's task list after applying the call. | ||
| case list([WorkstreamTaskTodo]) | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.