Skip to content

Commit 72b75c7

Browse files
authored
Merge pull request #4 from ReScienceLab/issue-2-onboarding-raycast-release
Implement developer onboarding and Raycast release readiness
2 parents 641660d + eed84b1 commit 72b75c7

12 files changed

Lines changed: 837 additions & 79 deletions

File tree

‎.github/workflows/release-cli.yml‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Release CLI
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
build-macos:
14+
name: Build macOS CLI
15+
runs-on: macos-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
target:
20+
- aarch64-apple-darwin
21+
- x86_64-apple-darwin
22+
steps:
23+
- name: Validate release tag
24+
if: startsWith(github.ref, 'refs/tags/')
25+
run: |
26+
if ! echo "${GITHUB_REF_NAME}" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
27+
echo "Release tags must use semantic version format: vX.Y.Z"
28+
exit 1
29+
fi
30+
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
- name: Install Rust target
35+
run: rustup target add ${{ matrix.target }}
36+
37+
- name: Build perch CLI
38+
run: cargo build --release --manifest-path cli/Cargo.toml --target ${{ matrix.target }}
39+
40+
- name: Package binary
41+
run: |
42+
cp cli/target/${{ matrix.target }}/release/perch perch-${{ matrix.target }}
43+
shasum -a 256 perch-${{ matrix.target }} > perch-${{ matrix.target }}.sha256
44+
45+
- name: Upload workflow artifacts
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: perch-${{ matrix.target }}
49+
path: |
50+
perch-${{ matrix.target }}
51+
perch-${{ matrix.target }}.sha256
52+
53+
- name: Upload release assets
54+
if: startsWith(github.ref, 'refs/tags/')
55+
env:
56+
GH_TOKEN: ${{ github.token }}
57+
run: |
58+
gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1 || \
59+
gh release create "${GITHUB_REF_NAME}" --title "${GITHUB_REF_NAME}" --generate-notes
60+
if ! gh release upload "${GITHUB_REF_NAME}" \
61+
perch-${{ matrix.target }} \
62+
perch-${{ matrix.target }}.sha256 \
63+
--clobber; then
64+
echo "Failed to upload release assets"
65+
exit 1
66+
fi
67+
gh release view "${GITHUB_REF_NAME}" --json assets --jq '.assets[].name'

‎App/Sources/PerchAppCore/StatusMenuController.swift‎

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,28 @@ enum StatusMenuLogic {
3434
return "cd '\(dir)' && \(session.resumeCmd)"
3535
}
3636

37+
static func projectLabel(from workingDir: String) -> String {
38+
guard !workingDir.isEmpty else { return "" }
39+
let name = URL(fileURLWithPath: workingDir).lastPathComponent
40+
return name.isEmpty ? workingDir : name
41+
}
42+
43+
static func groupedByProject(from sessions: [Session]) -> [(label: String, sessions: [Session])] {
44+
var groups: [(label: String, sessions: [Session])] = []
45+
var index: [String: Int] = [:]
46+
for session in sessions {
47+
let key = (session.workingDir as NSString).standardizingPath
48+
let label = projectLabel(from: session.workingDir)
49+
if let i = index[key] {
50+
groups[i].sessions.append(session)
51+
} else {
52+
index[key] = groups.count
53+
groups.append((label: label, sessions: [session]))
54+
}
55+
}
56+
return groups
57+
}
58+
3759
static func relativeTime(from iso8601: String, now: Date = Date()) -> String {
3860
let formatter = ISO8601DateFormatter()
3961
formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
@@ -175,8 +197,15 @@ public class StatusMenuController: NSObject, NSMenuDelegate {
175197
emptyItem.isEnabled = false
176198
menu.addItem(emptyItem)
177199
} else {
178-
for session in pending {
179-
menu.addItem(makeSessionItem(session, isDone: false))
200+
let projectGroups = StatusMenuLogic.groupedByProject(from: pending)
201+
let useGroupHeaders = projectGroups.count > 1
202+
for group in projectGroups {
203+
if useGroupHeaders {
204+
menu.addItem(makeProjectHeader(group.label))
205+
}
206+
for session in group.sessions {
207+
menu.addItem(makeSessionItem(session, isDone: false))
208+
}
180209
}
181210
}
182211

@@ -236,6 +265,19 @@ public class StatusMenuController: NSObject, NSMenuDelegate {
236265
menu.addItem(quitItem)
237266
}
238267

268+
private func makeProjectHeader(_ label: String) -> NSMenuItem {
269+
let item = NSMenuItem(title: label, action: nil, keyEquivalent: "")
270+
item.isEnabled = false
271+
item.attributedTitle = NSAttributedString(
272+
string: label,
273+
attributes: [
274+
.font: NSFont.systemFont(ofSize: 11, weight: .medium),
275+
.foregroundColor: NSColor.secondaryLabelColor
276+
]
277+
)
278+
return item
279+
}
280+
239281
private func makeSessionItem(_ session: Session, isDone: Bool) -> NSMenuItem {
240282
let time = StatusMenuLogic.relativeTime(from: session.createdAt)
241283
let item = NSMenuItem(

‎App/Tests/PerchAppCoreTests/PerchAppCoreTests.swift‎

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,102 @@ final class PerchAppCoreTests: XCTestCase {
302302
XCTAssertEqual(groups.done.map(\.id), ["done"])
303303
}
304304

305+
func testStatusMenuLogicExtractsProjectLabelFromPath() {
306+
XCTAssertEqual(StatusMenuLogic.projectLabel(from: "/Users/yilin/Developer/Perch"), "Perch")
307+
XCTAssertEqual(StatusMenuLogic.projectLabel(from: "/tmp/my-project"), "my-project")
308+
XCTAssertEqual(StatusMenuLogic.projectLabel(from: "/root"), "root")
309+
XCTAssertEqual(StatusMenuLogic.projectLabel(from: ""), "")
310+
}
311+
312+
func testStatusMenuLogicGroupsByProjectPreservingSessionOrder() {
313+
let p1a = sampleSession(id: "p1a", workingDir: "/projects/alpha", title: "Alpha 1")
314+
let p1b = sampleSession(id: "p1b", workingDir: "/projects/alpha", title: "Alpha 2")
315+
let p2a = sampleSession(id: "p2a", workingDir: "/projects/beta", title: "Beta 1")
316+
317+
let groups = StatusMenuLogic.groupedByProject(from: [p1a, p1b, p2a])
318+
319+
XCTAssertEqual(groups.count, 2)
320+
XCTAssertEqual(groups[0].label, "alpha")
321+
XCTAssertEqual(groups[0].sessions.map(\.id), ["p1a", "p1b"])
322+
XCTAssertEqual(groups[1].label, "beta")
323+
XCTAssertEqual(groups[1].sessions.map(\.id), ["p2a"])
324+
}
325+
326+
func testStatusMenuLogicGroupsByProjectSingleProjectProducesOneGroup() {
327+
let s1 = sampleSession(id: "s1", workingDir: "/projects/alpha")
328+
let s2 = sampleSession(id: "s2", workingDir: "/projects/alpha")
329+
330+
let groups = StatusMenuLogic.groupedByProject(from: [s1, s2])
331+
332+
XCTAssertEqual(groups.count, 1)
333+
XCTAssertEqual(groups[0].sessions.map(\.id), ["s1", "s2"])
334+
}
335+
336+
func testStatusMenuLogicGroupsByFullPathWhenLabelsCollide() {
337+
let homeApp = sampleSession(id: "home", workingDir: "/Users/yilin/app")
338+
let tmpApp = sampleSession(id: "tmp", workingDir: "/tmp/app")
339+
340+
let groups = StatusMenuLogic.groupedByProject(from: [homeApp, tmpApp])
341+
342+
XCTAssertEqual(groups.count, 2)
343+
XCTAssertEqual(groups[0].label, "app")
344+
XCTAssertEqual(groups[0].sessions.map(\.id), ["home"])
345+
XCTAssertEqual(groups[1].label, "app")
346+
XCTAssertEqual(groups[1].sessions.map(\.id), ["tmp"])
347+
}
348+
349+
func testStatusMenuLogicNormalizesProjectPathBeforeGrouping() {
350+
let s1 = sampleSession(id: "s1", workingDir: "/projects/alpha")
351+
let s2 = sampleSession(id: "s2", workingDir: "/projects/./alpha/")
352+
353+
let groups = StatusMenuLogic.groupedByProject(from: [s1, s2])
354+
355+
XCTAssertEqual(groups.count, 1)
356+
XCTAssertEqual(groups[0].sessions.map(\.id), ["s1", "s2"])
357+
}
358+
359+
func testStatusMenuControllerRendersProjectHeadersForMultipleProjects() {
360+
let alpha = sampleSession(id: "a", workingDir: "/projects/Alpha", title: "Task A", status: "pending")
361+
let beta = sampleSession(id: "b", workingDir: "/projects/Beta", title: "Task B", status: "pending")
362+
let controller = StatusMenuController(
363+
sessionLoader: { [alpha, beta] },
364+
configLoader: { PerchConfig() },
365+
statusWriter: { _, _ in },
366+
pasteboard: .withUniqueName(),
367+
watchFile: false
368+
)
369+
370+
controller.rebuildMenu()
371+
372+
let titles = controller.menu.items.map(\.title)
373+
XCTAssertTrue(titles.contains("Alpha"), "Expected project header 'Alpha' in \(titles)")
374+
XCTAssertTrue(titles.contains("Beta"), "Expected project header 'Beta' in \(titles)")
375+
let alphaIdx = try! XCTUnwrap(titles.firstIndex(of: "Alpha"))
376+
let taskAIdx = try! XCTUnwrap(titles.firstIndex { $0.contains("Task A") })
377+
let betaIdx = try! XCTUnwrap(titles.firstIndex(of: "Beta"))
378+
let taskBIdx = try! XCTUnwrap(titles.firstIndex { $0.contains("Task B") })
379+
XCTAssertLessThan(alphaIdx, taskAIdx)
380+
XCTAssertLessThan(betaIdx, taskBIdx)
381+
}
382+
383+
func testStatusMenuControllerOmitsProjectHeadersForSingleProject() {
384+
let s1 = sampleSession(id: "s1", workingDir: "/projects/Perch", title: "Task 1", status: "pending")
385+
let s2 = sampleSession(id: "s2", workingDir: "/projects/Perch", title: "Task 2", status: "pending")
386+
let controller = StatusMenuController(
387+
sessionLoader: { [s1, s2] },
388+
configLoader: { PerchConfig() },
389+
statusWriter: { _, _ in },
390+
pasteboard: .withUniqueName(),
391+
watchFile: false
392+
)
393+
394+
controller.rebuildMenu()
395+
396+
XCTAssertFalse(controller.menu.items.contains { $0.title == "Perch" && !$0.isEnabled },
397+
"Should not add a project header when all sessions share one project")
398+
XCTAssertTrue(controller.menu.items[0].title.contains("Task 1"))
399+
}
400+
305401
func testStatusMenuLogicMapsAgentIconResourceNames() {
306402
let cases: [(String, String)] = [
307403
("claude", "claudecode"),

‎README.md‎

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
# Perch
22

3-
Perch is a lightweight macOS menu bar app for parking AI coding sessions and resuming them later. Run `/perch` inside a supported coding agent, and Perch saves the current session into `~/.config/perch/sessions.json`. The menu bar app lists pending sessions; click one to copy a project-aware resume command to the clipboard.
3+
Perch helps developers park AI coding sessions and resume them later from the CLI, menu bar, or Raycast. Run `/perch` inside a supported coding agent, and Perch saves the current session into `~/.config/perch/sessions.json`.
4+
5+
## 60-Second Quick Start
6+
7+
Install the Perch CLI and supported agent `/perch` commands:
8+
9+
```sh
10+
curl -fsSL https://raw.githubusercontent.com/ReScienceLab/Perch/main/install.sh | sh
11+
```
12+
13+
Then:
14+
15+
1. Make sure `~/.local/bin` is in your shell `PATH`.
16+
2. Restart your coding agent.
17+
3. Type `/perch My task title` inside Claude Code, Codex, Pi, Droid, or OpenCode to save the current session.
18+
4. Resume from Raycast with **Search Sessions**, from the menu bar, or by running `perch list` and copying the resume command.
19+
5. Verify setup any time with:
20+
21+
```sh
22+
perch doctor
23+
```
24+
25+
Perch stores sessions locally only; no service or account is required.
426

527
## Highlights
628

@@ -30,6 +52,14 @@ Perch is a lightweight macOS menu bar app for parking AI coding sessions and res
3052
3153
## Install
3254

55+
Recommended remote install:
56+
57+
```sh
58+
curl -fsSL https://raw.githubusercontent.com/ReScienceLab/Perch/main/install.sh | sh
59+
```
60+
61+
Local repo install for contributors:
62+
3363
```sh
3464
git clone https://github.com/ReScienceLab/Perch.git
3565
cd Perch
@@ -38,12 +68,13 @@ cd Perch
3868

3969
The installer is idempotent. It:
4070

41-
- Builds and installs the `perch` CLI to `~/.local/bin/perch`.
71+
- Installs the `perch` CLI to `~/.local/bin/perch`, using the latest GitHub Release prebuilt binary by default.
72+
- Falls back to a local Cargo build only when running from a cloned repo and release download is unavailable.
4273
- Installs the same agent-agnostic command from `Commands/perch.md` for every detected agent.
4374
- Creates `~/.config/perch/sessions.json` if missing.
4475
- Creates `~/.config/perch/config` if missing.
4576

46-
Make sure `~/.local/bin` is in your shell `PATH` and is also visible inside your coding agents.
77+
Make sure `~/.local/bin` is in your shell `PATH` and is also visible inside your coding agents. Run `perch doctor` after installation for actionable diagnostics.
4778

4879
### Installed command locations
4980

@@ -163,6 +194,8 @@ perch done <perch-id-or-prefix>
163194
perch done --session-id <agent-session-id>
164195
perch reopen <perch-id-or-prefix>
165196
perch reopen --session-id <agent-session-id>
197+
perch doctor
198+
perch doctor --json
166199
```
167200

168201
## Save Semantics

0 commit comments

Comments
 (0)