1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
use super::{agents::*, path::*, settings::*, skills::*, ui::*, *};
// ── Main entry point ──────────────────────────────────────────────────────────
pub fn run_install() -> anyhow::Result<()> {
let version = env!("CARGO_PKG_VERSION");
box_open(&format!("Innate v{version}"));
let current_exe = std::env::current_exe()?;
// ── 1. Scope: global vs project ────────────────────────────────────────
let scope_options = ["All projects (global)", "Just this project"];
let scope_idx = prompt_select(
"Apply agent configs to all your projects, or just this one?",
&scope_options,
);
let global = scope_idx == 0;
// ── 2. Agent selection ─────────────────────────────────────────────────
let agents = detect_agents(global);
let options: Vec<(&str, bool)> = agents
.iter()
.map(|a| (a.label.as_str(), a.detected))
.collect();
let selected = prompt_multi_select("Which agents should Innate configure?", &options);
let chosen_agents: Vec<&Agent> = agents
.iter()
.zip(selected.iter())
.filter(|(_, &s)| s)
.map(|(a, _)| a)
.collect();
// ── 3. PATH installation ───────────────────────────────────────────────
// When the binary is on PATH, write just "innate" into agent configs so
// the config is portable across machines and users. Only fall back to an
// absolute path when the user declines PATH installation.
let on_path = check_on_path();
let binary_path: PathBuf = if let Some(p) = &on_path {
question("Install innate CLI on your PATH?");
info(&format!(
"Already on PATH {}",
gray(&format!("({})", p.display()))
));
sep();
PathBuf::from(binary_name())
} else {
let do_install = prompt_confirm(
"Install innate CLI on your PATH? (Required for agents to launch the MCP server)",
true,
);
if do_install {
match install_to_path(¤t_exe) {
Ok(dest) => {
result_line(&format!(
"Installed innate to {}",
bold(&dest.display().to_string())
));
if !path_has_local_bin() {
let written = write_path_to_profiles();
if written.is_empty() {
#[cfg(windows)]
warn_line(&yellow(
"Add .local\\bin to PATH:\
\n│ [Environment]::SetEnvironmentVariable('PATH', $env:USERPROFILE + '\\.local\\bin;' + $env:PATH, 'User')",
));
#[cfg(not(windows))]
warn_line(&yellow(
"Add ~/.local/bin to PATH in your shell profile:\
\n│ export PATH=\"$HOME/.local/bin:$PATH\"",
));
} else {
for p in &written {
result_line(&format!(
"Added PATH export to {}",
bold(&tilde_path(p))
));
}
#[cfg(windows)]
info(&dim(
"Open a new terminal for the PATH change to take effect",
));
#[cfg(not(windows))]
info(&dim("Run: source ~/.bashrc (or open a new terminal)"));
}
}
sep();
PathBuf::from(binary_name())
}
Err(e) => {
warn_line(&format!("Could not install to PATH: {e}"));
info("Falling back to current binary location");
sep();
current_exe.clone()
}
}
} else {
current_exe.clone()
}
};
// ── 4. Auto-allow ──────────────────────────────────────────────────────
let auto_allow = prompt_confirm(
"Auto-allow Innate MCP tools? (Skips permission prompts in agents)",
true,
);
// ── 5. LLM configuration (optional) ───────────────────────────────────
configure_llm_interactive();
// ── 5b. Daemon watch dirs (optional) ──────────────────────────────────
configure_daemon_interactive();
// ── 6. Apply configs ───────────────────────────────────────────────────
for agent in &chosen_agents {
let status = match agent.id {
"claude" => configure_claude(agent, &binary_path, auto_allow),
"codex" => configure_codex(agent, &binary_path, auto_allow),
"opencode" => configure_opencode(agent, &binary_path, auto_allow),
_ => ConfigStatus::Skipped("unknown agent".into()),
};
match &status {
ConfigStatus::Updated(p) => {
result_line(&format!(
"{}: Updated {}",
bold(agent.id),
gray(&tilde_path(p))
));
}
ConfigStatus::Unchanged(p) => {
result_line(&format!(
"{}: {}",
bold(agent.id),
gray(&format!("Unchanged {}", tilde_path(p)))
));
}
ConfigStatus::Skipped(reason) => {
warn_line(&format!(
"{}: {}",
bold(agent.id),
yellow(&format!("Skipped — {reason}"))
));
}
ConfigStatus::Error(e) => {
warn_line(&format!("{}: \x1b[31mError — {e}\x1b[0m", bold(agent.id)));
}
}
if agent.id == "claude" {
match install_skill() {
ConfigStatus::Updated(p) => {
result_line(&format!(
"{}: Installed skill {}",
bold("claude"),
gray(&tilde_path(&p))
));
}
ConfigStatus::Unchanged(p) => {
result_line(&format!(
"{}: {}",
bold("claude"),
gray(&format!("Skill unchanged {}", tilde_path(&p)))
));
}
ConfigStatus::Skipped(reason) => {
warn_line(&format!(
"{}: {}",
bold("claude"),
yellow(&format!("Skill skipped — {reason}"))
));
}
ConfigStatus::Error(e) => {
warn_line(&format!(
"{}: \x1b[31mSkill error — {e}\x1b[0m",
bold("claude")
));
}
}
// Install slash commands alongside the skill
for (name, status) in install_commands() {
match status {
ConfigStatus::Updated(p) => {
result_line(&format!(
"{}: /{name} {}",
bold("claude"),
gray(&tilde_path(&p))
));
}
ConfigStatus::Unchanged(_) => {}
ConfigStatus::Skipped(_) => {}
ConfigStatus::Error(e) => {
warn_line(&format!(
"{}: \x1b[31mCommand /{name} error — {e}\x1b[0m",
bold("claude")
));
}
}
}
// Install Stop hook so daemon gets session events automatically.
match configure_claude_stop_hook(&agent.config, &binary_path) {
ConfigStatus::Updated(p) => {
result_line(&format!(
"{}: Stop hook → {}",
bold("claude"),
gray(&tilde_path(&p))
));
}
ConfigStatus::Unchanged(_) => {}
ConfigStatus::Skipped(_) => {}
ConfigStatus::Error(e) => {
warn_line(&format!(
"{}: \x1b[31mStop hook error — {e}\x1b[0m",
bold("claude")
));
}
}
}
}
sep();
// ── 7. Quick start ─────────────────────────────────────────────────────
// Box: inner display width = 28. Total row width = │ {28}│ = 32 chars.
// Header dashes = 28 - 12 ("Quick start ") = 16.
// Bottom dashes = 28 + 2 = 30.
const INNER: usize = 28;
let bar = gray("│");
let qs_top = format!(
"{} Quick start {}{}",
cyan("◇"),
gray(&"─".repeat(INNER - 12)),
gray("╮")
);
let qs_row = |s: &str| -> String {
let pad = INNER.saturating_sub(s.chars().count());
format!("{bar} {s}{}{bar}", " ".repeat(pad))
};
let qs_empty = qs_row("");
let qs_sep = format!("{}{}╯", gray("├"), gray(&"─".repeat(INNER + 2)));
println!("{qs_top}");
println!("{qs_empty}");
println!("{}", qs_row("innate recall \"query\""));
println!("{}", qs_row("innate record <trace_id>"));
println!("{}", qs_row("innate evolve"));
println!("{qs_empty}");
println!("{qs_sep}");
box_close("Done! Restart your agents to use Innate.");
Ok(())
}