@cavelon/cli 0.1.2 → 0.1.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/README.md +27 -13
- package/dist/agents.js +15 -7
- package/dist/choose.js +112 -0
- package/dist/commands/index.js +2 -0
- package/dist/commands/init.js +161 -23
- package/dist/commands/limits-set.js +2 -2
- package/dist/commands/limits.js +1 -1
- package/dist/commands/loops.js +1 -1
- package/dist/commands/sandboxes.js +2 -2
- package/dist/commands/session.js +176 -46
- package/dist/commands/setup.js +426 -0
- package/dist/commands/solution.js +14 -38
- package/dist/commands/tenants.js +33 -22
- package/dist/commands/work.js +2 -2
- package/dist/embedded.js +7 -0
- package/dist/git.js +14 -9
- package/dist/harness-ref.js +54 -0
- package/dist/http.js +15 -7
- package/dist/install.js +94 -0
- package/dist/main.js +31 -2
- package/dist/markers.js +53 -0
- package/dist/paths.js +3 -3
- package/dist/principal.js +43 -0
- package/dist/prompt.js +55 -11
- package/dist/run-program.js +92 -0
- package/dist/session.js +72 -15
- package/dist/setup-agents.js +544 -0
- package/dist/skills/cavelon-loop/SKILL.md +11 -6
- package/dist/skills/cavelon-testing/SKILL.md +1 -1
- package/dist/tenant-choice.js +93 -0
- package/dist/update-check.js +118 -0
- package/dist/version.js +2 -1
- package/package.json +5 -2
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { NPM_PACKAGE, REPOSITORY } from "./install.js";
|
|
3
|
+
import { readJsonFile, writeFileAtomic } from "./fsutil.js";
|
|
4
|
+
import { cacheDir } from "./paths.js";
|
|
5
|
+
export const DAY_MS = 24 * 60 * 60 * 1000;
|
|
6
|
+
export const CHECK_TIMEOUT_MS = 1500;
|
|
7
|
+
const MAX_BODY = 1024 * 1024;
|
|
8
|
+
const STATE_FILE = "update-check.json";
|
|
9
|
+
const SOURCES = {
|
|
10
|
+
github: { url: `https://api.github.com/repos/${REPOSITORY}/releases/latest`, field: "tag_name" },
|
|
11
|
+
npm: { url: `https://registry.npmjs.org/${NPM_PACKAGE}/latest`, field: "version" },
|
|
12
|
+
};
|
|
13
|
+
const CI_VARIABLES = ["CI", "CONTINUOUS_INTEGRATION", "BUILD_NUMBER", "RUN_ID", "GITHUB_ACTIONS", "GITLAB_CI", "TF_BUILD", "BUILDKITE", "JENKINS_URL", "TEAMCITY_VERSION", "CODEBUILD_BUILD_ID"];
|
|
14
|
+
function setTo(value) {
|
|
15
|
+
return value !== undefined && !["", "0", "false", "no"].includes(value.trim().toLowerCase());
|
|
16
|
+
}
|
|
17
|
+
export function quietReason(request) {
|
|
18
|
+
const { io, install } = request;
|
|
19
|
+
if (setTo(io.env.CAVELON_NO_UPDATE_CHECK))
|
|
20
|
+
return "CAVELON_NO_UPDATE_CHECK";
|
|
21
|
+
if (request.json)
|
|
22
|
+
return "json";
|
|
23
|
+
if (request.command === "mcp")
|
|
24
|
+
return "mcp";
|
|
25
|
+
if (CI_VARIABLES.some((name) => setTo(io.env[name])))
|
|
26
|
+
return "ci";
|
|
27
|
+
if (!io.stderr.isTTY)
|
|
28
|
+
return "no terminal";
|
|
29
|
+
if (!install.source)
|
|
30
|
+
return install.method;
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
export function startUpdateCheck(request) {
|
|
34
|
+
if (quietReason(request))
|
|
35
|
+
return Promise.resolve(undefined);
|
|
36
|
+
return check(request).catch(() => undefined);
|
|
37
|
+
}
|
|
38
|
+
async function check(request) {
|
|
39
|
+
const { io, install, version } = request;
|
|
40
|
+
const source = install.source;
|
|
41
|
+
const file = path.join(cacheDir(io.env), STATE_FILE);
|
|
42
|
+
const state = (await readJsonFile(file)) ?? {};
|
|
43
|
+
const now = io.now();
|
|
44
|
+
const before = JSON.stringify(state);
|
|
45
|
+
if (state.source !== source) {
|
|
46
|
+
delete state.latest;
|
|
47
|
+
delete state.checked_at;
|
|
48
|
+
state.source = source;
|
|
49
|
+
}
|
|
50
|
+
if (!within(state.checked_at, now)) {
|
|
51
|
+
state.checked_at = now.toISOString();
|
|
52
|
+
const latest = await latestVersion(source, version, request.fetch ?? fetch).catch(() => undefined);
|
|
53
|
+
if (latest)
|
|
54
|
+
state.latest = latest;
|
|
55
|
+
}
|
|
56
|
+
let notice;
|
|
57
|
+
if (state.latest && newer(state.latest, version) && !within(state.notified_at, now)) {
|
|
58
|
+
notice = noticeText(state.latest, version, install);
|
|
59
|
+
state.notified_at = now.toISOString();
|
|
60
|
+
}
|
|
61
|
+
if (JSON.stringify(state) !== before)
|
|
62
|
+
await writeFileAtomic(file, `${JSON.stringify(state, null, 2)}\n`, 0o600, 0o700);
|
|
63
|
+
return notice;
|
|
64
|
+
}
|
|
65
|
+
function within(stamp, now) {
|
|
66
|
+
const at = stamp ? Date.parse(stamp) : NaN;
|
|
67
|
+
return Number.isFinite(at) && at <= now.getTime() && now.getTime() - at < DAY_MS;
|
|
68
|
+
}
|
|
69
|
+
async function latestVersion(source, version, fetchImpl) {
|
|
70
|
+
const { url, field } = SOURCES[source];
|
|
71
|
+
const response = await fetchImpl(url, {
|
|
72
|
+
headers: { accept: source === "github" ? "application/vnd.github+json" : "application/json", "user-agent": `cavelon/${version}` },
|
|
73
|
+
redirect: "follow",
|
|
74
|
+
signal: AbortSignal.timeout(CHECK_TIMEOUT_MS),
|
|
75
|
+
});
|
|
76
|
+
if (!response.ok)
|
|
77
|
+
return undefined;
|
|
78
|
+
const length = Number(response.headers.get("content-length") ?? 0);
|
|
79
|
+
if (length > MAX_BODY)
|
|
80
|
+
return undefined;
|
|
81
|
+
const text = await response.text();
|
|
82
|
+
if (text.length > MAX_BODY)
|
|
83
|
+
return undefined;
|
|
84
|
+
const value = JSON.parse(text)[field];
|
|
85
|
+
if (typeof value !== "string")
|
|
86
|
+
return undefined;
|
|
87
|
+
const parsed = parseVersion(value);
|
|
88
|
+
return parsed && !parsed.pre ? parsed.text : undefined;
|
|
89
|
+
}
|
|
90
|
+
export function parseVersion(value) {
|
|
91
|
+
let text = value.trim();
|
|
92
|
+
if (text.startsWith("v"))
|
|
93
|
+
text = text.slice(1);
|
|
94
|
+
const dash = text.indexOf("-");
|
|
95
|
+
const pre = dash < 0 ? undefined : text.slice(dash + 1);
|
|
96
|
+
const match = /^(\d{1,9})\.(\d{1,9})\.(\d{1,9})$/.exec(dash < 0 ? text : text.slice(0, dash));
|
|
97
|
+
if (!match || (pre !== undefined && !/^[0-9A-Za-z.-]{1,64}$/.test(pre)))
|
|
98
|
+
return undefined;
|
|
99
|
+
const parts = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
100
|
+
return { parts, pre, text: `${parts.join(".")}${pre ? `-${pre}` : ""}` };
|
|
101
|
+
}
|
|
102
|
+
export function newer(candidate, current) {
|
|
103
|
+
const a = parseVersion(candidate);
|
|
104
|
+
const b = parseVersion(current);
|
|
105
|
+
if (!a || !b)
|
|
106
|
+
return false;
|
|
107
|
+
for (let i = 0; i < 3; i++) {
|
|
108
|
+
if (a.parts[i] !== b.parts[i])
|
|
109
|
+
return a.parts[i] > b.parts[i];
|
|
110
|
+
}
|
|
111
|
+
return !a.pre && b.pre !== undefined;
|
|
112
|
+
}
|
|
113
|
+
export function noticeText(latest, version, install) {
|
|
114
|
+
const head = `cavelon ${latest} is out; this is ${version}.`;
|
|
115
|
+
if (install.update)
|
|
116
|
+
return `${head} Update with:\n ${install.update}\n`;
|
|
117
|
+
return `${head}${install.advice ? ` ${install.advice}` : ""}\n`;
|
|
118
|
+
}
|
package/dist/version.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { embeddedContent } from "./embedded.js";
|
|
4
5
|
function readVersion() {
|
|
5
6
|
const file = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "package.json");
|
|
6
7
|
try {
|
|
@@ -10,7 +11,7 @@ function readVersion() {
|
|
|
10
11
|
return "0.0.0";
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
|
-
export const KIT_VERSION = readVersion();
|
|
14
|
+
export const KIT_VERSION = embeddedContent()?.version ?? readVersion();
|
|
14
15
|
export const SUPPORTED_CONTRACTS = {
|
|
15
16
|
api_versions: ["v1"],
|
|
16
17
|
package_versions: ["v1", "v2", "v3"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cavelon/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "The cavelon binary: CLI and local MCP server for building Cavelon solutions with a coding agent.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/goodguys-gmbh/cavelon-dev-kit",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
17
|
"dist/",
|
|
18
|
+
"!dist/executable.js",
|
|
18
19
|
"README.md"
|
|
19
20
|
],
|
|
20
21
|
"engines": {
|
|
@@ -26,7 +27,9 @@
|
|
|
26
27
|
"lint": "eslint .",
|
|
27
28
|
"test": "vitest run",
|
|
28
29
|
"docs:commands": "vitest run test/commands-doc.test.ts --update",
|
|
29
|
-
"prepack": "npm run build"
|
|
30
|
+
"prepack": "npm run build",
|
|
31
|
+
"build:executable": "bun scripts/build-executable.mjs",
|
|
32
|
+
"test:executable": "vitest run test/executable.test.ts"
|
|
30
33
|
},
|
|
31
34
|
"dependencies": {
|
|
32
35
|
"@modelcontextprotocol/sdk": "^1.31.0",
|