iterate.com / kernel

git clone https://git.iterate.com/repos/kernel

The flags of a birth are --kernel-repo and --config-repo

`iterate deploy --kernel-repo <address> --config-repo <address>`: Misha's choice of
names, so that `--config` means one thing in this CLI, the profile to sign in with.

With no flag of a command named `--config` any more, the profile flag is read as it
was before 126eb7a, wherever it stands: `profileFlagIn` and its spec are gone, and
that part of cli.ts is upstream's again.

Run for real over the second mind with `--plan`: each flag reached the deploy and was
refused there as a flag of a birth, with nothing changed. `--kernel` is now an unknown
option.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

Misha Kaletsky, 2026-11-25 21:21 UTC · 8d212b857bed022189435bac2f3243c0e35944d5 · parent 126eb7a

5 files changed

M core/lib/src/cli/README.md
@@ -146,14 +146,14 @@
      deploy ([The mind's identity key](#the-minds-identity-key)). A mind that is there already
      keeps its own.
 7. **The kernel.** Which one a deploy builds:
-   - **A new mind:** the repo that `--kernel <address>` names, at its `main` (`--ref <branch>`
-     takes another branch). The mind clones the same repo at birth, so its own `/repos/kernel`
-     holds the commit that it runs. The command fetches it into
+   - **A new mind:** the repo that `--kernel-repo <address>` names, at its `main`
+     (`--ref <branch>` takes another branch). The mind clones the same repo at birth, so its own
+     `/repos/kernel` holds the commit that it runs. The command fetches it into
      `${XDG_CACHE_HOME:-~/.cache}/iterate/kernel` with git, sending no credential.
    - **A mind that is there:** its own `/repos/kernel`, read with the Cloudflare access the
      command holds. Nothing is fetched from outside the mind. So a deploy for another reason
      builds the same kernel again, and a new kernel arrives by a pull or a merge into that repo
-     first. `--kernel` and `--config` are refused here: they are for a birth.
+     first. `--kernel-repo` and `--config-repo` are refused here: they are for a birth.
    - **`--source <folder>`:** a checkout on this computer, whatever it holds, over any mind. For
      someone who works on the kernel, and for the mind that hosts the source.
 
@@ -635,9 +635,6 @@
 the profile the current folder or a parent of it is mapped to, the default profile, the only
 profile, then `default`. `iterate login <address>` points the selected profile at the mind.
 `--mind <address>` names another mind for one command, with that mind's own sign-in.
-
-`--config <profile>` stands before the command. After the command the flag is the command's own:
-`iterate deploy --config <address>` names the repo that a new mind's config starts as.
 
 ```sh
 iterate login example.com                  # the profile `default`
M core/lib/src/cli/cli.test.ts
@@ -3,19 +3,7 @@
 import { fileURLToPath } from "node:url";
 import { expect, test } from "vitest";
 import { z } from "zod";
-import { packageVersionOf, profileFlagIn } from "./cli.ts";
-
-test("--config before the command picks a profile; after the command it is the command's own flag", () => {
-  expect(profileFlagIn(["--config", "lab", "whoami"])).toEqual({
-    profile: "lab",
-    rest: ["whoami"],
-  });
-
-  const birth = ["deploy", "--config", "https://git.mindlew.com/repos/config-template"];
-  expect(profileFlagIn(birth)).toEqual({ profile: undefined, rest: birth });
-
-  expect(() => profileFlagIn(["--config"])).toThrow("--config requires a value");
-});
+import { packageVersionOf } from "./cli.ts";
 
 test("iterate --version and -v print the package version and exit 0", () => {
   const pkg = z
M core/lib/src/cli/cli.ts
@@ -1,8 +1,8 @@
 // cli.ts — THE `iterate` CLI: sign in to a mind by its address, run scripts in it, and lend it
 // what runs on this machine (a file's functions, a local port, this computer). A profile
-// (./config.ts) names one mind; `--config <name>` before the command, a folder mapped to a
-// profile, the default profile, or the only one picks it, and `--mind <address>` overrides it for
-// one command. Every connection is the Node client's (../node.ts `connectMind`).
+// (./config.ts) names one mind; `--config <name>`, a folder mapped to a profile, the default
+// profile, or the only one picks it, and `--mind <address>` overrides it for one command. Every
+// connection is the Node client's (../node.ts `connectMind`).
 import { spawnSync } from "node:child_process";
 import { existsSync, readFileSync, rmSync } from "node:fs";
 import { readFile } from "node:fs/promises";
@@ -54,18 +54,16 @@
 
 const isAgent = isCodingAgent(process.env);
 let configFlagOverride: string | undefined;
+const consumeCliStringFlag = (flagName: string): string | undefined => {
+  const args = process.argv.slice(2);
+  const flagIndex = args.indexOf(flagName);
+  if (flagIndex === -1) return undefined;
+  const value = args[flagIndex + 1];
+  if (!value || value.startsWith("-")) throw new Error(`${flagName} requires a value`);
+  process.argv.splice(flagIndex + 2, 2);
+  return value;
+};
 
-/** THE CLI'S OWN FLAG `--config <profile>` STANDS BEFORE THE COMMAND: `iterate --config lab
- *  whoami`. A `--config` after the command is that command's own flag and is left where it is:
- *  `iterate deploy --config <address>` names the repo that a new mind's config starts as. Answers
- *  the profile, and the arguments without the flag. */
-export function profileFlagIn(args: string[]) {
-  if (args[0] !== "--config") return { profile: undefined, rest: args };
-  const profile = args[1];
-  if (!profile || profile.startsWith("-")) throw new Error("--config requires a value");
-  return { profile, rest: args.slice(2) };
-}
-
 /**
  * Which profile to use. Priority: --config flag > workspace match (walk up from cwd) > default >
  * the only profile > `default`.
@@ -292,13 +290,13 @@
           .describe(
             "Forward each mail to the mind there as it arrived, a verified destination address of the account's Email Routing; none stops it (default: none; for a mind that is there already: the one it has)",
           ),
-        kernel: z
+        kernelRepo: z
           .string()
           .optional()
           .describe(
             "For a new mind: the https address of the kernel repo, such as https://git.<a mind's domain>/repos/kernel. The deploy builds it, and the mind clones it at birth as its own /repos/kernel. Refused over a mind that is there, whose own /repos/kernel is what a deploy builds",
           ),
-        config: z
+        configRepo: z
           .string()
           .optional()
           .describe(
@@ -330,7 +328,7 @@
           .string()
           .optional()
           .describe(
-            "A checkout of iterate's kernel on this computer to deploy, whatever it holds, over any mind (default: none; a new mind's kernel is the repo that --kernel names, and a mind that is there builds its own /repos/kernel)",
+            "A checkout of iterate's kernel on this computer to deploy, whatever it holds, over any mind (default: none; a new mind's kernel is the repo that --kernel-repo names, and a mind that is there builds its own /repos/kernel)",
           ),
         ref: z
           .string()
@@ -906,9 +904,7 @@
     process.exitCode = await runFs(process.argv.slice(3), process);
     return;
   }
-  const { profile, rest } = profileFlagIn(process.argv.slice(2));
-  configFlagOverride = profile;
-  process.argv.splice(2, process.argv.length, ...rest);
+  configFlagOverride = consumeCliStringFlag("--config");
   if (process.argv.length === 2) process.argv.push("--help");
   if (process.argv.length === 3 && process.argv[2] === "-v") process.argv[2] = "--version";
   const cli = createCli({
M core/lib/src/cli/deploy.test.ts
@@ -117,8 +117,8 @@
   accountId: "0".repeat(32),
   domain: "ada-labs.com",
   owner: "Ada@Example.org",
-  kernel: "https://git.mindlew.com/repos/kernel",
-  config: "https://git.mindlew.com/repos/config-template",
+  kernelRepo: "https://git.mindlew.com/repos/kernel",
+  configRepo: "https://git.mindlew.com/repos/config-template",
 };
 
 test("a new mind's config is the script's one input but for its id: the zone whole, one owner, iterate.<zone>, and the stage from the zone", () => {
@@ -162,62 +162,66 @@
   expect(() => deployConfigOf({ ...answers, owner: undefined })).toThrow(/is an email address/);
 });
 
-test("a new mind's deploy names two repos, the kernel's and its config, each with the address it is cloned from; --config none starts the mind with empty repos", () => {
-  const reposOf = (flags: { kernel?: string; config?: string }) =>
+test("a new mind's deploy names two repos, the kernel's and its config, each with the address it is cloned from; --config-repo none starts the mind with empty repos", () => {
+  const reposOf = (flags: { kernelRepo?: string; configRepo?: string }) =>
     deployConfigOf({ accountId: "0".repeat(32), domain: "ada-labs.com", owner: "ada@example.org", ...flags }).repos;
 
   expect(
     reposOf({
-      kernel: "https://git.ada-labs.com/repos/kernel",
-      config: "https://git.ada-labs.com/repos/config-template/",
+      kernelRepo: "https://git.ada-labs.com/repos/kernel",
+      configRepo: "https://git.ada-labs.com/repos/config-template/",
     }),
   ).toEqual([
     { path: "/repos/kernel", origin: "https://git.ada-labs.com/repos/kernel" },
     { path: "/repos/config", origin: "https://git.ada-labs.com/repos/config-template" },
   ]);
   // the mind that hosts the source is deployed from a checkout, and its repos get their code by pushes
-  expect(reposOf({ config: "none" })).toEqual([
+  expect(reposOf({ configRepo: "none" })).toEqual([
     { path: "/repos/kernel", origin: null },
     { path: "/repos/config", origin: null },
   ]);
-  expect(() => reposOf({ config: "somewhere" })).toThrow("--config somewhere is no address");
-  expect(() => reposOf({ kernel: "git@ada-labs.com:kernel", config: "none" })).toThrow(
-    "--kernel git@ada-labs.com:kernel is no address",
+  expect(() => reposOf({ configRepo: "somewhere" })).toThrow(
+    "--config-repo somewhere is no address",
   );
-  expect(() => reposOf({})).toThrow("A new mind needs --config");
+  expect(() => reposOf({ kernelRepo: "git@ada-labs.com:kernel", configRepo: "none" })).toThrow(
+    "--kernel-repo git@ada-labs.com:kernel is no address",
+  );
+  expect(() => reposOf({})).toThrow("A new mind needs --config-repo");
 });
 
-test("the kernel that a deploy builds: the checkout that --source names, the address that --kernel names for a new mind, and for a mind that is there its own kernel repo", () => {
-  const kernel = "https://git.ada-labs.com/repos/kernel";
+test("the kernel that a deploy builds: the checkout that --source names, the address that --kernel-repo names for a new mind, and for a mind that is there its own kernel repo", () => {
+  const kernelRepo = "https://git.ada-labs.com/repos/kernel";
   const newMind = { deployed: false, begunWith: null };
-  const mindThatIs = { deployed: true, begunWith: kernel };
+  const mindThatIs = { deployed: true, begunWith: kernelRepo };
 
   expect(kernelPlanOf({ source: "/work/kernel" }, newMind)).toEqual({
     kind: "checkout",
     dir: "/work/kernel",
   });
-  expect(kernelPlanOf({ kernel, ref: "next" }, newMind)).toEqual({
+  expect(kernelPlanOf({ kernelRepo, ref: "next" }, newMind)).toEqual({
     kind: "address",
-    origin: kernel,
+    origin: kernelRepo,
     ref: "next",
   });
   // a deploy for any other reason builds what the mind's own kernel repo holds: nothing is fetched from outside
   expect(kernelPlanOf({}, mindThatIs)).toEqual({ kind: "own", ref: "main" });
   // a deploy that stopped before the mind was there goes on with the kernel it named
-  expect(kernelPlanOf({}, { deployed: false, begunWith: kernel })).toEqual({
+  expect(kernelPlanOf({}, { deployed: false, begunWith: kernelRepo })).toEqual({
     kind: "address",
-    origin: kernel,
+    origin: kernelRepo,
     ref: "main",
   });
   expect(() => kernelPlanOf({}, newMind)).toThrow(
-    "A new mind needs a kernel: --kernel with the address of a kernel repo, or --source with a checkout of one.",
+    "A new mind needs a kernel: --kernel-repo with the address of a kernel repo, or --source with a checkout of one.",
   );
   // the flags of a birth say where a new mind's repos come from: a mind that is there has its own
-  expect(() => kernelPlanOf({ kernel }, mindThatIs)).toThrow(
-    "--kernel is for a mind's birth. This mind has a kernel repo of its own: bring the change into /repos/kernel there, then deploy.",
+  expect(() => kernelPlanOf({ kernelRepo }, mindThatIs)).toThrow(
+    "--kernel-repo is for a mind's birth. This mind has a kernel repo of its own: bring the change into /repos/kernel there, then deploy.",
   );
-  expect(() => kernelPlanOf({ config: "https://git.ada-labs.com/repos/config" }, mindThatIs)).toThrow(
-    "--config is for a mind's birth. This mind has a config repo of its own: change /repos/config there.",
+  expect(() =>
+    kernelPlanOf({ configRepo: "https://git.ada-labs.com/repos/config" }, mindThatIs),
+  ).toThrow(
+    "--config-repo is for a mind's birth. This mind has a config repo of its own: change /repos/config there.",
   );
   // a checkout is deployed over any mind: that is how a kernel is tried before it is in a repo
   expect(kernelPlanOf({ source: "/work/kernel" }, mindThatIs)).toMatchObject({ kind: "checkout" });
@@ -1813,7 +1817,7 @@
     domain: "ada-labs.com",
     owner: "cf@work.com",
     extraOwners: ["Personal@Gmail.com", "cf@work.com"],
-    config: "none",
+    configRepo: "none",
   });
   expect(config).toMatchObject({ ownerEmails: ["cf@work.com", "personal@gmail.com"] });
 });
M core/lib/src/cli/deploy.ts

Not shown: the change is larger than this page shows. A clone has it.