From e97952ecaa519f0cf7be9301408b5e470b80c8e8 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 4 Jan 2026 19:14:03 +0000 Subject: [PATCH] feat: add /login command to command palette Add login command to enable account management via command palette. Supports read-only accounts (npub, nip-05, hex, nprofile) and will support browser extension (NIP-07) via dialog. Changes: - Added login command to man pages with full documentation - Command parser uses createAccountFromInput() from login-parser - Supports direct login: `login npub1...` or `login alice@nostr.com` - Opens dialog when called without arguments: `login` - Added "login-handler" to AppId type Example usage: - `login` - Open login dialog - `login npub1abc...` - Add read-only account from npub - `login alice@nostr.com` - Add read-only account from NIP-05 Build successful. --- src/types/app.ts | 3 ++- src/types/man.ts | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/types/app.ts b/src/types/app.ts index 7ecd39c..006975a 100644 --- a/src/types/app.ts +++ b/src/types/app.ts @@ -18,7 +18,8 @@ export type AppId = | "conn" | "spells" | "spellbooks" - | "win"; + | "win" + | "login-handler"; export interface WindowInstance { id: string; diff --git a/src/types/man.ts b/src/types/man.ts index 758813f..c20e258 100644 --- a/src/types/man.ts +++ b/src/types/man.ts @@ -5,6 +5,7 @@ import { parseOpenCommand } from "@/lib/open-parser"; import { parseProfileCommand } from "@/lib/profile-parser"; import { parseRelayCommand } from "@/lib/relay-parser"; import { resolveNip05Batch } from "@/lib/nip05"; +import { createAccountFromInput } from "@/lib/login-parser"; export interface ManPageEntry { name: string; @@ -92,6 +93,53 @@ export const manPages: Record = { category: "System", defaultProps: { cmd: "help" }, }, + login: { + name: "login", + section: "1", + synopsis: "login [identifier]", + description: + "Add a new Nostr account to Grimoire. Supports read-only accounts (npub, nip-05, hex pubkey, nprofile) and signing accounts (browser extension via NIP-07). When called without arguments, opens the login dialog with method selection.", + options: [ + { + flag: "[identifier]", + description: + "Account identifier: npub1..., user@domain.com, hex pubkey, nprofile1..., or leave empty to open dialog", + }, + ], + examples: [ + "login Open login dialog", + "login npub1abc... Add read-only account from npub", + "login alice@nostr.com Add read-only account from NIP-05", + "login nprofile1... Add read-only account with relay hints", + "login 3bf0c63f... Add read-only account from hex pubkey", + ], + seeAlso: ["profile", "req"], + appId: "login-handler", + category: "System", + argParser: async (args: string[]) => { + const input = args.join(" ").trim(); + + // No input - open dialog + if (!input) { + return { action: "open-dialog" }; + } + + // Try to create account from input + try { + const account = await createAccountFromInput(input); + return { + action: "add-account", + account, + }; + } catch (error) { + return { + action: "error", + message: error instanceof Error ? error.message : "Unknown error", + }; + } + }, + defaultProps: { action: "open-dialog" }, + }, kinds: { name: "kinds", section: "1",