Skip to content

feat: interactive postinstall onboarding for npm global installs#172

Open
arein wants to merge 5 commits intoopen-wallet-standard:mainfrom
arein:feat/postinstall-onboarding
Open

feat: interactive postinstall onboarding for npm global installs#172
arein wants to merge 5 commits intoopen-wallet-standard:mainfrom
arein:feat/postinstall-onboarding

Conversation

@arein
Copy link
Copy Markdown

@arein arein commented Apr 3, 2026

Screenshot 2026-04-03 at 12 42 41 PM

Summary

  • Adds a postinstall script that runs after npm install -g @open-wallet-standard/core and walks users through optional first-time setup:
    1. Install the OWS AI coding skillnpx skills add https://github.com/open-wallet-standard/core --skill ows
    2. Create their first wallet — prompts for a name, runs ows wallet create
    3. Fund the walletows fund deposit via MoonPay (Base USDC)
  • Only activates on global installs + interactive TTY — silent in CI and local npm install
  • Zero external dependencies (Node.js built-ins only: readline, child_process, fs)
  • Entire flow wrapped in .catch(() => {}) so errors never break installation

Inspired by nansen-ai/nansen-cli#302.

Test plan

  • npm install -g . from bindings/node/ — verify the onboarding flow triggers
  • Verify each prompt can be skipped with n
  • Verify defaults work (Enter accepts Y, empty wallet name defaults to my-wallet)
  • npm_config_global=false node scripts/postinstall.js — verify it exits silently
  • Pipe stdin (echo "" | node scripts/postinstall.js) — verify non-interactive fallback tips
  • Verify the script is included in npm pack output

🤖 Generated with Claude Code

After `npm install -g @open-wallet-standard/core`, users are walked
through optional first-time setup: installing the OWS AI coding skill,
creating their first wallet, and funding it with USDC via MoonPay.

- Only runs on global installs + interactive TTY (silent in CI)
- Zero external dependencies (Node.js built-ins only)
- Errors never break installation (wrapped in .catch)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@arein arein requested a review from njdawn as a code owner April 3, 2026 16:39
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 3, 2026

@arein is attempting to deploy a commit to the MoonPay Team on Vercel.

A member of the Team first needs to authorize it.

arein and others added 3 commits April 3, 2026 12:43
The postinstall script now checks for `ows` on $PATH as a final
fallback, which covers the common case where the binary is already
globally linked (e.g. via homebrew or a prior install).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix double-resolve in prompt() where the readline "close" event
  races with the question callback, resolving with "" (treated as
  default yes) before the actual answer is processed
- Add "ows" to skill directory detection (the skill installs as
  ~/.claude/skills/ows, not ~/.claude/skills/core)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
rl.close() synchronously emits "close", which called done("") before
done(answer.trim()) had a chance to run. Swapping the order ensures
the actual user answer is captured first.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@njdawn njdawn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium — bindings/node/scripts/postinstall.js: this is described as a first-time onboarding flow, but it has no persisted completion marker and no wallet-exists check, so it re-prompts on every interactive global reinstall/upgrade. I verified this by simulating two TTY installs against the same HOME; both runs asked the same skill and wallet questions again. That makes npm install -g @open-wallet-standard/core upgrades repeatedly interactive instead of “first-time only”.

Low — bindings/node/scripts/postinstall.js: non-interactive global installs are not actually silent. With npm_config_global=true and piped stdin, the script still prints onboarding tips to stderr. That contradicts the PR summary and can add noise to automation or scripted installs that expect postinstall to stay quiet outside interactive use.

- Write ~/.ows/.onboarding-done after first interactive run so upgrades
  don't re-prompt
- Remove stderr tips for non-interactive global installs (piped stdin)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@arein
Copy link
Copy Markdown
Author

arein commented Apr 4, 2026

Addressed both items in 384847a:

  • Completion marker — writes ~/.ows/.onboarding-done after the first interactive run. Marker is persisted early (right after guard checks pass) so all code paths — skip, failure, or full completion — are covered. Subsequent npm install -g upgrades exit silently.
  • Silent non-interactive — replaced the stderr tips block with a bare return when !process.stdin.isTTY. Non-interactive global installs now produce zero output.

🤖 Generated with Claude Code

@arein arein requested a review from njdawn April 4, 2026 13:18
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.

2 participants