@coderook/cli 0.47.0 → 0.47.1
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/.claude-plugin/plugin.json +1 -1
- package/dist/cbx/src/core/cbx.js +78 -5
- package/dist/cbx/src/core/download.js +114 -24
- package/dist/cbx/src/local/durable.js +66 -0
- package/dist/cbx/src/local/repository.js +116 -11
- package/dist/cbx/src/local/store.js +84 -17
- package/dist/cbx/src/local/store_v2.js +7 -2
- package/dist/cbx/src/shared/native_engine.js +68 -12
- package/dist/cbx/src/shared/path_rules.js +231 -0
- package/dist/cbx/src/shared/safe_path.js +60 -34
- package/dist/cli/src/api.js +24 -2
- package/dist/cli/src/build_command.js +46 -1
- package/dist/cli/src/build_pins.js +162 -0
- package/dist/cli/src/cli.js +45 -3
- package/dist/cli/src/config.js +27 -4
- package/dist/cli/src/import_command.js +24 -1
- package/dist/cli/src/mcp.js +12 -1
- package/dist/cli/src/portable_python.js +29 -22
- package/dist/cli/src/runner.js +3 -1
- package/dist/cli/src/settings_commands.js +1 -1
- package/dist/cli/src/transfer_command.js +12 -2
- package/dist/cli/src/workspace_machine.js +17 -3
- package/dist/cli/src/workspace_review.js +2 -0
- package/engine-bin/darwin-arm64/cbx-engine +0 -0
- package/engine-bin/darwin-x64/cbx-engine +0 -0
- package/engine-bin/linux-arm64/cbx-engine +0 -0
- package/engine-bin/linux-x64/cbx-engine +0 -0
- package/engine-bin/win32-x64/cbx-engine.exe +0 -0
- package/package.json +1 -1
package/dist/cli/src/cli.js
CHANGED
|
@@ -3248,7 +3248,7 @@ const SPECS = [
|
|
|
3248
3248
|
summary: "edit, save and run a private project remotely without a checkout",
|
|
3249
3249
|
usage: "workspace | workspace <usage|open|list|show|read|files|search|diff|patch|put|starter|review|reviewers|save|run|runs|logs|cancel|deploy|preview|handoff|close|reopen|recipe|assign|assignments|unassign|checkout|say|thread|mute|unmute> <project> [workspace] [job] | workspace put <project> <workspace> <path…> | workspace push [folder] | workspace watch [project] [workspace]",
|
|
3250
3250
|
brief: "workspace <action> <project>",
|
|
3251
|
-
detail: "Works on CodeRook's durable remote draft, never the current local folder. Use --data-file for structured edits or recipe configuration. Mutations need the reviewed --revision and a unique --key; reuse the same key and request when retrying. Recipes reference existing project workflows. Usage reads the shared workspace credits and separate PR allowance without a draft ID. put copies files from this folder into a draft: text as text, images, fonts and other binary files as bytes (up to 1 MiB each), a file that is gone here is removed there, and each file must still be the version the draft holds, so a teammate's edit is never overwritten. starter reads this folder (package.json scripts, Cargo.toml, go.mod, Python) and suggests one check recipe per package so drafts have something to run; --apply adds them, never replacing a recipe that exists. review shows who must OK a draft before it is saved or deployed; --ok or --changes -m gives your verdict on the current revision, and counts only from the reviewer's own sign-in or token, never a name given with --as. reviewers lists the project's rules, and an administrator sets them with --data-file. Saving and deploying are separate operations. close refuses a draft with edits that were never saved unless --unsaved is given (the edits are kept, not thrown away); reopen opens a closed draft again, edits and all. Run on its own at a terminal, it lists your open workspaces with their unread messages: choose one to see its changes and what is being discussed, and reply, save, run checks, hand it over or close it with one key. say and thread post to and read a workspace's discussion as JSON; a machine signed in to your account can name itself with --as (or CBX_NAME) so its messages and unread count are its own. watch prints each new message, each message addressed to you (@your name, or the name given with --as) and each new saved version as it happens, until stopped; --json gives one JSON object per line for a program.",
|
|
3251
|
+
detail: "Works on CodeRook's durable remote draft, never the current local folder. Use --data-file for structured edits or recipe configuration. Mutations need the reviewed --revision and a unique --key; reuse the same key and request when retrying. Recipes reference existing project workflows. Usage reads the shared workspace credits and separate PR allowance without a draft ID. put copies files from this folder into a draft: text as text, images, fonts and other binary files as bytes (up to 1 MiB each), a file that is gone here is removed there, and each file must still be the version the draft holds, so a teammate's edit is never overwritten. starter reads this folder (package.json scripts, Cargo.toml, go.mod, Python) and suggests one check recipe per package so drafts have something to run; --apply adds them, never replacing a recipe that exists. review shows who must OK a draft before it is saved or deployed (the rules hold drafts only, not saves made outside a draft); --ok or --changes -m gives your verdict on the current revision, and counts only from the reviewer's own sign-in or token, never a name given with --as. reviewers lists the project's rules, and an administrator sets them with --data-file. Saving and deploying are separate operations. close refuses a draft with edits that were never saved unless --unsaved is given (the edits are kept, not thrown away); reopen opens a closed draft again, edits and all. Run on its own at a terminal, it lists your open workspaces with their unread messages: choose one to see its changes and what is being discussed, and reply, save, run checks, hand it over or close it with one key. say and thread post to and read a workspace's discussion as JSON; a machine signed in to your account can name itself with --as (or CBX_NAME) so its messages and unread count are its own. watch prints each new message, each message addressed to you (@your name, or the name given with --as) and each new saved version as it happens, until stopped; --json gives one JSON object per line for a program.",
|
|
3252
3252
|
options: [
|
|
3253
3253
|
{ flags: "--data-file <path>", description: "read an operation's JSON from this local file" },
|
|
3254
3254
|
{ flags: "--name <name>", description: "name a new workspace" },
|
|
@@ -3494,7 +3494,7 @@ const SPECS = [
|
|
|
3494
3494
|
name: "hand-over",
|
|
3495
3495
|
group: "Project settings",
|
|
3496
3496
|
summary: "offer a project to another owner, or answer an offer",
|
|
3497
|
-
usage: "hand-over <username
|
|
3497
|
+
usage: "hand-over <username> [project] [--drop-access] [--yes] | hand-over offers | hand-over accept|decline|cancel <project>",
|
|
3498
3498
|
brief: "hand-over <user> [project]",
|
|
3499
3499
|
detail: "Offers the project to another account, as the website's Settings →\n" +
|
|
3500
3500
|
"Danger zone does. Nothing moves until they accept, and the offer lapses\n" +
|
|
@@ -3511,7 +3511,7 @@ const SPECS = [
|
|
|
3511
3511
|
],
|
|
3512
3512
|
examples: [
|
|
3513
3513
|
"cbx hand-over sam my-project",
|
|
3514
|
-
"cbx hand-over sam
|
|
3514
|
+
"cbx hand-over @sam --drop-access",
|
|
3515
3515
|
"cbx hand-over offers",
|
|
3516
3516
|
"cbx hand-over accept night-owl-diner",
|
|
3517
3517
|
],
|
|
@@ -4715,6 +4715,47 @@ async function main(argv) {
|
|
|
4715
4715
|
*/
|
|
4716
4716
|
function leave(code) {
|
|
4717
4717
|
node_process_1.default.exitCode = code;
|
|
4718
|
+
/*
|
|
4719
|
+
The belt, as git_remote_bin.ts has: only fires if something is still
|
|
4720
|
+
holding the loop open five seconds after the command finished (a socket
|
|
4721
|
+
a fetch left behind, a stray timer), and being unreferenced it cannot be
|
|
4722
|
+
that thing itself. Without it such a command printed its answer and then
|
|
4723
|
+
never returned to the prompt.
|
|
4724
|
+
*/
|
|
4725
|
+
setTimeout(() => node_process_1.default.exit(code), 5000).unref();
|
|
4726
|
+
}
|
|
4727
|
+
/*
|
|
4728
|
+
Before a folder's own `.coderook/link.json` is taken up on a machine that
|
|
4729
|
+
never linked it, the person is asked, with the project and its owner named
|
|
4730
|
+
as the service knows them rather than as the file says (config.ts). With
|
|
4731
|
+
nobody at a terminal to ask, it is not taken up, and one line says how to.
|
|
4732
|
+
*/
|
|
4733
|
+
async function askAboutFolderLink({ folder, link }) {
|
|
4734
|
+
const project = await (0, api_js_2.projectById)(link.repositoryId).catch(() => null);
|
|
4735
|
+
if (!project) {
|
|
4736
|
+
console.error(dim(`${folder} carries a link to a project (${link.slug}) this account cannot open; it was not used.`));
|
|
4737
|
+
return false;
|
|
4738
|
+
}
|
|
4739
|
+
const name = project.ownerHandle ? `${project.ownerHandle}/${project.slug}` : project.slug;
|
|
4740
|
+
console.log(`This folder says it belongs to ${accent(name)}` +
|
|
4741
|
+
(project.member ? "" : dim(" (a project you are not a member of)")) +
|
|
4742
|
+
`, but this machine has never linked it.`);
|
|
4743
|
+
if (project.slug !== link.slug) {
|
|
4744
|
+
console.log(dim(` The folder's own file calls it "${link.slug}".`));
|
|
4745
|
+
}
|
|
4746
|
+
const reader = (0, promises_1.createInterface)({ input: node_process_1.default.stdin, output: node_process_1.default.stdout });
|
|
4747
|
+
try {
|
|
4748
|
+
const answer = (await reader.question(`Save and fetch this folder as ${name}? [y/N] `)).trim().toLowerCase();
|
|
4749
|
+
return answer === "y" || answer === "yes";
|
|
4750
|
+
}
|
|
4751
|
+
finally {
|
|
4752
|
+
reader.close();
|
|
4753
|
+
}
|
|
4754
|
+
}
|
|
4755
|
+
async function tellAboutFolderLink({ folder, link }) {
|
|
4756
|
+
console.error(dim(`${folder} carries a link to ${link.slug} that this machine never made, so it was not used. `) +
|
|
4757
|
+
dim("Link it with ") + accent(`cbx link ${link.slug}`) + dim(" if that is right."));
|
|
4758
|
+
return false;
|
|
4718
4759
|
}
|
|
4719
4760
|
/*
|
|
4720
4761
|
Run only when started as the program. A test loads this file to read the
|
|
@@ -4724,6 +4765,7 @@ function leave(code) {
|
|
|
4724
4765
|
/** Run the command line with this process's arguments. bin.ts calls this for everything it does not answer itself. */
|
|
4725
4766
|
function start() {
|
|
4726
4767
|
(0, network_js_1.tuneNetwork)();
|
|
4768
|
+
(0, config_js_1.judgeFolderLinks)(node_process_1.default.stdin.isTTY && node_process_1.default.stdout.isTTY ? askAboutFolderLink : tellAboutFolderLink);
|
|
4727
4769
|
main(node_process_1.default.argv.slice(2))
|
|
4728
4770
|
.then(leave)
|
|
4729
4771
|
.catch((error) => {
|
package/dist/cli/src/config.js
CHANGED
|
@@ -12,6 +12,8 @@ exports.loadToken = loadToken;
|
|
|
12
12
|
exports.clearToken = clearToken;
|
|
13
13
|
exports.keyFor = keyFor;
|
|
14
14
|
exports.linkFileFor = linkFileFor;
|
|
15
|
+
exports.judgeFolderLinks = judgeFolderLinks;
|
|
16
|
+
exports.folderLinkOf = folderLinkOf;
|
|
15
17
|
exports.readLink = readLink;
|
|
16
18
|
exports.forgetLink = forgetLink;
|
|
17
19
|
exports.writeLink = writeLink;
|
|
@@ -380,6 +382,17 @@ async function writeFolderLink(localPath, link) {
|
|
|
380
382
|
/* A folder that cannot hold the copy still has the machine's record. */
|
|
381
383
|
}
|
|
382
384
|
}
|
|
385
|
+
let folderLinkJudge = null;
|
|
386
|
+
/** Set (or clear, with null) who is asked before a folder's own link is adopted. */
|
|
387
|
+
function judgeFolderLinks(judge) {
|
|
388
|
+
folderLinkJudge = judge;
|
|
389
|
+
}
|
|
390
|
+
/** A folder's own copy of its link, without adopting it. */
|
|
391
|
+
async function folderLinkOf(localPath) {
|
|
392
|
+
return readFolderLink(localPath);
|
|
393
|
+
}
|
|
394
|
+
/* Asked once per folder per run, however many times the link is read. */
|
|
395
|
+
const folderLinkAnswers = new Map();
|
|
383
396
|
async function readLink(localPath) {
|
|
384
397
|
let found = await lookUp(localPath);
|
|
385
398
|
if (!found &&
|
|
@@ -393,10 +406,20 @@ async function readLink(localPath) {
|
|
|
393
406
|
return null;
|
|
394
407
|
let link = found;
|
|
395
408
|
if (!link) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
409
|
+
const offered = await readFolderLink(localPath);
|
|
410
|
+
if (offered && folderLinkJudge) {
|
|
411
|
+
const folder = node_path_1.default.resolve(localPath);
|
|
412
|
+
let answer = folderLinkAnswers.get(folder);
|
|
413
|
+
if (!answer) {
|
|
414
|
+
answer = folderLinkJudge({ folder, link: offered }).catch(() => false);
|
|
415
|
+
folderLinkAnswers.set(folder, answer);
|
|
416
|
+
}
|
|
417
|
+
/* Adopted, so this machine knows the folder from now on. */
|
|
418
|
+
if (await answer) {
|
|
419
|
+
await writeLink(localPath, offered);
|
|
420
|
+
link = offered;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
400
423
|
}
|
|
401
424
|
if (!link)
|
|
402
425
|
return null;
|
|
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.projectNameFromUrl = projectNameFromUrl;
|
|
7
|
+
exports.gitOperand = gitOperand;
|
|
8
|
+
exports.safeBranchName = safeBranchName;
|
|
7
9
|
exports.looksLikeRepositoryUrl = looksLikeRepositoryUrl;
|
|
8
10
|
exports.gitAvailable = gitAvailable;
|
|
9
11
|
exports.fetchSnapshot = fetchSnapshot;
|
|
@@ -37,6 +39,25 @@ function projectNameFromUrl(url) {
|
|
|
37
39
|
const name = tail.replace(/\.git$/i, "").trim();
|
|
38
40
|
return name || "imported-project";
|
|
39
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Values handed to git that git must never read as options.
|
|
44
|
+
*
|
|
45
|
+
* A repository address or branch name arrives from somebody else: typed from
|
|
46
|
+
* a page, or listed by the forge being transferred from. Git reads anything
|
|
47
|
+
* starting with "-" as an option, and `--upload-pack=<command>` as a program
|
|
48
|
+
* to run, so such a value is refused here, and every value is also placed
|
|
49
|
+
* after "--" so git stops reading options before it (audit, 16 November 2026).
|
|
50
|
+
*/
|
|
51
|
+
function gitOperand(value, what) {
|
|
52
|
+
if (!value || value.startsWith("-")) {
|
|
53
|
+
throw new Error(`Refusing ${what} "${value}": git would read it as an option.`);
|
|
54
|
+
}
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
/** Whether a branch name may be handed to git: not empty, and not an option. */
|
|
58
|
+
function safeBranchName(name) {
|
|
59
|
+
return Boolean(name) && !name.startsWith("-");
|
|
60
|
+
}
|
|
40
61
|
/**
|
|
41
62
|
* Refuse anything that is not a repository location.
|
|
42
63
|
*
|
|
@@ -111,7 +132,9 @@ async function fetchSnapshot(url, into, log = () => { }) {
|
|
|
111
132
|
fetching every branch's tip would cost time to produce content this
|
|
112
133
|
command then discards.
|
|
113
134
|
*/
|
|
114
|
-
await run("git",
|
|
135
|
+
await run("git",
|
|
136
|
+
/* After "--": an address is never read as an option (gitOperand, above). */
|
|
137
|
+
["clone", "--depth", "1", "--single-branch", "--", gitOperand(url, "the address"), folder], { windowsHide: true, maxBuffer: 32 * 1024 * 1024 });
|
|
115
138
|
const gitDirectory = node_path_1.default.join(folder, ".git");
|
|
116
139
|
if (await exists(gitDirectory)) {
|
|
117
140
|
await (0, promises_1.rm)(gitDirectory, { recursive: true, force: true });
|
package/dist/cli/src/mcp.js
CHANGED
|
@@ -384,6 +384,13 @@ async function commandMcp(version) {
|
|
|
384
384
|
serverVersion = version;
|
|
385
385
|
node_process_1.default.stdin.setEncoding("utf8");
|
|
386
386
|
let buffer = "";
|
|
387
|
+
/*
|
|
388
|
+
Requests still being answered when the assistant closes its end. They
|
|
389
|
+
are finished before this returns: the command line exits a few seconds
|
|
390
|
+
after a command returns (cli.ts leave), and an answer cut off there is
|
|
391
|
+
one the assistant waited for and never got.
|
|
392
|
+
*/
|
|
393
|
+
const answering = new Set();
|
|
387
394
|
await new Promise((done) => {
|
|
388
395
|
node_process_1.default.stdin.on("data", (piece) => {
|
|
389
396
|
buffer += piece;
|
|
@@ -395,7 +402,9 @@ async function commandMcp(version) {
|
|
|
395
402
|
if (!line)
|
|
396
403
|
continue;
|
|
397
404
|
try {
|
|
398
|
-
|
|
405
|
+
const work = handle(JSON.parse(line)).catch(() => undefined);
|
|
406
|
+
answering.add(work);
|
|
407
|
+
void work.finally(() => answering.delete(work));
|
|
399
408
|
}
|
|
400
409
|
catch {
|
|
401
410
|
/* Not JSON. Nothing to answer, and nobody to answer to. */
|
|
@@ -405,5 +414,7 @@ async function commandMcp(version) {
|
|
|
405
414
|
node_process_1.default.stdin.on("end", () => done());
|
|
406
415
|
node_process_1.default.stdin.on("close", () => done());
|
|
407
416
|
});
|
|
417
|
+
while (answering.size)
|
|
418
|
+
await Promise.allSettled([...answering]);
|
|
408
419
|
return 0;
|
|
409
420
|
}
|
|
@@ -43,6 +43,7 @@ const node_process_1 = __importDefault(require("node:process"));
|
|
|
43
43
|
const node_zlib_1 = require("node:zlib");
|
|
44
44
|
const rules_js_1 = require("../../cbx/src/core/rules.js");
|
|
45
45
|
const worktree_js_1 = require("../../cbx/src/core/worktree.js");
|
|
46
|
+
const build_pins_js_1 = require("./build_pins.js");
|
|
46
47
|
/** python-build-standalone's name for each system. */
|
|
47
48
|
exports.PYTHON_TRIPLE = {
|
|
48
49
|
"windows-x64": "x86_64-pc-windows-msvc",
|
|
@@ -173,7 +174,8 @@ const isProgram = (body) => (body[0] === 0x7f && body.toString("latin1", 1, 4) =
|
|
|
173
174
|
function run(program, args, options = {}) {
|
|
174
175
|
return new Promise((done) => {
|
|
175
176
|
let out = "";
|
|
176
|
-
|
|
177
|
+
/* Without the CodeRook token: dependencies' own setup code runs here (build_pins.ts). */
|
|
178
|
+
const child = (0, node_child_process_1.spawn)(program, args, { windowsHide: true, stdio: ["ignore", "pipe", "pipe"], env: (0, build_pins_js_1.buildEnvironment)() });
|
|
177
179
|
child.stdout.on("data", (chunk) => {
|
|
178
180
|
out += chunk;
|
|
179
181
|
if (!options.quiet)
|
|
@@ -195,36 +197,41 @@ async function findUv(cache) {
|
|
|
195
197
|
const local = node_path_1.default.join(cache, "uv", "bin", node_process_1.default.platform === "win32" ? "uv.exe" : "uv");
|
|
196
198
|
if ((0, node_fs_1.existsSync)(local))
|
|
197
199
|
return local;
|
|
200
|
+
/* One uv, and only the wheels whose digests are pinned (build_pins.ts). */
|
|
201
|
+
await (0, promises_1.mkdir)(cache, { recursive: true });
|
|
202
|
+
const requirements = node_path_1.default.join(cache, `uv-${build_pins_js_1.UV_VERSION}-requirements.txt`);
|
|
203
|
+
await (0, promises_1.writeFile)(requirements, (0, build_pins_js_1.uvRequirements)());
|
|
198
204
|
for (const python of ["python3", "python"]) {
|
|
199
|
-
const installed = await run(python, [
|
|
205
|
+
const installed = await run(python, [
|
|
206
|
+
"-m", "pip", "install", "--quiet", "--disable-pip-version-check", "--no-deps", "--only-binary", ":all:",
|
|
207
|
+
"--require-hashes", "--target", node_path_1.default.join(cache, "uv"), "-r", requirements,
|
|
208
|
+
], { quiet: true });
|
|
200
209
|
if (installed.code === 0 && (0, node_fs_1.existsSync)(local))
|
|
201
210
|
return local;
|
|
202
211
|
}
|
|
203
212
|
throw new Error("needs uv (https://docs.astral.sh/uv) or Python with pip to fetch it");
|
|
204
213
|
}
|
|
205
|
-
/**
|
|
214
|
+
/**
|
|
215
|
+
* The target's CPython, downloaded once and checked against the digest
|
|
216
|
+
* pinned in build_pins.ts. A copy already in the cache is checked again
|
|
217
|
+
* before use: the cache is a folder anything on the machine can write to.
|
|
218
|
+
*/
|
|
206
219
|
async function pythonRuntime(cache, version, target, say) {
|
|
207
220
|
const folder = node_path_1.default.join(cache, "python");
|
|
208
221
|
await (0, promises_1.mkdir)(folder, { recursive: true });
|
|
209
|
-
const
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
say(`Fetching ${asset.name}…`);
|
|
223
|
-
const body = Buffer.from(await (await fetch(asset.browser_download_url, { signal: AbortSignal.timeout(15 * 60_000) })).arrayBuffer());
|
|
224
|
-
if ((0, node_crypto_1.createHash)("sha256").update(body).digest("hex") !== asset.digest.slice("sha256:".length)) {
|
|
225
|
-
throw new Error("the download does not match its published digest");
|
|
226
|
-
}
|
|
227
|
-
await (0, promises_1.writeFile)(node_path_1.default.join(folder, asset.name), body);
|
|
222
|
+
const pinned = (0, build_pins_js_1.pinnedPython)(version, target, exports.PYTHON_TRIPLE[target]);
|
|
223
|
+
const sha = (bytes) => (0, node_crypto_1.createHash)("sha256").update(bytes).digest("hex");
|
|
224
|
+
const cached = await (0, promises_1.readFile)(node_path_1.default.join(folder, pinned.name)).catch(() => null);
|
|
225
|
+
if (cached && sha(cached) === pinned.sha256)
|
|
226
|
+
return cached;
|
|
227
|
+
say(`Fetching ${pinned.name}…`);
|
|
228
|
+
const reply = await fetch(pinned.url, { signal: AbortSignal.timeout(15 * 60_000) });
|
|
229
|
+
if (!reply.ok)
|
|
230
|
+
throw new Error(`could not fetch ${pinned.name} (${reply.status})`);
|
|
231
|
+
const body = Buffer.from(await reply.arrayBuffer());
|
|
232
|
+
if (sha(body) !== pinned.sha256)
|
|
233
|
+
throw new Error(`${pinned.name} does not match its pinned digest`);
|
|
234
|
+
await (0, promises_1.writeFile)(node_path_1.default.join(folder, pinned.name), body);
|
|
228
235
|
return body;
|
|
229
236
|
}
|
|
230
237
|
/* ------------------------------------------------------------- project */
|
package/dist/cli/src/runner.js
CHANGED
|
@@ -43,6 +43,7 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
43
43
|
const download_js_1 = require("../../cbx/src/core/download.js");
|
|
44
44
|
const identify_js_1 = require("../../cbx/src/core/identify.js");
|
|
45
45
|
const config_js_1 = require("./config.js");
|
|
46
|
+
const api_js_1 = require("./api.js");
|
|
46
47
|
const progress_js_1 = require("./progress.js");
|
|
47
48
|
/** Replace each secret's value with ***, longest first. */
|
|
48
49
|
function maskSecrets(text, secrets) {
|
|
@@ -73,7 +74,8 @@ async function call(route, options = {}) {
|
|
|
73
74
|
signal: AbortSignal.timeout(REQUEST_DEADLINE_MS),
|
|
74
75
|
});
|
|
75
76
|
const text = await response.text();
|
|
76
|
-
|
|
77
|
+
/* Status first: a gateway's HTML page is not a reason to lose the status (api.ts replyBody). */
|
|
78
|
+
const body = (0, api_js_1.replyBody)(text, route, response.status, response.ok);
|
|
77
79
|
if (!response.ok) {
|
|
78
80
|
const error = new Error(body?.error?.message ?? `${route} failed (${response.status})`);
|
|
79
81
|
error.code = body?.error?.code;
|
|
@@ -510,7 +510,7 @@ async function typed(question) {
|
|
|
510
510
|
async function commandHandOver(parsed) {
|
|
511
511
|
const first = parsed.positional[0];
|
|
512
512
|
if (!first) {
|
|
513
|
-
console.error((0, colour_js_1.red)("To whom? cbx hand-over <username
|
|
513
|
+
console.error((0, colour_js_1.red)("To whom? cbx hand-over <username> [project]") + (0, colour_js_1.dim)(" (or: cbx hand-over offers)"));
|
|
514
514
|
return 1;
|
|
515
515
|
}
|
|
516
516
|
if (first === "offers") {
|
|
@@ -48,6 +48,7 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
48
48
|
const node_process_1 = __importDefault(require("node:process"));
|
|
49
49
|
const api_js_1 = require("./api.js");
|
|
50
50
|
const forge_url_js_1 = require("./forge_url.js");
|
|
51
|
+
const import_command_js_1 = require("./import_command.js");
|
|
51
52
|
const colour_js_1 = require("./colour.js");
|
|
52
53
|
/** A read token from the environment, or nothing. Never a flag. */
|
|
53
54
|
function forgeToken(forge) {
|
|
@@ -192,7 +193,7 @@ async function commandTransfer(parsed) {
|
|
|
192
193
|
a command whose name promises everything.
|
|
193
194
|
*/
|
|
194
195
|
console.log(`\n${(0, colour_js_1.dim)("Fetching the repository with its full history…")}`);
|
|
195
|
-
const cloned = run("git", ["clone", "--no-single-branch", forge.clone, checkout]);
|
|
196
|
+
const cloned = run("git", ["clone", "--no-single-branch", "--", (0, import_command_js_1.gitOperand)(forge.clone, "the address"), checkout]);
|
|
196
197
|
if (!cloned.ok) {
|
|
197
198
|
console.error((0, colour_js_1.red)(`\nCould not clone ${forge.clone}`));
|
|
198
199
|
console.error(cloned.out.trim().split("\n").slice(-4).join("\n"));
|
|
@@ -218,8 +219,17 @@ async function commandTransfer(parsed) {
|
|
|
218
219
|
.filter((one) => one.startsWith("origin/"))
|
|
219
220
|
.map((one) => one.slice("origin/".length))
|
|
220
221
|
.filter((one) => one && one !== "HEAD");
|
|
222
|
+
/*
|
|
223
|
+
A branch named like an option would be read as one by git; it is left
|
|
224
|
+
out and named, rather than handed over.
|
|
225
|
+
*/
|
|
226
|
+
const refused = remoteBranches.filter((one) => !(0, import_command_js_1.safeBranchName)(one));
|
|
227
|
+
for (const branch of refused) {
|
|
228
|
+
console.error((0, colour_js_1.red)(` Left out branch "${branch}": git would read its name as an option.`));
|
|
229
|
+
}
|
|
230
|
+
remoteBranches.splice(0, remoteBranches.length, ...remoteBranches.filter(import_command_js_1.safeBranchName));
|
|
221
231
|
for (const branch of remoteBranches) {
|
|
222
|
-
run("git", ["branch", "--force", branch, `origin/${branch}`], checkout);
|
|
232
|
+
run("git", ["branch", "--force", "--", branch, `origin/${branch}`], checkout);
|
|
223
233
|
}
|
|
224
234
|
const commits = Number(run("git", ["rev-list", "--all", "--count"], checkout).out.trim() || "0");
|
|
225
235
|
const tags = run("git", ["tag", "-l"], checkout).out.split("\n").filter(Boolean);
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.MACHINE_OPERATIONS = void 0;
|
|
7
7
|
exports.readWhole = readWhole;
|
|
8
|
+
exports.pushKey = pushKey;
|
|
8
9
|
exports.commandWorkspaceMachine = commandWorkspaceMachine;
|
|
9
10
|
exports.commandMachines = commandMachines;
|
|
10
11
|
/**
|
|
@@ -70,7 +71,20 @@ function flag(parsed, ...names) {
|
|
|
70
71
|
return undefined;
|
|
71
72
|
}
|
|
72
73
|
const sha = (bytes) => (0, node_crypto_1.createHash)("sha256").update(bytes).digest("hex");
|
|
73
|
-
|
|
74
|
+
/**
|
|
75
|
+
* The operation key for one request of a push, from what it sends.
|
|
76
|
+
*
|
|
77
|
+
* A fresh random key per batch meant that a push cut off after the draft
|
|
78
|
+
* took a batch, but before this folder heard back, sent the same batch again
|
|
79
|
+
* as a new operation the next time; the draft had moved on, so it was
|
|
80
|
+
* refused, and the folder could not catch up (audit, 16 November 2026). The
|
|
81
|
+
* same draft, revision and changes now always make the same key, so sending
|
|
82
|
+
* it again replays the answer the draft already gave.
|
|
83
|
+
*/
|
|
84
|
+
function pushKey(what, workspaceId, revision, payload) {
|
|
85
|
+
const digest = sha(`${workspaceId}\n${revision}\n${JSON.stringify(payload)}`);
|
|
86
|
+
return `${what}-${digest.slice(0, 48)}`;
|
|
87
|
+
}
|
|
74
88
|
async function readRecord(folder) {
|
|
75
89
|
try {
|
|
76
90
|
return JSON.parse(await (0, promises_1.readFile)(node_path_1.default.join(folder, RECORD), "utf8"));
|
|
@@ -274,7 +288,7 @@ async function push(parsed, where) {
|
|
|
274
288
|
for (const batch of (0, workspace_put_js_1.batches)(changes, sizes)) {
|
|
275
289
|
const result = await (0, api_js_1.callApi)(`${draft}/changes`, {
|
|
276
290
|
method: "POST",
|
|
277
|
-
body: { expectedRevision: revision, operationKey:
|
|
291
|
+
body: { expectedRevision: revision, operationKey: pushKey("push", record.workspaceId, revision, batch), changes: batch },
|
|
278
292
|
});
|
|
279
293
|
revision = result.workspace.revision;
|
|
280
294
|
for (const one of batch) {
|
|
@@ -296,7 +310,7 @@ async function push(parsed, where) {
|
|
|
296
310
|
}
|
|
297
311
|
const saved = await (0, api_js_1.callApi)(`${draft}/save`, {
|
|
298
312
|
method: "POST",
|
|
299
|
-
body: { expectedRevision: revision, operationKey:
|
|
313
|
+
body: { expectedRevision: revision, operationKey: pushKey("save", record.workspaceId, revision, message), message },
|
|
300
314
|
});
|
|
301
315
|
if (saved.mergeTrack) {
|
|
302
316
|
console.log(`${(0, colour_js_1.accent)("Saved onto a merge track")} ${saved.mergeTrack.reference ?? ""}: somebody else changed the same lines, so it waits to be settled.`);
|
|
@@ -103,5 +103,7 @@ async function commandWorkspaceReviewers(parsed, root) {
|
|
|
103
103
|
else
|
|
104
104
|
for (const r of rules)
|
|
105
105
|
console.log(`${(0, colour_js_1.bold)(r.label)} ${(0, colour_js_1.dim)(r.reviewer)} ${r.paths.length ? r.paths.join(", ") : "every path"} ${(0, colour_js_1.dim)(`before ${[r.beforeSave && "save", r.beforeDeploy && "deploy"].filter(Boolean).join(" + ")}${r.ownerMayOverride ? "; owner may go ahead without" : ""}`)}`);
|
|
106
|
+
if (rules.length && !parsed.flags.has("json") && !source)
|
|
107
|
+
console.log((0, colour_js_1.dim)("These hold drafts only. A save made outside a draft (cbx submit, the app, git push) is not held by them."));
|
|
106
108
|
return 0;
|
|
107
109
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderook/cli",
|
|
3
|
-
"version": "0.47.
|
|
3
|
+
"version": "0.47.1",
|
|
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",
|