Skip to content

feat: streamline setup with platform-specific guidance and SSH helper - #21

Merged
neuromechanist merged 4 commits into
mainfrom
feature/self-contained-setup
Jan 16, 2026
Merged

neuromechanist merged 4 commits into
mainfrom
feature/self-contained-setup

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Jan 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR improves the onboarding experience for new users by:

  1. Platform-specific installation messages (closes datalad install #10)

    • macOS: suggests brew install datalad and brew install git-annex
    • Linux: suggests apt install datalad and apt install git-annex
    • Updates SSH error to suggest nemar auth setup-ssh
  2. New nemar auth setup-ssh command (refs Auto-generate SSH keys for GitHub access during upload #19)

    • Generates a dedicated Ed25519 SSH key for NEMAR (~/.ssh/nemar_ed25519)
    • Configures ~/.ssh/config automatically
    • Tests if SSH already works, skips setup if so
    • Provides clear step-by-step instructions to add the key to GitHub

Note on issue #19

The original issue proposed auto-registering SSH keys with GitHub. This requires OAuth authorization from the user (to get admin:public_key scope), which is not yet implemented. The current implementation:

  • Generates and configures SSH keys locally (automated)
  • Requires users to manually add the key to GitHub (one-time setup)

Full automation is tracked in #20.

Test plan

  • nemar auth --help shows new setup-ssh command
  • All 109 existing tests pass
  • SSH key generation works on macOS
  • Platform-specific messages show correctly

Related issues

…ecific guidance

- macOS: suggest brew install
- Linux: suggest apt install
- Update SSH error message to suggest 'nemar auth setup-ssh'

Closes #10
- Add ssh.ts utility for SSH key generation and configuration
- Add 'nemar auth setup-ssh' command that:
  - Generates Ed25519 SSH key dedicated to NEMAR (~/.ssh/nemar_ed25519)
  - Configures ~/.ssh/config automatically
  - Provides clear instructions to add key to GitHub
- Add API types for future OAuth-based auto-registration (see #20)

This partially addresses #19. Full auto-registration requires OAuth flow (tracked in #20).
@neuromechanist

Copy link
Copy Markdown
Contributor Author

PR Review Summary

Critical Issues (2 found)

Agent Issue Location
silent-failure-hunter Empty catch block in readPublicKey() - Returns null without any indication of why read failed (permission denied, encoding issues, etc.) ssh.ts:117-121
silent-failure-hunter Empty catch block in hasSSHConfigEntry() - Returns false on read errors, could cause attempting to overwrite protected files ssh.ts:132-139

Important Issues (3 found)

Agent Issue Location
code-reviewer Unused API functions - registerSSHKey() and checkSSHKeyStatus() are defined but never called api.ts:188-204
code-reviewer Unused setupSSH() function - Defined but not exported or used ssh.ts:159-195
silent-failure-hunter mkdirSync can throw unhandled errors - Outside try-catch, will throw exceptions that propagate unexpectedly ssh.ts:65-67, 150-152

Medium Issues (5 found)

Agent Issue Location
code-reviewer Logic bug in setupSSH() - keyGenerated and configUpdated flags have inverted logic (checked after operation) ssh.ts:174-175, 188-189
silent-failure-hunter Race condition - TOCTOU between existsSync and readFileSync ssh.ts:70-77
silent-failure-hunter Broad catch block - readFileSync inside try block after ssh-keygen, wrong error message if read fails ssh.ts:104-106
silent-failure-hunter Poor error message - "Could not read public key" lacks actionable guidance auth.ts:507-509
silent-failure-hunter No logging infrastructure - Errors displayed but not logged for debugging All files

Suggestions

Agent Suggestion
code-simplifier Extract getInstallCommand() helper to eliminate duplicated platform detection ✅ (applied)
code-simplifier Remove unused setupSSH() function and SSHSetupResult interface
code-reviewer Add comment warning that SSH config may override existing Host github.com entry

Strengths

  • Result-object pattern {success, error} is good for explicit error handling
  • User-facing spinners with ora provide good feedback
  • Proper stderr capture from ssh-keygen
  • Platform-specific installation messages are helpful

Recommended Actions

  1. Should fix before merge:

    • Add error details to empty catch blocks (preserve error messages)
    • Wrap mkdirSync calls in try-catch
    • Remove unused setupSSH() function (or mark API functions as TODO for future)
  2. Optional improvements:

    • Add actionable guidance to error messages
    • Consider adding debug mode (NEMAR_DEBUG=1)

- Remove unused setupSSH() function and SSHSetupResult interface
- Extract getInstallCommand() helper to reduce duplication
- Wrap mkdirSync calls in try-catch for proper error handling
- Preserve error details in catch blocks instead of silently failing
- Add TODO comments to unused API functions (for future backend integration)
- Add null check for apiKey before login call (TS2345)
- Apply biome formatting and template literal fixes
- Sort imports alphabetically
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-generate SSH keys for GitHub access during upload datalad install

1 participant