> **Preview 1.9.3rc26.** Shared initialization and repair behavior described below ships in this opt-in preview; stable remains 1.9.2. See [release notes](https://github.com/openonion/connectonion/releases/tag/v1.9.3rc26). # ConnectOnion Init Command `co init` prepares the local identity, profile, coding-agent integration and REM. Project initialization requires an explicit directory, such as `co init ./`. ## Quick start ```bash co init # identity, profile, skills, command index and REM consent co init --yes # automatic local setup; REM storage only, no source access co init --no-rem # skip REM setup co init ./ --yes # configuration in this existing project co init /path/to/project --yes # configuration in another existing project co init ./ --template co-ai # also add the hosted agent template ``` The path must name an existing directory. Use `co create my-agent` to create a new directory with the default `co-ai` template. ## Global setup: no path Plain `co init` creates or reuses the signing identity in `~/.co/keys/` and attempts managed-key authentication, saving credentials to `~/.co/keys.env`. It also creates a missing `~/.co/agent.json` local profile. Your existing profile is kept; use `co setup --name my-agent --bio "My work" --no-skills` to customize only those fields. ### REM setup Global `co init` prepares `~/.co/rem`, offers mailbox login and asks once for source/model/schedule consent. After installing Codex Scheduled task or launchd upkeep on macOS, it runs the same foreground first notebook build as `co rem init`. Before model work, the estimate pauses at `Build the first map now? [Y/n]`; Enter builds, while `n` keeps upkeep installed and prints `co rem init` to continue. The final summary reports mapped and written pages and names the scheduler; read with `co rem open`. Without a terminal or with `co init --yes`, only storage is created: no login, consent, source reads or scheduler. Connect later with `co auth google` or `co auth microsoft`, then run `co rem init`. `--no-rem` skips REM, rerunning init leaves existing REM unchanged, and `--background` uses this same REM step. See [REM: Start here](rem.md#start-here). It does **not** create or modify the current directory's `.env`, `.co/`, `agent.py`, or other project files—even when run inside an existing project. Existing global provider credentials are preserved. An explicit `--key` saves that provider key globally; keys merely present in the process environment or loaded from a project are not copied into global storage. Avoid putting secrets into shell history; editing the private keys file is also supported. If authentication cannot complete, local identity setup remains available and the command tells you to run `co auth` later. Successful local initialization does not mean managed models or email are authenticated. ### Telling Codex and Claude Code that `co` exists `co init`, `co init ./`, `co create` and `co setup` all do two things for the coding agents on this machine, only for those installed (their `~/.codex` or `~/.claude` directory exists): - runs `co skills link`, so ConnectOnion's bundled skills appear in `~/.codex/skills/` and `~/.claude/skills/`; - writes ConnectOnion's command index into `~/.codex/AGENTS.md` and `~/.claude/CLAUDE.md`, between `` and ``. It is generated from the CLI: a few rules (use `co commands` and `co --help` before a browser or a script; do not hunt for credentials) and one line per top-level command. It prints each path it changed. A directory it cannot write, like `~/.codex` inside Codex's sandbox, is skipped with a line saying so, and init still finishes; run `co skills link` and `co skills index` outside the sandbox later. Your own skill directories are kept, including when project init uses `--force`. Your own text outside the markers is never touched. To take the block out: `co skills index --remove`; to refresh it without re-running init: `co skills index`. Agents started with `host()` or `co ai` refresh a stale block on their own, and `co doctor` reports one that is missing or stale. See [co skills index](skills.md#co-skills-index). ### Rerun to repair missing setup Initialization checks these files on every run, including when a signing key already exists. It restores a missing `keys.env` from that identity, creates a missing local profile, repairs dangling bundled-skill symlinks, and connects a coding agent installed since the previous run. It preserves the existing identity, profile, user skill directories and instruction text outside the generated block. It does not require a separate `co skills link` after project initialization. The global directory defaults to `~/.co/`; an explicit process `AGENT_CONFIG_PATH` selects its identity, profile and user skill library together. Browser installation and publishing remain separate commands. REM uses `~/.co/rem`, the same default as `co rem`, independently of `AGENT_CONFIG_PATH`. ## Project setup: explicit path `co init ./` uses the global identity and initializes the selected directory. It also completes the same local profile, skills and command-index setup as plain init. It does not mint a separate project keypair or initialize REM. | File | Behavior | |---|---| | `.env` | Create or append missing credentials; preserve existing provider and application values | | Identity entries in `.env` | Refresh from global identity, including after `co reset` | | `CO_INVITE_CODE` | Create once per project; preserve on subsequent runs | | `.co/host.yaml` | Create project configuration if missing | | `.co/docs/` | Refresh bundled framework documentation | | `.co/admins.txt` | Record the creating identity as an admin | | Template files such as `agent.py` | Only with `--template`; preserve existing files unless `--force` | | `.gitignore` | Add secret/runtime exclusions when initializing inside a Git repository | Personal Google/Microsoft OAuth credentials and machine-specific configuration paths are not copied from global keys into a project. Keep both `.env` and `keys.env` out of source control. ```bash # Add configuration without generating agent.py co init ./ --yes # Add the hosted template co init ./ --template co-ai --yes # Generate a custom agent co init ./ --template custom --description "Monitor a site and alert me" # Refresh configuration and bundled docs without selecting a code template co init ./ --yes ``` Non-empty and special directories prompt for confirmation unless `--yes` is given. `--yes` does not authorize overwriting existing template code; `--force` does. Treat refreshed `.co/docs/` as generated framework reference, not a place for personal notes. ## Options | Option | Meaning | |---|---| | `PATH` | Optional existing project directory; omission selects global setup | | `--key` | Explicit provider key: global storage without PATH, project configuration with PATH | | `--yes`, `-y` | Skip project confirmation prompts | | `--template`, `-t` | Project only: `co-ai` or `custom`; omitted means configuration only | | `--description` | Project only: description for a custom template | | `--force` | Project only: allow replacing existing template files | Project-only options without PATH fail before writing files and show an example using `co init ./`. ## Migrating scripts Commands that formerly relied on implicit project initialization must add a path: ```bash # Before: co init --yes --template co-ai co init ./ --yes --template co-ai ``` Global setup scripts can keep `co init --yes`. `co create` now completes the same local coding-agent setup when it creates a project. At runtime, explicit process variables take precedence over the selected env file, which is global `~/.co/keys.env` unless `co --env-file PATH` names a project file; there is no per-key fallback between files. `co env` shows what the selected file holds and `co env set` edits it. See [CLI reference](README.md) for authentication and credential diagnostics. In preview 1.9.3rc26, rerunning initialization also refreshes a bundled skill symlink into an older installed ConnectOnion package. Personal skill directories and links outside installed package layouts are preserved. Missing local profile fields receive defaults; invalid skill metadata is kept and reports how to repair it. All four entry points share this preparation.