@coderook/cli 0.46.7 → 0.46.9
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/README.md +4 -0
- package/dist/cbx/src/core/download.js +212 -34
- package/dist/cbx/src/core/upload.js +12 -1
- package/dist/cbx/src/shared/merge_diff.js +136 -0
- package/dist/cli/src/cli.js +59 -10
- package/dist/cli/src/diff_command.js +32 -34
- package/dist/cli/src/paint.js +3 -1
- package/dist/cli/src/project_commands.js +4 -2
- package/dist/cli/src/remote_restore.js +20 -24
- package/dist/cli/src/workspace_command.js +14 -1
- package/dist/cli/src/workspace_put.js +34 -6
- package/dist/cli/src/workspace_review.js +15 -7
- package/dist/cli/src/workspace_starter.js +61 -7
- package/package.json +2 -2
|
@@ -21,6 +21,54 @@ const promises_1 = require("node:fs/promises");
|
|
|
21
21
|
const node_path_1 = require("node:path");
|
|
22
22
|
const api_js_1 = require("./api.js");
|
|
23
23
|
const colour_js_1 = require("./colour.js");
|
|
24
|
+
/*
|
|
25
|
+
Installs Rust where the runner has none; CodeRook's hosted runner does not ship
|
|
26
|
+
it. Nor a C compiler, which most crates' build scripts link with ("linker `cc`
|
|
27
|
+
not found", 2026-11-11), so gcc comes too when cc is missing.
|
|
28
|
+
*/
|
|
29
|
+
const CARGO = "command -v cc >/dev/null 2>&1 || { S=; [ \"$(id -u)\" = 0 ] || S=sudo; $S apt-get update -qq && $S apt-get install -y -qq --no-install-recommends gcc libc6-dev; }; " +
|
|
30
|
+
"command -v cargo >/dev/null 2>&1 || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal; }; " +
|
|
31
|
+
'. "$HOME/.cargo/env" 2>/dev/null; cargo test';
|
|
32
|
+
/** Sibling folders a package reaches with ../, from its tsconfig and file: dependencies. */
|
|
33
|
+
function siblingsOf(directory, seen) {
|
|
34
|
+
if (!directory)
|
|
35
|
+
return [];
|
|
36
|
+
const at = (name) => `${directory}/${name}`;
|
|
37
|
+
const found = new Set();
|
|
38
|
+
const add = (relative) => {
|
|
39
|
+
const parts = [...directory.split("/"), ...relative.split("/")];
|
|
40
|
+
const out = [];
|
|
41
|
+
for (const part of parts) {
|
|
42
|
+
if (!part || part === ".")
|
|
43
|
+
continue;
|
|
44
|
+
if (part === "..")
|
|
45
|
+
out.pop();
|
|
46
|
+
else
|
|
47
|
+
out.push(part);
|
|
48
|
+
}
|
|
49
|
+
const top = out.join("/");
|
|
50
|
+
if (top && top !== directory && !top.startsWith(`${directory}/`))
|
|
51
|
+
found.add(top);
|
|
52
|
+
};
|
|
53
|
+
const text = seen.get(at("tsconfig.json")) ?? "";
|
|
54
|
+
for (const match of text.matchAll(/"((?:\.\.\/)+[A-Za-z0-9_.-]+)/g))
|
|
55
|
+
add(match[1]);
|
|
56
|
+
try {
|
|
57
|
+
const pkg = JSON.parse(seen.get(at("package.json")) ?? "{}");
|
|
58
|
+
for (const group of ["dependencies", "devDependencies", "optionalDependencies"]) {
|
|
59
|
+
for (const value of Object.values(pkg[group] ?? {})) {
|
|
60
|
+
const local = /^file:((?:\.\.\/)+[A-Za-z0-9_.-]+)/.exec(String(value));
|
|
61
|
+
if (local)
|
|
62
|
+
add(local[1]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
/* A package.json that does not parse already produced no starter. */
|
|
68
|
+
}
|
|
69
|
+
return [...found].sort();
|
|
70
|
+
}
|
|
71
|
+
const pathsFor = (directory, extra = []) => directory ? [`${directory}/`, ...extra.map((one) => `${one}/`)] : [];
|
|
24
72
|
const SKIP = new Set(["node_modules", ".git", ".coderook", ".rook", "dist", "build", "target", ".venv", "venv", "vendor", ".next"]);
|
|
25
73
|
const slug = (directory) => (directory.split("/").pop() || "project").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "project";
|
|
26
74
|
function nodeStarter(directory, seen) {
|
|
@@ -50,6 +98,7 @@ function nodeStarter(directory, seen) {
|
|
|
50
98
|
directory,
|
|
51
99
|
command: [install, ...steps.map((s) => `${run} ${s}`)].join(" && "),
|
|
52
100
|
because: `package.json scripts: ${steps.join(", ")}`,
|
|
101
|
+
includePaths: pathsFor(directory, siblingsOf(directory, seen)),
|
|
53
102
|
};
|
|
54
103
|
}
|
|
55
104
|
/** The starters a folder's files suggest, one per recognised package. */
|
|
@@ -66,12 +115,12 @@ function detectStarters(seen) {
|
|
|
66
115
|
if (node)
|
|
67
116
|
out.push(node);
|
|
68
117
|
else if (seen.has(at("Cargo.toml")))
|
|
69
|
-
out.push({ recipe: `${slug(directory)}-check`, workflow: `Draft check · ${directory || "project"}`, directory, command:
|
|
118
|
+
out.push({ recipe: `${slug(directory)}-check`, workflow: `Draft check · ${directory || "project"}`, directory, command: CARGO, because: "Cargo.toml (Rust is installed on the runner if missing)", includePaths: pathsFor(directory) });
|
|
70
119
|
else if (seen.has(at("go.mod")))
|
|
71
|
-
out.push({ recipe: `${slug(directory)}-check`, workflow: `Draft check · ${directory || "project"}`, directory, command: "go vet ./... && go test ./...", because: "go.mod" });
|
|
120
|
+
out.push({ recipe: `${slug(directory)}-check`, workflow: `Draft check · ${directory || "project"}`, directory, command: "go vet ./... && go test ./...", because: "go.mod", includePaths: pathsFor(directory) });
|
|
72
121
|
else if (seen.has(at("pyproject.toml")) || seen.has(at("requirements.txt"))) {
|
|
73
122
|
const install = seen.has(at("requirements.txt")) ? "python -m pip install -r requirements.txt" : "python -m pip install -e .";
|
|
74
|
-
out.push({ recipe: `${slug(directory)}-check`, workflow: `Draft check · ${directory || "project"}`, directory, command: `${install} && python -m pytest`, because: seen.has(at("pyproject.toml")) ? "pyproject.toml" : "requirements.txt" });
|
|
123
|
+
out.push({ recipe: `${slug(directory)}-check`, workflow: `Draft check · ${directory || "project"}`, directory, command: `${install} && python -m pytest`, because: seen.has(at("pyproject.toml")) ? "pyproject.toml" : "requirements.txt", includePaths: pathsFor(directory) });
|
|
75
124
|
}
|
|
76
125
|
}
|
|
77
126
|
/* Two folders with the same last name ("app/web", "site/web") keep apart by their full path. */
|
|
@@ -83,7 +132,9 @@ function detectStarters(seen) {
|
|
|
83
132
|
s.recipe = `${s.directory.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "project"}-check`;
|
|
84
133
|
return out;
|
|
85
134
|
}
|
|
86
|
-
const MARKERS = new Set(["package.json", "package-lock.json", "pnpm-lock.yaml", "yarn.lock", "Cargo.toml", "go.mod", "pyproject.toml", "requirements.txt"]);
|
|
135
|
+
const MARKERS = new Set(["package.json", "package-lock.json", "pnpm-lock.yaml", "yarn.lock", "Cargo.toml", "go.mod", "pyproject.toml", "requirements.txt", "tsconfig.json"]);
|
|
136
|
+
/* Read for what they say, not only noticed. */
|
|
137
|
+
const READ = new Set(["package.json", "tsconfig.json"]);
|
|
87
138
|
/** The marker files in a folder, two levels deep, skipping dependencies and build output. */
|
|
88
139
|
async function scan(root) {
|
|
89
140
|
const seen = new Map();
|
|
@@ -96,7 +147,7 @@ async function scan(root) {
|
|
|
96
147
|
await walk(path, depth + 1);
|
|
97
148
|
}
|
|
98
149
|
else if (MARKERS.has(entry.name)) {
|
|
99
|
-
seen.set(path, entry.name
|
|
150
|
+
seen.set(path, READ.has(entry.name) ? await (0, promises_1.readFile)((0, node_path_1.join)(root, ...path.split("/")), "utf8") : "");
|
|
100
151
|
}
|
|
101
152
|
}
|
|
102
153
|
};
|
|
@@ -126,8 +177,11 @@ async function commandWorkspaceStarter(parsed, root) {
|
|
|
126
177
|
for (const s of starters) {
|
|
127
178
|
const kept = taken.has(s.recipe);
|
|
128
179
|
console.log(`${kept ? (0, colour_js_1.dim)("exists ") : (0, colour_js_1.green)("new ")} ${(0, colour_js_1.bold)(s.recipe)} ${(0, colour_js_1.dim)(`in ${s.directory || "."}`)}`);
|
|
129
|
-
if (!kept)
|
|
180
|
+
if (!kept) {
|
|
130
181
|
console.log(` ${s.command}\n ${(0, colour_js_1.dim)(s.because)}`);
|
|
182
|
+
if (s.includePaths.length > 1)
|
|
183
|
+
console.log(` ${(0, colour_js_1.dim)(`also sends ${s.includePaths.slice(1).join(", ")} (it builds from them)`)}`);
|
|
184
|
+
}
|
|
131
185
|
}
|
|
132
186
|
console.log(fresh.length
|
|
133
187
|
? (0, colour_js_1.dim)(`\nNothing was created. Add ${fresh.length === 1 ? "it" : "them"} with `) + (0, colour_js_1.accent)("--apply") + (0, colour_js_1.dim)("; drafts then run them with cbx workspace run <project> <draft> --recipe <name>.")
|
|
@@ -150,7 +204,7 @@ async function commandWorkspaceStarter(parsed, root) {
|
|
|
150
204
|
}
|
|
151
205
|
await (0, api_js_1.callApi)(`${root}/workspace-recipes/${encodeURIComponent(s.recipe)}`, {
|
|
152
206
|
method: "PUT",
|
|
153
|
-
body: { kind: "check", workflowId, includePaths: s.
|
|
207
|
+
body: { kind: "check", workflowId, includePaths: s.includePaths },
|
|
154
208
|
});
|
|
155
209
|
made.push(s.recipe);
|
|
156
210
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderook/cli",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.9",
|
|
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",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"test:matrix": "node test/state-matrix.mjs",
|
|
45
45
|
"test:attempt": "node test/attempt-identity.mjs",
|
|
46
46
|
"test:get": "node test/get-safety.mjs",
|
|
47
|
-
"test:live": "node test/e2e.mjs --allow-production && node test/state-matrix.mjs --allow-production && node test/get-safety.mjs --allow-production && node test/get-track.mjs --allow-production && node test/get-protects-edits.mjs --allow-production && node test/upgrade-migration.mjs --allow-production && node test/fault-get.mjs --allow-production && node test/version-floor.mjs --allow-production && node test/fault-submit.mjs --allow-production && node test/race-attempts.mjs --allow-production && node test/attempt-identity.mjs --allow-production",
|
|
47
|
+
"test:live": "node test/e2e.mjs --allow-production && node test/state-matrix.mjs --allow-production && node test/get-safety.mjs --allow-production && node test/get-track.mjs --allow-production && node test/get-protects-edits.mjs --allow-production && node test/upgrade-migration.mjs --allow-production && node test/fault-get.mjs --allow-production && node test/rename-sync.mjs --allow-production && node test/exercise-fixes.mjs --allow-production && node test/version-floor.mjs --allow-production && node test/fault-submit.mjs --allow-production && node test/race-attempts.mjs --allow-production && node test/attempt-identity.mjs --allow-production",
|
|
48
48
|
"test:getedits": "node test/get-protects-edits.mjs",
|
|
49
49
|
"test:upgrade": "node test/upgrade-migration.mjs",
|
|
50
50
|
"test:faultget": "node test/fault-get.mjs",
|