@coderook/cli 0.46.12 → 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 +110 -7
- package/dist/cbx/src/core/download.js +194 -27
- package/dist/cbx/src/core/tracks.js +4 -0
- package/dist/cbx/src/core/upload.js +2 -0
- package/dist/cbx/src/core/worktree.js +8 -1
- 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 +61 -24
- package/dist/cli/src/api.js +25 -2
- package/dist/cli/src/bin.js +2 -0
- package/dist/cli/src/build_command.js +48 -3
- package/dist/cli/src/build_pins.js +162 -0
- package/dist/cli/src/cli.js +65 -10
- package/dist/cli/src/config.js +47 -7
- package/dist/cli/src/import_command.js +24 -1
- package/dist/cli/src/mcp.js +12 -1
- package/dist/cli/src/mods_command.js +2 -0
- package/dist/cli/src/portable_python.js +29 -21
- package/dist/cli/src/runner.js +3 -1
- package/dist/cli/src/service_commands.js +4 -3
- package/dist/cli/src/settings_commands.js +1 -1
- package/dist/cli/src/terminal_guard.js +37 -0
- package/dist/cli/src/transfer_command.js +12 -2
- package/dist/cli/src/verify_command.js +14 -0
- package/dist/cli/src/workspace_machine.js +28 -4
- package/dist/cli/src/workspace_review.js +2 -0
- package/dist/cli.bundle.cjs +28322 -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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printable = printable;
|
|
4
|
+
/**
|
|
5
|
+
* Text from other people never drives the terminal.
|
|
6
|
+
*
|
|
7
|
+
* Issue titles, comments, names, version messages and the service's own
|
|
8
|
+
* error text were printed as they came. A title holding an OSC 52 sequence
|
|
9
|
+
* wrote the reader's clipboard, an OSC 8 one disguised a link, and others
|
|
10
|
+
* retitled the window or moved the cursor to overwrite what came before
|
|
11
|
+
* (security audit, 16 November 2026).
|
|
12
|
+
*
|
|
13
|
+
* Filtered once, here, for everything written to a terminal: the few
|
|
14
|
+
* sequences cbx itself prints (colours, clearing a line or the screen) pass,
|
|
15
|
+
* and every other escape sequence and C1 control is dropped. Output that is
|
|
16
|
+
* piped or redirected is left byte for byte, and so is anything written as
|
|
17
|
+
* bytes rather than text.
|
|
18
|
+
*/
|
|
19
|
+
const ESCAPES = new RegExp([
|
|
20
|
+
"\\u001b\\][\\s\\S]*?(?:\\u0007|\\u001b\\\\)", // OSC ... BEL or ST
|
|
21
|
+
"\\u001b\\][^\\u0007\\u001b]*$", // OSC never ended in this write
|
|
22
|
+
"\\u001b[PX^_][\\s\\S]*?\\u001b\\\\", // DCS, SOS, PM, APC ... ST
|
|
23
|
+
"\\u001b\\[[0-?]*[ -/]*[@-~]", // CSI
|
|
24
|
+
"\\u001b[^\\[\\]PX^_]", // any other two-character escape
|
|
25
|
+
"[\\u0080-\\u009f]", // C1 controls
|
|
26
|
+
].join("|"), "g");
|
|
27
|
+
/** CSI sequences cbx prints itself: colours (m), clearing a line (K) or the screen (J), cursor home (H). */
|
|
28
|
+
const OWN = /^\u001b\[[0-9;]*[mKJH]$/;
|
|
29
|
+
function printable(text) {
|
|
30
|
+
return text.replace(ESCAPES, (found) => (OWN.test(found) ? found : ""));
|
|
31
|
+
}
|
|
32
|
+
for (const stream of [process.stdout, process.stderr]) {
|
|
33
|
+
if (!stream.isTTY)
|
|
34
|
+
continue;
|
|
35
|
+
const write = stream.write.bind(stream);
|
|
36
|
+
stream.write = ((chunk, ...rest) => write(typeof chunk === "string" ? printable(chunk) : chunk, ...rest));
|
|
37
|
+
}
|
|
@@ -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);
|
|
@@ -77,6 +77,20 @@ async function commandVerify(parsed) {
|
|
|
77
77
|
console.error((0, colour_js_1.red)("The manifest's signature does not check out. Do not trust these files."));
|
|
78
78
|
return 1;
|
|
79
79
|
}
|
|
80
|
+
/*
|
|
81
|
+
One key signs every project's manifests, so a valid signature alone said
|
|
82
|
+
only that CodeRook signed *some* release. It must be the one asked about,
|
|
83
|
+
or another project's manifest could vouch for these files
|
|
84
|
+
(audit, 16 November 2026).
|
|
85
|
+
*/
|
|
86
|
+
if (String(answer.manifest.project ?? "").toLowerCase() !== project.toLowerCase() ||
|
|
87
|
+
String(answer.manifest.release ?? "") !== release) {
|
|
88
|
+
console.error((0, colour_js_1.red)(`The signed manifest is for ${answer.manifest.project} ${answer.manifest.release}, not ${project} ${release}. Do not trust these files.`));
|
|
89
|
+
return 1;
|
|
90
|
+
}
|
|
91
|
+
if (key === answer.publicKey && typeof pinned !== "string" && !(exports.PINNED_RELEASE_KEY && (0, config_js_1.apiOrigin)() === config_js_1.DEFAULT_API)) {
|
|
92
|
+
console.log((0, colour_js_1.dim)("The signing key came from the same service as the manifest, so this checks the files, not the service. Pass --key to pin one."));
|
|
93
|
+
}
|
|
80
94
|
console.log(`${(0, colour_js_1.green)("✓")} Signed manifest for ${(0, colour_js_1.bold)(`${answer.manifest.project} ${answer.manifest.release}`)} ${(0, colour_js_1.dim)(`(key ${key.slice(0, 12)}…)`)}`);
|
|
81
95
|
let failed = false;
|
|
82
96
|
for (const file of files) {
|
|
@@ -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
|
/**
|
|
@@ -31,6 +32,7 @@ const node_fs_1 = require("node:fs");
|
|
|
31
32
|
const promises_1 = require("node:fs/promises");
|
|
32
33
|
const node_path_1 = __importDefault(require("node:path"));
|
|
33
34
|
const download_js_1 = require("../../cbx/src/core/download.js");
|
|
35
|
+
const safe_path_js_1 = require("../../cbx/src/shared/safe_path.js");
|
|
34
36
|
const worktree_js_1 = require("../../cbx/src/core/worktree.js");
|
|
35
37
|
const api_js_1 = require("./api.js");
|
|
36
38
|
const config_js_1 = require("./config.js");
|
|
@@ -69,7 +71,20 @@ function flag(parsed, ...names) {
|
|
|
69
71
|
return undefined;
|
|
70
72
|
}
|
|
71
73
|
const sha = (bytes) => (0, node_crypto_1.createHash)("sha256").update(bytes).digest("hex");
|
|
72
|
-
|
|
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
|
+
}
|
|
73
88
|
async function readRecord(folder) {
|
|
74
89
|
try {
|
|
75
90
|
return JSON.parse(await (0, promises_1.readFile)(node_path_1.default.join(folder, RECORD), "utf8"));
|
|
@@ -165,7 +180,16 @@ async function checkout(found, draft, workspaceId, into) {
|
|
|
165
180
|
const page = await (0, api_js_1.callApi)(`${draft}/diff?offset=${offset}`);
|
|
166
181
|
revision = page.revision;
|
|
167
182
|
for (const change of page.changes) {
|
|
168
|
-
|
|
183
|
+
/*
|
|
184
|
+
The same rules as every other writer: a draft path the folder must
|
|
185
|
+
not hold (`..`, git's own directory, a drive letter), or one reached
|
|
186
|
+
through a link, is refused, not written or removed. This was the one
|
|
187
|
+
writer that took the service's paths on trust (audit, 16 November 2026).
|
|
188
|
+
*/
|
|
189
|
+
const unsafe = (0, safe_path_js_1.whyUnsafe)(change.path) ?? (await (0, download_js_1.placementProblem)(folder, change.path));
|
|
190
|
+
if (unsafe)
|
|
191
|
+
throw new Error(`The draft holds ${JSON.stringify(change.path)}, which cannot be written here (${unsafe}); nothing past it was changed.`);
|
|
192
|
+
const target = (0, safe_path_js_1.inside)(folder, change.path);
|
|
169
193
|
if (change.removed || !change.after) {
|
|
170
194
|
await (0, promises_1.rm)(target, { force: true });
|
|
171
195
|
delete manifest[change.path];
|
|
@@ -264,7 +288,7 @@ async function push(parsed, where) {
|
|
|
264
288
|
for (const batch of (0, workspace_put_js_1.batches)(changes, sizes)) {
|
|
265
289
|
const result = await (0, api_js_1.callApi)(`${draft}/changes`, {
|
|
266
290
|
method: "POST",
|
|
267
|
-
body: { expectedRevision: revision, operationKey:
|
|
291
|
+
body: { expectedRevision: revision, operationKey: pushKey("push", record.workspaceId, revision, batch), changes: batch },
|
|
268
292
|
});
|
|
269
293
|
revision = result.workspace.revision;
|
|
270
294
|
for (const one of batch) {
|
|
@@ -286,7 +310,7 @@ async function push(parsed, where) {
|
|
|
286
310
|
}
|
|
287
311
|
const saved = await (0, api_js_1.callApi)(`${draft}/save`, {
|
|
288
312
|
method: "POST",
|
|
289
|
-
body: { expectedRevision: revision, operationKey:
|
|
313
|
+
body: { expectedRevision: revision, operationKey: pushKey("save", record.workspaceId, revision, message), message },
|
|
290
314
|
});
|
|
291
315
|
if (saved.mergeTrack) {
|
|
292
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
|
}
|