@coderook/cli 0.47.2 → 0.48.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.47.2",
5
+ "version": "0.48.0",
6
6
  "author": {
7
7
  "name": "ACCA Gaming Productions",
8
8
  "url": "https://coderook.com"
package/README.md CHANGED
@@ -598,6 +598,24 @@ https://api.coderook.com/v1/public/projects/OWNER/SLUG/releases
598
598
  https://api.coderook.com/v1/public/projects/OWNER/SLUG/updates electron-updater's generic provider
599
599
  ```
600
600
 
601
+ ## A copy on another git host
602
+
603
+ ```
604
+ cbx mirror set https://github.com/you/project.git push each save to main there as well
605
+ cbx mirror set <url> --lines main,beta or to these lines' branches
606
+ cbx mirror where it goes and whether it is up to date
607
+ cbx mirror push send the newest version after commits made there
608
+ cbx mirror off stop
609
+ ```
610
+
611
+ Each save is pushed as one commit on top of the last. It never forces: if
612
+ somebody else pushed to that branch, the mirror stops and says so until
613
+ `cbx mirror push` puts CodeRook's newest version after their commits. A branch
614
+ that already holds the same files is left alone, so a project also updated
615
+ from that remote does not loop. The token needs push access and is read like a
616
+ secret: piped in, from `--from-env VAR`, or typed at a hidden prompt. Only the
617
+ project's administrators can set a mirror.
618
+
601
619
  ## Mod repositories for games
602
620
 
603
621
  A mod repository is where a game's players get mods from. The game's maker
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.commandSecret = commandSecret;
7
+ exports.commandMirror = commandMirror;
7
8
  exports.commandCheckWorkflows = commandCheckWorkflows;
8
9
  exports.commandSetWorkflow = commandSetWorkflow;
9
10
  exports.commandApprove = commandApprove;
@@ -119,6 +120,80 @@ async function commandSecret(parsed) {
119
120
  console.error((0, colour_js_1.red)(`cbx secret has no "${sub}". `) + "Try: list, set, remove");
120
121
  return 1;
121
122
  }
123
+ /**
124
+ * cbx mirror [status] | set <https-url> [--lines main,release] | push | off
125
+ *
126
+ * Keeps the project on another git host as well: after each save to the named
127
+ * lines, CodeRook pushes it to the remote's branch of the same name, never
128
+ * forcing (the service's project_mirror.ts). The token is read like a
129
+ * secret's value, never from an argument.
130
+ */
131
+ async function commandMirror(parsed) {
132
+ const sub = parsed.positional[0] ?? "status";
133
+ const project = await (0, project_commands_js_1.resolveProject)(projectFlag(parsed));
134
+ if (!project)
135
+ return 1;
136
+ const base = `/v1/repositories/${encodeURIComponent(project.id)}/mirror`;
137
+ if (sub === "status") {
138
+ const { mirror } = await (0, api_js_1.callApi)(base);
139
+ if (!mirror) {
140
+ console.log(`${(0, colour_js_1.bold)(project.slug)} is not mirrored anywhere.`);
141
+ console.log((0, colour_js_1.dim)(" Set one up: cbx mirror set https://github.com/you/project.git (you are asked for a token)"));
142
+ return 0;
143
+ }
144
+ const state = mirror.state === "ok" ? (0, colour_js_1.green)("up to date") : mirror.state === "diverged" ? (0, colour_js_1.red)("stopped") : mirror.state === "failed" ? (0, colour_js_1.red)("failing") : (0, colour_js_1.dim)("not pushed yet");
145
+ console.log(`${(0, colour_js_1.bold)(project.slug)} mirrors to ${(0, colour_js_1.accent)(mirror.remoteUrl)} ${mirror.enabled ? "" : (0, colour_js_1.dim)("(paused)")}`);
146
+ console.log(` Lines ${mirror.lines.join(", ")}`);
147
+ console.log(` State ${state}${mirror.lastSuccessAt ? (0, colour_js_1.dim)(`, last pushed ${new Date(mirror.lastSuccessAt).toLocaleString()}`) : ""}`);
148
+ if (mirror.detail)
149
+ console.log(` ${mirror.detail}`);
150
+ if (mirror.state === "diverged")
151
+ console.log((0, colour_js_1.dim)(" To send CodeRook's newest version after the remote's own commits: cbx mirror push"));
152
+ return 0;
153
+ }
154
+ if (sub === "set") {
155
+ const remoteUrl = (parsed.positional[1] ?? "").trim();
156
+ if (!remoteUrl) {
157
+ console.error((0, colour_js_1.red)("Give the remote's address: cbx mirror set https://github.com/you/project.git"));
158
+ return 1;
159
+ }
160
+ const linesFlag = parsed.flags.get("lines");
161
+ const lines = typeof linesFlag === "string" ? linesFlag.split(",").map((line) => line.trim()).filter(Boolean) : undefined;
162
+ const { mirror: current } = await (0, api_js_1.callApi)(base);
163
+ /* A token is needed the first time and for a new remote; otherwise only when one is offered. */
164
+ let normalised = remoteUrl;
165
+ try {
166
+ normalised = new URL(remoteUrl).toString();
167
+ }
168
+ catch { /* the service says what is wrong with it */ }
169
+ const needsToken = !current || current.remoteUrl !== normalised || parsed.flags.has("from-env") || !process.stdin.isTTY;
170
+ const token = needsToken ? await readSecretValue("the remote's access token (it needs permission to push)", parsed) : null;
171
+ if (needsToken && !token) {
172
+ console.error((0, colour_js_1.red)("No token was entered, so nothing was saved."));
173
+ return 1;
174
+ }
175
+ const { mirror } = await (0, api_js_1.callApi)(base, {
176
+ method: "PUT",
177
+ body: { remoteUrl, lines: lines ?? current?.lines ?? ["main"], ...(token ? { token } : {}), enabled: !parsed.flags.has("paused") },
178
+ });
179
+ console.log(`${(0, colour_js_1.green)("Mirroring")} ${mirror.lines.join(", ")} to ${(0, colour_js_1.accent)(mirror.remoteUrl)}.`);
180
+ console.log((0, colour_js_1.dim)(" Each save to those lines is pushed after it lands. It never forces: if the remote has commits"));
181
+ console.log((0, colour_js_1.dim)(" CodeRook did not push, it stops and tells you. Its runs show under cbx runs."));
182
+ return 0;
183
+ }
184
+ if (sub === "push") {
185
+ const { queued } = await (0, api_js_1.callApi)(`${base}/push`, { method: "POST" });
186
+ console.log(queued ? `${(0, colour_js_1.green)("Pushing")} the newest version of ${queued === 1 ? "1 line" : `${queued} lines`}.` : "Nothing to push: none of the mirrored lines has a save yet.");
187
+ return 0;
188
+ }
189
+ if (sub === "off" || sub === "remove") {
190
+ await (0, api_js_1.callApi)(base, { method: "DELETE" });
191
+ console.log(`${(0, colour_js_1.green)("Stopped mirroring")} ${project.slug}. The token is deleted; the remote is left as it is.`);
192
+ return 0;
193
+ }
194
+ console.error((0, colour_js_1.red)(`cbx mirror has no "${sub}". `) + "Try: status, set, push, off");
195
+ return 1;
196
+ }
122
197
  const EVENT_WORDS = {
123
198
  manual: "by hand",
124
199
  version_saved: "on save",
@@ -4268,6 +4268,39 @@ const SPECS = [
4268
4268
  ],
4269
4269
  run: actions_command_js_1.commandSecret,
4270
4270
  },
4271
+ {
4272
+ name: "mirror",
4273
+ group: "Project settings",
4274
+ summary: "keep the project on another git host as well",
4275
+ usage: "mirror [status] | set <url> | push | off",
4276
+ arguments: {
4277
+ "[status]": "show where the project is mirrored and whether it is up to date (the default)",
4278
+ "<url>": "the remote's https address, like https://github.com/you/project.git",
4279
+ },
4280
+ brief: "mirror status|set|push|off",
4281
+ detail: "After each save to the named lines (main by default), CodeRook pushes it\n" +
4282
+ "to the remote's branch of the same name, as one commit. It never forces:\n" +
4283
+ "if somebody else has pushed there, it stops and tells you, and\n" +
4284
+ "`cbx mirror push` sends CodeRook's newest version after their commits.\n" +
4285
+ "A branch already holding the same files is left alone, so a project that\n" +
4286
+ "is also updated from that remote does not loop.\n\n" +
4287
+ "The token needs permission to push. It is read like a secret's value:\n" +
4288
+ "piped in, from --from-env, or typed at a hidden prompt.",
4289
+ options: [
4290
+ { flags: "--lines <a,b>", description: "which lines to mirror (default main)" },
4291
+ { flags: "--from-env <VAR>", description: "take the token from this environment variable" },
4292
+ { flags: "--paused", description: "save the settings without pushing yet" },
4293
+ { flags: "--project <name>", description: "which project" },
4294
+ ],
4295
+ examples: [
4296
+ "cbx mirror set https://github.com/you/project.git",
4297
+ "cbx mirror set https://github.com/you/project.git --lines main,release",
4298
+ "cbx mirror",
4299
+ "cbx mirror push",
4300
+ "cbx mirror off",
4301
+ ],
4302
+ run: actions_command_js_1.commandMirror,
4303
+ },
4271
4304
  {
4272
4305
  name: "runs",
4273
4306
  group: "Actions and builds",
@@ -43,7 +43,7 @@ exports.LISTING_ORDER = [
43
43
  "tracks", "line-rules", "merges", "merge", "propose", "proposals", "pr",
44
44
  "versions", "files", "mark", "notes", "labels", "promote", "release", "releases", "attach", "held", "review", "undo",
45
45
  "take-down", "verify", "deps",
46
- "about", "features", "visibility", "ai", "private", "upload-rules", "people", "watch", "hooks", "secret", "assistant",
46
+ "about", "features", "visibility", "ai", "private", "upload-rules", "people", "watch", "hooks", "secret", "mirror", "assistant",
47
47
  "security", "pages", "fork", "hand-over", "delete",
48
48
  "issues", "issue",
49
49
  "actions", "runs", "logs", "cancel", "rerun", "approve", "runner", "power", "build", "machines",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coderook/cli",
3
- "version": "0.47.2",
3
+ "version": "0.48.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",
@@ -387,6 +387,16 @@ project's owner; never put vulnerability details in a public issue.
387
387
  `cbx verify owner/project v2.0 ./file` checks a download; `cbx deps` lists
388
388
  known vulnerabilities in the lockfiles. Ask before publishing.
389
389
 
390
+ ## A copy on another git host
391
+
392
+ `cbx mirror set https://github.com/you/project.git` makes CodeRook push each
393
+ save to `main` (or `--lines a,b`) to that remote's branch of the same name. It
394
+ never forces: if somebody pushed there first it stops, `cbx mirror` says so,
395
+ and `cbx mirror push` sends the newest version after their commits. `cbx mirror
396
+ off` stops it. The token is read like a secret (piped, `--from-env VAR`, or a
397
+ hidden prompt), so let the person give it; never put it on the command line.
398
+ Only a project's administrators can set a mirror. Ask before setting one.
399
+
390
400
  ## Mod repositories for games
391
401
 
392
402
  A game's maker can run a mod repository: players' game clients read a signed