@coderook/cli 0.46.3 → 0.46.5
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/cbx/src/core/upload.js +127 -35
- package/dist/cbx/src/core/worktree.js +24 -4
- package/dist/cli/src/cli.js +290 -43
- package/dist/cli/src/config.js +21 -7
- package/dist/cli/src/help.js +119 -4
- package/dist/cli/src/machine.js +31 -14
- package/dist/cli/src/registry.js +1 -1
- package/package.json +2 -2
package/dist/cli/src/config.js
CHANGED
|
@@ -429,22 +429,36 @@ async function writeLink(localPath, link) {
|
|
|
429
429
|
if (legacy !== key)
|
|
430
430
|
await (0, promises_1.rm)(storedFileFor(legacy), { force: true });
|
|
431
431
|
}
|
|
432
|
-
const digestsFile = (projectId) =>
|
|
433
|
-
|
|
432
|
+
const digestsFile = (projectId, folder) => {
|
|
433
|
+
if (!folder)
|
|
434
|
+
return node_path_1.default.join(configDirectory(), "digests", `${projectId}.json`);
|
|
435
|
+
const where = node_path_1.default.resolve(folder);
|
|
436
|
+
const key = (0, node_crypto_1.createHash)("sha256")
|
|
437
|
+
.update(process.platform === "win32" ? where.toLowerCase() : where)
|
|
438
|
+
.digest("hex")
|
|
439
|
+
.slice(0, 16);
|
|
440
|
+
return node_path_1.default.join(configDirectory(), "digests", `${projectId}-${key}.json`);
|
|
441
|
+
};
|
|
442
|
+
async function readDigestFile(file) {
|
|
434
443
|
try {
|
|
435
|
-
const raw = await (0, promises_1.readFile)(
|
|
444
|
+
const raw = await (0, promises_1.readFile)(file, "utf8");
|
|
436
445
|
return new Map(Object.entries(JSON.parse(raw)));
|
|
437
446
|
}
|
|
438
447
|
catch {
|
|
439
|
-
|
|
440
|
-
return new Map();
|
|
448
|
+
return null;
|
|
441
449
|
}
|
|
442
450
|
}
|
|
443
|
-
async function
|
|
451
|
+
async function readDigests(projectId, folder) {
|
|
452
|
+
/* No record yet, or one this build cannot read: hash everything. */
|
|
453
|
+
return ((folder ? await readDigestFile(digestsFile(projectId, folder)) : null) ??
|
|
454
|
+
(await readDigestFile(digestsFile(projectId))) ??
|
|
455
|
+
new Map());
|
|
456
|
+
}
|
|
457
|
+
async function writeDigests(projectId, digests, folder) {
|
|
444
458
|
if (!digests.size)
|
|
445
459
|
return;
|
|
446
460
|
try {
|
|
447
|
-
await writePrivate(digestsFile(projectId), JSON.stringify(Object.fromEntries(digests)));
|
|
461
|
+
await writePrivate(digestsFile(projectId, folder), JSON.stringify(Object.fromEntries(digests)));
|
|
448
462
|
}
|
|
449
463
|
catch {
|
|
450
464
|
/* The next save hashes again, which is where this started. */
|
package/dist/cli/src/help.js
CHANGED
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
* afford whole sentences and examples.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.listedUsage = exports.USAGE_COLUMN = void 0;
|
|
18
|
+
exports.ALL_COMMANDS_HEADING = exports.listedUsage = exports.USAGE_COLUMN = void 0;
|
|
19
19
|
exports.renderHelp = renderHelp;
|
|
20
|
+
exports.explainArgument = explainArgument;
|
|
21
|
+
exports.unexplainedArguments = unexplainedArguments;
|
|
20
22
|
exports.renderCommandHelp = renderCommandHelp;
|
|
21
23
|
exports.renderUnknown = renderUnknown;
|
|
22
24
|
const registry_js_1 = require("./registry.js");
|
|
@@ -35,11 +37,50 @@ function rank(spec, declared) {
|
|
|
35
37
|
const at = registry_js_1.LISTING_ORDER.indexOf(spec.name);
|
|
36
38
|
return at === -1 ? registry_js_1.LISTING_ORDER.length + declared : at;
|
|
37
39
|
}
|
|
40
|
+
/*
|
|
41
|
+
The five things nearly everybody does, written out in full, before the list
|
|
42
|
+
of everything. The list is long because CodeRook does a lot, and somebody
|
|
43
|
+
looking for how to save their work with a message had to find `submit` in
|
|
44
|
+
the second group and then guess that `-m` takes the message (owner,
|
|
45
|
+
2026-11-10: "couldn't see how to do submit with comments or arguments").
|
|
46
|
+
*/
|
|
47
|
+
const START_HERE = [
|
|
48
|
+
["cbx sign-in", "connect this machine to your account (once)"],
|
|
49
|
+
["cbx clone <project>", "fetch a project into a new folder"],
|
|
50
|
+
["cbx status", "what changed here since the last save"],
|
|
51
|
+
['cbx submit -m "What changed"', "save the changes, with a message saying what"],
|
|
52
|
+
["cbx get", "bring this folder up to date with CodeRook"],
|
|
53
|
+
];
|
|
54
|
+
/* How a usage line is written, said once so every line below can be read. */
|
|
55
|
+
const READING = [
|
|
56
|
+
["<project>", "angle brackets: you must give it"],
|
|
57
|
+
["[folder]", "square brackets: you may leave it out"],
|
|
58
|
+
["a|b", "one of these words"],
|
|
59
|
+
['-m "Fix the menu"', "a message: in quotes whenever it has spaces"],
|
|
60
|
+
["--track spike", "an option and its value (--track=spike works too)"],
|
|
61
|
+
["cbx help submit", "everything one command takes, with examples"],
|
|
62
|
+
["cbx submit --help", "the same, from the command itself"],
|
|
63
|
+
];
|
|
64
|
+
/** Two aligned columns, indented like the rest of the help. */
|
|
65
|
+
function pairs(rows, colour) {
|
|
66
|
+
const width = rows.reduce((widest, [left]) => Math.max(widest, left.length), 0);
|
|
67
|
+
return rows.map(([left, right]) => ` ${colour(left.padEnd(width))} ${right}`);
|
|
68
|
+
}
|
|
69
|
+
/** The line that separates the introduction from the list of every command. */
|
|
70
|
+
exports.ALL_COMMANDS_HEADING = "Every command, by what you want to do";
|
|
38
71
|
function renderHelp(registry, version) {
|
|
39
72
|
const listed = registry.specs.filter((spec) => !spec.deprecatedBy);
|
|
40
73
|
const column = Math.min(nameColumn(listed), exports.USAGE_COLUMN);
|
|
41
74
|
const lines = [
|
|
42
|
-
`${(0, colour_js_1.bold)("cbx")} ${(0, colour_js_1.dim)(version)} —
|
|
75
|
+
`${(0, colour_js_1.bold)("cbx")} ${(0, colour_js_1.dim)(version)} — save, share and run your projects on CodeRook`,
|
|
76
|
+
"",
|
|
77
|
+
(0, colour_js_1.bold)("Start here"),
|
|
78
|
+
...pairs(START_HERE, colour_js_1.accent),
|
|
79
|
+
"",
|
|
80
|
+
(0, colour_js_1.bold)("How commands are written"),
|
|
81
|
+
...pairs(READING, colour_js_1.accent),
|
|
82
|
+
"",
|
|
83
|
+
(0, colour_js_1.bold)(exports.ALL_COMMANDS_HEADING),
|
|
43
84
|
"",
|
|
44
85
|
];
|
|
45
86
|
for (const group of registry_js_1.GROUP_ORDER) {
|
|
@@ -56,9 +97,73 @@ function renderHelp(registry, version) {
|
|
|
56
97
|
}
|
|
57
98
|
lines.push("");
|
|
58
99
|
}
|
|
59
|
-
lines.push((0, colour_js_1.dim)("cbx help <command> the full usage, options and examples for one command"), (0, colour_js_1.dim)("CODEROOK_TOKEN used instead of the stored sign-in, for automated runs"), (0, colour_js_1.dim)("CODEROOK_API_URL point at another service"));
|
|
100
|
+
lines.push((0, colour_js_1.dim)("cbx help <command> the full usage, arguments, options and examples for one command"), (0, colour_js_1.dim)("CODEROOK_TOKEN used instead of the stored sign-in, for automated runs"), (0, colour_js_1.dim)("CODEROOK_API_URL point at another service"));
|
|
60
101
|
return lines.join("\n");
|
|
61
102
|
}
|
|
103
|
+
/*
|
|
104
|
+
What each word in angle or square brackets means, said the same way on every
|
|
105
|
+
command's page. A command whose word means something else there names it in
|
|
106
|
+
its own `arguments`, which wins.
|
|
107
|
+
*/
|
|
108
|
+
const MEANINGS = {
|
|
109
|
+
project: { what: "a project on your account, by name (my-game) or as owner/name", leftOut: "the project this folder is linked to" },
|
|
110
|
+
folder: { what: "a folder on this machine", leftOut: "the folder you are in" },
|
|
111
|
+
dir: { what: "the folder to create", leftOut: "one named after what is being fetched" },
|
|
112
|
+
out: { what: "the file to write", leftOut: "the folder's name with .cbx, beside it" },
|
|
113
|
+
n: { what: "a save's number, as cbx versions shows it (12 or v12)", leftOut: "the newest save" },
|
|
114
|
+
number: { what: "the number cbx runs shows for a run (12 or #12)" },
|
|
115
|
+
line: { what: "a line of work, as cbx tracks lists them (main, spike)", leftOut: "the line this folder saves to" },
|
|
116
|
+
file: { what: "a file on this machine" },
|
|
117
|
+
"file…": { what: "one or more files on this machine" },
|
|
118
|
+
"paths…": { what: "one or more files or folders inside the project", leftOut: "everything" },
|
|
119
|
+
"path…": { what: "one or more paths inside the project" },
|
|
120
|
+
"pattern…": { what: "one or more paths or patterns, like art/ or *.psd" },
|
|
121
|
+
"owner/project": { what: "somebody's project, as owner/name (sam/encoder)" },
|
|
122
|
+
address: { what: "the project's web address on the other host" },
|
|
123
|
+
workspace: { what: "a draft's id, as cbx workspace list shows it" },
|
|
124
|
+
version: { what: "a save's number (12 or v12)", leftOut: "the newest save" },
|
|
125
|
+
release: { what: "a release's name, as cbx releases lists it (1.2)" },
|
|
126
|
+
"M-3": { what: "a pull request's reference, as cbx pr list shows it" },
|
|
127
|
+
NAME: { what: "the secret's name, as runs read it (API_KEY)" },
|
|
128
|
+
};
|
|
129
|
+
/** The words a usage line asks for, as written there: "<project>", "[folder]", "<a|b>". */
|
|
130
|
+
function argumentTokens(usage) {
|
|
131
|
+
const tokens = [];
|
|
132
|
+
/* An option and its value ("--name <text>", "--on|--off") is explained under Options. */
|
|
133
|
+
const words = usage.replace(/--?[A-Za-z][\w-]*(?:\|--?[A-Za-z][\w-]*)*(?:\s+(?:<[^<>]*>|[\w,.|-]+(?=\])))?/g, "");
|
|
134
|
+
for (const match of words.matchAll(/[<[]([^<>[\]]+)[>\]]/g)) {
|
|
135
|
+
const whole = match[0];
|
|
136
|
+
const inner = match[1].trim();
|
|
137
|
+
/* Options are explained under Options; a fragment with spaces is part of one. */
|
|
138
|
+
if (inner.startsWith("-") || (/\s/.test(inner) && !inner.includes("|")))
|
|
139
|
+
continue;
|
|
140
|
+
if (!tokens.includes(whole))
|
|
141
|
+
tokens.push(whole);
|
|
142
|
+
}
|
|
143
|
+
return tokens;
|
|
144
|
+
}
|
|
145
|
+
/** What one usage word means, or null for a word nothing here can explain. */
|
|
146
|
+
function explainArgument(token, spec) {
|
|
147
|
+
const own = spec.arguments?.[token];
|
|
148
|
+
if (own)
|
|
149
|
+
return own;
|
|
150
|
+
const optional = token.startsWith("[");
|
|
151
|
+
const inner = token.slice(1, -1).trim();
|
|
152
|
+
if (inner.includes("|")) {
|
|
153
|
+
const choices = inner.split("|").map((choice) => choice.trim()).filter(Boolean);
|
|
154
|
+
return `${optional ? "optionally " : ""}one of: ${choices.join(", ")}`;
|
|
155
|
+
}
|
|
156
|
+
const meaning = MEANINGS[inner];
|
|
157
|
+
if (!meaning)
|
|
158
|
+
return null;
|
|
159
|
+
if (!optional)
|
|
160
|
+
return meaning.what;
|
|
161
|
+
return meaning.leftOut ? `${meaning.what}; left out, ${meaning.leftOut}` : `${meaning.what}; may be left out`;
|
|
162
|
+
}
|
|
163
|
+
/** Every usage word the help cannot explain, for the test that keeps it complete. */
|
|
164
|
+
function unexplainedArguments(spec) {
|
|
165
|
+
return argumentTokens(spec.usage).filter((token) => !explainArgument(token, spec));
|
|
166
|
+
}
|
|
62
167
|
function renderCommandHelp(spec) {
|
|
63
168
|
const lines = [
|
|
64
169
|
`${(0, colour_js_1.bold)("cbx " + spec.name)} — ${spec.summary}`,
|
|
@@ -66,8 +171,17 @@ function renderCommandHelp(spec) {
|
|
|
66
171
|
(0, colour_js_1.bold)("Usage"),
|
|
67
172
|
` cbx ${spec.usage}`,
|
|
68
173
|
];
|
|
174
|
+
const words = argumentTokens(spec.usage)
|
|
175
|
+
.map((token) => [token, explainArgument(token, spec)])
|
|
176
|
+
.filter((row) => Boolean(row[1]));
|
|
177
|
+
if (words.length) {
|
|
178
|
+
const width = words.reduce((widest, [token]) => Math.max(widest, token.length), 0);
|
|
179
|
+
lines.push("", (0, colour_js_1.bold)("Arguments"));
|
|
180
|
+
for (const [token, meaning] of words)
|
|
181
|
+
lines.push(` ${token.padEnd(width)} ${meaning}`);
|
|
182
|
+
}
|
|
69
183
|
if (spec.aliases?.length) {
|
|
70
|
-
lines.push("", (0, colour_js_1.bold)("Also"), ` ${spec.aliases.map((alias) => `cbx ${alias}`).join(" ")}`);
|
|
184
|
+
lines.push("", (0, colour_js_1.bold)("Also called"), ` ${spec.aliases.map((alias) => `cbx ${alias}`).join(" ")}`);
|
|
71
185
|
}
|
|
72
186
|
if (spec.detail) {
|
|
73
187
|
lines.push("", spec.detail.trim());
|
|
@@ -84,6 +198,7 @@ function renderCommandHelp(spec) {
|
|
|
84
198
|
for (const example of spec.examples)
|
|
85
199
|
lines.push(` ${(0, colour_js_1.accent)(example)}`);
|
|
86
200
|
}
|
|
201
|
+
lines.push("", (0, colour_js_1.dim)("cbx help every command, and how commands are written"));
|
|
87
202
|
return lines.join("\n");
|
|
88
203
|
}
|
|
89
204
|
/**
|
package/dist/cli/src/machine.js
CHANGED
|
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.machineIdentity = machineIdentity;
|
|
7
|
+
exports.checkInBody = checkInBody;
|
|
8
|
+
exports.markCheckedIn = markCheckedIn;
|
|
7
9
|
exports.checkIn = checkIn;
|
|
8
10
|
/**
|
|
9
11
|
* This machine, as a project's Actions page shows it (backend machines.ts).
|
|
@@ -46,31 +48,46 @@ async function machineIdentity() {
|
|
|
46
48
|
cached = { id, name: (process.env.CODEROOK_MACHINE_NAME || (0, node_os_1.hostname)() || "This machine").slice(0, 120) };
|
|
47
49
|
return cached;
|
|
48
50
|
}
|
|
51
|
+
/** What a check-in says, as the service reads it (backend/src/machines.ts parseCheckIn). */
|
|
52
|
+
async function checkInBody(state) {
|
|
53
|
+
const me = await machineIdentity();
|
|
54
|
+
const client = (0, identify_js_1.clientHeaders)()["x-coderook-client"] ?? "";
|
|
55
|
+
return {
|
|
56
|
+
machineId: me.id,
|
|
57
|
+
name: me.name,
|
|
58
|
+
kind: state.kind,
|
|
59
|
+
platform: `${(0, node_os_1.platform)()} ${(0, node_os_1.release)()}`.slice(0, 80),
|
|
60
|
+
clientVersion: client.startsWith("cli/") ? client.slice(4) : null,
|
|
61
|
+
folderName: state.folder ? node_path_1.default.basename(node_path_1.default.resolve(state.folder)) : null,
|
|
62
|
+
track: state.track ?? null,
|
|
63
|
+
baseVersionId: state.baseVersionId ?? null,
|
|
64
|
+
changedFiles: state.changedFiles ?? null,
|
|
65
|
+
workspaceId: state.workspaceId ?? null,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/*
|
|
69
|
+
Projects a save has already checked this machine in to, as part of the save
|
|
70
|
+
itself (delta-save-v1 carries the check-in). The separate request after it
|
|
71
|
+
was half a second of every save, to say what the save had just said.
|
|
72
|
+
*/
|
|
73
|
+
const checkedIn = new Set();
|
|
74
|
+
function markCheckedIn(repositoryId) {
|
|
75
|
+
checkedIn.add(repositoryId);
|
|
76
|
+
}
|
|
49
77
|
/** Tell the project this machine is here. Never throws, and gives up after a moment. */
|
|
50
78
|
async function checkIn(repositoryId, state) {
|
|
51
79
|
if (!repositoryId || process.env.CODEROOK_NO_PRESENCE)
|
|
52
80
|
return;
|
|
81
|
+
if (checkedIn.has(repositoryId) && state.changedFiles === 0)
|
|
82
|
+
return;
|
|
53
83
|
try {
|
|
54
84
|
const token = await (0, config_js_1.loadToken)();
|
|
55
85
|
if (!token)
|
|
56
86
|
return;
|
|
57
|
-
const me = await machineIdentity();
|
|
58
|
-
const client = (0, identify_js_1.clientHeaders)()["x-coderook-client"] ?? "";
|
|
59
87
|
await fetch(`${(0, config_js_1.apiOrigin)()}/v1/repositories/${encodeURIComponent(repositoryId)}/machines`, {
|
|
60
88
|
method: "POST",
|
|
61
89
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json", ...(0, identify_js_1.clientHeaders)() },
|
|
62
|
-
body: JSON.stringify(
|
|
63
|
-
machineId: me.id,
|
|
64
|
-
name: me.name,
|
|
65
|
-
kind: state.kind,
|
|
66
|
-
platform: `${(0, node_os_1.platform)()} ${(0, node_os_1.release)()}`.slice(0, 80),
|
|
67
|
-
clientVersion: client.startsWith("cli/") ? client.slice(4) : null,
|
|
68
|
-
folderName: state.folder ? node_path_1.default.basename(node_path_1.default.resolve(state.folder)) : null,
|
|
69
|
-
track: state.track ?? null,
|
|
70
|
-
baseVersionId: state.baseVersionId ?? null,
|
|
71
|
-
changedFiles: state.changedFiles ?? null,
|
|
72
|
-
workspaceId: state.workspaceId ?? null,
|
|
73
|
-
}),
|
|
90
|
+
body: JSON.stringify(await checkInBody(state)),
|
|
74
91
|
signal: AbortSignal.timeout(2500),
|
|
75
92
|
});
|
|
76
93
|
}
|
package/dist/cli/src/registry.js
CHANGED
|
@@ -46,7 +46,7 @@ exports.LISTING_ORDER = [
|
|
|
46
46
|
"about", "features", "visibility", "ai", "private", "upload-rules", "people", "watch", "hooks", "secret", "assistant",
|
|
47
47
|
"security", "pages", "fork", "hand-over", "delete",
|
|
48
48
|
"issues", "issue",
|
|
49
|
-
"actions", "runs", "logs", "cancel", "rerun", "approve", "runner", "build", "machines",
|
|
49
|
+
"actions", "runs", "logs", "cancel", "rerun", "approve", "runner", "power", "build", "machines",
|
|
50
50
|
"workspace",
|
|
51
51
|
"mods", "bundle", "unbundle", "inspect",
|
|
52
52
|
"mcp", "skill", "tokens",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderook/cli",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.5",
|
|
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",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"git-remote-coderook": "dist/cli/src/git_remote_bin.js"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
|
-
".claude-plugin",
|
|
31
|
+
".claude-plugin",
|
|
32
32
|
"engine-bin",
|
|
33
33
|
"dist",
|
|
34
34
|
"skills",
|