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.
This commit is contained in:
Claude
2026-01-04 19:14:03 +00:00
parent e845445e64
commit e97952ecaa
2 changed files with 50 additions and 1 deletions

View File

@@ -18,7 +18,8 @@ export type AppId =
| "conn"
| "spells"
| "spellbooks"
| "win";
| "win"
| "login-handler";
export interface WindowInstance {
id: string;

View File

@@ -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<string, ManPageEntry> = {
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",