@datalabrotterdam/nova-ai-cli 1.1.0 → 1.2.0-alpha.10
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/CHANGELOG.md +165 -0
- package/README.md +211 -100
- package/dist/browser-setup-7SWHUQEL.js +57 -0
- package/dist/chunk-FMHWW3E6.js +11 -0
- package/dist/chunk-KDAUUQBE.js +643 -0
- package/dist/chunk-L77KQRGZ.js +170 -0
- package/dist/headless-BQXK7TNC.js +550 -0
- package/dist/index.js +193 -17
- package/dist/tui-TJFV6NC6.js +5185 -0
- package/dist/update-check-G3PYCRWM.js +23 -0
- package/package.json +35 -33
- package/dist/acp/agent.d.ts +0 -13
- package/dist/acp/agent.js +0 -242
- package/dist/acp/auth-server.d.ts +0 -10
- package/dist/acp/auth-server.js +0 -67
- package/dist/acp/credentials.d.ts +0 -11
- package/dist/acp/credentials.js +0 -30
- package/dist/acp/index.d.ts +0 -2
- package/dist/acp/index.js +0 -21
- package/dist/acp/mcp.d.ts +0 -11
- package/dist/acp/mcp.js +0 -90
- package/dist/acp/sessions.d.ts +0 -20
- package/dist/acp/sessions.js +0 -91
- package/dist/acp/tools/index.d.ts +0 -6
- package/dist/acp/tools/index.js +0 -5
- package/dist/acp/tools/marker.d.ts +0 -17
- package/dist/acp/tools/marker.js +0 -43
- package/dist/acp/tools/permission.d.ts +0 -2
- package/dist/acp/tools/permission.js +0 -20
- package/dist/acp/tools/read-file.d.ts +0 -2
- package/dist/acp/tools/read-file.js +0 -20
- package/dist/acp/tools/registry.d.ts +0 -4
- package/dist/acp/tools/registry.js +0 -10
- package/dist/acp/tools/reporting.d.ts +0 -3
- package/dist/acp/tools/reporting.js +0 -26
- package/dist/acp/tools/run-command.d.ts +0 -2
- package/dist/acp/tools/run-command.js +0 -29
- package/dist/acp/tools/system-prompt.d.ts +0 -2
- package/dist/acp/tools/system-prompt.js +0 -23
- package/dist/acp/tools/types.d.ts +0 -18
- package/dist/acp/tools/types.js +0 -1
- package/dist/acp/tools/write-file.d.ts +0 -2
- package/dist/acp/tools/write-file.js +0 -20
- package/dist/index.d.ts +0 -2
- package/dist/tui/index.d.ts +0 -7
- package/dist/tui/index.js +0 -11
- package/dist/webui/index.d.ts +0 -6
- package/dist/webui/index.js +0 -9
- package/src/acp/web/dist/assets/index-CSccI7lJ.css +0 -1
- package/src/acp/web/dist/assets/index-D2Z0sfLR.js +0 -1
- package/src/acp/web/dist/favicon.svg +0 -46
- package/src/acp/web/dist/index.html +0 -32
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CLI_PACKAGE_NAME,
|
|
3
|
+
cliVersion
|
|
4
|
+
} from "./chunk-FMHWW3E6.js";
|
|
5
|
+
|
|
6
|
+
// src/update-check.ts
|
|
7
|
+
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
8
|
+
import { dirname, join } from "path";
|
|
9
|
+
import { novaHomeRoot } from "@datalabrotterdam/nova-ai-agent/core/nova-home.js";
|
|
10
|
+
var DIST_TAGS_URL = `https://registry.npmjs.org/-/package/${CLI_PACKAGE_NAME.replace("/", "%2F")}/dist-tags`;
|
|
11
|
+
var DEFAULT_TIMEOUT_MS = 3e3;
|
|
12
|
+
var CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
13
|
+
function updateCachePath() {
|
|
14
|
+
return join(novaHomeRoot(), "update-check.json");
|
|
15
|
+
}
|
|
16
|
+
function updateChecksDisabled(env = process.env) {
|
|
17
|
+
return Boolean(env.NOVA_NO_UPDATE_CHECK || env.NO_UPDATE_NOTIFIER || env.CI);
|
|
18
|
+
}
|
|
19
|
+
async function checkForUpdate(options = {}) {
|
|
20
|
+
try {
|
|
21
|
+
if (updateChecksDisabled(options.env)) return null;
|
|
22
|
+
const currentVersion = options.currentVersion ?? cliVersion();
|
|
23
|
+
if (!currentVersion) return null;
|
|
24
|
+
const distTags = await readDistTags(options);
|
|
25
|
+
if (!distTags) return null;
|
|
26
|
+
return chooseUpdate(currentVersion, distTags);
|
|
27
|
+
} catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function chooseUpdate(currentVersion, distTags) {
|
|
32
|
+
const channel = prereleaseChannel(currentVersion);
|
|
33
|
+
const tags = channel && distTags[channel] ? [channel, "latest"] : ["latest"];
|
|
34
|
+
let best = null;
|
|
35
|
+
for (const tag of tags) {
|
|
36
|
+
const version = distTags[tag];
|
|
37
|
+
if (!version || !isNewerVersion(version, currentVersion)) continue;
|
|
38
|
+
if (!best || isNewerVersion(version, best.version)) best = { tag, version };
|
|
39
|
+
}
|
|
40
|
+
if (!best) return null;
|
|
41
|
+
return {
|
|
42
|
+
currentVersion,
|
|
43
|
+
latestVersion: best.version,
|
|
44
|
+
tag: best.tag,
|
|
45
|
+
command: `npm install -g ${CLI_PACKAGE_NAME}@${best.tag}`
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async function readDistTags(options) {
|
|
49
|
+
const now = (options.now ?? Date.now)();
|
|
50
|
+
const cachePath = options.cachePath === void 0 ? updateCachePath() : options.cachePath;
|
|
51
|
+
const cached = cachePath ? readCache(cachePath) : null;
|
|
52
|
+
if (cached && now - cached.checkedAt >= 0 && now - cached.checkedAt < CACHE_MAX_AGE_MS) {
|
|
53
|
+
return cached.distTags;
|
|
54
|
+
}
|
|
55
|
+
const response = await (options.fetchImpl ?? fetch)(DIST_TAGS_URL, {
|
|
56
|
+
headers: { accept: "application/json" },
|
|
57
|
+
signal: AbortSignal.any([
|
|
58
|
+
AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS),
|
|
59
|
+
...options.signal ? [options.signal] : []
|
|
60
|
+
])
|
|
61
|
+
});
|
|
62
|
+
if (!response.ok) return null;
|
|
63
|
+
const payload = await response.json();
|
|
64
|
+
if (!isDistTags(payload)) return null;
|
|
65
|
+
if (cachePath) writeCache(cachePath, { ...cached, checkedAt: now, distTags: payload });
|
|
66
|
+
return payload;
|
|
67
|
+
}
|
|
68
|
+
function readCache(path) {
|
|
69
|
+
try {
|
|
70
|
+
const value = JSON.parse(readFileSync(path, "utf8"));
|
|
71
|
+
if (value && typeof value === "object" && typeof value.checkedAt === "number" && isDistTags(value.distTags)) {
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
var SNOOZE_MS = 24 * 60 * 60 * 1e3;
|
|
79
|
+
function shouldAskAboutUpdate(update, options = {}) {
|
|
80
|
+
const cachePath = options.cachePath === void 0 ? updateCachePath() : options.cachePath;
|
|
81
|
+
const cached = cachePath ? readCache(cachePath) : null;
|
|
82
|
+
if (!cached) return true;
|
|
83
|
+
if (cached.skippedVersion === update.latestVersion) return false;
|
|
84
|
+
const now = (options.now ?? Date.now)();
|
|
85
|
+
return !(typeof cached.snoozedUntil === "number" && now < cached.snoozedUntil);
|
|
86
|
+
}
|
|
87
|
+
function rememberUpdateAnswer(answer, update, options = {}) {
|
|
88
|
+
const cachePath = options.cachePath === void 0 ? updateCachePath() : options.cachePath;
|
|
89
|
+
if (!cachePath) return;
|
|
90
|
+
const cached = readCache(cachePath);
|
|
91
|
+
const base = cached ?? { checkedAt: 0, distTags: {} };
|
|
92
|
+
const now = (options.now ?? Date.now)();
|
|
93
|
+
writeCache(
|
|
94
|
+
cachePath,
|
|
95
|
+
answer === "skip" ? { ...base, skippedVersion: update.latestVersion, snoozedUntil: void 0 } : { ...base, snoozedUntil: now + SNOOZE_MS }
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
function writeCache(path, value) {
|
|
99
|
+
try {
|
|
100
|
+
mkdirSync(dirname(path), { recursive: true, mode: 448 });
|
|
101
|
+
writeFileSync(path, `${JSON.stringify(value)}
|
|
102
|
+
`, { mode: 384 });
|
|
103
|
+
} catch {
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function isDistTags(value) {
|
|
107
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every((version) => typeof version === "string");
|
|
108
|
+
}
|
|
109
|
+
function prereleaseChannel(version) {
|
|
110
|
+
const parsed = parseVersion(version);
|
|
111
|
+
const first = parsed?.prerelease[0];
|
|
112
|
+
return first && !/^\d+$/.test(first) ? first : null;
|
|
113
|
+
}
|
|
114
|
+
function readInstalledVersion() {
|
|
115
|
+
return cliVersion();
|
|
116
|
+
}
|
|
117
|
+
function isNewerVersion(candidate, current) {
|
|
118
|
+
const next = parseVersion(candidate);
|
|
119
|
+
const installed = parseVersion(current);
|
|
120
|
+
if (!next || !installed) return false;
|
|
121
|
+
for (let index = 0; index < 3; index++) {
|
|
122
|
+
const difference = next.core[index] - installed.core[index];
|
|
123
|
+
if (difference !== 0) return difference > 0;
|
|
124
|
+
}
|
|
125
|
+
return comparePrerelease(next.prerelease, installed.prerelease) > 0;
|
|
126
|
+
}
|
|
127
|
+
function parseVersion(value) {
|
|
128
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(value);
|
|
129
|
+
if (!match) return null;
|
|
130
|
+
return {
|
|
131
|
+
core: [Number(match[1]), Number(match[2]), Number(match[3])],
|
|
132
|
+
prerelease: match[4]?.split(".") ?? []
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function comparePrerelease(left, right) {
|
|
136
|
+
if (left.length === 0 || right.length === 0) {
|
|
137
|
+
if (left.length === right.length) return 0;
|
|
138
|
+
return left.length === 0 ? 1 : -1;
|
|
139
|
+
}
|
|
140
|
+
const length = Math.max(left.length, right.length);
|
|
141
|
+
for (let index = 0; index < length; index++) {
|
|
142
|
+
const leftPart = left[index];
|
|
143
|
+
const rightPart = right[index];
|
|
144
|
+
if (leftPart === void 0 || rightPart === void 0) {
|
|
145
|
+
return leftPart === rightPart ? 0 : leftPart === void 0 ? -1 : 1;
|
|
146
|
+
}
|
|
147
|
+
if (leftPart === rightPart) continue;
|
|
148
|
+
const leftNumber = /^\d+$/.test(leftPart) ? Number(leftPart) : null;
|
|
149
|
+
const rightNumber = /^\d+$/.test(rightPart) ? Number(rightPart) : null;
|
|
150
|
+
if (leftNumber !== null && rightNumber !== null) return leftNumber - rightNumber;
|
|
151
|
+
if (leftNumber !== null || rightNumber !== null) return leftNumber !== null ? -1 : 1;
|
|
152
|
+
return leftPart < rightPart ? -1 : 1;
|
|
153
|
+
}
|
|
154
|
+
return 0;
|
|
155
|
+
}
|
|
156
|
+
function formatUpdateNotice(update) {
|
|
157
|
+
return `Update available: nova-ai ${update.currentVersion} \u2192 ${update.latestVersion}. Run: ${update.command}`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export {
|
|
161
|
+
updateCachePath,
|
|
162
|
+
updateChecksDisabled,
|
|
163
|
+
checkForUpdate,
|
|
164
|
+
chooseUpdate,
|
|
165
|
+
shouldAskAboutUpdate,
|
|
166
|
+
rememberUpdateAnswer,
|
|
167
|
+
readInstalledVersion,
|
|
168
|
+
isNewerVersion,
|
|
169
|
+
formatUpdateNotice
|
|
170
|
+
};
|