@freesyntax/notch-cli 0.5.21 → 0.5.22
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/dist/{apply-patch-D5PDUXUC.js → apply-patch-U6K67CMT.js} +1 -0
- package/dist/auth-UAMMP5IJ.js +29 -0
- package/dist/{chunk-OSWUX6TC.js → chunk-4HPRBCSY.js} +1 -1
- package/dist/{chunk-QKM27RHS.js → chunk-6NKRMZTX.js} +1 -1
- package/dist/{chunk-TU465P2P.js → chunk-EPSOOCNB.js} +4 -2
- package/dist/{chunk-MMBFNIKE.js → chunk-FZVPGJJW.js} +5 -3
- package/dist/chunk-J66N6AFH.js +137 -0
- package/dist/{chunk-443G6HCC.js → chunk-JXQ4HZ47.js} +56 -55
- package/dist/chunk-KCAR5DOB.js +52 -0
- package/dist/chunk-KFQGP6VL.js +33 -0
- package/dist/chunk-O6AKZ4OH.js +0 -0
- package/dist/{chunk-FIFC4V2R.js → chunk-PPEBWOMJ.js} +91 -7
- package/dist/{compression-SQAIQ2UU.js → compression-YJLWEHCC.js} +1 -0
- package/dist/config-set-3IWEVZQ4.js +110 -0
- package/dist/{edit-JEFEK43H.js → edit-6QYAXVNU.js} +1 -0
- package/dist/{git-5T5TSQTX.js → git-DNQ5EELH.js} +1 -0
- package/dist/{github-DWRGWX6U.js → github-34T4QQIH.js} +1 -0
- package/dist/{glob-BI3P4C7Q.js → glob-XT43LEJ4.js} +1 -0
- package/dist/{grep-VZ3I5GNW.js → grep-T2CXYNRI.js} +1 -0
- package/dist/index.js +420 -298
- package/dist/{lsp-UPY6I3L7.js → lsp-JXQVU7NP.js} +1 -0
- package/dist/model-download-3NDKS3VM.js +176 -0
- package/dist/{notebook-FXJBTSPA.js → notebook-MFODW345.js} +1 -0
- package/dist/{ollama-bench-QQHBIG2D.js → ollama-bench-5V5CCOCQ.js} +6 -2
- package/dist/{ollama-launch-2ASVER3S.js → ollama-launch-P5KBK7AJ.js} +6 -2
- package/dist/{ollama-usage-2WPCZJJI.js → ollama-usage-3PROM2WC.js} +1 -0
- package/dist/{plugins-OG2P75K5.js → plugins-PNGRZLFW.js} +1 -0
- package/dist/{read-OVJG2XKW.js → read-B64XE7N3.js} +1 -0
- package/dist/{server-7UQKCB2Z.js → server-IGOZHW52.js} +17 -15
- package/dist/{session-index-SSGOOZXK.js → session-index-7FWEVP6E.js} +3 -2
- package/dist/{shell-4X545EVN.js → shell-BOZTHQUT.js} +1 -0
- package/dist/{task-OS3E5F3X.js → task-67G4KLYC.js} +1 -0
- package/dist/{tools-7WAWS6V4.js → tools-XWKCW4RN.js} +4 -3
- package/dist/{web-fetch-KNIV3Z3W.js → web-fetch-OTNDICGJ.js} +1 -0
- package/dist/{write-NNHLOTYK.js → write-ZOSB7I4J.js} +1 -0
- package/package.json +1 -1
- package/dist/auth-JQX6MHJG.js +0 -16
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MODEL_CATALOG
|
|
3
|
+
} from "./chunk-JXQ4HZ47.js";
|
|
4
|
+
import "./chunk-PPEBWOMJ.js";
|
|
5
|
+
import "./chunk-KFQGP6VL.js";
|
|
6
|
+
|
|
7
|
+
// src/commands/model-download.ts
|
|
8
|
+
import { spawn } from "child_process";
|
|
9
|
+
import { statfs, promises as fsp } from "fs";
|
|
10
|
+
import os from "os";
|
|
11
|
+
import path from "path";
|
|
12
|
+
import chalk from "chalk";
|
|
13
|
+
async function probeSystemCapabilities(cacheDir = os.homedir()) {
|
|
14
|
+
const totalRamBytes = os.totalmem();
|
|
15
|
+
const totalRamGb = Number((totalRamBytes / 1024 / 1024 / 1024).toFixed(1));
|
|
16
|
+
const freeDiskGb = await new Promise((resolve) => {
|
|
17
|
+
try {
|
|
18
|
+
statfs(cacheDir, (err, stats) => {
|
|
19
|
+
if (err) return resolve(null);
|
|
20
|
+
const freeBytes = Number(stats.bsize) * Number(stats.bavail);
|
|
21
|
+
resolve(Math.round(freeBytes / 1024 / 1024 / 1024));
|
|
22
|
+
});
|
|
23
|
+
} catch {
|
|
24
|
+
resolve(null);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const gpu = await probeNvidiaSmi();
|
|
28
|
+
return {
|
|
29
|
+
platform: process.platform,
|
|
30
|
+
totalRamGb,
|
|
31
|
+
freeDiskGb,
|
|
32
|
+
gpuVramGb: gpu?.vramGb ?? null,
|
|
33
|
+
gpuName: gpu?.name ?? null
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function probeNvidiaSmi() {
|
|
37
|
+
return new Promise((resolve) => {
|
|
38
|
+
try {
|
|
39
|
+
const proc = spawn("nvidia-smi", [
|
|
40
|
+
"--query-gpu=name,memory.total",
|
|
41
|
+
"--format=csv,noheader,nounits"
|
|
42
|
+
], { stdio: ["ignore", "pipe", "ignore"] });
|
|
43
|
+
let buf = "";
|
|
44
|
+
proc.stdout.on("data", (c) => {
|
|
45
|
+
buf += c.toString();
|
|
46
|
+
});
|
|
47
|
+
proc.on("error", () => resolve(null));
|
|
48
|
+
proc.on("close", (code) => {
|
|
49
|
+
if (code !== 0 || !buf.trim()) return resolve(null);
|
|
50
|
+
const first = buf.split("\n")[0]?.trim();
|
|
51
|
+
if (!first) return resolve(null);
|
|
52
|
+
const [name, memStr] = first.split(",").map((s) => s.trim());
|
|
53
|
+
const memMb = Number(memStr);
|
|
54
|
+
if (!name || !Number.isFinite(memMb) || memMb <= 0) return resolve(null);
|
|
55
|
+
resolve({ vramGb: Number((memMb / 1024).toFixed(1)), name });
|
|
56
|
+
});
|
|
57
|
+
} catch {
|
|
58
|
+
resolve(null);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function evaluateHardware(info, caps) {
|
|
63
|
+
const hw = info.hardware;
|
|
64
|
+
const checks = [];
|
|
65
|
+
checks.push({
|
|
66
|
+
label: "RAM",
|
|
67
|
+
required: `${hw.ramGb} GB`,
|
|
68
|
+
detected: `${caps.totalRamGb} GB`,
|
|
69
|
+
status: caps.totalRamGb >= hw.ramGb ? "pass" : caps.totalRamGb >= hw.ramGb * 0.75 ? "warn" : "fail"
|
|
70
|
+
});
|
|
71
|
+
checks.push({
|
|
72
|
+
label: "Disk",
|
|
73
|
+
required: `${hw.diskGb} GB`,
|
|
74
|
+
detected: caps.freeDiskGb == null ? "unknown" : `${caps.freeDiskGb} GB free`,
|
|
75
|
+
status: caps.freeDiskGb == null ? "unknown" : caps.freeDiskGb >= hw.diskGb ? "pass" : "fail"
|
|
76
|
+
});
|
|
77
|
+
if (caps.gpuVramGb == null) {
|
|
78
|
+
checks.push({
|
|
79
|
+
label: "GPU",
|
|
80
|
+
required: `${hw.vramGb} GB VRAM (${hw.recommendedGpu})`,
|
|
81
|
+
detected: "no CUDA GPU detected",
|
|
82
|
+
// Apple silicon users run well on unified memory with Ollama even
|
|
83
|
+
// without a discrete GPU — don't fail, just warn so the CLI stays
|
|
84
|
+
// usable on Macs.
|
|
85
|
+
status: caps.platform === "darwin" ? "warn" : "warn"
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
checks.push({
|
|
89
|
+
label: "GPU",
|
|
90
|
+
required: `${hw.vramGb} GB VRAM (${hw.recommendedGpu})`,
|
|
91
|
+
detected: `${caps.gpuVramGb} GB \xB7 ${caps.gpuName ?? "unknown"}`,
|
|
92
|
+
status: caps.gpuVramGb >= hw.vramGb ? "pass" : caps.gpuVramGb >= hw.vramGb * 0.75 ? "warn" : "fail"
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const ok = checks.every((c) => c.status === "pass" || c.status === "warn");
|
|
96
|
+
const failures = checks.filter((c) => c.status === "fail").map((c) => c.label);
|
|
97
|
+
const summary = ok ? `Your system meets the ${hw.tier} tier requirements for ${info.label}.` : `Your system is under-resourced for ${info.label} \u2014 ${failures.join(", ")} below minimum.`;
|
|
98
|
+
return { ok, checks, summary };
|
|
99
|
+
}
|
|
100
|
+
function renderVerdict(info, verdict) {
|
|
101
|
+
const lines = [];
|
|
102
|
+
lines.push(chalk.gray(` \u2500\u2500\u2500 ${info.label} (${info.size}) \xB7 ${info.hardware.tier} tier \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`));
|
|
103
|
+
for (const c of verdict.checks) {
|
|
104
|
+
const icon = c.status === "pass" ? chalk.green("\u2713") : c.status === "warn" ? chalk.yellow("!") : c.status === "fail" ? chalk.red("\u2717") : chalk.gray("?");
|
|
105
|
+
lines.push(` ${icon} ${c.label.padEnd(5)} required: ${chalk.white(c.required.padEnd(34))} detected: ${chalk.gray(c.detected)}`);
|
|
106
|
+
}
|
|
107
|
+
lines.push("");
|
|
108
|
+
lines.push(verdict.ok ? chalk.green(` ${verdict.summary}`) : chalk.yellow(` ${verdict.summary}`));
|
|
109
|
+
return lines.join("\n");
|
|
110
|
+
}
|
|
111
|
+
var activeDownloads = /* @__PURE__ */ new Map();
|
|
112
|
+
function getDownloadStatus(id) {
|
|
113
|
+
return activeDownloads.get(id) ?? null;
|
|
114
|
+
}
|
|
115
|
+
function listDownloads() {
|
|
116
|
+
return [...activeDownloads.values()];
|
|
117
|
+
}
|
|
118
|
+
function getHuggingFaceCacheDir() {
|
|
119
|
+
const hfHome = process.env.HF_HOME ?? process.env.HUGGINGFACE_HUB_CACHE;
|
|
120
|
+
if (hfHome) return hfHome;
|
|
121
|
+
return path.join(os.homedir(), ".cache", "huggingface", "hub");
|
|
122
|
+
}
|
|
123
|
+
async function startModelDownload(id) {
|
|
124
|
+
const info = MODEL_CATALOG[id];
|
|
125
|
+
if (!info) throw new Error(`Unknown Notch model: ${id}`);
|
|
126
|
+
if (!info.hfRepo) {
|
|
127
|
+
throw new Error(
|
|
128
|
+
`${info.label} is not yet available for local download. Use the hosted Notch API in the meantime \u2014 run \`notch login\` to get a key.`
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
const existing = activeDownloads.get(id);
|
|
132
|
+
if (existing && existing.result == null) return existing;
|
|
133
|
+
const cacheDir = getHuggingFaceCacheDir();
|
|
134
|
+
await fsp.mkdir(cacheDir, { recursive: true });
|
|
135
|
+
const handle = {
|
|
136
|
+
modelId: id,
|
|
137
|
+
startedAt: /* @__PURE__ */ new Date(),
|
|
138
|
+
cacheDir,
|
|
139
|
+
pid: 0,
|
|
140
|
+
lastLine: "queued",
|
|
141
|
+
result: null
|
|
142
|
+
};
|
|
143
|
+
const args = ["download", info.hfRepo, "--local-dir-use-symlinks", "False"];
|
|
144
|
+
const proc = spawn("huggingface-cli", args, {
|
|
145
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
146
|
+
detached: false,
|
|
147
|
+
env: { ...process.env, HF_HUB_ENABLE_HF_TRANSFER: "1" }
|
|
148
|
+
});
|
|
149
|
+
handle.pid = proc.pid ?? 0;
|
|
150
|
+
activeDownloads.set(id, handle);
|
|
151
|
+
const absorb = (buf) => {
|
|
152
|
+
const text = buf.toString();
|
|
153
|
+
const line = text.split(/\r?\n/).filter((l) => l.trim().length > 0).pop();
|
|
154
|
+
if (line) handle.lastLine = line.slice(0, 200);
|
|
155
|
+
};
|
|
156
|
+
proc.stdout?.on("data", absorb);
|
|
157
|
+
proc.stderr?.on("data", absorb);
|
|
158
|
+
proc.on("error", (err) => {
|
|
159
|
+
handle.result = { code: null, error: err.message };
|
|
160
|
+
handle.lastLine = `error: ${err.message}`;
|
|
161
|
+
});
|
|
162
|
+
proc.on("close", (code) => {
|
|
163
|
+
handle.result = { code, error: code === 0 ? null : `exited with code ${code ?? "null"}` };
|
|
164
|
+
if (code === 0) handle.lastLine = "complete";
|
|
165
|
+
});
|
|
166
|
+
return handle;
|
|
167
|
+
}
|
|
168
|
+
export {
|
|
169
|
+
evaluateHardware,
|
|
170
|
+
getDownloadStatus,
|
|
171
|
+
getHuggingFaceCacheDir,
|
|
172
|
+
listDownloads,
|
|
173
|
+
probeSystemCapabilities,
|
|
174
|
+
renderVerdict,
|
|
175
|
+
startModelDownload
|
|
176
|
+
};
|
|
@@ -2,15 +2,19 @@ import {
|
|
|
2
2
|
printNotReachable,
|
|
3
3
|
renderProgressLine,
|
|
4
4
|
resolveEndpoint
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FZVPGJJW.js";
|
|
6
6
|
import {
|
|
7
7
|
detectDaemon,
|
|
8
8
|
listModels,
|
|
9
9
|
pullModel
|
|
10
10
|
} from "./chunk-GFVLHUSS.js";
|
|
11
|
+
import "./chunk-O6AKZ4OH.js";
|
|
12
|
+
import "./chunk-KCAR5DOB.js";
|
|
11
13
|
import {
|
|
12
14
|
resolveByokModel
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-JXQ4HZ47.js";
|
|
16
|
+
import "./chunk-PPEBWOMJ.js";
|
|
17
|
+
import "./chunk-KFQGP6VL.js";
|
|
14
18
|
|
|
15
19
|
// src/commands/ollama-bench.ts
|
|
16
20
|
import fs from "fs/promises";
|
|
@@ -5,9 +5,13 @@ import {
|
|
|
5
5
|
renderProgressLine,
|
|
6
6
|
resolveEndpoint,
|
|
7
7
|
runOllamaCli
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-FZVPGJJW.js";
|
|
9
9
|
import "./chunk-GFVLHUSS.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-O6AKZ4OH.js";
|
|
11
|
+
import "./chunk-KCAR5DOB.js";
|
|
12
|
+
import "./chunk-JXQ4HZ47.js";
|
|
13
|
+
import "./chunk-PPEBWOMJ.js";
|
|
14
|
+
import "./chunk-KFQGP6VL.js";
|
|
11
15
|
export {
|
|
12
16
|
parseFlags,
|
|
13
17
|
persistOllamaChoice,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import "./chunk-KFQGP6VL.js";
|
|
2
|
+
|
|
1
3
|
// src/mcp/server.ts
|
|
2
4
|
import readline from "readline";
|
|
3
5
|
|
|
@@ -1315,8 +1317,8 @@ function toolsToMcpList(tools) {
|
|
|
1315
1317
|
}));
|
|
1316
1318
|
}
|
|
1317
1319
|
async function runMcpServer(opts) {
|
|
1318
|
-
const toolsModule = await import("./tools-
|
|
1319
|
-
const { pluginManager } = await import("./plugins-
|
|
1320
|
+
const toolsModule = await import("./tools-XWKCW4RN.js");
|
|
1321
|
+
const { pluginManager } = await import("./plugins-PNGRZLFW.js");
|
|
1320
1322
|
if (opts.includePlugins !== false) {
|
|
1321
1323
|
try {
|
|
1322
1324
|
await pluginManager.init(opts.cwd, (m) => logStderr(m));
|
|
@@ -1325,19 +1327,19 @@ async function runMcpServer(opts) {
|
|
|
1325
1327
|
}
|
|
1326
1328
|
}
|
|
1327
1329
|
const getTools = () => toolsModule.listToolNames().map((name) => ({ name, desc: toolsModule.describeTools() })).filter(() => true);
|
|
1328
|
-
const { readTool } = await import("./read-
|
|
1329
|
-
const { writeTool } = await import("./write-
|
|
1330
|
-
const { editTool } = await import("./edit-
|
|
1331
|
-
const { applyPatchTool } = await import("./apply-patch-
|
|
1332
|
-
const { shellTool } = await import("./shell-
|
|
1333
|
-
const { gitTool } = await import("./git-
|
|
1334
|
-
const { githubTool } = await import("./github-
|
|
1335
|
-
const { grepTool } = await import("./grep-
|
|
1336
|
-
const { globTool } = await import("./glob-
|
|
1337
|
-
const { webFetchTool } = await import("./web-fetch-
|
|
1338
|
-
const { lspTool } = await import("./lsp-
|
|
1339
|
-
const { notebookTool } = await import("./notebook-
|
|
1340
|
-
const { taskTool } = await import("./task-
|
|
1330
|
+
const { readTool } = await import("./read-B64XE7N3.js");
|
|
1331
|
+
const { writeTool } = await import("./write-ZOSB7I4J.js");
|
|
1332
|
+
const { editTool } = await import("./edit-6QYAXVNU.js");
|
|
1333
|
+
const { applyPatchTool } = await import("./apply-patch-U6K67CMT.js");
|
|
1334
|
+
const { shellTool } = await import("./shell-BOZTHQUT.js");
|
|
1335
|
+
const { gitTool } = await import("./git-DNQ5EELH.js");
|
|
1336
|
+
const { githubTool } = await import("./github-34T4QQIH.js");
|
|
1337
|
+
const { grepTool } = await import("./grep-T2CXYNRI.js");
|
|
1338
|
+
const { globTool } = await import("./glob-XT43LEJ4.js");
|
|
1339
|
+
const { webFetchTool } = await import("./web-fetch-OTNDICGJ.js");
|
|
1340
|
+
const { lspTool } = await import("./lsp-JXQVU7NP.js");
|
|
1341
|
+
const { notebookTool } = await import("./notebook-MFODW345.js");
|
|
1342
|
+
const { taskTool } = await import("./task-67G4KLYC.js");
|
|
1341
1343
|
const exposed = [
|
|
1342
1344
|
readTool,
|
|
1343
1345
|
writeTool,
|
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
rebuildIndex,
|
|
8
8
|
tagSession,
|
|
9
9
|
upsertSessionIndexEntry
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-4HPRBCSY.js";
|
|
11
|
+
import "./chunk-6NKRMZTX.js";
|
|
12
|
+
import "./chunk-KFQGP6VL.js";
|
|
12
13
|
export {
|
|
13
14
|
deriveEntryFromRollout,
|
|
14
15
|
forgetSession,
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
initMCPServers,
|
|
6
6
|
listToolNames,
|
|
7
7
|
mcpToolCount
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-EPSOOCNB.js";
|
|
9
|
+
import "./chunk-6NKRMZTX.js";
|
|
10
10
|
import "./chunk-6CZCFY6H.js";
|
|
11
11
|
import "./chunk-6U3ZAGYA.js";
|
|
12
12
|
import "./chunk-FFB7GK3Y.js";
|
|
@@ -15,13 +15,14 @@ import "./chunk-TH6GKC7E.js";
|
|
|
15
15
|
import "./chunk-KZAS754V.js";
|
|
16
16
|
import "./chunk-UR4XL6OM.js";
|
|
17
17
|
import "./chunk-3QUV4JEX.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-PPEBWOMJ.js";
|
|
19
19
|
import "./chunk-CQMAVWLJ.js";
|
|
20
20
|
import "./chunk-O3WZW7GS.js";
|
|
21
21
|
import "./chunk-YAYPQTOU.js";
|
|
22
22
|
import "./chunk-C4CPDDMN.js";
|
|
23
23
|
import "./chunk-W4FAGQFL.js";
|
|
24
24
|
import "./chunk-FAULT7VE.js";
|
|
25
|
+
import "./chunk-KFQGP6VL.js";
|
|
25
26
|
export {
|
|
26
27
|
buildToolMap,
|
|
27
28
|
describeTools,
|
package/package.json
CHANGED
package/dist/auth-JQX6MHJG.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
clearCredentials,
|
|
3
|
-
getConfigDir,
|
|
4
|
-
getCredentialsPath,
|
|
5
|
-
loadCredentials,
|
|
6
|
-
login,
|
|
7
|
-
saveCredentials
|
|
8
|
-
} from "./chunk-FIFC4V2R.js";
|
|
9
|
-
export {
|
|
10
|
-
clearCredentials,
|
|
11
|
-
getConfigDir,
|
|
12
|
-
getCredentialsPath,
|
|
13
|
-
loadCredentials,
|
|
14
|
-
login,
|
|
15
|
-
saveCredentials
|
|
16
|
-
};
|