@networkbase/cli 2.1.2 → 2.1.4

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.
@@ -70,11 +70,20 @@ export async function taskEdit(ctx) {
70
70
  export async function resolvePerson(ctx, who) {
71
71
  if (who === "none") return null;
72
72
  if (who === "me") return /** @type {any} */ (await ctx.api.get("/api/v1/me")).user.id;
73
- const name = who.replace(/^@/, "").toLowerCase();
73
+ const name = who.replace(/^@/, "").trim().toLowerCase();
74
74
  const { members } = /** @type {any} */ (await ctx.api.get(`/api/v1/workspaces/${encodeURIComponent(ctx.requireWorkspace())}/members`, { query: { q: name } }));
75
- const hit = members.find((/** @type {any} */ m) => String(m.username ?? "").toLowerCase() === name);
76
- if (!hit) throw new CliError("NOT_FOUND", `No member @${name} in this workspace`, { hint: "nb member list" });
77
- return hit.id;
75
+ // A username, then a full name, then the only member whose name holds every word (report D2). Several: ask which.
76
+ const words = name.split(/\s+/).filter(Boolean);
77
+ const text = (/** @type {any} */ m) => `${m.username ?? ""} ${m.fullName ?? ""}`.toLowerCase();
78
+ const hit = members.find((/** @type {any} */ m) => String(m.username ?? "").toLowerCase() === name)
79
+ ?? members.find((/** @type {any} */ m) => String(m.fullName ?? "").toLowerCase() === name);
80
+ if (hit) return hit.id;
81
+ const fits = members.filter((/** @type {any} */ m) => m.username && words.every((w) => text(m).includes(w)));
82
+ if (fits.length === 1) return fits[0].id;
83
+ if (!fits.length) throw new CliError("NOT_FOUND", `No member @${name} in this workspace`, { hint: "nb member list" });
84
+ const { ask } = await import("../tui/ask.mjs");
85
+ const picked = await ask(ctx, { key: "person", header: "Who", question: `Which member did you mean by "${who}"?`, options: fits.slice(0, 4).map((/** @type {any} */ m) => ({ value: `@${m.username}`, label: safe(m.fullName ?? m.username), description: `@${m.username}` })) });
86
+ return resolvePerson(ctx, picked);
78
87
  }
79
88
 
80
89
  /**
package/lib/context.mjs CHANGED
@@ -15,7 +15,7 @@ const PACKAGE_JSON = path.join(path.dirname(fileURLToPath(import.meta.url)), "..
15
15
  export const VERSION = JSON.parse(fs.readFileSync(PACKAGE_JSON, "utf8")).version;
16
16
 
17
17
  /**
18
- * @param {{ flags: Record<string, any>, positionals: string[], cwd?: string, env?: NodeJS.ProcessEnv, fetchImpl?: typeof fetch, io?: Parameters<typeof createOutput>[1] }} input
18
+ * @param {{ flags: Record<string, any>, positionals: string[], cwd?: string, env?: NodeJS.ProcessEnv, fetchImpl?: typeof fetch, io?: Parameters<typeof createOutput>[1] & { onUndo?: (u: { token: string }) => void } }} input
19
19
  */
20
20
  export function createContext({ flags, positionals, cwd = process.cwd(), env = process.env, fetchImpl, io }) {
21
21
  if (flags.format !== undefined && !["table", "json", "csv", "md"].includes(String(flags.format))) throw new CliError("USAGE", `--format ${flags.format}: use table, json, csv or md`);
@@ -29,7 +29,8 @@ export function createContext({ flags, positionals, cwd = process.cwd(), env = p
29
29
  version: VERSION,
30
30
  fetchImpl,
31
31
  confirmToken: typeof flags.confirm === "string" ? flags.confirm : null,
32
- onUndo: (u) => appendUndo(env, { token: u.token, at: Date.now(), method: u.method, path: u.path, origin: profile.origin, session: env.NB_AGENT_SESSION ?? null }),
32
+ onUndo: (u) => { appendUndo(env, { token: u.token, at: Date.now(), method: u.method, path: u.path, origin: profile.origin, session: env.NB_AGENT_SESSION ?? null }); io?.onUndo?.(u); },
33
+ keySeed: typeof flags["key-seed"] === "string" ? flags["key-seed"] : null,
33
34
  onRetry: ({ waitMs, reason }) => out.note(out.c.muted(`${reason}; retrying in ${Math.max(1, Math.round(waitMs / 1000))} s`)),
34
35
  // Commands with their own --dry-run (push, pull) plan without writing; every other one stops at its first write.
35
36
  dryRun: Boolean(flags["dry-run"]) && !flags.ownDryRun,
@@ -14,10 +14,10 @@ export const TOPICS = /** @type {Record<string, { title: string, lines: string[]
14
14
  agents: {
15
15
  title: "Agents: Claude Code, Codex, Cursor and others working with you",
16
16
  lines: [
17
- "nb agent setup connects an agent; you approve it once in the browser and choose what it may do alone.",
17
+ "nb agent setup connects every agent installed here (or the one you name); you approve each once in the browser and choose what it may do alone.",
18
18
  "Big changes (finishing tasks, final files, deleting) wait for your yes. Everything it changes can be undone.",
19
19
  ],
20
- examples: ["nb agent setup claude", "nb agent access claude --small", "nb agent status", "nb undo --session"],
20
+ examples: ["nb agent setup", "nb agent setup claude", "nb agent access claude --small", "nb agent status", "nb undo --session"],
21
21
  },
22
22
  classes: {
23
23
  title: "Classes: assignments, hand-ins and reviews",