taskify-nostr 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +38 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import { Command } from "commander";
3
3
  import chalk from "chalk";
4
4
  import { readFile, writeFile } from "fs/promises";
5
5
  import { createInterface } from "readline";
6
+ import { createRequire } from "module";
6
7
  import { nip19, getPublicKey, generateSecretKey } from "nostr-tools";
7
8
  import { loadConfig, saveConfig, saveProfiles, DEFAULT_RELAYS } from "./config.js";
8
9
  import { createNostrRuntime } from "./nostrRuntime.js";
@@ -10,10 +11,12 @@ import { renderTable, renderTaskCard, renderJson } from "./render.js";
10
11
  import { zshCompletion, bashCompletion, fishCompletion } from "./completions.js";
11
12
  import { readCache, clearCache, CACHE_TTL_MS } from "./taskCache.js";
12
13
  import { runOnboarding } from "./onboarding.js";
14
+ const require = createRequire(import.meta.url);
15
+ const { version } = require("../package.json");
13
16
  const program = new Command();
14
17
  program
15
18
  .name("taskify")
16
- .version("0.1.0")
19
+ .version(version)
17
20
  .description("Taskify CLI — manage tasks over Nostr")
18
21
  .option("-P, --profile <name>", "Use a specific profile for this command (does not change active profile)");
19
22
  // ---- Validation helpers ----
@@ -2109,12 +2112,45 @@ profileCmd
2109
2112
  profileCmd
2110
2113
  .command("add <name>")
2111
2114
  .description("Add a new profile (runs mini onboarding for the new identity)")
2112
- .action(async (name) => {
2115
+ .option("--nsec <key>", "Nostr private key (skips interactive prompt)")
2116
+ .option("--relay <url>", "Add a relay (repeatable)", (val, acc) => { acc.push(val); return acc; }, [])
2117
+ .action(async (name, opts) => {
2113
2118
  const config = await loadConfig(program.opts().profile);
2114
2119
  if (config.profiles[name]) {
2115
2120
  console.error(chalk.red(`Profile already exists: "${name}"`));
2116
2121
  process.exit(1);
2117
2122
  }
2123
+ // Non-interactive mode when --nsec is provided
2124
+ if (opts.nsec !== undefined) {
2125
+ const nsecInput = opts.nsec.trim();
2126
+ if (!nsecInput.startsWith("nsec1")) {
2127
+ console.error(chalk.red("Invalid nsec key"));
2128
+ process.exit(1);
2129
+ }
2130
+ try {
2131
+ nip19.decode(nsecInput);
2132
+ }
2133
+ catch {
2134
+ console.error(chalk.red("Invalid nsec key"));
2135
+ process.exit(1);
2136
+ }
2137
+ const relays = opts.relay.length > 0 ? opts.relay : [...DEFAULT_RELAYS];
2138
+ const newProfile = {
2139
+ nsec: nsecInput,
2140
+ relays,
2141
+ boards: [],
2142
+ trustedNpubs: [],
2143
+ securityMode: "moderate",
2144
+ securityEnabled: true,
2145
+ defaultBoard: "Personal",
2146
+ taskReminders: {},
2147
+ };
2148
+ const newProfiles = { ...config.profiles, [name]: newProfile };
2149
+ await saveProfiles(config.activeProfile, newProfiles);
2150
+ console.log(chalk.green(`✓ Profile '${name}' created.`));
2151
+ process.exit(0);
2152
+ }
2153
+ // Interactive mode
2118
2154
  console.log();
2119
2155
  console.log(chalk.bold(`Setting up profile: ${name}`));
2120
2156
  console.log();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskify-nostr",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Nostr-powered task management CLI",
5
5
  "type": "module",
6
6
  "bin": {