rtk-ai/rtk · error · anyhow::Error

Kilo Code is project-scoped. Use: rtk init --agent kilocode

Error message

Kilo Code is project-scoped. Use: rtk init --agent kilocode

What it means

The Kilo Code integration is written into project files (.kilocode workspace rules), so there is no global install; rtk rejects `--global` to avoid writing to a nonexistent global location. Mirror image of the windsurf/gemini-style global-only errors — same validation family, opposite direction.

Source

Thrown at src/main.rs:2058

                let patch_mode = if auto_patch {
                    hooks::init::PatchMode::Auto
                } else if no_patch {
                    hooks::init::PatchMode::Skip
                } else {
                    hooks::init::PatchMode::Ask
                };
                hooks::init::run_gemini(global, hook_only, patch_mode, ctx)?;
            } else if copilot {
                if global {
                    hooks::init::run_copilot_global(ctx)?;
                } else {
                    hooks::init::run_copilot(ctx)?;
                }
            } else if agent == Some(AgentTarget::Pi) {
                hooks::init::run_pi_mode(global, ctx)?
            } else if agent == Some(AgentTarget::Kilocode) {
                if global {
                    anyhow::bail!("Kilo Code is project-scoped. Use: rtk init --agent kilocode");
                }
                hooks::init::run_kilocode_mode(ctx)?;
            } else if agent == Some(AgentTarget::Antigravity) {
                if global {
                    anyhow::bail!(
                        "Antigravity is project-scoped. Use: rtk init --agent antigravity"
                    );
                }
                hooks::init::run_antigravity_mode(ctx)?;
            } else if agent == Some(AgentTarget::Kimi) {
                if global {
                    anyhow::bail!("Kimi AI is project-scoped. Use: rtk init --agent kimi");
                }
                hooks::init::run_kimi_mode(ctx)?;
            } else if agent == Some(AgentTarget::Hermes) {
                hooks::init::run_hermes_mode(ctx)?;
            } else if agent == Some(AgentTarget::Droid) {
                hooks::init::run_droid_mode(global, ctx)?;

View on GitHub (pinned to d977e1c316)

Solutions

  1. Run `rtk init --agent kilocode` from the project root, without -g
  2. For per-machine provisioning, loop over project directories instead of relying on -g

Example fix

# before
rtk init -g --agent kilocode   # error: project-scoped

# after
rtk init --agent kilocode
Defensive patterns

Strategy: validation

Validate before calling

# bash: project-scoped agents must not receive -g
case "$AGENT" in kilocode|antigravity|kimi) GLOBAL_FLAG='';; *) GLOBAL_FLAG='-g';; esac
rtk init $GLOBAL_FLAG --agent "$AGENT"

Prevention

When it happens

Trigger: `rtk init -g --agent kilocode` (or --global) — the bail at src/main.rs:2060.

Common situations: Wrapper scripts that always pass -g for 'machine setup'; copy-pasting another agent's -g invocation.

Related errors


AI-assisted analysis of rtk-ai/rtk@d977e1c316 (2026-08-16). Data as JSON: /api/errors/e1d47b1fb8c54da1. Report an issue: GitHub.