@networkbase/cli 1.0.2 → 1.0.3
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 +345 -52
- package/package.json +1 -1
package/bin/nb.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { fileURLToPath } from "node:url";
|
|
|
11
11
|
|
|
12
12
|
const CLI_SCRIPT_PATH = fileURLToPath(import.meta.url);
|
|
13
13
|
|
|
14
|
-
const CLI_VERSION = "1.0.
|
|
14
|
+
const CLI_VERSION = "1.0.3";
|
|
15
15
|
const DEFAULT_API_URL = process.env.NETWORKBASE_API_URL || "https://networkbase.in";
|
|
16
16
|
const GLOBAL_CONFIG_DIR = path.join(os.homedir(), ".networkbase");
|
|
17
17
|
const GLOBAL_CREDENTIALS_PATH = path.join(GLOBAL_CONFIG_DIR, "credentials.json");
|
|
@@ -2213,7 +2213,9 @@ async function handleStatus(flags) {
|
|
|
2213
2213
|
outputResult(statusPayload, flags, (res) => {
|
|
2214
2214
|
const identity = res.authenticated
|
|
2215
2215
|
? `${c.emerald}●${c.reset} ${c.bold}${c.ink}${res.user?.username ? `@${res.user.username}` : res.user?.email || res.sessionId}${c.reset} ${c.muted}(${res.tokenType || "device"})${c.reset}`
|
|
2216
|
-
:
|
|
2216
|
+
: creds?.token && (creds?.user || creds?.sessionId)
|
|
2217
|
+
? `${c.emerald}●${c.reset} ${c.bold}${c.ink}${creds.user?.username ? `@${creds.user.username}` : creds.user?.email || creds.sessionId}${c.reset} ${c.muted}(${creds.tokenType || "device"})${c.reset}`
|
|
2218
|
+
: `${c.amber}○ Not signed in${c.reset}`;
|
|
2217
2219
|
|
|
2218
2220
|
const wsDisplay = res.workspace?.projectId
|
|
2219
2221
|
? `${c.bold}${c.ink}${res.workspace.title || res.workspace.projectId}${c.reset} ${c.muted}(${res.workspace.slug || res.workspace.projectId.slice(0, 8)})${c.reset}`
|
|
@@ -2238,6 +2240,67 @@ async function handleStatus(flags) {
|
|
|
2238
2240
|
return statusPayload;
|
|
2239
2241
|
}
|
|
2240
2242
|
|
|
2243
|
+
async function ensureWorkspaceLinked(flags = {}, cwd = process.cwd()) {
|
|
2244
|
+
const cfg = getLocalConfig(cwd);
|
|
2245
|
+
const explicitWorkspace = typeof flags.workspace === "string" ? flags.workspace.trim() : null;
|
|
2246
|
+
const projectId = explicitWorkspace || cfg.projectId;
|
|
2247
|
+
|
|
2248
|
+
if (projectId) {
|
|
2249
|
+
return { projectId, cfg };
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
// Not linked locally. Attempt to discover accessible workspaces.
|
|
2253
|
+
let workspaces = [];
|
|
2254
|
+
try {
|
|
2255
|
+
const creds = getCredentials();
|
|
2256
|
+
const apiUrl = await resolveBestApiUrl(typeof flags.url === "string" ? flags.url : creds?.apiUrl);
|
|
2257
|
+
const res = await apiRequest("/api/v1/extension/workspaces", { apiUrl });
|
|
2258
|
+
workspaces = res?.workspaces || res?.projects || [];
|
|
2259
|
+
} catch {
|
|
2260
|
+
// Session may be missing or unauthenticated
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
if (workspaces.length === 0) {
|
|
2264
|
+
throw new Error(
|
|
2265
|
+
"No workspace linked in this directory. Run `nb login` followed by `nb init` to link a workspace.",
|
|
2266
|
+
);
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
// If in interactive TTY and not json, offer immediate 1-click workspace selection
|
|
2270
|
+
if (process.stdin.isTTY && !flags.json) {
|
|
2271
|
+
renderBrandHeader({ subtitle: "Workspace Setup · Select a Workspace" });
|
|
2272
|
+
const chosen = await tuiSelect({
|
|
2273
|
+
title: "No workspace is linked to this directory. Choose one to link:",
|
|
2274
|
+
stepLabel: "Workspace",
|
|
2275
|
+
searchable: workspaces.length > 5,
|
|
2276
|
+
items: workspaces.map((w) => ({
|
|
2277
|
+
label: w.title,
|
|
2278
|
+
badge: formatStatusBadge(w.role || "member"),
|
|
2279
|
+
description: `ID: ${w.id}${w.slug ? ` · /${w.slug}` : ""}`,
|
|
2280
|
+
value: w,
|
|
2281
|
+
})),
|
|
2282
|
+
});
|
|
2283
|
+
|
|
2284
|
+
if (chosen) {
|
|
2285
|
+
const updatedCfg = {
|
|
2286
|
+
...cfg,
|
|
2287
|
+
projectId: chosen.id,
|
|
2288
|
+
title: chosen.title,
|
|
2289
|
+
slug: chosen.slug,
|
|
2290
|
+
};
|
|
2291
|
+
saveLocalConfig(updatedCfg, cwd);
|
|
2292
|
+
printStepDone("Linked Workspace", `${chosen.title} (${chosen.id})`);
|
|
2293
|
+
return { projectId: chosen.id, cfg: updatedCfg };
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
// Non-interactive or cancelled: output accessible workspaces so user or agent can select immediately
|
|
2298
|
+
const wsList = workspaces.map((w) => ` - ${w.title} (${w.id})`).join("\n");
|
|
2299
|
+
throw new Error(
|
|
2300
|
+
`No workspace linked. Run \`nb init\` or pass \`--workspace <id>\`.\nAvailable workspaces:\n${wsList}`,
|
|
2301
|
+
);
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2241
2304
|
async function handleWorkspace(sub, positional, flags) {
|
|
2242
2305
|
if (sub === "switch" || (!sub && process.stdin.isTTY && !flags.json)) {
|
|
2243
2306
|
const target = positional[0] || flags.workspace;
|
|
@@ -2267,9 +2330,9 @@ async function handleWorkspace(sub, positional, flags) {
|
|
|
2267
2330
|
}
|
|
2268
2331
|
|
|
2269
2332
|
if (sub === "info") {
|
|
2270
|
-
const
|
|
2271
|
-
|
|
2272
|
-
const summary = await apiRequest(`/api/v1/extension/workspace-summary?projectId=${
|
|
2333
|
+
const cwd = process.cwd();
|
|
2334
|
+
const { projectId, cfg } = await ensureWorkspaceLinked(flags, cwd);
|
|
2335
|
+
const summary = await apiRequest(`/api/v1/extension/workspace-summary?projectId=${projectId}`);
|
|
2273
2336
|
outputResult({ workspace: cfg, summary }, flags, (res) => {
|
|
2274
2337
|
renderBrandHeader({
|
|
2275
2338
|
subtitle: "Workspace Summary",
|
|
@@ -2309,16 +2372,23 @@ async function hydrateTaskAttachedFiles(projectId, attachedFiles, cwd = process.
|
|
|
2309
2372
|
const cleanRel = normPath.replace(/^\/+/, "");
|
|
2310
2373
|
const mirrorDest = path.join(mirrorDir, cleanRel);
|
|
2311
2374
|
const expectedHash = (f.contentHash || manifestFiles[normPath]?.contentHash || "").toLowerCase();
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2375
|
+
const expectedVersion = f.currentVersion || f.version;
|
|
2376
|
+
const manifestVersion = manifestFiles[normPath]?.version;
|
|
2377
|
+
|
|
2378
|
+
if (fs.existsSync(mirrorDest)) {
|
|
2379
|
+
if (expectedHash) {
|
|
2380
|
+
try {
|
|
2381
|
+
const localHash = computeFileSha256(mirrorDest).hash.toLowerCase();
|
|
2382
|
+
if (localHash === expectedHash) {
|
|
2383
|
+
hydratedCount++;
|
|
2384
|
+
return;
|
|
2385
|
+
}
|
|
2386
|
+
} catch {
|
|
2387
|
+
// Re-download if unreadable
|
|
2319
2388
|
}
|
|
2320
|
-
}
|
|
2321
|
-
|
|
2389
|
+
} else if (expectedVersion && manifestVersion && expectedVersion === manifestVersion) {
|
|
2390
|
+
hydratedCount++;
|
|
2391
|
+
return;
|
|
2322
2392
|
}
|
|
2323
2393
|
}
|
|
2324
2394
|
|
|
@@ -2473,8 +2543,8 @@ function renderTaskDetailCard(res, cfg, hydratedCount = 0) {
|
|
|
2473
2543
|
|
|
2474
2544
|
async function handleTask(sub, positional, flags) {
|
|
2475
2545
|
const cwd = process.cwd();
|
|
2476
|
-
|
|
2477
|
-
|
|
2546
|
+
let cfg = getLocalConfig(cwd);
|
|
2547
|
+
let projectId = typeof flags.workspace === "string" ? flags.workspace : cfg.projectId;
|
|
2478
2548
|
|
|
2479
2549
|
// Support `nb task list --all` / `nb task --all-workspaces` across all accessible workspaces
|
|
2480
2550
|
if ((!sub || sub === "list" || sub === "ls") && (flags.all || flags["all-workspaces"])) {
|
|
@@ -2523,7 +2593,7 @@ async function handleTask(sub, positional, flags) {
|
|
|
2523
2593
|
return;
|
|
2524
2594
|
}
|
|
2525
2595
|
|
|
2526
|
-
|
|
2596
|
+
({ projectId, cfg } = await ensureWorkspaceLinked(flags, cwd));
|
|
2527
2597
|
|
|
2528
2598
|
// Allow shorthand `nb task #4` or `nb task 4` to directly open `nb task view #4`
|
|
2529
2599
|
if (sub && (/^#?\d+$/.test(sub) || /^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(sub))) {
|
|
@@ -2531,6 +2601,73 @@ async function handleTask(sub, positional, flags) {
|
|
|
2531
2601
|
sub = "view";
|
|
2532
2602
|
}
|
|
2533
2603
|
|
|
2604
|
+
if (sub === "create" || sub === "new" || sub === "add") {
|
|
2605
|
+
let title = typeof flags.title === "string" ? flags.title : positional.join(" ").trim();
|
|
2606
|
+
if (!title && process.stdin.isTTY && !flags.json) {
|
|
2607
|
+
renderBrandHeader({ subtitle: `Create Sprint Task · ${cfg.title || projectId}` });
|
|
2608
|
+
title = await tuiInput({
|
|
2609
|
+
title: "Enter task title",
|
|
2610
|
+
stepLabel: "Task Title",
|
|
2611
|
+
placeholder: "e.g., Implement OAuth callback flow",
|
|
2612
|
+
});
|
|
2613
|
+
}
|
|
2614
|
+
if (!title) {
|
|
2615
|
+
throw new Error('Usage: nb task create "<title>" [-m description] [--priority low|medium|high|urgent]');
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
const description =
|
|
2619
|
+
typeof flags.message === "string"
|
|
2620
|
+
? flags.message
|
|
2621
|
+
: typeof flags.description === "string"
|
|
2622
|
+
? flags.description
|
|
2623
|
+
: undefined;
|
|
2624
|
+
const priority =
|
|
2625
|
+
flags.priority && ["low", "medium", "high", "urgent"].includes(flags.priority.toLowerCase())
|
|
2626
|
+
? flags.priority.toLowerCase()
|
|
2627
|
+
: "medium";
|
|
2628
|
+
|
|
2629
|
+
const createdRes = await withSpinner(
|
|
2630
|
+
"Creating sprint task…",
|
|
2631
|
+
() =>
|
|
2632
|
+
apiRequest("/api/v1/extension/create-task", {
|
|
2633
|
+
method: "POST",
|
|
2634
|
+
body: {
|
|
2635
|
+
projectId,
|
|
2636
|
+
title,
|
|
2637
|
+
description,
|
|
2638
|
+
priority,
|
|
2639
|
+
},
|
|
2640
|
+
}),
|
|
2641
|
+
{ silent: Boolean(flags.json) },
|
|
2642
|
+
);
|
|
2643
|
+
|
|
2644
|
+
// Refresh local tasks and TASKS.md immediately
|
|
2645
|
+
try {
|
|
2646
|
+
const refreshed = await apiRequest(`/api/v1/extension/workspace-tasks?projectId=${projectId}&scope=all`);
|
|
2647
|
+
writeLocalTaskIntelligence(projectId, cfg.title || projectId, refreshed.tasks || [], cwd);
|
|
2648
|
+
} catch {}
|
|
2649
|
+
|
|
2650
|
+
const createdTask = createdRes.task || createdRes;
|
|
2651
|
+
outputResult(
|
|
2652
|
+
createdRes,
|
|
2653
|
+
flags,
|
|
2654
|
+
() => {
|
|
2655
|
+
console.log(RAIL);
|
|
2656
|
+
console.log(
|
|
2657
|
+
`${STEP_DONE} ${c.bold}${c.ink}Created Task ${createdTask.taskNumber ? `#${createdTask.taskNumber}` : createdTask.id}${c.reset} ${formatPriorityBadge(priority)} ${formatStatusBadge("todo")}`,
|
|
2658
|
+
);
|
|
2659
|
+
console.log(`${RAIL} ${c.ink}${createdTask.title || title}${c.reset}`);
|
|
2660
|
+
if (description) {
|
|
2661
|
+
console.log(`${RAIL} ${c.muted}${description.slice(0, 100)}${c.reset}`);
|
|
2662
|
+
}
|
|
2663
|
+
console.log(
|
|
2664
|
+
`${c.dim}╰─${c.reset} Run ${c.accent}nb task work ${createdTask.taskNumber ? `#${createdTask.taskNumber}` : createdTask.id}${c.reset} to begin working on it.\n`,
|
|
2665
|
+
);
|
|
2666
|
+
},
|
|
2667
|
+
);
|
|
2668
|
+
return;
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2534
2671
|
if (sub === "work") {
|
|
2535
2672
|
let rawTarget = positional[0];
|
|
2536
2673
|
if (!rawTarget && process.stdin.isTTY && !flags.json) {
|
|
@@ -2788,6 +2925,77 @@ async function handleTask(sub, positional, flags) {
|
|
|
2788
2925
|
return;
|
|
2789
2926
|
}
|
|
2790
2927
|
|
|
2928
|
+
if (sub === "subtask" || sub === "subtasks") {
|
|
2929
|
+
const action = positional[0];
|
|
2930
|
+
if (action === "add" || action === "create" || action === "new") {
|
|
2931
|
+
let args = positional.slice(1);
|
|
2932
|
+
const rawTask = flags.task ? String(flags.task) : null;
|
|
2933
|
+
let targetTaskId = rawTask ? resolveTaskIdentifier(rawTask, cwd) : null;
|
|
2934
|
+
|
|
2935
|
+
// Check if next arg is a task identifier (e.g. #4, 4, or UUID)
|
|
2936
|
+
if (!targetTaskId && args.length > 1 && (/^#?\d+$/.test(args[0]) || /^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(args[0]))) {
|
|
2937
|
+
targetTaskId = resolveTaskIdentifier(args.shift(), cwd);
|
|
2938
|
+
}
|
|
2939
|
+
if (!targetTaskId) {
|
|
2940
|
+
const inferred = inferActiveTaskId(flags, cwd);
|
|
2941
|
+
if (inferred) targetTaskId = resolveTaskIdentifier(inferred, cwd);
|
|
2942
|
+
}
|
|
2943
|
+
|
|
2944
|
+
if (!targetTaskId) {
|
|
2945
|
+
throw new Error("No active task bound. Specify task with `#<number>` or pass `--task <#number>`.");
|
|
2946
|
+
}
|
|
2947
|
+
|
|
2948
|
+
const title = flags.title || flags.message || args.join(" ").trim();
|
|
2949
|
+
if (!title) {
|
|
2950
|
+
throw new Error('Usage: nb task subtask add [#number] "<subtask title>"');
|
|
2951
|
+
}
|
|
2952
|
+
|
|
2953
|
+
const detail = await apiRequest(
|
|
2954
|
+
`/api/v1/extension/task-detail?projectId=${projectId}&taskId=${encodeURIComponent(targetTaskId)}`,
|
|
2955
|
+
);
|
|
2956
|
+
const task = detail.task;
|
|
2957
|
+
|
|
2958
|
+
const created = await withSpinner(
|
|
2959
|
+
`Creating subtask on "${task.title}"…`,
|
|
2960
|
+
() =>
|
|
2961
|
+
apiRequest("/api/v1/extension/task-subtask", {
|
|
2962
|
+
method: "POST",
|
|
2963
|
+
body: {
|
|
2964
|
+
projectId,
|
|
2965
|
+
taskId: task.id,
|
|
2966
|
+
title,
|
|
2967
|
+
},
|
|
2968
|
+
}),
|
|
2969
|
+
{ silent: Boolean(flags.json) },
|
|
2970
|
+
);
|
|
2971
|
+
|
|
2972
|
+
// Refresh local tasks and TASKS.md immediately
|
|
2973
|
+
try {
|
|
2974
|
+
const refreshed = await apiRequest(`/api/v1/extension/workspace-tasks?projectId=${projectId}&scope=all`);
|
|
2975
|
+
writeLocalTaskIntelligence(projectId, cfg.title || projectId, refreshed.tasks || [], cwd);
|
|
2976
|
+
} catch {}
|
|
2977
|
+
|
|
2978
|
+
outputResult(
|
|
2979
|
+
{
|
|
2980
|
+
taskId: task.id,
|
|
2981
|
+
taskNumber: task.taskNumber,
|
|
2982
|
+
taskTitle: task.title,
|
|
2983
|
+
subtask: created.subtask,
|
|
2984
|
+
},
|
|
2985
|
+
flags,
|
|
2986
|
+
(res) => {
|
|
2987
|
+
console.log(RAIL);
|
|
2988
|
+
console.log(
|
|
2989
|
+
`${STEP_DONE} ${c.bold}${c.ink}Created subtask on Task ${res.taskNumber ? `#${res.taskNumber}` : res.taskId}${c.reset} ${c.muted}("${res.taskTitle}")${c.reset}`,
|
|
2990
|
+
);
|
|
2991
|
+
console.log(`${RAIL} ${c.muted}[ ]${c.reset} ${c.ink}${res.subtask.title}${c.reset}`);
|
|
2992
|
+
console.log(`${c.dim}╰─${c.reset} Subtask added and synced to .networkbase/tasks/TASKS.md\n`);
|
|
2993
|
+
},
|
|
2994
|
+
);
|
|
2995
|
+
return;
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
|
|
2791
2999
|
if (sub === "check" || sub === "subtask" || sub === "subtasks") {
|
|
2792
3000
|
const rawTaskTarget = flags.task ? String(flags.task) : inferActiveTaskId(flags, cwd);
|
|
2793
3001
|
let targetTaskId = rawTaskTarget ? resolveTaskIdentifier(rawTaskTarget, cwd) : null;
|
|
@@ -2935,6 +3143,11 @@ async function handleTask(sub, positional, flags) {
|
|
|
2935
3143
|
expectedUpdatedAt: new Date(task.updatedAt).toISOString(),
|
|
2936
3144
|
},
|
|
2937
3145
|
});
|
|
3146
|
+
// Refresh local tasks and TASKS.md immediately
|
|
3147
|
+
try {
|
|
3148
|
+
const refreshed = await apiRequest(`/api/v1/extension/workspace-tasks?projectId=${projectId}&scope=all`);
|
|
3149
|
+
writeLocalTaskIntelligence(projectId, cfg.title || projectId, refreshed.tasks || [], cwd);
|
|
3150
|
+
} catch {}
|
|
2938
3151
|
outputResult(updated, flags, () => {
|
|
2939
3152
|
console.log(
|
|
2940
3153
|
`\n${c.emerald}✔${c.reset} Task ${c.bold}${c.ink}"${task.title}"${c.reset} marked as ${formatStatusBadge("done")}\n`,
|
|
@@ -3003,6 +3216,11 @@ async function handleTask(sub, positional, flags) {
|
|
|
3003
3216
|
method: "POST",
|
|
3004
3217
|
body: { taskId: detail.task.id, content },
|
|
3005
3218
|
});
|
|
3219
|
+
// Refresh local tasks and TASKS.md immediately
|
|
3220
|
+
try {
|
|
3221
|
+
const refreshed = await apiRequest(`/api/v1/extension/workspace-tasks?projectId=${projectId}&scope=all`);
|
|
3222
|
+
writeLocalTaskIntelligence(projectId, cfg.title || projectId, refreshed.tasks || [], cwd);
|
|
3223
|
+
} catch {}
|
|
3006
3224
|
outputResult(created, flags, () => {
|
|
3007
3225
|
console.log(`\n${c.emerald}✔${c.reset} Posted comment to task "${detail.task.title}"\n`);
|
|
3008
3226
|
});
|
|
@@ -3064,9 +3282,8 @@ async function downloadRemoteFileBuffer(projectId, remotePath, options = {}) {
|
|
|
3064
3282
|
}
|
|
3065
3283
|
|
|
3066
3284
|
async function handleFile(sub, positional, flags) {
|
|
3067
|
-
const
|
|
3068
|
-
const projectId = flags
|
|
3069
|
-
if (!projectId) throw new Error("No workspace linked. Run `nb init` first.");
|
|
3285
|
+
const cwd = process.cwd();
|
|
3286
|
+
const { projectId, cfg } = await ensureWorkspaceLinked(flags, cwd);
|
|
3070
3287
|
|
|
3071
3288
|
if (sub === "ls" || !sub) {
|
|
3072
3289
|
const filterQuery = positional[0] || "";
|
|
@@ -3218,9 +3435,9 @@ async function handleFile(sub, positional, flags) {
|
|
|
3218
3435
|
throw new Error(`Unknown file subcommand: ${sub}`);
|
|
3219
3436
|
}
|
|
3220
3437
|
|
|
3221
|
-
function prepareLocalFilesForPush(targetPaths, flags, cwd = process.cwd()) {
|
|
3438
|
+
function prepareLocalFilesForPush(targetPaths, flags, cwd = process.cwd(), explicitProjectId = null) {
|
|
3222
3439
|
const cfg = getLocalConfig(cwd);
|
|
3223
|
-
const projectId = flags.workspace || cfg.projectId;
|
|
3440
|
+
const projectId = explicitProjectId || flags.workspace || cfg.projectId;
|
|
3224
3441
|
if (!projectId) {
|
|
3225
3442
|
throw new Error("No workspace linked in this directory. Run `nb init` first.");
|
|
3226
3443
|
}
|
|
@@ -3306,7 +3523,7 @@ function prepareLocalFilesForPush(targetPaths, flags, cwd = process.cwd()) {
|
|
|
3306
3523
|
};
|
|
3307
3524
|
}
|
|
3308
3525
|
|
|
3309
|
-
async function executePrePushAnalysis(targetPaths, flags, cwd = process.cwd()) {
|
|
3526
|
+
async function executePrePushAnalysis(targetPaths, flags, cwd = process.cwd(), explicitProjectId = null) {
|
|
3310
3527
|
const {
|
|
3311
3528
|
projectId,
|
|
3312
3529
|
taskId,
|
|
@@ -3314,7 +3531,7 @@ async function executePrePushAnalysis(targetPaths, flags, cwd = process.cwd()) {
|
|
|
3314
3531
|
allPreparedCount,
|
|
3315
3532
|
skippedByLocalManifestCount,
|
|
3316
3533
|
secretViolations,
|
|
3317
|
-
} = prepareLocalFilesForPush(targetPaths, flags, cwd);
|
|
3534
|
+
} = prepareLocalFilesForPush(targetPaths, flags, cwd, explicitProjectId);
|
|
3318
3535
|
|
|
3319
3536
|
const analysis = await apiRequest("/api/v1/extension/pre-push", {
|
|
3320
3537
|
method: "POST",
|
|
@@ -3399,7 +3616,8 @@ async function executeFastPushRequest({
|
|
|
3399
3616
|
}
|
|
3400
3617
|
|
|
3401
3618
|
async function handlePush(positional, flags, { skipHeader = false } = {}) {
|
|
3402
|
-
const
|
|
3619
|
+
const cwd = process.cwd();
|
|
3620
|
+
const { projectId, cfg } = await ensureWorkspaceLinked(flags, cwd);
|
|
3403
3621
|
if (!flags.json && !skipHeader && !flags["dry-run"]) {
|
|
3404
3622
|
renderBrandHeader({
|
|
3405
3623
|
subtitle: `High-EQ Smart Push · ${cfg.title || flags.workspace || "Workspace"}`,
|
|
@@ -3407,20 +3625,20 @@ async function handlePush(positional, flags, { skipHeader = false } = {}) {
|
|
|
3407
3625
|
}
|
|
3408
3626
|
|
|
3409
3627
|
const explicitRole = resolveRoleFromFlags(flags);
|
|
3628
|
+
const isAuto = Boolean(flags.yes || flags.y || flags.auto || !process.stdin.isTTY);
|
|
3410
3629
|
const transitionFromFlags = flags.done ? "done" : flags.wip ? "in_progress" : undefined;
|
|
3411
3630
|
|
|
3412
3631
|
// ULTRA-FAST 1-ROUND-TRIP PATH:
|
|
3413
|
-
// When role is already specified (e.g. --deliverable / --draft / --reference / --json)
|
|
3632
|
+
// When role is already specified (e.g. --deliverable / --draft / --reference / --json) or auto/non-TTY,
|
|
3414
3633
|
// skip /pre-push completely and execute atomic /fast-push in 1 single HTTP round-trip!
|
|
3415
|
-
if (!flags["dry-run"] && (explicitRole || flags.json ||
|
|
3634
|
+
if (!flags["dry-run"] && (explicitRole || flags.json || isAuto)) {
|
|
3416
3635
|
const {
|
|
3417
|
-
projectId,
|
|
3418
3636
|
taskId,
|
|
3419
3637
|
preparedFiles,
|
|
3420
3638
|
allPreparedCount,
|
|
3421
3639
|
skippedByLocalManifestCount,
|
|
3422
3640
|
secretViolations,
|
|
3423
|
-
} = prepareLocalFilesForPush(positional, flags);
|
|
3641
|
+
} = prepareLocalFilesForPush(positional, flags, cwd, projectId);
|
|
3424
3642
|
|
|
3425
3643
|
if (secretViolations.length > 0 && !flags["allow-secrets"]) {
|
|
3426
3644
|
const errPayload = {
|
|
@@ -3522,12 +3740,17 @@ async function handlePush(positional, flags, { skipHeader = false } = {}) {
|
|
|
3522
3740
|
console.log(`${c.dim}╰─${c.reset} ${c.emerald}✔${c.reset} Sync complete.\n`);
|
|
3523
3741
|
}
|
|
3524
3742
|
});
|
|
3743
|
+
if (projectId) {
|
|
3744
|
+
try {
|
|
3745
|
+
const refreshed = await apiRequest(`/api/v1/extension/workspace-tasks?projectId=${projectId}&scope=all`);
|
|
3746
|
+
writeLocalTaskIntelligence(projectId, cfg.title || projectId, refreshed.tasks || [], cwd);
|
|
3747
|
+
} catch {}
|
|
3748
|
+
}
|
|
3525
3749
|
return finalFast;
|
|
3526
3750
|
}
|
|
3527
3751
|
}
|
|
3528
3752
|
|
|
3529
3753
|
const {
|
|
3530
|
-
projectId,
|
|
3531
3754
|
taskId,
|
|
3532
3755
|
preparedFiles,
|
|
3533
3756
|
skippedByLocalManifestCount,
|
|
@@ -3535,7 +3758,7 @@ async function handlePush(positional, flags, { skipHeader = false } = {}) {
|
|
|
3535
3758
|
analysis,
|
|
3536
3759
|
} = await withSpinner(
|
|
3537
3760
|
"Analyzing local files & SHA-256 manifest…",
|
|
3538
|
-
() => executePrePushAnalysis(positional, flags),
|
|
3761
|
+
() => executePrePushAnalysis(positional, flags, cwd, projectId),
|
|
3539
3762
|
{ silent: Boolean(flags.json) },
|
|
3540
3763
|
);
|
|
3541
3764
|
|
|
@@ -3599,7 +3822,7 @@ async function handlePush(positional, flags, { skipHeader = false } = {}) {
|
|
|
3599
3822
|
let selectedRole = explicitRole;
|
|
3600
3823
|
|
|
3601
3824
|
// Interactive Multi-File Selection & Role Classification when running in a terminal without flags
|
|
3602
|
-
if (process.stdin.isTTY && !flags.json && !selectedRole) {
|
|
3825
|
+
if (process.stdin.isTTY && !flags.json && !selectedRole && !isAuto) {
|
|
3603
3826
|
if (changedAnalysisFiles.length > 1) {
|
|
3604
3827
|
const chosenPaths = await tuiMultiSelect({
|
|
3605
3828
|
title: "Select changed files to include in this push",
|
|
@@ -3669,7 +3892,8 @@ async function handlePush(positional, flags, { skipHeader = false } = {}) {
|
|
|
3669
3892
|
selectedRole === "deliverable" &&
|
|
3670
3893
|
!transitionStatus &&
|
|
3671
3894
|
process.stdin.isTTY &&
|
|
3672
|
-
!flags.json
|
|
3895
|
+
!flags.json &&
|
|
3896
|
+
!isAuto
|
|
3673
3897
|
) {
|
|
3674
3898
|
const taskTitle = analysis.task?.title || taskId;
|
|
3675
3899
|
const markDone = await tuiConfirm({
|
|
@@ -3904,13 +4128,19 @@ async function handlePush(positional, flags, { skipHeader = false } = {}) {
|
|
|
3904
4128
|
}
|
|
3905
4129
|
});
|
|
3906
4130
|
|
|
4131
|
+
if (projectId) {
|
|
4132
|
+
try {
|
|
4133
|
+
const refreshed = await apiRequest(`/api/v1/extension/workspace-tasks?projectId=${projectId}&scope=all`);
|
|
4134
|
+
writeLocalTaskIntelligence(projectId, cfg.title || projectId, refreshed.tasks || [], cwd);
|
|
4135
|
+
} catch {}
|
|
4136
|
+
}
|
|
4137
|
+
|
|
3907
4138
|
return finalPayload;
|
|
3908
4139
|
}
|
|
3909
4140
|
|
|
3910
4141
|
async function handlePull(positional, flags, { skipHeader = false } = {}) {
|
|
3911
|
-
const
|
|
3912
|
-
const projectId = flags
|
|
3913
|
-
if (!projectId) throw new Error("No workspace linked. Run `nb init` first.");
|
|
4142
|
+
const cwd = process.cwd();
|
|
4143
|
+
const { projectId, cfg } = await ensureWorkspaceLinked(flags, cwd);
|
|
3914
4144
|
|
|
3915
4145
|
if (!flags.json && !skipHeader) {
|
|
3916
4146
|
renderBrandHeader({ subtitle: `Pull Workspace Files · ${cfg.title || projectId}` });
|
|
@@ -4140,18 +4370,7 @@ async function hydrateWorkspaceMirror(projectId, { cwd = process.cwd(), force =
|
|
|
4140
4370
|
|
|
4141
4371
|
async function handleSync(positional, flags) {
|
|
4142
4372
|
const cwd = process.cwd();
|
|
4143
|
-
let cfg =
|
|
4144
|
-
|
|
4145
|
-
// Allow switching workspace in the same single `nb sync --workspace <slug-or-id>` call
|
|
4146
|
-
if (typeof flags.workspace === "string" && flags.workspace.trim() && flags.workspace !== cfg.projectId) {
|
|
4147
|
-
await handleInit([flags.workspace.trim()], { ...flags, "no-task": true, silent: true }, { skipHeader: true });
|
|
4148
|
-
cfg = getLocalConfig(cwd);
|
|
4149
|
-
}
|
|
4150
|
-
|
|
4151
|
-
const projectId = cfg.projectId;
|
|
4152
|
-
if (!projectId) {
|
|
4153
|
-
throw new Error("No workspace linked. Run `nb init` first.");
|
|
4154
|
-
}
|
|
4373
|
+
let { projectId, cfg } = await ensureWorkspaceLinked(flags, cwd);
|
|
4155
4374
|
|
|
4156
4375
|
if (!flags.json) {
|
|
4157
4376
|
renderBrandHeader({ subtitle: `Unified One-Permission Sync · ${cfg.title || projectId}` });
|
|
@@ -4277,9 +4496,7 @@ async function handleSync(positional, flags) {
|
|
|
4277
4496
|
|
|
4278
4497
|
async function handleWatch(positional, flags) {
|
|
4279
4498
|
const cwd = process.cwd();
|
|
4280
|
-
const cfg =
|
|
4281
|
-
const projectId = flags.workspace || cfg.projectId;
|
|
4282
|
-
if (!projectId) throw new Error("No workspace linked. Run `nb init` first.");
|
|
4499
|
+
const { projectId, cfg } = await ensureWorkspaceLinked(flags, cwd);
|
|
4283
4500
|
|
|
4284
4501
|
const isDaemonWorker = Boolean(flags["daemon-worker"]);
|
|
4285
4502
|
const role = resolveRoleFromFlags(flags) || "deliverable";
|
|
@@ -4720,6 +4937,31 @@ async function startMcpServer() {
|
|
|
4720
4937
|
properties: { paths: { type: "array", items: { type: "string" } } },
|
|
4721
4938
|
},
|
|
4722
4939
|
},
|
|
4940
|
+
{
|
|
4941
|
+
name: "nb_subtask_create",
|
|
4942
|
+
description: "Create a new subtask checklist item on a Sprint Task in NetworkBase.",
|
|
4943
|
+
inputSchema: {
|
|
4944
|
+
type: "object",
|
|
4945
|
+
properties: {
|
|
4946
|
+
taskId: { type: "string", description: "Task UUID or task number (e.g. #4 or 4)" },
|
|
4947
|
+
title: { type: "string", description: "Subtask title / description" },
|
|
4948
|
+
},
|
|
4949
|
+
required: ["taskId", "title"],
|
|
4950
|
+
},
|
|
4951
|
+
},
|
|
4952
|
+
{
|
|
4953
|
+
name: "nb_task_create",
|
|
4954
|
+
description: "Create a new Sprint Task in the active NetworkBase workspace.",
|
|
4955
|
+
inputSchema: {
|
|
4956
|
+
type: "object",
|
|
4957
|
+
properties: {
|
|
4958
|
+
title: { type: "string", description: "Task title" },
|
|
4959
|
+
description: { type: "string", description: "Optional markdown description" },
|
|
4960
|
+
priority: { type: "string", enum: ["low", "medium", "high", "urgent"] },
|
|
4961
|
+
},
|
|
4962
|
+
required: ["title"],
|
|
4963
|
+
},
|
|
4964
|
+
},
|
|
4723
4965
|
],
|
|
4724
4966
|
});
|
|
4725
4967
|
return;
|
|
@@ -4905,6 +5147,51 @@ async function startMcpServer() {
|
|
|
4905
5147
|
return;
|
|
4906
5148
|
}
|
|
4907
5149
|
|
|
5150
|
+
if (toolName === "nb_subtask_create") {
|
|
5151
|
+
const cfg = getLocalConfig();
|
|
5152
|
+
const targetId = resolveTaskIdentifier(args.taskId || getLocalState()?.activeTaskId);
|
|
5153
|
+
const detail = await apiRequest(
|
|
5154
|
+
`/api/v1/extension/task-detail?projectId=${cfg.projectId}&taskId=${encodeURIComponent(targetId)}`,
|
|
5155
|
+
);
|
|
5156
|
+
const res = await apiRequest("/api/v1/extension/task-subtask", {
|
|
5157
|
+
method: "POST",
|
|
5158
|
+
body: {
|
|
5159
|
+
projectId: cfg.projectId,
|
|
5160
|
+
taskId: detail.task.id,
|
|
5161
|
+
title: args.title,
|
|
5162
|
+
},
|
|
5163
|
+
});
|
|
5164
|
+
try {
|
|
5165
|
+
const refreshed = await apiRequest(`/api/v1/extension/workspace-tasks?projectId=${cfg.projectId}&scope=all`);
|
|
5166
|
+
writeLocalTaskIntelligence(cfg.projectId, cfg.title || cfg.projectId, refreshed.tasks || []);
|
|
5167
|
+
} catch {}
|
|
5168
|
+
sendJsonRpc(id, {
|
|
5169
|
+
content: [{ type: "text", text: JSON.stringify(res, null, 2) }],
|
|
5170
|
+
});
|
|
5171
|
+
return;
|
|
5172
|
+
}
|
|
5173
|
+
|
|
5174
|
+
if (toolName === "nb_task_create") {
|
|
5175
|
+
const cfg = getLocalConfig();
|
|
5176
|
+
const res = await apiRequest("/api/v1/extension/create-task", {
|
|
5177
|
+
method: "POST",
|
|
5178
|
+
body: {
|
|
5179
|
+
projectId: cfg.projectId,
|
|
5180
|
+
title: args.title,
|
|
5181
|
+
description: args.description,
|
|
5182
|
+
priority: args.priority || "medium",
|
|
5183
|
+
},
|
|
5184
|
+
});
|
|
5185
|
+
try {
|
|
5186
|
+
const refreshed = await apiRequest(`/api/v1/extension/workspace-tasks?projectId=${cfg.projectId}&scope=all`);
|
|
5187
|
+
writeLocalTaskIntelligence(cfg.projectId, cfg.title || cfg.projectId, refreshed.tasks || []);
|
|
5188
|
+
} catch {}
|
|
5189
|
+
sendJsonRpc(id, {
|
|
5190
|
+
content: [{ type: "text", text: JSON.stringify(res, null, 2) }],
|
|
5191
|
+
});
|
|
5192
|
+
return;
|
|
5193
|
+
}
|
|
5194
|
+
|
|
4908
5195
|
sendJsonRpc(id, null, { code: -32601, message: `Unknown tool: ${toolName}` });
|
|
4909
5196
|
}
|
|
4910
5197
|
} catch (err) {
|
|
@@ -4936,15 +5223,21 @@ Core Commands:
|
|
|
4936
5223
|
nb auth setup-git Configure Git HTTPS credential helper
|
|
4937
5224
|
nb workspace list | switch List or switch active NetworkBase workspaces
|
|
4938
5225
|
nb task [list] [--all | --mine] View project tasks, descriptions, subtasks & attached files
|
|
5226
|
+
nb task <#number|id> Shorthand to inspect task details & mirror attached files
|
|
4939
5227
|
nb task view <#number|id> Inspect task description, subtasks & mirror attached files
|
|
4940
5228
|
nb task work <#number|id> Bind active task, transition to in_progress & mirror files
|
|
4941
|
-
nb task
|
|
5229
|
+
nb task create "<title>" [-m] Create a new sprint task (--priority low|medium|high|urgent)
|
|
5230
|
+
nb task subtask add [#id] <t> Add a new subtask checklist item to active or specified task
|
|
5231
|
+
nb task check [#id] [1 2|--all] Toggle subtasks interactively (Space) or via CLI numbers
|
|
4942
5232
|
nb task done [#number|id] Mark active or specified task as Done
|
|
5233
|
+
nb task comment <#id> <message> Add a comment to active or specified task
|
|
5234
|
+
nb task status View sprint & task health metrics and completion rate
|
|
4943
5235
|
nb file ls | log | diff | lock Inspect workspace files, history, diffs, or CLI locks
|
|
4944
5236
|
nb hook install Install local .git/hooks/pre-push secret scanner
|
|
4945
5237
|
nb pull [paths...] Download remote workspace files to local directory
|
|
4946
5238
|
nb watch [paths...] Live debounced auto-sync watcher (1-RTT fast-push on save)
|
|
4947
5239
|
nb push [paths...] High-EQ Smart Push (SHA-256 diff + v1->v2 bump + task link)
|
|
5240
|
+
-y, --yes, --auto Non-interactive push with smart defaults (no prompt blocking)
|
|
4948
5241
|
--deliverable Classify pushed files as Final Deliverable (#deliverable)
|
|
4949
5242
|
--draft Classify pushed files as Working Draft (#editor_working)
|
|
4950
5243
|
--reference Classify pushed files as Reference Material (#reference)
|