@coderook/cli 0.44.0 → 0.45.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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "coderook",
|
|
3
3
|
"displayName": "CodeRook",
|
|
4
4
|
"description": "Save, browse and restore whole-snapshot versions of a project on CodeRook, with cbx or plain git, from Claude Code.",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.45.0",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "ACCA Gaming Productions",
|
|
8
8
|
"url": "https://coderook.com"
|
package/dist/cli/src/api.js
CHANGED
|
@@ -427,6 +427,8 @@ async function aiAccess(repositoryId) {
|
|
|
427
427
|
const allowed = (key) => ai[key] !== false;
|
|
428
428
|
return {
|
|
429
429
|
aiRead: allowed("read"),
|
|
430
|
+
/* The one answer that starts as no: a service that does not send it has not been asked. */
|
|
431
|
+
aiTrain: ai.train === true,
|
|
430
432
|
aiDownload: allowed("download"),
|
|
431
433
|
aiContribute: allowed("contribute"),
|
|
432
434
|
aiRequest: allowed("request"),
|
package/dist/cli/src/cli.js
CHANGED
|
@@ -33,6 +33,7 @@ const upload_progress_js_1 = require("./upload_progress.js");
|
|
|
33
33
|
const publish_js_1 = require("./publish.js");
|
|
34
34
|
const attach_command_js_1 = require("./attach_command.js");
|
|
35
35
|
const build_command_js_1 = require("./build_command.js");
|
|
36
|
+
const update_command_js_1 = require("./update_command.js");
|
|
36
37
|
const node_check_js_1 = require("./node_check.js");
|
|
37
38
|
const pages_command_js_1 = require("./pages_command.js");
|
|
38
39
|
const mods_command_js_1 = require("./mods_command.js");
|
|
@@ -4050,6 +4051,23 @@ const SPECS = [
|
|
|
4050
4051
|
examples: ["claude mcp add coderook -- cbx mcp"],
|
|
4051
4052
|
run: parsed => parsed.flags.has("workspaces") ? (0, workspace_command_js_1.commandWorkspaceMcp)() : (0, mcp_js_1.commandMcp)(version_js_1.VERSION),
|
|
4052
4053
|
},
|
|
4054
|
+
{
|
|
4055
|
+
name: "update",
|
|
4056
|
+
aliases: ["upgrade"],
|
|
4057
|
+
group: "Getting started",
|
|
4058
|
+
summary: "install the newest cbx",
|
|
4059
|
+
usage: "update",
|
|
4060
|
+
options: [
|
|
4061
|
+
{ flags: "--check", description: "only say whether a newer cbx is out" },
|
|
4062
|
+
],
|
|
4063
|
+
detail: "Updates cbx itself, not a folder: `cbx get` brings a project's files\n" +
|
|
4064
|
+
"up to date. Asks the npm registry for the newest @coderook/cli and\n" +
|
|
4065
|
+
"installs it the way this copy was installed: globally with npm, or in\n" +
|
|
4066
|
+
"the project whose packages hold it. Through npx there is nothing to\n" +
|
|
4067
|
+
"install. Your folders, sign-in and settings are left as they are.",
|
|
4068
|
+
examples: ["cbx update", "cbx update --check"],
|
|
4069
|
+
run: parsed => (0, update_command_js_1.commandUpdate)(parsed.flags),
|
|
4070
|
+
},
|
|
4053
4071
|
{
|
|
4054
4072
|
name: "doctor",
|
|
4055
4073
|
group: "Getting started",
|
|
@@ -56,13 +56,19 @@ async function resolveProject(reference) {
|
|
|
56
56
|
}
|
|
57
57
|
return project;
|
|
58
58
|
}
|
|
59
|
-
/** The
|
|
59
|
+
/** The answers, in the order the site shows them. */
|
|
60
60
|
const AI_SWITCHES = [
|
|
61
61
|
[
|
|
62
62
|
"read",
|
|
63
63
|
"aiRead",
|
|
64
64
|
"Can AI read this?",
|
|
65
|
-
"reading, indexing, summarising and
|
|
65
|
+
"reading, indexing, summarising and quoting in answers",
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
"train",
|
|
69
|
+
"aiTrain",
|
|
70
|
+
"Can AI train on this?",
|
|
71
|
+
"using what it reads to train a model",
|
|
66
72
|
],
|
|
67
73
|
[
|
|
68
74
|
"download",
|
|
@@ -122,8 +128,8 @@ async function commandAi(parsed) {
|
|
|
122
128
|
console.log(` ${(0, colour_js_1.dim)(meaning)}`);
|
|
123
129
|
}
|
|
124
130
|
console.log("");
|
|
125
|
-
console.log((0, colour_js_1.dim)("Everything is allowed until somebody says otherwise
|
|
126
|
-
console.log((0, colour_js_1.dim)("
|
|
131
|
+
console.log((0, colour_js_1.dim)("Everything but training is allowed until somebody says otherwise; training"));
|
|
132
|
+
console.log((0, colour_js_1.dim)("is refused until the owner allows it, and reading off refuses it too."));
|
|
127
133
|
console.log((0, colour_js_1.dim)("Change these on the website (Settings → Access & AI) or in the desktop app."));
|
|
128
134
|
return 0;
|
|
129
135
|
}
|
package/dist/cli/src/registry.js
CHANGED
|
@@ -37,7 +37,7 @@ exports.GROUP_ORDER = [
|
|
|
37
37
|
* from this list still appears, after the ones that are in it.
|
|
38
38
|
*/
|
|
39
39
|
exports.LISTING_ORDER = [
|
|
40
|
-
"sign-in", "whoami", "sign-out", "doctor", "projects", "clone", "link", "unlink", "import", "transfer",
|
|
40
|
+
"sign-in", "whoami", "sign-out", "doctor", "update", "projects", "clone", "link", "unlink", "import", "transfer",
|
|
41
41
|
"status", "submit", "diff", "get", "track", "ignore", "licence",
|
|
42
42
|
"init", "save", "log", "restore", "switch", "push", "pull",
|
|
43
43
|
"tracks", "line-rules", "merges", "merge", "propose", "proposals", "pr",
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.compareVersions = compareVersions;
|
|
7
|
+
exports.installKind = installKind;
|
|
8
|
+
exports.projectFolder = projectFolder;
|
|
9
|
+
exports.commandUpdate = commandUpdate;
|
|
10
|
+
/**
|
|
11
|
+
* `cbx update` — bring this copy of cbx itself up to the newest release.
|
|
12
|
+
*
|
|
13
|
+
* Not the folder: `cbx get` (and `cbx pull`) bring a project's files up to
|
|
14
|
+
* date. This asks the npm registry for the newest @coderook/cli and installs it
|
|
15
|
+
* the way this copy was installed, because the right command differs:
|
|
16
|
+
*
|
|
17
|
+
* global npm install npm install -g @coderook/cli@<newest>, run here
|
|
18
|
+
* npx nothing to install; npx fetches what it is told to
|
|
19
|
+
* a project's packages npm install @coderook/cli@<newest> in that project
|
|
20
|
+
* anything else the command to run, printed rather than guessed at
|
|
21
|
+
*
|
|
22
|
+
* Every outward call has a deadline, so a registry or npm that never answers
|
|
23
|
+
* ends in a message instead of a hang.
|
|
24
|
+
*/
|
|
25
|
+
const node_child_process_1 = require("node:child_process");
|
|
26
|
+
const node_fs_1 = require("node:fs");
|
|
27
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
28
|
+
const node_process_1 = __importDefault(require("node:process"));
|
|
29
|
+
const version_js_1 = require("./version.js");
|
|
30
|
+
const PACKAGE = "@coderook/cli";
|
|
31
|
+
/** A release number and nothing else: it is put on an npm command line. */
|
|
32
|
+
const RELEASE = /^\d{1,6}\.\d{1,6}\.\d{1,6}(?:-[0-9A-Za-z.]{1,40})?$/;
|
|
33
|
+
const REGISTRY = "https://registry.npmjs.org/" + PACKAGE.replace("/", "%2F") + "/latest";
|
|
34
|
+
const colour = node_process_1.default.stdout.isTTY && !node_process_1.default.env.NO_COLOR;
|
|
35
|
+
const paint = (code) => (text) => (colour ? `\x1b[${code}m${text}\x1b[0m` : text);
|
|
36
|
+
const dim = paint(2), accent = paint(33), red = paint(31), green = paint(32);
|
|
37
|
+
/** Compares two release numbers (1.2.3, pre-release tags rank below the release). Negative when a is older. */
|
|
38
|
+
function compareVersions(a, b) {
|
|
39
|
+
const parse = (v) => {
|
|
40
|
+
const [core = "", pre = ""] = v.trim().replace(/^v/, "").split("-", 2);
|
|
41
|
+
return { parts: core.split(".").map((n) => Number.parseInt(n, 10) || 0), pre };
|
|
42
|
+
};
|
|
43
|
+
const x = parse(a), y = parse(b);
|
|
44
|
+
for (let i = 0; i < 3; i += 1) {
|
|
45
|
+
const d = (x.parts[i] ?? 0) - (y.parts[i] ?? 0);
|
|
46
|
+
if (d)
|
|
47
|
+
return d;
|
|
48
|
+
}
|
|
49
|
+
if (x.pre === y.pre)
|
|
50
|
+
return 0;
|
|
51
|
+
if (!x.pre)
|
|
52
|
+
return 1;
|
|
53
|
+
if (!y.pre)
|
|
54
|
+
return -1;
|
|
55
|
+
return x.pre < y.pre ? -1 : 1;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* How the running copy was installed, from where its files are.
|
|
59
|
+
* `globalRoot` is `npm root -g` (null when npm could not say).
|
|
60
|
+
*/
|
|
61
|
+
function installKind(script, globalRoot, platform = node_process_1.default.platform) {
|
|
62
|
+
const norm = (p) => {
|
|
63
|
+
const s = p.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
64
|
+
return platform === "win32" ? s.toLowerCase() : s;
|
|
65
|
+
};
|
|
66
|
+
const here = norm(script);
|
|
67
|
+
if (!here.includes("/node_modules/@coderook/cli/"))
|
|
68
|
+
return "other";
|
|
69
|
+
if (/\/_npx\//.test(here))
|
|
70
|
+
return "npx";
|
|
71
|
+
if (globalRoot && here.startsWith(norm(globalRoot) + "/"))
|
|
72
|
+
return "global";
|
|
73
|
+
return "project";
|
|
74
|
+
}
|
|
75
|
+
/** The folder holding the node_modules this copy sits in (for a project install). */
|
|
76
|
+
function projectFolder(script) {
|
|
77
|
+
const s = script.replace(/\\/g, "/");
|
|
78
|
+
const at = s.lastIndexOf("/node_modules/@coderook/cli/");
|
|
79
|
+
return at < 0 ? node_path_1.default.dirname(script) : s.slice(0, at);
|
|
80
|
+
}
|
|
81
|
+
async function newestRelease() {
|
|
82
|
+
const response = await fetch(REGISTRY, { signal: AbortSignal.timeout(10_000), headers: { accept: "application/json" } });
|
|
83
|
+
if (!response.ok)
|
|
84
|
+
throw new Error(`the npm registry answered ${response.status}`);
|
|
85
|
+
const body = (await response.json());
|
|
86
|
+
if (typeof body.version !== "string" || !RELEASE.test(body.version))
|
|
87
|
+
throw new Error("the npm registry gave no usable version");
|
|
88
|
+
return body.version;
|
|
89
|
+
}
|
|
90
|
+
/** Runs npm with a deadline; output goes to this terminal when `show` is set. */
|
|
91
|
+
function npm(args, options) {
|
|
92
|
+
return new Promise((resolve) => {
|
|
93
|
+
/*
|
|
94
|
+
npm is npm.cmd on Windows, which Node only starts through a shell, and a
|
|
95
|
+
shell takes one command line rather than an argument list. Every word
|
|
96
|
+
here is ours or a release number checked by RELEASE, so joining is safe.
|
|
97
|
+
*/
|
|
98
|
+
const stdio = options.show ? ["inherit", "inherit", "inherit"] : ["ignore", "pipe", "ignore"];
|
|
99
|
+
const child = node_process_1.default.platform === "win32"
|
|
100
|
+
? (0, node_child_process_1.spawn)(["npm", ...args].join(" "), { cwd: options.cwd, shell: true, stdio })
|
|
101
|
+
: (0, node_child_process_1.spawn)("npm", args, { cwd: options.cwd, stdio });
|
|
102
|
+
let out = "";
|
|
103
|
+
child.stdout?.on("data", (chunk) => { out += chunk.toString(); });
|
|
104
|
+
const timer = setTimeout(() => { child.kill(); resolve({ code: -1, out }); }, options.deadlineMs);
|
|
105
|
+
child.on("error", () => { clearTimeout(timer); resolve({ code: -2, out }); });
|
|
106
|
+
child.on("close", (code) => { clearTimeout(timer); resolve({ code: code ?? 1, out }); });
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
async function commandUpdate(flags) {
|
|
110
|
+
const checkOnly = flags.has("check");
|
|
111
|
+
let newest;
|
|
112
|
+
try {
|
|
113
|
+
newest = await newestRelease();
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
console.error(red("Could not find out the newest cbx: " + (error instanceof Error ? error.message : String(error)) + "."));
|
|
117
|
+
console.error(dim("Check the connection and try again. Nothing was changed."));
|
|
118
|
+
return 1;
|
|
119
|
+
}
|
|
120
|
+
const order = compareVersions(version_js_1.VERSION, newest);
|
|
121
|
+
if (order >= 0) {
|
|
122
|
+
console.log(green(`cbx ${version_js_1.VERSION} is the newest.`) + (order > 0 ? dim(` (the registry's newest is ${newest})`) : ""));
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
125
|
+
console.log(`cbx ${version_js_1.VERSION} is installed; ${accent(newest)} is out.`);
|
|
126
|
+
let script = node_process_1.default.argv[1] ?? "";
|
|
127
|
+
try {
|
|
128
|
+
script = (0, node_fs_1.realpathSync)(script);
|
|
129
|
+
}
|
|
130
|
+
catch { /* keep what we were given */ }
|
|
131
|
+
const root = await npm(["root", "-g"], { show: false, deadlineMs: 20_000 });
|
|
132
|
+
const kind = installKind(script, root.code === 0 ? root.out.trim() : null);
|
|
133
|
+
const target = `${PACKAGE}@${newest}`;
|
|
134
|
+
if (kind === "npx") {
|
|
135
|
+
console.log(`This copy runs through npx. Ask for the newest each time with ${accent(`npx ${PACKAGE}@latest`)}.`);
|
|
136
|
+
return 0;
|
|
137
|
+
}
|
|
138
|
+
if (kind === "other") {
|
|
139
|
+
console.log(`This copy was not installed by npm, so install the newest with ${accent(`npm install -g ${target}`)}.`);
|
|
140
|
+
return 0;
|
|
141
|
+
}
|
|
142
|
+
const folder = kind === "project" ? projectFolder(script) : undefined;
|
|
143
|
+
const args = kind === "global" ? ["install", "-g", target] : ["install", target];
|
|
144
|
+
if (checkOnly) {
|
|
145
|
+
console.log(`Update with ${accent("cbx update")}, or ${accent("npm " + args.join(" "))}${folder ? dim(` in ${folder}`) : ""}.`);
|
|
146
|
+
return 0;
|
|
147
|
+
}
|
|
148
|
+
console.log(dim(`Running npm ${args.join(" ")}${folder ? ` in ${folder}` : ""}…`));
|
|
149
|
+
const result = await npm(args, { show: true, cwd: folder, deadlineMs: 5 * 60_000 });
|
|
150
|
+
if (result.code !== 0) {
|
|
151
|
+
console.error(red(result.code === -1 ? "npm did not finish within five minutes." : result.code === -2 ? "npm could not be started." : `npm stopped with code ${result.code}.`));
|
|
152
|
+
if (kind === "global")
|
|
153
|
+
console.error(dim("If it was refused for permissions, run the same command from a terminal that can install global packages."));
|
|
154
|
+
console.error(dim(`Your current cbx ${version_js_1.VERSION} is untouched.`));
|
|
155
|
+
return 1;
|
|
156
|
+
}
|
|
157
|
+
console.log(green(`cbx is now ${newest}.`) + dim(" Your folders, sign-in and settings are as they were."));
|
|
158
|
+
return 0;
|
|
159
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderook/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0",
|
|
4
4
|
"description": "The command line for CodeRook (coderook.com): version control and project hosting for projects of any size. Every save is a compressed snapshot, private or public, never used to train AI.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://coderook.com",
|