@networkbase/cli 2.0.3 → 2.1.0
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.
- package/bin/nb.mjs +6 -1
- package/lib/api.mjs +3 -1
- package/lib/args.mjs +37 -17
- package/lib/commands/account.mjs +93 -20
- package/lib/commands/agent.mjs +55 -10
- package/lib/commands/browse.mjs +19 -2
- package/lib/commands/extras.mjs +1 -1
- package/lib/commands/files.mjs +73 -5
- package/lib/commands/inbox.mjs +33 -1
- package/lib/commands/link.mjs +33 -1
- package/lib/commands/mcp.mjs +11 -6
- package/lib/commands/misc.mjs +72 -13
- package/lib/commands/table.mjs +47 -14
- package/lib/commands/tasks.mjs +162 -20
- package/lib/commands/undo.mjs +1 -1
- package/lib/commands/work.mjs +53 -16
- package/lib/config.mjs +1 -1
- package/lib/context.mjs +7 -0
- package/lib/dates.mjs +47 -0
- package/lib/error-fixes.mjs +60 -0
- package/lib/errors.mjs +2 -0
- package/lib/mcp/tools.mjs +101 -23
- package/lib/print/notices.mjs +6 -0
- package/lib/print/out.mjs +4 -2
- package/lib/print/qr.mjs +251 -0
- package/lib/sync/queue.mjs +1 -1
- package/package.json +1 -1
package/lib/commands/tasks.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Tasks, subtasks and comments (report §17.4, §42.10, findings 1–3, 7–9, 24, 51–58).
|
|
2
|
+
import { dueRange, parseDate } from "../dates.mjs";
|
|
2
3
|
import crypto from "node:crypto";
|
|
3
4
|
import fs from "node:fs";
|
|
4
5
|
import path from "node:path";
|
|
@@ -17,23 +18,61 @@ const ROLE = /** @type {Record<string, string>} */ ({ deliverable: "final", work
|
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* A task by number (4, #4, T-4) or id, with subtasks and files (report A2.7).
|
|
20
|
-
* @param {Context} ctx @param {string} ref
|
|
21
|
+
* @param {Context} ctx @param {string} ref @param {{ brief?: boolean }} [opts] brief: the task row only (no subtasks or files)
|
|
21
22
|
*/
|
|
22
|
-
export async function resolveTask(ctx, ref) {
|
|
23
|
+
export async function resolveTask(ctx, ref, { brief = false } = {}) {
|
|
23
24
|
const workspaceId = ctx.requireWorkspace();
|
|
24
25
|
const cleaned = ref.trim().replace(/^(T-|#)/i, "");
|
|
25
26
|
const isUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(cleaned);
|
|
26
|
-
if (!isUuid && !/^\d+$/.test(cleaned))
|
|
27
|
-
const detail = /** @type {any} */ (await ctx.api.get("/api/v1/extension/task-detail", { query: { projectId: workspaceId, ...(isUuid ? { taskId: cleaned } : { taskNumber: cleaned }) } }).catch((error) => {
|
|
27
|
+
if (!isUuid && !/^\d+$/.test(cleaned)) return resolveTask(ctx, await taskByWords(ctx, ref), { brief });
|
|
28
|
+
const detail = /** @type {any} */ (await ctx.api.get("/api/v1/extension/task-detail", { query: { projectId: workspaceId, ...(isUuid ? { taskId: cleaned } : { taskNumber: cleaned }), ...(brief ? { brief: "1" } : {}) } }).catch((error) => {
|
|
28
29
|
if (error instanceof CliError && (error.status === 404 || error.code === "NOT_FOUND")) throw new CliError("TASK_NOT_FOUND", `No task ${ref} in this workspace`, { hint: "See nb task list" });
|
|
29
30
|
throw error;
|
|
30
31
|
}));
|
|
31
32
|
return { ...detail.task, subtasks: detail.subtasks ?? [], files: detail.files ?? [], comments: detail.comments ?? [], pushes: detail.pushes ?? [] };
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Tasks by words (C2): one open match is that task; several ask in a terminal, or exit 6 with the choices.
|
|
37
|
+
* @param {Context} ctx @param {string} words @returns {Promise<string>} the task number
|
|
38
|
+
*/
|
|
39
|
+
async function taskByWords(ctx, words) {
|
|
40
|
+
const { tasks } = /** @type {any} */ (await ctx.api.get("/api/v1/extension/workspace-tasks", { query: { projectId: ctx.requireWorkspace(), scope: "all", open: "1", q: words, limit: "10" } }));
|
|
41
|
+
if (!tasks.length) {
|
|
42
|
+
// "Did you mean" for task names too (C1): open tasks with a title word one or two letters off.
|
|
43
|
+
const { didYouMean } = await import("../args.mjs");
|
|
44
|
+
const { tasks: open } = /** @type {any} */ (await ctx.api.get("/api/v1/extension/workspace-tasks", { query: { projectId: ctx.requireWorkspace(), scope: "all", open: "1", limit: "50" } }));
|
|
45
|
+
const want = words.toLowerCase().split(/\s+/).filter((w) => w.length >= 4);
|
|
46
|
+
const near = open.filter((/** @type {any} */ t) => want.some((w) => didYouMean(w, String(t.title).toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)) !== null)).slice(0, 3);
|
|
47
|
+
throw new CliError("TASK_NOT_FOUND", `No open task matches "${words}"`, { hint: near.length ? `Did you mean ${near.map((/** @type {any} */ t) => `#${t.taskNumber} ${safe(t.title)}`).join(", or ")}?` : "Try fewer words, or nb task list --all" });
|
|
48
|
+
}
|
|
49
|
+
if (tasks.length === 1) return String(tasks[0].taskNumber);
|
|
50
|
+
const { ask } = await import("../tui/ask.mjs");
|
|
51
|
+
return ask(ctx, { key: "task", header: "Task", question: `Which task do you mean by "${words}"?`, options: tasks.slice(0, 4).map((/** @type {any} */ t, /** @type {number} */ i) => ({ value: String(t.taskNumber), label: `#${t.taskNumber} ${safe(t.title)}`, recommended: i === 0 })) });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The task number in this folder's git branch, when it's one `nb task start --branch` made (nb/4-login-bug), C8.
|
|
56
|
+
* Reads .git/HEAD directly (a worktree's .git file points at its own); no git process, so it's cheap.
|
|
57
|
+
* @param {string | null} dir @returns {string | null}
|
|
58
|
+
*/
|
|
59
|
+
export function branchTask(dir) {
|
|
60
|
+
for (let d = dir; d; d = path.dirname(d) === d ? null : path.dirname(d)) {
|
|
61
|
+
const dotGit = path.join(d, ".git");
|
|
62
|
+
if (!fs.existsSync(dotGit)) continue;
|
|
63
|
+
try {
|
|
64
|
+
const gitDir = fs.statSync(dotGit).isFile() ? path.resolve(d, fs.readFileSync(dotGit, "utf8").replace(/^gitdir:\s*/, "").trim()) : dotGit;
|
|
65
|
+
return /^ref: refs\/heads\/nb\/(\d+)-/.exec(fs.readFileSync(path.join(gitDir, "HEAD"), "utf8"))?.[1] ?? null;
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The task a command means (C8): an argument, --task, the folder's started task, or its nb/<n>- git branch. @param {Context} ctx @param {string | undefined} given */
|
|
35
74
|
export function taskRef(ctx, given) {
|
|
36
|
-
const ref = given ?? ctx.flags.task ?? (ctx.project?.startedTask?.number ? String(ctx.project.startedTask.number) : ctx.project?.startedTask?.id);
|
|
75
|
+
const ref = given ?? ctx.flags.task ?? (ctx.project?.startedTask?.number ? String(ctx.project.startedTask.number) : ctx.project?.startedTask?.id) ?? branchTask(ctx.root);
|
|
37
76
|
if (!ref) throw usage("Which task?", "Pass a task number, --task <n>, or start one with nb task start <n>");
|
|
38
77
|
return String(ref);
|
|
39
78
|
}
|
|
@@ -53,11 +92,26 @@ export async function list(ctx) {
|
|
|
53
92
|
const { applySavedFilter } = await import("./extras.mjs");
|
|
54
93
|
applySavedFilter(ctx);
|
|
55
94
|
const workspaceId = ctx.requireWorkspace();
|
|
56
|
-
const scope = ctx.flags.all ? "all" : "mine";
|
|
57
|
-
const { tasks } = /** @type {any} */ (await ctx.api.get("/api/v1/extension/workspace-tasks", { query: { projectId: workspaceId, scope } }));
|
|
95
|
+
const scope = ctx.flags.all || ctx.flags.to ? "all" : "mine";
|
|
58
96
|
const wanted = ctx.flags.status ? new Set(String(ctx.flags.status).split(",").map((s) => s.trim())) : null;
|
|
59
|
-
let rows = tasks.filter((/** @type {any} */ t) => (wanted ? wanted.has(t.status) || (wanted.has("review") && t.reviewStatus === "pending") : t.status !== "done" || t.reviewStatus === "pending"));
|
|
60
97
|
const limit = ctx.flags.limit ? Number(ctx.flags.limit) : 50;
|
|
98
|
+
// Filters run on the server (C2), so open work never falls off a page of done tasks.
|
|
99
|
+
const due = ctx.flags.due ? dueRange(String(ctx.flags.due)) : null;
|
|
100
|
+
if (ctx.flags.due && !due) throw usage(`--due ${ctx.flags.due} isn't a range I know`, "Use today, week, overdue, or a date like friday or 2026-12-01");
|
|
101
|
+
if (ctx.flags.sort && !["due", "priority", "updated"].includes(String(ctx.flags.sort))) throw usage(`--sort ${ctx.flags.sort}: use due, priority or updated`);
|
|
102
|
+
const { resolvePerson } = ctx.flags.to ? await import("./work.mjs") : { resolvePerson: null };
|
|
103
|
+
/** @type {Record<string, string>} */
|
|
104
|
+
const query = { projectId: workspaceId, scope, limit: String(Math.min(100, limit + 1)) };
|
|
105
|
+
if (!wanted) query.open = "1";
|
|
106
|
+
else if (!wanted.has("review")) query.status = [...wanted].join(",");
|
|
107
|
+
if (due?.after) query.dueAfter = due.after;
|
|
108
|
+
if (due?.before) query.dueBefore = due.before;
|
|
109
|
+
if (resolvePerson) query.assignee = (await resolvePerson(ctx, String(ctx.flags.to))) ?? "none";
|
|
110
|
+
if (ctx.flags.sprint) query.sprint = await resolveSprint(ctx, String(ctx.flags.sprint));
|
|
111
|
+
if (ctx.flags.priority) query.priority = String(ctx.flags.priority);
|
|
112
|
+
if (ctx.flags.sort) query.sort = String(ctx.flags.sort);
|
|
113
|
+
const { tasks } = /** @type {any} */ (await ctx.api.get("/api/v1/extension/workspace-tasks", { query }));
|
|
114
|
+
let rows = tasks.filter((/** @type {any} */ t) => (wanted ? wanted.has(t.status) || (wanted.has("review") && t.reviewStatus === "pending") : true));
|
|
61
115
|
const more = Math.max(0, rows.length - limit);
|
|
62
116
|
rows = rows.slice(0, limit);
|
|
63
117
|
const data = { scope, tasks: rows.map((/** @type {any} */ t) => ({ id: t.id, number: t.taskNumber, title: t.title, status: t.status, reviewStatus: t.reviewStatus ?? null, priority: t.priority ?? null, dueDate: t.dueDate ?? null, assignee: t.assigneeUsername ?? t.assigneeName ?? null, subtasks: t.subtaskSummary ?? null })), more };
|
|
@@ -66,13 +120,49 @@ export async function list(ctx) {
|
|
|
66
120
|
const started = ctx.project?.startedTask?.id;
|
|
67
121
|
return [
|
|
68
122
|
...ctx.out.table([
|
|
69
|
-
|
|
123
|
+
// The started task gets a marker and a space, so plain output never reads as "-1" (C16 #4).
|
|
124
|
+
{ title: "#", value: (t) => `${t.id === started ? ctx.out.c.brand(ctx.out.sym.cursor) : " "} ${t.number ?? ""}`, align: "right" },
|
|
70
125
|
{ title: "Task", value: (t) => safe(t.title), flex: true },
|
|
71
126
|
{ title: "Status", value: (t) => statusWord(t) },
|
|
72
127
|
{ title: "Due", value: (t) => (t.dueDate ? formatDate(t.dueDate) : "—"), optional: true },
|
|
73
128
|
{ title: "Assignee", value: (t) => (t.assignee ? `@${safe(t.assignee)}` : "—"), optional: true },
|
|
74
129
|
], d.tasks),
|
|
75
|
-
ctx.out.c.muted(` ${d.tasks.length} ${d.tasks.length === 1 ? "task" : "tasks"}${d.more ? ` (
|
|
130
|
+
ctx.out.c.muted(` ${d.tasks.length} ${d.tasks.length === 1 ? "task" : "tasks"}${d.more ? ` (more: --limit ${Math.min(100, limit * 2)})` : ""} · nb task view <n>`),
|
|
131
|
+
];
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* What to work on now (C2), in the report's order: overdue, due soon, blocked work to unblock, reviews waiting for
|
|
137
|
+
* you, assignments due; then what's in progress and to do. Each item says the command that starts on it.
|
|
138
|
+
* @param {Context} ctx
|
|
139
|
+
*/
|
|
140
|
+
export async function next(ctx) {
|
|
141
|
+
const limit = Number(ctx.flags.limit ?? 5) || 5;
|
|
142
|
+
const workspaceId = ctx.requireWorkspace();
|
|
143
|
+
const [{ tasks }, home] = await Promise.all([
|
|
144
|
+
/** @type {Promise<any>} */ (ctx.api.get("/api/v1/extension/workspace-tasks", { query: { projectId: workspaceId, scope: "mine", open: "1", sort: "due", limit: "100" } })),
|
|
145
|
+
/** @type {Promise<any>} */ (ctx.api.get("/api/v1/home").catch(() => ({ reviews: [], assignments: [] }))),
|
|
146
|
+
]);
|
|
147
|
+
const now = Date.now();
|
|
148
|
+
const due = (/** @type {any} */ t) => (t.dueDate ? Date.parse(t.dueDate) : Infinity);
|
|
149
|
+
const why = (/** @type {any} */ t) => (t.reviewStatus === "pending" ? "waiting for review" : due(t) < now ? "overdue" : due(t) < now + 7 * 86_400_000 ? "due soon" : t.status === "blocked" ? "blocked" : t.status === "in_progress" ? "in progress" : "to do");
|
|
150
|
+
const RANK = ["overdue", "assignment late", "due soon", "blocked", "review waiting", "assignment due", "in progress", "to do", "waiting for review"];
|
|
151
|
+
const elsewhere = (/** @type {any} */ r) => (r.workspaceId && r.workspaceId !== workspaceId ? ` -w ${r.workspaceSlug ?? r.workspaceId}` : "");
|
|
152
|
+
const items = [
|
|
153
|
+
...tasks.map((/** @type {any} */ t) => ({ kind: "task", id: t.id, number: t.taskNumber, title: t.title, dueDate: t.dueDate ?? null, why: why(t), next: `nb task start ${t.taskNumber}` })),
|
|
154
|
+
...(home.reviews ?? []).map((/** @type {any} */ r) => ({ kind: "review", id: r.id, number: r.number, title: r.title, dueDate: null, why: "review waiting", where: r.workspaceId !== workspaceId ? r.workspaceTitle : null, next: `nb task review ${r.number} approve${elsewhere(r)}` })),
|
|
155
|
+
...(home.assignments ?? []).map((/** @type {any} */ a) => ({ kind: "assignment", id: a.id, number: a.number, title: a.title, dueDate: a.due, why: a.late ? "assignment late" : "assignment due", where: a.org, next: `nb assignment view ${a.number}` })),
|
|
156
|
+
]
|
|
157
|
+
.sort((a, b) => RANK.indexOf(a.why) - RANK.indexOf(b.why) || due(a) - due(b) || (a.number ?? 0) - (b.number ?? 0))
|
|
158
|
+
.slice(0, limit);
|
|
159
|
+
const { c } = ctx.out;
|
|
160
|
+
ctx.out.result("nb.next/1", { items }, (d) => {
|
|
161
|
+
if (!d.items.length) return "Nothing open is yours · nb task list --all for everyone's";
|
|
162
|
+
return [
|
|
163
|
+
...d.items.map((/** @type {any} */ t, /** @type {number} */ i) => ` ${i + 1}. #${t.number} ${safe(t.title)}${t.where ? c.muted(` (${safe(t.where)})`) : ""} ${c.muted("·")} ${t.why === "overdue" || t.why === "assignment late" ? c.warning(t.why) : c.muted(t.why)}${t.dueDate ? c.muted(` (${formatDate(t.dueDate)})`) : ""}`),
|
|
164
|
+
"",
|
|
165
|
+
c.muted(` Next: ${d.items[0].next}`),
|
|
76
166
|
];
|
|
77
167
|
});
|
|
78
168
|
}
|
|
@@ -93,7 +183,13 @@ export async function count(ctx) {
|
|
|
93
183
|
const counts = /** @type {any} */ (await ctx.api.get("/api/v1/tasks/count"));
|
|
94
184
|
ctx.out.result("nb.task.count/1", counts, (c) => {
|
|
95
185
|
const parts = [["in progress", c.byStatus.in_progress], ["to do", c.byStatus.todo], ["blocked", c.byStatus.blocked], ["in review", c.byStatus.in_review]].filter(([, n]) => n).map(([w, n]) => `${n} ${w}`);
|
|
96
|
-
|
|
186
|
+
// Which workspaces these cover (D24), so "1 overdue" is never read as this folder's.
|
|
187
|
+
const where = (c.workspaces ?? []).filter((/** @type {any} */ w) => w.open);
|
|
188
|
+
return [
|
|
189
|
+
`${c.open} open ${c.open === 1 ? "task" : "tasks"}${where.length > 1 ? " across all your workspaces" : where.length === 1 ? ` in ${safe(where[0].title)}` : ""}${parts.length ? `: ${parts.join(", ")}` : ""}`,
|
|
190
|
+
...(c.overdue || c.dueThisWeek ? [`${c.overdue ? `${c.overdue} overdue` : ""}${c.overdue && c.dueThisWeek ? " · " : ""}${c.dueThisWeek ? `${c.dueThisWeek} due this week` : ""}`] : []),
|
|
191
|
+
...(where.length > 1 ? where.map((/** @type {any} */ w) => ` ${safe(w.title)}: ${w.open} open${w.overdue ? `, ${w.overdue} overdue` : ""}${w.dueThisWeek ? `, ${w.dueThisWeek} due this week` : ""}`) : []),
|
|
192
|
+
];
|
|
97
193
|
});
|
|
98
194
|
}
|
|
99
195
|
|
|
@@ -170,22 +266,50 @@ export async function create(ctx) {
|
|
|
170
266
|
const priority = ctx.flags.priority;
|
|
171
267
|
if (priority && !["low", "medium", "high", "urgent"].includes(priority)) throw usage("--priority must be low, medium, high or urgent");
|
|
172
268
|
const projectId = ctx.requireWorkspace();
|
|
173
|
-
|
|
269
|
+
// Everything at once (report C2): a due date in words, who it's for, and the sprint.
|
|
270
|
+
const dueDate = ctx.flags.due === undefined ? undefined : parseDate(String(ctx.flags.due));
|
|
271
|
+
if (dueDate === null) throw usage(`--due ${ctx.flags.due} isn't a date I know`, "Try today, tomorrow, friday, next week, in 3 days, or 2026-12-01");
|
|
272
|
+
const { resolvePerson } = await import("./work.mjs");
|
|
273
|
+
const assigneeId = ctx.flags.to === undefined ? undefined : await resolvePerson(ctx, String(ctx.flags.to));
|
|
274
|
+
const sprintId = ctx.flags.sprint === undefined ? undefined : await resolveSprint(ctx, String(ctx.flags.sprint));
|
|
275
|
+
const res = /** @type {any} */ (await ctx.api.post("/api/v1/extension/create-task", { projectId, title, ...(ctx.flags.message ? { description: ctx.flags.message } : {}), ...(priority ? { priority } : {}),
|
|
276
|
+
...(dueDate ? { dueDate } : {}), ...(assigneeId !== undefined ? { assigneeId } : {}), ...(sprintId ? { sprintId } : {}) }));
|
|
174
277
|
const task = res.task ?? res;
|
|
175
278
|
for (const sub of /** @type {string[]} */ (ctx.flags.subtask ?? [])) await ctx.api.post("/api/v1/extension/task-subtask", { projectId, taskId: task.id, title: sub });
|
|
176
|
-
ctx.out.result("nb.task.create/1", { id: task.id, number: task.taskNumber, title: task.title ?? title, subtasks: (ctx.flags.subtask ?? []).length
|
|
279
|
+
ctx.out.result("nb.task.create/1", { id: task.id, number: task.taskNumber, title: task.title ?? title, subtasks: (ctx.flags.subtask ?? []).length, dueDate: dueDate ?? null }, (d) => [
|
|
280
|
+
`${ctx.out.c.success(ctx.out.sym.done)} Created #${d.number} ${safe(d.title)}${d.subtasks ? ` with ${d.subtasks} subtasks` : ""}${d.dueDate ? ` · due ${d.dueDate}` : ""}`,
|
|
281
|
+
// The next step (C16 #8).
|
|
282
|
+
ctx.out.c.muted(` Next: nb task start ${d.number}`),
|
|
283
|
+
]);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** A sprint by id, name, or "current" (the active one). @param {Context} ctx @param {string} ref */
|
|
287
|
+
async function resolveSprint(ctx, ref) {
|
|
288
|
+
if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(ref)) return ref;
|
|
289
|
+
const { sprints } = /** @type {any} */ (await ctx.api.get(`/api/v1/workspaces/${encodeURIComponent(ctx.requireWorkspace())}/sprints`));
|
|
290
|
+
const want = ref.toLowerCase();
|
|
291
|
+
const hit = want === "current" ? sprints.find((/** @type {any} */ s) => s.status === "active") : sprints.find((/** @type {any} */ s) => String(s.name).toLowerCase() === want);
|
|
292
|
+
if (!hit) throw new CliError("NOT_FOUND", want === "current" ? "No sprint is running here" : `No sprint called ${ref}`, { hint: "nb sprint list" });
|
|
293
|
+
return hit.id;
|
|
177
294
|
}
|
|
178
295
|
|
|
179
296
|
/** Make it this folder's task and move it to In progress — and say so (finding 24). @param {Context} ctx */
|
|
180
297
|
export async function start(ctx) {
|
|
181
298
|
const { root, project } = ctx.requireRoot();
|
|
182
|
-
const task = await resolveTask(ctx, taskRef(ctx, ctx.positionals[0]));
|
|
299
|
+
const task = await resolveTask(ctx, taskRef(ctx, ctx.positionals[0]), { brief: true });
|
|
183
300
|
writeProjectConfig(root, { ...project, startedTask: { id: task.id, number: task.taskNumber, title: task.title } });
|
|
301
|
+
// The move checks updatedAt, so it goes before the assign (which changes it).
|
|
184
302
|
let moved = null;
|
|
185
303
|
if (task.status === "todo") {
|
|
186
304
|
const res = await setStatus(ctx, task, "in_progress").catch((error) => ({ error: error instanceof Error ? error.message : String(error) }));
|
|
187
305
|
moved = res?.error ? { ok: false, message: res.error } : { ok: true, status: "in_progress" };
|
|
188
306
|
}
|
|
307
|
+
// Starting an unassigned task makes it yours (C16 #3), so it shows in your nb task list.
|
|
308
|
+
let assigned = false;
|
|
309
|
+
if (!task.assignee && !task.assigneeId && !task.assigneeUsername) {
|
|
310
|
+
const me = ctx.profile.profile?.user?.id ?? /** @type {any} */ (await ctx.api.get("/api/v1/me")).user.id;
|
|
311
|
+
assigned = await ctx.api.patch("/api/v1/extension/task-update", { kind: "assign", projectId: ctx.requireWorkspace(), taskId: task.id, assigneeId: me }).then(() => true, () => false);
|
|
312
|
+
}
|
|
189
313
|
// --branch: a git branch per task (finding 146), created the first time.
|
|
190
314
|
let branch = null;
|
|
191
315
|
if (ctx.flags.branch) {
|
|
@@ -193,8 +317,8 @@ export async function start(ctx) {
|
|
|
193
317
|
const name = branchName(task.taskNumber, task.title);
|
|
194
318
|
branch = { name, did: await switchToBranch(root, name) };
|
|
195
319
|
}
|
|
196
|
-
ctx.out.result("nb.task.start/1", { id: task.id, number: task.taskNumber, title: task.title, moved, branch }, (d) => [
|
|
197
|
-
`${ctx.out.c.success(ctx.out.sym.done)} Started #${d.number} ${safe(d.title)}`,
|
|
320
|
+
ctx.out.result("nb.task.start/1", { id: task.id, number: task.taskNumber, title: task.title, moved, branch, assigned }, (d) => [
|
|
321
|
+
`${ctx.out.c.success(ctx.out.sym.done)} Started #${d.number} ${safe(d.title)}${d.assigned ? " · assigned to you" : ""}`,
|
|
198
322
|
...(d.moved ? [d.moved.ok ? " Moved to In progress" : ctx.out.c.warning(` Status not changed: ${safe(d.moved.message)}`)] : []),
|
|
199
323
|
...(d.branch ? [` On branch ${d.branch.name} (${d.branch.did}). Link commits: git commit --trailer "NetworkBase-Task: ${d.number}"`] : []),
|
|
200
324
|
ctx.out.c.muted(` nb push <files> links to it · nb task done when finished`),
|
|
@@ -211,16 +335,34 @@ export async function stop(ctx) {
|
|
|
211
335
|
|
|
212
336
|
/** @param {Context} ctx */
|
|
213
337
|
export async function move(ctx) {
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
338
|
+
const refs = ctx.positionals.slice(0, -1);
|
|
339
|
+
const to = ctx.positionals.at(-1);
|
|
340
|
+
const [ref] = refs;
|
|
341
|
+
if (!ref || !to) throw usage("nb task move <task…> todo|in_progress|blocked");
|
|
217
342
|
if (to === "blocked" && !ctx.flags.reason) throw usage("Say why it's blocked: --reason \"waiting for API keys\"");
|
|
343
|
+
// Several at once (C2): one request, all or nothing, one undo. Done is allowed here, as in the app's bulk move.
|
|
344
|
+
if (refs.length > 1) {
|
|
345
|
+
if (!["todo", "in_progress", "blocked", "done"].includes(to)) throw usage("Move to todo, in_progress, blocked or done");
|
|
346
|
+
const d = await bulkChange(ctx, refs, { kind: "status", status: to, ...(ctx.flags.reason ? { note: String(ctx.flags.reason) } : {}) });
|
|
347
|
+
ctx.out.result("nb.task.move/1", { numbers: d.tasks.map((/** @type {any} */ t) => t.number), status: to }, (r) => `${ctx.out.c.success(ctx.out.sym.done)} ${r.numbers.map((/** @type {number} */ n) => `#${n}`).join(", ")} ${r.numbers.length === 1 ? "is" : "are"} ${STATUS_WORDS[r.status]} · nb undo puts them back`);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
if (!["todo", "in_progress", "blocked"].includes(to)) throw usage(`Move to todo, in_progress or blocked (use nb task done to finish)`);
|
|
218
351
|
const task = await resolveTask(ctx, ref);
|
|
219
352
|
await setStatus(ctx, task, to);
|
|
220
353
|
if (to === "blocked") await ctx.api.post("/api/v1/extension/comments", { kind: "task", projectId: ctx.requireWorkspace(), taskId: task.id, text: `Blocked: ${ctx.flags.reason}` });
|
|
221
354
|
ctx.out.result("nb.task.move/1", { number: task.taskNumber, status: to }, (d) => `${ctx.out.c.success(ctx.out.sym.done)} #${d.number} is ${STATUS_WORDS[d.status]}`);
|
|
222
355
|
}
|
|
223
356
|
|
|
357
|
+
/**
|
|
358
|
+
* One change to several tasks (report C2): POST /api/v1/tasks/bulk, all or nothing, one undo.
|
|
359
|
+
* @param {Context} ctx @param {string[]} refs @param {Record<string, unknown>} change
|
|
360
|
+
*/
|
|
361
|
+
export async function bulkChange(ctx, refs, change) {
|
|
362
|
+
const tasks = await Promise.all(refs.map((r) => resolveTask(ctx, r, { brief: true })));
|
|
363
|
+
return /** @type {any} */ (await ctx.api.post("/api/v1/tasks/bulk", { projectId: ctx.requireWorkspace(), taskIds: tasks.map((t) => t.id), change }));
|
|
364
|
+
}
|
|
365
|
+
|
|
224
366
|
/**
|
|
225
367
|
* Checks people ran (--check "npm test=pass[:note]") become review evidence the reviewer sees (report §13, F52).
|
|
226
368
|
* @param {string[]} raw @param {string} summary
|
package/lib/commands/undo.mjs
CHANGED
|
@@ -44,7 +44,7 @@ export async function undo(ctx) {
|
|
|
44
44
|
try {
|
|
45
45
|
const res = /** @type {any} */ (await ctx.api.post(`/api/v1/undo/${encodeURIComponent(entry.token)}`, {}));
|
|
46
46
|
dropUndo(ctx.env, entry.token);
|
|
47
|
-
ctx.out.result("nb.undo/1", { token: entry.token, undone: res.undone, result: res.result }, (d) => `${ctx.out.c.success(ctx.out.sym.done)}
|
|
47
|
+
ctx.out.result("nb.undo/1", { token: entry.token, undone: res.undone, result: res.result }, (d) => `${ctx.out.c.success(ctx.out.sym.done)} ${safe(d.result || `Undid: ${d.undone}`)}`);
|
|
48
48
|
} catch (error) {
|
|
49
49
|
if (error instanceof CliError && error.status === 410) dropUndo(ctx.env, entry.token);
|
|
50
50
|
throw error;
|
package/lib/commands/work.mjs
CHANGED
|
@@ -7,7 +7,8 @@ import path from "node:path";
|
|
|
7
7
|
import { CliError, EXIT, usage } from "../errors.mjs";
|
|
8
8
|
import { safe } from "../print/style.mjs";
|
|
9
9
|
import { confirm } from "../tui/ask.mjs";
|
|
10
|
-
import {
|
|
10
|
+
import { parseDate } from "../dates.mjs";
|
|
11
|
+
import { bulkChange, resolveTask, taskRef } from "./tasks.mjs";
|
|
11
12
|
|
|
12
13
|
/** @typedef {import("../context.mjs").Context} Context */
|
|
13
14
|
|
|
@@ -16,7 +17,6 @@ const update = (ctx, body) => ctx.api.patch("/api/v1/extension/task-update", { p
|
|
|
16
17
|
|
|
17
18
|
/** @param {Context} ctx */
|
|
18
19
|
export async function taskEdit(ctx) {
|
|
19
|
-
const task = await resolveTask(ctx, taskRef(ctx, ctx.positionals[0]));
|
|
20
20
|
/** @type {Array<[string, string | null]>} */
|
|
21
21
|
const changes = [];
|
|
22
22
|
if (ctx.flags.title) changes.push(["title", String(ctx.flags.title)]);
|
|
@@ -26,29 +26,66 @@ export async function taskEdit(ctx) {
|
|
|
26
26
|
changes.push(["priority", ctx.flags.priority]);
|
|
27
27
|
}
|
|
28
28
|
if (ctx.flags.due) {
|
|
29
|
+
// Natural dates everywhere a date is taken (C2): friday, next week, in 3 days, 2026-12-01.
|
|
29
30
|
const due = String(ctx.flags.due);
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
const date = due === "none" ? null : parseDate(due);
|
|
32
|
+
if (due !== "none" && !date) throw usage(`--due ${due} isn't a date I know`, "Use today, tomorrow, friday, next week, in 3 days, 2026-12-01, or none");
|
|
33
|
+
changes.push(["dueDate", date]);
|
|
34
|
+
}
|
|
35
|
+
if (!changes.length) throw usage("nb task edit <task…> [--title text] [-m description] [--priority high] [--due friday|none]");
|
|
36
|
+
if (ctx.positionals.length > 1) {
|
|
37
|
+
if (changes.some(([f]) => f === "title" || f === "description")) throw usage("Several tasks take --priority and --due; change a title one task at a time");
|
|
38
|
+
let numbers = [];
|
|
39
|
+
for (const [field, value] of changes) numbers = (await bulkChange(ctx, ctx.positionals, { kind: "edit", field, value })).tasks.map((/** @type {any} */ t) => t.number);
|
|
40
|
+
ctx.out.result("nb.task.edit/1", { numbers, changed: changes.map(([f]) => f) }, (d) => `${ctx.out.c.success(ctx.out.sym.done)} Changed ${d.changed.join(", ")} on ${d.numbers.map((/** @type {number} */ n) => `#${n}`).join(", ")}`);
|
|
41
|
+
return;
|
|
32
42
|
}
|
|
33
|
-
|
|
43
|
+
const task = await resolveTask(ctx, taskRef(ctx, ctx.positionals[0]));
|
|
34
44
|
for (const [field, value] of changes) await update(ctx, { kind: "edit", taskId: task.id, field, value });
|
|
35
45
|
ctx.out.result("nb.task.edit/1", { number: task.taskNumber, changed: changes.map(([f]) => f) }, (d) => `${ctx.out.c.success(ctx.out.sym.done)} Changed ${d.changed.join(", ")} on #${d.number}`);
|
|
36
46
|
}
|
|
37
47
|
|
|
48
|
+
/** A person for --to and task assign: @username, me, or none (null). @param {Context} ctx @param {string} who */
|
|
49
|
+
export async function resolvePerson(ctx, who) {
|
|
50
|
+
if (who === "none") return null;
|
|
51
|
+
if (who === "me") return /** @type {any} */ (await ctx.api.get("/api/v1/me")).user.id;
|
|
52
|
+
const name = who.replace(/^@/, "").toLowerCase();
|
|
53
|
+
const { members } = /** @type {any} */ (await ctx.api.get(`/api/v1/workspaces/${encodeURIComponent(ctx.requireWorkspace())}/members`, { query: { q: name } }));
|
|
54
|
+
const hit = members.find((/** @type {any} */ m) => String(m.username ?? "").toLowerCase() === name);
|
|
55
|
+
if (!hit) throw new CliError("NOT_FOUND", `No member @${name} in this workspace`, { hint: "nb member list" });
|
|
56
|
+
return hit.id;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A picker when the person is left out (C2): in a terminal, choose; scripts and agents get exit 6 with the choices.
|
|
61
|
+
* @param {Context} ctx @returns {Promise<string>}
|
|
62
|
+
*/
|
|
63
|
+
async function pickPerson(ctx) {
|
|
64
|
+
const { members } = /** @type {any} */ (await ctx.api.get(`/api/v1/workspaces/${encodeURIComponent(ctx.requireWorkspace())}/members`));
|
|
65
|
+
const { ask } = await import("../tui/ask.mjs");
|
|
66
|
+
return ask(ctx, { key: "person", header: "Assign to", question: "Who should do it?", options: [
|
|
67
|
+
{ value: "me", label: "Me", recommended: true },
|
|
68
|
+
...members.filter((/** @type {any} */ m) => m.username).slice(0, 7).map((/** @type {any} */ m) => ({ value: `@${m.username}`, label: safe(m.fullName ?? m.username), description: `@${m.username}` })),
|
|
69
|
+
{ value: "none", label: "Nobody" },
|
|
70
|
+
] });
|
|
71
|
+
}
|
|
72
|
+
|
|
38
73
|
/** @param {Context} ctx */
|
|
39
74
|
export async function taskAssign(ctx) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
75
|
+
// nb task assign 4 @sam, or several: nb task assign 3 4 --to sam (C2). Left out: choose from the members.
|
|
76
|
+
const picking = !ctx.flags.to && ctx.positionals.length === 1;
|
|
77
|
+
const refs = ctx.flags.to || picking ? ctx.positionals : ctx.positionals.slice(0, -1);
|
|
78
|
+
const who = ctx.flags.to ? String(ctx.flags.to) : picking ? await pickPerson(ctx) : ctx.positionals.at(-1);
|
|
79
|
+
const [ref] = refs;
|
|
80
|
+
if (!ref || !who) throw usage("nb task assign <task…> <@username|me|none>, or --to @sam");
|
|
81
|
+
if (refs.length > 1) {
|
|
82
|
+
const assigneeId = await resolvePerson(ctx, who);
|
|
83
|
+
const d = await bulkChange(ctx, refs, { kind: "assign", assigneeId });
|
|
84
|
+
ctx.out.result("nb.task.assign/1", { numbers: d.tasks.map((/** @type {any} */ t) => t.number), assignee: who === "none" ? null : who.replace(/^@/, "") }, (r) => `${ctx.out.c.success(ctx.out.sym.done)} ${r.numbers.map((/** @type {number} */ n) => `#${n}`).join(", ")} ${r.assignee ? `assigned to ${r.assignee === "me" ? "you" : `@${safe(r.assignee)}`}` : "unassigned"}`);
|
|
85
|
+
return;
|
|
51
86
|
}
|
|
87
|
+
const task = await resolveTask(ctx, ref);
|
|
88
|
+
const assigneeId = await resolvePerson(ctx, who);
|
|
52
89
|
await update(ctx, { kind: "assign", taskId: task.id, assigneeId });
|
|
53
90
|
ctx.out.result("nb.task.assign/1", { number: task.taskNumber, assignee: who === "none" ? null : who.replace(/^@/, "") }, (d) => `${ctx.out.c.success(ctx.out.sym.done)} #${d.number} ${d.assignee ? `is assigned to ${d.assignee === "me" ? "you" : `@${safe(d.assignee)}`}` : "is unassigned"}`);
|
|
54
91
|
}
|
package/lib/config.mjs
CHANGED
|
@@ -73,7 +73,7 @@ export function normalizeOrigin(origin) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
* @typedef {{ origin: string, token: string, user?: { id: string, username?: string | null, email?: string | null } | null, savedAt?: string, source?: "file" | "env", storage?: "keychain" | "secret-service" | "dpapi" | "file", sealed?: string }} Profile
|
|
76
|
+
* @typedef {{ origin: string, token: string, user?: { id: string, username?: string | null, email?: string | null } | null, savedAt?: string, expiresAt?: string, source?: "file" | "env", storage?: "keychain" | "secret-service" | "dpapi" | "file", sealed?: string }} Profile
|
|
77
77
|
*/
|
|
78
78
|
|
|
79
79
|
/** Settings: flag > environment > project > user > default. @param {{ profile?: string }} [flags] @param {NodeJS.ProcessEnv} [env] @param {any} [project] */
|
package/lib/context.mjs
CHANGED
|
@@ -32,6 +32,11 @@ export function createContext({ flags, positionals, cwd = process.cwd(), env = p
|
|
|
32
32
|
onRetry: ({ waitMs, reason }) => out.note(out.c.muted(`${reason}; retrying in ${Math.max(1, Math.round(waitMs / 1000))} s`)),
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
+
// The first step comes first (C1): signed out, "link this folder" is the wrong advice.
|
|
36
|
+
const signedInFirst = () => {
|
|
37
|
+
if (!profile.token) throw new CliError("NOT_SIGNED_IN", "Sign in first: nb login", { hint: "Then run this again" });
|
|
38
|
+
};
|
|
39
|
+
|
|
35
40
|
return {
|
|
36
41
|
out,
|
|
37
42
|
flags,
|
|
@@ -45,6 +50,7 @@ export function createContext({ flags, positionals, cwd = process.cwd(), env = p
|
|
|
45
50
|
version: VERSION,
|
|
46
51
|
/** Workspace id from --workspace or the link; an error naming the fix otherwise. */
|
|
47
52
|
requireWorkspace() {
|
|
53
|
+
signedInFirst();
|
|
48
54
|
if (flags.workspace) return /** @type {string} */ (flags.workspace);
|
|
49
55
|
if (project?.workspaceId) return project.workspaceId;
|
|
50
56
|
// A default for scripts, CI and the hosted MCP server (an agent token's own workspace).
|
|
@@ -63,6 +69,7 @@ export function createContext({ flags, positionals, cwd = process.cwd(), env = p
|
|
|
63
69
|
},
|
|
64
70
|
/** The linked folder; commands that sync files need one. */
|
|
65
71
|
requireRoot() {
|
|
72
|
+
signedInFirst();
|
|
66
73
|
if (!root || !project) throw new CliError("NOT_LINKED", "This folder isn't linked to a workspace", { hint: "Run nb init <workspace> here" });
|
|
67
74
|
return { root, project };
|
|
68
75
|
},
|
package/lib/dates.mjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Natural dates for --due and friends (report C2): "today", "tomorrow", "friday", "next week", "in 3 days",
|
|
2
|
+
// "2026-12-01". Read in the person's own time zone; the result is a calendar date (YYYY-MM-DD).
|
|
3
|
+
|
|
4
|
+
const DAYS = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
|
|
5
|
+
const iso = (/** @type {Date} */ d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
6
|
+
const plus = (/** @type {Date} */ d, /** @type {number} */ days) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + days);
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A calendar date for words people type, or null when it isn't one.
|
|
10
|
+
* @param {string} text @param {Date} [now]
|
|
11
|
+
*/
|
|
12
|
+
export function parseDate(text, now = new Date()) {
|
|
13
|
+
const t = String(text ?? "").trim().toLowerCase().replace(/\s+/g, " ");
|
|
14
|
+
if (!t) return null;
|
|
15
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(t)) {
|
|
16
|
+
const [y, m, d] = t.split("-").map(Number);
|
|
17
|
+
const date = new Date(y, m - 1, d);
|
|
18
|
+
return date.getMonth() === m - 1 && date.getDate() === d ? t : null;
|
|
19
|
+
}
|
|
20
|
+
if (t === "today" || t === "eod") return iso(now);
|
|
21
|
+
if (t === "tomorrow" || t === "tmrw") return iso(plus(now, 1));
|
|
22
|
+
if (t === "next week") return iso(plus(now, ((8 - now.getDay()) % 7) || 7));
|
|
23
|
+
const inN = /^in (\d{1,3}) (day|days|week|weeks)$/.exec(t);
|
|
24
|
+
if (inN) return iso(plus(now, Number(inN[1]) * (inN[2].startsWith("week") ? 7 : 1)));
|
|
25
|
+
const day = DAYS.findIndex((d) => d === t.replace(/^(next |this )/, "") || d.slice(0, 3) === t.replace(/^(next |this )/, ""));
|
|
26
|
+
if (day >= 0) {
|
|
27
|
+
// "friday" is the coming one (today counts only as "this friday"); "next friday" is the one after.
|
|
28
|
+
const ahead = (day - now.getDay() + 7) % 7;
|
|
29
|
+
const base = t.startsWith("this ") ? ahead : ahead || 7;
|
|
30
|
+
return iso(plus(now, t.startsWith("next ") && ahead !== 0 ? base + 7 : base));
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* `--due today|week|overdue` (or a date) as the instants the server filters on, in the person's own day (C2).
|
|
37
|
+
* @param {string} word @param {Date} [now] @returns {{ after?: string, before?: string } | null}
|
|
38
|
+
*/
|
|
39
|
+
export function dueRange(word, now = new Date()) {
|
|
40
|
+
const w = String(word ?? "").trim().toLowerCase();
|
|
41
|
+
if (w === "overdue") return { before: now.toISOString() };
|
|
42
|
+
if (w === "week") return { after: now.toISOString(), before: new Date(now.getTime() + 7 * 86_400_000).toISOString() };
|
|
43
|
+
const date = parseDate(w === "today" ? "today" : w, now);
|
|
44
|
+
if (!date) return null;
|
|
45
|
+
const [y, m, d] = date.split("-").map(Number);
|
|
46
|
+
return { after: new Date(y, m - 1, d).toISOString(), before: new Date(y, m - 1, d + 1).toISOString() };
|
|
47
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Generated by scripts/api/export-schemas.ts from src/lib/api/errors.ts. Do not edit.
|
|
2
|
+
/** Each error code's next step (report C5); every code here has an entry on /docs/cli. */
|
|
3
|
+
export const FIXES = /** @type {Record<string, string>} */ ({
|
|
4
|
+
"BAD_REQUEST": "Check the command's flags; nb help <command>",
|
|
5
|
+
"VALIDATION": "Fix the value named in the message",
|
|
6
|
+
"UNAUTHORIZED": "nb login",
|
|
7
|
+
"FORBIDDEN": "Check you're a member of the workspace: nb whoami",
|
|
8
|
+
"SCOPE_MISSING": "Sign in again with nb login, or make a token with more access in Settings",
|
|
9
|
+
"ACCESS_REQUESTED": "Tell the person; once they answer, try the same request again",
|
|
10
|
+
"ACCESS_DENIED_BY_PERSON": "Leave it to the person for now",
|
|
11
|
+
"WORKSPACE_NOT_ALLOWED": "Use the folder linked to that workspace, or approve a new agent sign-in",
|
|
12
|
+
"AGENT_NOT_ALLOWED": "Do this one yourself, or ask the organization's admins",
|
|
13
|
+
"AGENTS_PAUSED": "Turn agents back on in workspace settings",
|
|
14
|
+
"STEP_UP_REQUIRED": "Confirm it in the browser, then try again",
|
|
15
|
+
"NOT_FOUND": "Check the number or path: nb task list, nb file list",
|
|
16
|
+
"EXPIRED": "Start again",
|
|
17
|
+
"CONFLICT": "Look at it again, then retry",
|
|
18
|
+
"VERSION_CONFLICT": "nb pull, then push again, or nb resolve <path>",
|
|
19
|
+
"TASK_CHANGED": "nb task view <n>, then retry",
|
|
20
|
+
"FILE_LOCKED": "Wait for them to finish, or ask them",
|
|
21
|
+
"CLIENT_TOO_OLD": "npm i -g @networkbase/cli@latest",
|
|
22
|
+
"NEEDS_CONFIRMATION": "Show the summary; on a yes, send the same request with the confirm token (--confirm)",
|
|
23
|
+
"SECRET_DETECTED": "Remove it, or push with --confirm-secrets if it's safe (agents can't)",
|
|
24
|
+
"CONTENT_MISMATCH": "Run the command again",
|
|
25
|
+
"CONTENT_HASH_MISMATCH": "Run the command again",
|
|
26
|
+
"RATE_LIMITED": "Wait for the time in Retry-After",
|
|
27
|
+
"NOT_SUPPORTED": "Use the app for now",
|
|
28
|
+
"UNAVAILABLE": "Try again in a minute",
|
|
29
|
+
"INTERNAL_ERROR": "Try again; if it keeps happening, nb feedback",
|
|
30
|
+
"USAGE": "nb <command> --help shows what it takes",
|
|
31
|
+
"UNKNOWN_COMMAND": "nb help lists them; the error suggests the closest one",
|
|
32
|
+
"UNKNOWN_FLAG": "nb <command> --help lists its flags",
|
|
33
|
+
"NOT_SIGNED_IN": "nb login",
|
|
34
|
+
"NOT_LINKED": "nb init <workspace>, or pass --workspace",
|
|
35
|
+
"WORKSPACE_NOT_FOUND": "nb workspace list",
|
|
36
|
+
"TASK_NOT_FOUND": "nb task list --all",
|
|
37
|
+
"DOC_NOT_FOUND": "nb doc list",
|
|
38
|
+
"NOT_A_TASK": "nb inbox open <n>",
|
|
39
|
+
"NOTHING_TO_APPROVE": "nb inbox open <n>",
|
|
40
|
+
"NEEDS_INPUT": "Answer with --answer key=value, or --yes for the recommended choice",
|
|
41
|
+
"CANCELLED": "Run the command again when ready",
|
|
42
|
+
"OFFLINE": "nb doctor checks the connection; nb sync sends the queue",
|
|
43
|
+
"TIMEOUT": "Try again; nb doctor checks the connection",
|
|
44
|
+
"SERVER_ERROR": "Try again in a minute; nb doctor checks the connection",
|
|
45
|
+
"UNEXPECTED_RESPONSE": "Update: npm i -g @networkbase/cli@latest",
|
|
46
|
+
"LOCAL_CONFLICT": "nb resolve <path> --mine|--theirs|--both",
|
|
47
|
+
"READ_ONLY": "Ask the owner for edit access",
|
|
48
|
+
"PLAN_LIMIT_FILE_SIZE": "Make it smaller, or see the limits in Settings → Plan",
|
|
49
|
+
"LOCKED": "Wait for it to finish, then run this again",
|
|
50
|
+
"UNSAFE_PATH": "Rename the file in the app, then nb pull",
|
|
51
|
+
"RESERVED_NAME": "Rename the file in the app, then nb pull",
|
|
52
|
+
"CORRUPT_STATE": "nb doctor; relinking with nb init keeps your files",
|
|
53
|
+
"CORRUPT_DOWNLOAD": "Run nb pull again",
|
|
54
|
+
"UPLOAD_FAILED": "Run nb push again; it picks up where it stopped",
|
|
55
|
+
"CONFIRMATION_INVALID": "Run the command without --confirm to get a new one",
|
|
56
|
+
"GIT_FAILED": "Run the git command yourself to see why",
|
|
57
|
+
"EDITOR_FAILED": "Set your editor: export EDITOR=nano",
|
|
58
|
+
"UNKNOWN_TOOL": "Restart the agent so it reads the current tool list",
|
|
59
|
+
"INTERNAL": "If it keeps happening, tell us: nb feedback"
|
|
60
|
+
});
|
package/lib/errors.mjs
CHANGED
|
@@ -22,6 +22,8 @@ const EXIT_BY_CODE = {
|
|
|
22
22
|
NOT_SIGNED_IN: EXIT.auth,
|
|
23
23
|
FORBIDDEN: EXIT.auth,
|
|
24
24
|
SCOPE_MISSING: EXIT.auth,
|
|
25
|
+
ACCESS_REQUESTED: EXIT.needsInput,
|
|
26
|
+
ACCESS_DENIED_BY_PERSON: EXIT.auth,
|
|
25
27
|
WORKSPACE_NOT_ALLOWED: EXIT.auth,
|
|
26
28
|
AGENTS_PAUSED: EXIT.auth,
|
|
27
29
|
AGENT_NOT_ALLOWED: EXIT.auth,
|