Add pear open <dir> CLI to open or create a project for a directory#72
Conversation
Adds a CLI command so `pear open ./my-directory` opens Pear with the first project that already contains that directory (as an exact root or nested under one), or creates a new project with that directory as its only root. - bin/pear.mjs: thin launcher forwarding args to the Electron app - src/main/cli.ts: pure, testable argv parsing + find-or-create logic - src/main/index.ts: single-instance lock routes a second `pear open` invocation to the running window; initial-launch path is queued until the renderer loads - renderer listens for cli:open-project to reload and switch projects - tests cover argv parsing and find/create/reuse behavior
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
CodeAnt AI is reviewing your PR. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a pear CLI launcher and package bin, parses and resolves ChangesCLI and project open flow
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI Launcher
participant App as MainProcess
participant Window as MainWindow
participant Renderer as Renderer
CLI->>App: spawn Electron with argv
App->>App: requestSingleInstanceLock()
alt lock acquired
App->>App: handleOpenCommand(argv,cwd)
App->>Window: createWindow()
Window->>Renderer: register IPC on did-finish-load
App->>Renderer: cli:open-project (if pending)
else lock not acquired
App->>App: emit second-instance
App->>Window: focus/restore
App->>App: handleOpenCommand(argv,cwd)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f5fdef281f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
CodeAnt AI finished reviewing your PR. |
|
✅ pr-reviewer applied fixes — committed and pushed Reviewed PR #72 and made scoped fixes:
Checked PR bot comments; there were no actionable bot findings beyond summaries/quota notices. Verification:
|
|
Reviewed PR #72 and fixed the issues I found. Changes made:
Local verification:
|
|
✅ pr-reviewer applied fixes — committed and pushed Reviewed PR #72 and fixed the issues I found. Changes made:
Local verification:
|
- Resolve index.ts conflict: keep cli:renderer-ready IPC handler and fold in burnManager.warmUp() from main - Guard second-instance window calls with !mainWindow.isDestroyed() - bin/pear.mjs: propagate signal termination as non-zero exit (128+signal) instead of reporting success - parseOpenCommand: treat -- as end-of-options so dash-named dirs can open - Serialize cli:open-project handling (latest-wins) to avoid out-of-order active-project switches on rapid opens
|
CodeAnt AI is running Incremental review |
|
Merged latest
All 22 tests pass and Generated by Claude Code |
|
CodeAnt AI Incremental review completed. |
Make Pear a releasable signed/notarized macOS app: - electron-builder.yml: dmg + zip (arm64/x64), hardened runtime, entitlements, native-module unpacking (ssh2/cpu-features), GitHub publish config - build/entitlements.mac.plist + build/notarize.cjs (afterSign notarization, App Store Connect API key or Apple ID, skips cleanly without creds) - electron-updater wiring (src/main/updater.ts): checks GitHub Releases on launch + every 6h, prompts to restart, 'Check for Updates…' menu item - In-app 'Install pear CLI' action (src/main/cli-install.ts): admin-elevated shim into /usr/local/bin/pear pointing at the packaged app binary - .github/workflows/release.yml: tag-triggered macOS build/sign/notarize/publish - RELEASING.md: required Apple credentials + GitHub secrets and release steps - package.json: pack/dist/release scripts, electron-builder/-updater/notarize deps
Ship downloads as Pear-<version>-<arch>.dmg/.zip while keeping the installed app named 'Pear by Agent Relay'.
Resolve the packaging conflicts by adopting the pipeline from #76/#77 (now on main), which correctly handles the per-arch prebuilt broker binary, and layer our additive features on top: - electron-builder.yml: take main's config (arm64-only, npmRebuild:false, resources bundled + app-icon extraResource, build/icon.png, notarize:true, draft release); add a zip target so electron-updater can self-update - release.yml, entitlements.mac.plist, package.json deps/scripts: adopt main's - Drop our redundant afterSign notarize hook + @electron/notarize dep (replaced by built-in notarize:true) - Keep our additions: pear open CLI, in-app CLI installer, electron-updater auto-update wiring, and clean artifact filenames - Update RELEASING.md to match (manual dispatch, draft, arm64)
|
CodeAnt AI is running Incremental review |
|
CodeAnt AI Incremental review completed. |
main now owns the signed/notarized release pipeline (#76/#77), so drop the duplicate packaging config from this PR and keep only the application-level work: - Revert electron-builder.yml / release.yml / entitlements.mac.plist to main's - Remove RELEASING.md and the stale release/ gitignore entry - Keep: pear open CLI, in-app CLI installer, and electron-updater auto-update - The sole release-config change retained is a zip target in electron-builder.yml, which auto-update requires (generates latest-mac.yml + the update artifact)
User description
Summary
Adds a CLI command so
pear open ./my-directoryopens Pear with the first project that already contains that directory, or creates a new project with that directory as its only root.Matching behavior: a project matches if the directory is an exact root or nested under one of its roots (paths are resolved to absolute, so relative inputs like
./my-directorymatch stored absolute roots). If no project matches, a new one is created, named after the directory's basename, with that single root.How it works
bin/pear.mjs— thin launcher (wired viapackage.json"bin") that forwards args to the Electron app.src/main/cli.ts— pure, dependency-injected logic:parseOpenCommand(argv)— extracts the path after theopenverb (robust to Electron's varying argv shapes and intervening flags).findProjectForPath(projects, path)— finds the first project whose roots contain the directory.openProjectForPath(path, deps)— reuses + activates a matching project, or creates a new one (rejecting non-directories).src/main/index.ts— a single-instance lock routes a secondpear open …invocation into the already-running window (restoring/focusing it). The initial-launch path is queued until the renderer finishes loading, then sent ascli:open-project.use-broker-events.ts— the renderer listens forcli:open-project, reloads the project list (to pick up a newly created project), and switches the active project.Testing
src/main/__tests__/cli.test.tscovering argv parsing, exact/nested/sibling matching, reuse, create, and non-directory rejection. Full suite passes (20/20).npm run buildsucceeds with the new code bundled.Notes
bin/pear.mjslaunches the locally-built app (out/main/index.js), so it works in the repo afternpm run build. A packaged distributable would pointpearat the installed binary instead — happy to wire that up in a follow-up if wanted.https://claude.ai/code/session_01BGTwZWKEUQ324n1REnhZPW
Generated by Claude Code
CodeAnt-AI Description
Add a terminal command to open projects from a directory, with installer and update support
What Changed
pear open <dir>now opens the matching project for that folder, or creates a new project when none existspearcommand into your PATH from the menu, and shows a confirmation or error message after installpear open -- -nameImpact
✅ Faster access to the right project from the terminal✅ Fewer duplicate app windows when reopening Pear✅ Clearer install and update feedback for macOS users🔄 Retrigger CodeAnt AI Review
💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.