iterate.com / config-template

git clone https://git.iterate.com/repos/config-template

config-template / README.mdmain at 3b8ad1b

# config

This mind's wiring. `worker.ts` is the first file the mind loads: it says which app answers on
which hostname, what a mail does, and what runs at each event. `AGENTS.md` says how the mind's
repos fit together, and every agent is told it.

It began as a clone of `config-template`, the config that every new mind starts with. It is this
mind's own from its first change: nothing brings the template into it again.

No repo is public at first. To let anyone read and clone one, list its path in `worker.ts`:

```ts
const git = gitApp({ icon, public: ["/repos/stdlib"] });
```

## On a laptop

The mind's repos sit side by side in one folder, each under its own name, as they do in the mind
(`/repos/<name>`). This repo is where that folder starts:

```sh
git clone https://git.<domain>/repos/config <folder>/config
<folder>/config/clone.sh
```

`clone.sh` clones the kernel and each repo that `package.json` names, from beside this repo's
address, and installs them. Add the name of any other repo you want: `clone.sh task-board`. A repo
that is not public cannot be cloned this way yet (see "Push").

```
<folder>/
  config/      this repo
  kernel/      the platform. Only a deploy changes what runs of it.
  stdlib/      the agent, what worker.ts calls, and what every repo is checked and tested with
  dash/        the Dash app
  tasks/       the Tasks app
  docs/        the Docs app
  onboarding/  the first steps of a new mind: the page at onboarding.<domain> and its guides
  git/         the git app: it serves git.<domain>
```

How they link:

- A file imports a file of another repo by the repo's name:
  `import { init } from "@repos/stdlib/init.ts"`. The importing repo's `package.json` lists it,
  `"@repos/stdlib": "../stdlib"`: the folder next door. So the folder names are part of the code.
  Keep them.
- This repo's `package.json` lists every repo a mind is born with beside its kernel and its
  config.
- `iterate/*` and `zod` come from the kernel. Worker code uses no npm package.
- Each repo stands alone once its neighbours are beside it: `pnpm install` in its folder links
  them and brings its tools, and `pnpm typecheck` and `pnpm test` check it.

## Check before you push

Nothing checks a push. Run this first:

```sh
./check.sh
```

It type-checks and tests this repo and each repo it imports from.

## Push

Plain `git push` to `git.<domain>` needs a credential for the repo, and there is no supported way
yet to give a laptop one. Do not mint an Artifacts token for it in a script: what a script answers
is kept on the mind's log, so a token that a script returns is written down where every agent and
member of the mind reads it, for as long as the token lives.

If you made tokens with the recipe that stood here before (a year's write tokens, one for each
repo, returned by a script): each still pushes to its repo until it ends, and its text is in the
answer of that script on the mind's log. Cloudflare's Artifacts binding can list and revoke a
repo's tokens (`listTokens`, `revokeToken`), but `itx.cfArtifacts` does not pass those two on
yet. Until it does, treat those tokens as live, and remove them from the laptop's keychain when
you stop using them.

Until git has a sign-in of its own, a change reaches the mind in one of these ways. Neither hands
anyone a credential.

**Commit through the mind.** A member's script commits whole files on the tip, with the `run`
tool of the mind's MCP server or with `iterate itx run --mind <domain> --file commit.js`:

```js
const repo = itx.repos.get("/repos/config");
const tip = await repo.tip();
const { commitOid } = await repo.commitFiles({
  message: "Say what changed, and why",
  parent: tip, // refused when main moved since you read it
  changes: [{ path: "homepage.ts", content: "<the whole new text of the file>" }],
});
return commitOid;
```

A file that goes away is `{ path, delete: true }`. Run `./check.sh` first: the commit publishes
the mind a few seconds later.

**Let the repo pull.** Push your commits to a git host that the mind can read, then have the
mind's repo pull that address's `main`. That `main` must hold the repo's own newest commit (a
fast-forward): when the mind's repo got a commit since you cloned, merge it first, or the pull is
refused. The answer says what it did (`status`):

```js
return await itx.repos.get("/repos/config").pull({ remote: "https://<a git host>/<your repo>" });
```

**Not yet: plain git with the mind's sign-in.** The kernel has `npx iterate git setup git.<domain>`
(a credential helper that lends git the CLI's sign-in, so that `git clone` of a repo that is not
public and `git push` work with no token to paste). It is not in a released `iterate` CLI, and the
git app does not read that sign-in yet. This section says so when it does.