@rafter-security/cli 0.11.7 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/agent/auto-update.js +171 -0
- package/dist/commands/agent/components.js +50 -176
- package/dist/commands/agent/enable.js +11 -1
- package/dist/commands/agent/index.js +2 -0
- package/dist/commands/agent/init.js +654 -764
- package/dist/commands/agent/install-files.js +689 -0
- package/dist/commands/agent/instruction-block.js +82 -40
- package/dist/commands/agent/scan.js +70 -21
- package/dist/commands/agent/status.js +11 -0
- package/dist/commands/agent/update.js +179 -0
- package/dist/commands/agent/verify.js +11 -0
- package/dist/commands/backend/get.js +5 -10
- package/dist/commands/backend/run.js +10 -20
- package/dist/commands/backend/scan-status.js +16 -3
- package/dist/commands/backend/usage.js +3 -6
- package/dist/commands/brief.js +6 -12
- package/dist/commands/counters.js +146 -0
- package/dist/commands/gates.js +36 -0
- package/dist/commands/hook/pretool.js +22 -9
- package/dist/commands/mcp/server.js +1 -1
- package/dist/commands/skill/registry.js +48 -0
- package/dist/core/usage-counters.js +439 -0
- package/dist/index.js +36 -0
- package/dist/scanners/gate-scanner.js +721 -0
- package/dist/scanners/regex-scanner.js +26 -25
- package/dist/utils/skill-manager.js +8 -338
- package/package.json +1 -1
- package/resources/continue-rules/rafter-code-review.md +6 -6
- package/resources/continue-rules/rafter-secure-design.md +3 -4
- package/resources/continue-rules/rafter-skill-review.md +4 -4
- package/resources/continue-rules/rafter.md +2 -2
- package/resources/cursor-rules/rafter-code-review.mdc +6 -6
- package/resources/cursor-rules/rafter-secure-design.mdc +3 -4
- package/resources/cursor-rules/rafter-skill-review.mdc +4 -4
- package/resources/cursor-rules/rafter.mdc +2 -2
- package/resources/rafter-security-skill.md +1 -1
- package/resources/shipped-hashes.json +332 -0
- package/resources/skills/rafter/SKILL.md +7 -7
- package/resources/skills/rafter/docs/cli-reference.md +37 -10
- package/resources/skills/rafter/docs/finding-triage.md +1 -1
- package/resources/skills/rafter/docs/guardrails.md +2 -2
- package/resources/skills/rafter/docs/shift-left.md +4 -4
- package/resources/skills/rafter-code-review/SKILL.md +43 -14
- package/resources/skills/rafter-code-review/docs/llm.md +2 -2
- package/resources/skills/rafter-code-review/docs/security-gates.md +53 -0
- package/resources/skills/rafter-secure-design/SKILL.md +1 -0
- package/resources/skills/rafter-skill-review/SKILL.md +1 -0
- package/resources/windsurf-rules/rafter-code-review.md +6 -6
- package/resources/windsurf-rules/rafter-secure-design.md +3 -4
- package/resources/windsurf-rules/rafter-skill-review.md +4 -4
- package/resources/windsurf-rules/rafter.md +2 -2
|
@@ -2,7 +2,6 @@ import { Command } from "commander";
|
|
|
2
2
|
import { ConfigManager } from "../../core/config-manager.js";
|
|
3
3
|
import { BinaryManager } from "../../utils/binary-manager.js";
|
|
4
4
|
import { SkillScannerInstaller, SKILL_SCANNER_VERSION } from "../../scanners/skill-scanner.js";
|
|
5
|
-
import { SkillManager } from "../../utils/skill-manager.js";
|
|
6
5
|
import fs from "fs";
|
|
7
6
|
import path from "path";
|
|
8
7
|
import os from "os";
|
|
@@ -11,7 +10,9 @@ import { fileURLToPath } from "url";
|
|
|
11
10
|
import { createRequire } from "module";
|
|
12
11
|
import { askYesNo } from "../../utils/prompt.js";
|
|
13
12
|
import { fmt } from "../../utils/formatter.js";
|
|
14
|
-
import { injectInstructionFile } from "./instruction-block.js";
|
|
13
|
+
import { injectInstructionFile, injectAiderNote, retireInstructionFile } from "./instruction-block.js";
|
|
14
|
+
import { KNOWN_SKILL_NAMES } from "../skill/registry.js";
|
|
15
|
+
import { InstallSession, claudeAgentArtifacts, cleanupRetiredRules, cleanupLegacyOpenClaw, cleanupRetiredSkills, cursorAgentArtifacts, openclawSkillArtifacts, openclawSkillPath, FORCE_HINT, reportKeptSummary, reportUnchangedSummary, unchangedLine, ruleArtifacts, skillArtifacts, } from "./install-files.js";
|
|
15
16
|
import yaml from "js-yaml";
|
|
16
17
|
const __filename = fileURLToPath(import.meta.url);
|
|
17
18
|
const __dirname = path.dirname(__filename);
|
|
@@ -97,19 +98,6 @@ function installedHookWarnings() {
|
|
|
97
98
|
catch { /* best-effort confirmation */ }
|
|
98
99
|
return warnings;
|
|
99
100
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Skills installed by `rafter agent init` for Claude Code / Codex.
|
|
102
|
-
*
|
|
103
|
-
* Sourced from `resources/skills/<name>/SKILL.md` in the shipped package.
|
|
104
|
-
* Keep this list in sync with Python's installer and the skills that actually
|
|
105
|
-
* ship in both resources/skills/ trees.
|
|
106
|
-
*/
|
|
107
|
-
const AGENT_SKILLS = [
|
|
108
|
-
{ name: "rafter", description: "Rafter Remote" },
|
|
109
|
-
{ name: "rafter-secure-design", description: "Rafter Secure Design" },
|
|
110
|
-
{ name: "rafter-code-review", description: "Rafter Code Review" },
|
|
111
|
-
{ name: "rafter-skill-review", description: "Rafter Skill Review" },
|
|
112
|
-
];
|
|
113
101
|
/**
|
|
114
102
|
* Print every file path the install would touch — without writing anything.
|
|
115
103
|
*
|
|
@@ -135,6 +123,37 @@ function printDryRunPlan(plan) {
|
|
|
135
123
|
const S = (p, note) => {
|
|
136
124
|
console.log(` SKIP ${p} (${note})`);
|
|
137
125
|
};
|
|
126
|
+
// Whole-file artifacts: the predicted outcome per file, from the same
|
|
127
|
+
// policy the real run applies (install-files.ts).
|
|
128
|
+
const F = (artifacts) => {
|
|
129
|
+
for (const a of artifacts) {
|
|
130
|
+
const outcome = plan.session.apply(a);
|
|
131
|
+
if (outcome === "unchanged")
|
|
132
|
+
continue; // summed into one line below
|
|
133
|
+
else if (outcome === "kept")
|
|
134
|
+
W(`${a.dest}.rafter-new`, `${a.dest} kept: modified`);
|
|
135
|
+
else if (outcome === "replaced")
|
|
136
|
+
W(a.dest, `replaced; backup at ${a.dest}.bak`);
|
|
137
|
+
else if (outcome === "reconciled")
|
|
138
|
+
S(a.dest, "modified, reconciled with this version; recorded");
|
|
139
|
+
else
|
|
140
|
+
W(a.dest, outcome);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const retired = (r) => {
|
|
144
|
+
for (const p of r.removed)
|
|
145
|
+
R(p, "retired");
|
|
146
|
+
for (const p of r.kept)
|
|
147
|
+
S(p, "retired, but modified; kept");
|
|
148
|
+
};
|
|
149
|
+
const skills = (dir, platform, component) => {
|
|
150
|
+
F(skillArtifacts(dir, platform, component));
|
|
151
|
+
retired(cleanupRetiredSkills(plan.session, dir));
|
|
152
|
+
};
|
|
153
|
+
const rules = (kind) => {
|
|
154
|
+
F(ruleArtifacts(kind, plan.root));
|
|
155
|
+
retired(cleanupRetiredRules(plan.session, kind));
|
|
156
|
+
};
|
|
138
157
|
console.log();
|
|
139
158
|
console.log(fmt.info("DRY RUN — no files will be created or modified."));
|
|
140
159
|
console.log(fmt.info(`Scope: ${plan.scope}${plan.scope === "project" ? ` (cwd: ${plan.root})` : ""}`));
|
|
@@ -162,14 +181,23 @@ function printDryRunPlan(plan) {
|
|
|
162
181
|
console.log("skill-scanner deep engine (--with-skill-scanner):");
|
|
163
182
|
D("skill-scanner", "heavy PyPI package, isolated install via uv tool / pip --user");
|
|
164
183
|
}
|
|
184
|
+
// Same order as the real run, which installs OpenClaw before the others.
|
|
185
|
+
if (plan.wantOpenClaw) {
|
|
186
|
+
console.log();
|
|
187
|
+
console.log("OpenClaw (--with-openclaw):");
|
|
188
|
+
F(openclawSkillArtifacts(home));
|
|
189
|
+
const legacy = cleanupLegacyOpenClaw(plan.session);
|
|
190
|
+
for (const p of legacy.removed)
|
|
191
|
+
R(p, "legacy file from rafter ≤ 0.7.7");
|
|
192
|
+
for (const p of legacy.kept)
|
|
193
|
+
S(p, "legacy file from rafter ≤ 0.7.7, but modified; kept");
|
|
194
|
+
}
|
|
165
195
|
if (plan.wantClaudeCode) {
|
|
166
196
|
console.log();
|
|
167
197
|
console.log("Claude Code (--with-claude-code):");
|
|
168
198
|
W(path.join(plan.root, ".claude", "settings.json"), "PreToolUse + PostToolUse hooks merged");
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
W(path.join(plan.root, ".claude", "agents", "rafter.md"), "sub-agent");
|
|
199
|
+
skills(path.join(plan.root, ".claude", "skills"), "claude-code", "claude-code.skills");
|
|
200
|
+
F(claudeAgentArtifacts(plan.root));
|
|
173
201
|
W(path.join(plan.root, ".claude", "CLAUDE.md"), "rafter:start/end marker block");
|
|
174
202
|
// .mcp.json is a project-scope file; the user-scope install never writes it.
|
|
175
203
|
if (plan.scope === "project") {
|
|
@@ -185,9 +213,7 @@ function printDryRunPlan(plan) {
|
|
|
185
213
|
console.log();
|
|
186
214
|
console.log("Codex CLI (--with-codex):");
|
|
187
215
|
W(path.join(plan.root, ".codex", "hooks.json"), "PreToolUse: Bash|apply_patch, PostToolUse: Bash|apply_patch");
|
|
188
|
-
|
|
189
|
-
W(path.join(plan.root, ".agents", "skills", s.name, "SKILL.md"));
|
|
190
|
-
}
|
|
216
|
+
skills(path.join(plan.root, ".agents", "skills"), "codex", "codex.skills");
|
|
191
217
|
const agentsMd = plan.scope === "user" ? path.join(plan.root, ".codex", "AGENTS.md") : path.join(plan.root, "AGENTS.md");
|
|
192
218
|
W(agentsMd, "shared with Windsurf when --with-windsurf");
|
|
193
219
|
}
|
|
@@ -195,9 +221,7 @@ function printDryRunPlan(plan) {
|
|
|
195
221
|
console.log();
|
|
196
222
|
console.log("Gemini CLI (--with-gemini):");
|
|
197
223
|
W(path.join(plan.root, ".gemini", "settings.json"), "MCP + BeforeTool/AfterTool hooks");
|
|
198
|
-
|
|
199
|
-
W(path.join(plan.root, ".agents", "skills", s.name, "SKILL.md"), "shared with Codex");
|
|
200
|
-
}
|
|
224
|
+
skills(path.join(plan.root, ".agents", "skills"), "gemini", "gemini.skills");
|
|
201
225
|
const geminiMd = plan.scope === "user" ? path.join(plan.root, ".gemini", "GEMINI.md") : path.join(plan.root, "GEMINI.md");
|
|
202
226
|
W(geminiMd);
|
|
203
227
|
if (plan.scope === "user") {
|
|
@@ -208,10 +232,8 @@ function printDryRunPlan(plan) {
|
|
|
208
232
|
console.log();
|
|
209
233
|
console.log("Cursor (--with-cursor):");
|
|
210
234
|
W(path.join(plan.root, ".cursor", "hooks.json"), "preToolUse + postToolUse + beforeShellExecution");
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
W(path.join(plan.root, ".cursor", "agents", "rafter.md"), "sub-agent (Cursor reads .claude/agents/ too)");
|
|
235
|
+
rules("cursor");
|
|
236
|
+
F(cursorAgentArtifacts(plan.root));
|
|
215
237
|
W(path.join(plan.root, ".cursor", "mcp.json"));
|
|
216
238
|
}
|
|
217
239
|
if (plan.wantWindsurf) {
|
|
@@ -220,9 +242,7 @@ function printDryRunPlan(plan) {
|
|
|
220
242
|
if (plan.scope === "user") {
|
|
221
243
|
W(path.join(home, ".codeium", "windsurf", "mcp_config.json"), "user-scope MCP only");
|
|
222
244
|
}
|
|
223
|
-
|
|
224
|
-
W(path.join(plan.root, ".windsurf", "rules", `${s}.md`));
|
|
225
|
-
}
|
|
245
|
+
rules("windsurf");
|
|
226
246
|
W(path.join(plan.root, "AGENTS.md"), "shared with Codex; idempotent if already written");
|
|
227
247
|
}
|
|
228
248
|
if (plan.wantContinue) {
|
|
@@ -231,9 +251,7 @@ function printDryRunPlan(plan) {
|
|
|
231
251
|
if (plan.scope === "user") {
|
|
232
252
|
W(path.join(home, ".continue", "config.json"), "MCP entry; preserves existing keys");
|
|
233
253
|
}
|
|
234
|
-
|
|
235
|
-
W(path.join(plan.root, ".continue", "rules", `${s}.md`));
|
|
236
|
-
}
|
|
254
|
+
rules("continue");
|
|
237
255
|
}
|
|
238
256
|
if (plan.wantAider) {
|
|
239
257
|
console.log();
|
|
@@ -251,11 +269,10 @@ function printDryRunPlan(plan) {
|
|
|
251
269
|
console.log("OpenCode (--with-opencode):");
|
|
252
270
|
W(path.join(plan.root, ".config", "opencode", "opencode.json"), "mcp.rafter local/stdio entry merged into existing JSON");
|
|
253
271
|
}
|
|
254
|
-
|
|
272
|
+
const unchanged = plan.session.count("unchanged");
|
|
273
|
+
if (unchanged > 0) {
|
|
255
274
|
console.log();
|
|
256
|
-
console.log(
|
|
257
|
-
W(path.join(home, ".openclaw", "workspace", "skills", "rafter-security", "SKILL.md"), "ClawHub-shape");
|
|
258
|
-
R(path.join(home, ".openclaw", "skills", "rafter-security.md"), "legacy file from rafter ≤ 0.7.7, if present");
|
|
275
|
+
console.log(` SKIP ${unchangedLine(unchanged)}`);
|
|
259
276
|
}
|
|
260
277
|
console.log();
|
|
261
278
|
console.log(fmt.divider());
|
|
@@ -428,7 +445,7 @@ function installCodexHooks(root, out) {
|
|
|
428
445
|
*
|
|
429
446
|
* Covers the full pre/post-tool lifecycle plus shell-specific gating:
|
|
430
447
|
* - preToolUse — rafter classifies every tool call
|
|
431
|
-
* - postToolUse — rafter post-hook (audit,
|
|
448
|
+
* - postToolUse — rafter post-hook (audit, usage counters)
|
|
432
449
|
* - beforeShellExecution — narrower complement; some Cursor versions
|
|
433
450
|
* fire this without firing preToolUse for shell.
|
|
434
451
|
*
|
|
@@ -468,13 +485,6 @@ function installCursorHooks(root, out) {
|
|
|
468
485
|
fs.writeFileSync(hooksPath, JSON.stringify(config, null, 2), "utf-8");
|
|
469
486
|
out.info(fmt.success(`Installed hooks to ${hooksPath}`));
|
|
470
487
|
}
|
|
471
|
-
/** Skills shipped as both Cursor rules and (Claude Code / Codex / Gemini) skills. */
|
|
472
|
-
const CURSOR_RULE_SKILLS = [
|
|
473
|
-
"rafter",
|
|
474
|
-
"rafter-secure-design",
|
|
475
|
-
"rafter-code-review",
|
|
476
|
-
"rafter-skill-review",
|
|
477
|
-
];
|
|
478
488
|
/**
|
|
479
489
|
* Install per-skill Cursor rules at <root>/.cursor/rules/<skill>.mdc.
|
|
480
490
|
*
|
|
@@ -485,41 +495,23 @@ const CURSOR_RULE_SKILLS = [
|
|
|
485
495
|
* Replaces the legacy consolidated `.cursor/rules/rafter-security.mdc` — that
|
|
486
496
|
* single file is no longer written by the Cursor install path.
|
|
487
497
|
*/
|
|
488
|
-
function installCursorRules(root, out) {
|
|
498
|
+
function installCursorRules(session, root, out) {
|
|
489
499
|
const rulesDir = path.join(root, ".cursor", "rules");
|
|
490
500
|
fs.mkdirSync(rulesDir, { recursive: true });
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
path.resolve(__dirname, "..", "..", "resources", "cursor-rules"),
|
|
496
|
-
];
|
|
497
|
-
const sourceDir = candidates.find((p) => fs.existsSync(p));
|
|
498
|
-
if (!sourceDir) {
|
|
499
|
-
out.warn(fmt.warning(`Cursor rule templates not found in resources/cursor-rules`));
|
|
500
|
-
return;
|
|
501
|
-
}
|
|
502
|
-
for (const name of CURSOR_RULE_SKILLS) {
|
|
503
|
-
const src = path.join(sourceDir, `${name}.mdc`);
|
|
504
|
-
const dest = path.join(rulesDir, `${name}.mdc`);
|
|
505
|
-
if (!fs.existsSync(src)) {
|
|
506
|
-
out.warn(fmt.warning(`Cursor rule template missing: ${src}`));
|
|
507
|
-
continue;
|
|
508
|
-
}
|
|
509
|
-
fs.copyFileSync(src, dest);
|
|
510
|
-
out.info(fmt.success(`Installed Cursor rule to ${dest}`));
|
|
511
|
-
}
|
|
512
|
-
// Remove the legacy consolidated rule if present, so reinstall on top of
|
|
513
|
-
// an old layout migrates cleanly.
|
|
501
|
+
session.applyAll(ruleArtifacts("cursor", root, out));
|
|
502
|
+
cleanupRetiredRules(session, "cursor");
|
|
503
|
+
// Take rafter's block out of the legacy consolidated rule, so reinstall on
|
|
504
|
+
// top of an old layout migrates cleanly. Anything else in it is the user's.
|
|
514
505
|
const legacy = path.join(rulesDir, "rafter-security.mdc");
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
506
|
+
try {
|
|
507
|
+
const done = retireInstructionFile(legacy);
|
|
508
|
+
if (done === "removed")
|
|
518
509
|
out.info(fmt.info(`Removed legacy ${legacy} (superseded by per-skill rules)`));
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
510
|
+
else if (done === "stripped")
|
|
511
|
+
out.info(fmt.info(`Removed rafter's block from legacy ${legacy}; kept the rest`));
|
|
512
|
+
}
|
|
513
|
+
catch {
|
|
514
|
+
/* best-effort */
|
|
523
515
|
}
|
|
524
516
|
}
|
|
525
517
|
/**
|
|
@@ -531,38 +523,8 @@ function installCursorRules(root, out) {
|
|
|
531
523
|
* apply, since Cursor relies on prompt-level constraints rather than
|
|
532
524
|
* structural restriction.
|
|
533
525
|
*/
|
|
534
|
-
function installCursorSubAgents(root, out) {
|
|
535
|
-
|
|
536
|
-
fs.mkdirSync(agentsDir, { recursive: true });
|
|
537
|
-
const candidates = [
|
|
538
|
-
path.resolve(__dirname, "..", "..", "..", "resources", "agents", "rafter.md"),
|
|
539
|
-
path.resolve(__dirname, "..", "..", "resources", "agents", "rafter.md"),
|
|
540
|
-
];
|
|
541
|
-
const src = candidates.find((p) => fs.existsSync(p));
|
|
542
|
-
if (!src) {
|
|
543
|
-
out.warn(fmt.warning(`Rafter sub-agent template not found in resources/agents`));
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
const raw = fs.readFileSync(src, "utf-8");
|
|
547
|
-
const cursored = stripToolsFromFrontmatter(raw);
|
|
548
|
-
const dest = path.join(agentsDir, "rafter.md");
|
|
549
|
-
fs.writeFileSync(dest, cursored, "utf-8");
|
|
550
|
-
out.info(fmt.success(`Installed Cursor sub-agent to ${dest}`));
|
|
551
|
-
}
|
|
552
|
-
/** Strip the Claude-Code `tools:` line from sub-agent frontmatter — Cursor doesn't have it. */
|
|
553
|
-
function stripToolsFromFrontmatter(content) {
|
|
554
|
-
if (!content.startsWith("---\n"))
|
|
555
|
-
return content;
|
|
556
|
-
const fmEnd = content.indexOf("\n---", 4);
|
|
557
|
-
if (fmEnd === -1)
|
|
558
|
-
return content;
|
|
559
|
-
const frontmatter = content.slice(4, fmEnd);
|
|
560
|
-
const body = content.slice(fmEnd);
|
|
561
|
-
const cleaned = frontmatter
|
|
562
|
-
.split("\n")
|
|
563
|
-
.filter((line) => !/^tools:\s/.test(line))
|
|
564
|
-
.join("\n");
|
|
565
|
-
return `---\n${cleaned}${body}`;
|
|
526
|
+
function installCursorSubAgents(session, root, out) {
|
|
527
|
+
session.applyAll(cursorAgentArtifacts(root, out));
|
|
566
528
|
}
|
|
567
529
|
function installGeminiHooks(root, out) {
|
|
568
530
|
const geminiDir = path.join(root, ".gemini");
|
|
@@ -605,13 +567,6 @@ function installGeminiHooks(root, out) {
|
|
|
605
567
|
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2), "utf-8");
|
|
606
568
|
out.info(fmt.success(`Installed hooks to ${settingsPath}`));
|
|
607
569
|
}
|
|
608
|
-
/** Skills shipped as Windsurf per-workspace rules at .windsurf/rules/<skill>.md (rf-0vr3). */
|
|
609
|
-
const WINDSURF_RULE_SKILLS = [
|
|
610
|
-
"rafter",
|
|
611
|
-
"rafter-secure-design",
|
|
612
|
-
"rafter-code-review",
|
|
613
|
-
"rafter-skill-review",
|
|
614
|
-
];
|
|
615
570
|
/**
|
|
616
571
|
* Install per-skill Windsurf rules at <root>/.windsurf/rules/<skill>.md.
|
|
617
572
|
*
|
|
@@ -624,28 +579,9 @@ const WINDSURF_RULE_SKILLS = [
|
|
|
624
579
|
* no-op — Windsurf has no documented hook surface as of v1.x (research bead
|
|
625
580
|
* rf-s1n3, gap reports rf-p1ri / rf-vayl).
|
|
626
581
|
*/
|
|
627
|
-
function installWindsurfRules(root, out) {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
const candidates = [
|
|
631
|
-
path.resolve(__dirname, "..", "..", "..", "resources", "windsurf-rules"),
|
|
632
|
-
path.resolve(__dirname, "..", "..", "resources", "windsurf-rules"),
|
|
633
|
-
];
|
|
634
|
-
const sourceDir = candidates.find((p) => fs.existsSync(p));
|
|
635
|
-
if (!sourceDir) {
|
|
636
|
-
out.warn(fmt.warning(`Windsurf rule templates not found in resources/windsurf-rules`));
|
|
637
|
-
return;
|
|
638
|
-
}
|
|
639
|
-
for (const name of WINDSURF_RULE_SKILLS) {
|
|
640
|
-
const src = path.join(sourceDir, `${name}.md`);
|
|
641
|
-
const dest = path.join(rulesDir, `${name}.md`);
|
|
642
|
-
if (!fs.existsSync(src)) {
|
|
643
|
-
out.warn(fmt.warning(`Windsurf rule template missing: ${src}`));
|
|
644
|
-
continue;
|
|
645
|
-
}
|
|
646
|
-
fs.copyFileSync(src, dest);
|
|
647
|
-
out.info(fmt.success(`Installed Windsurf rule to ${dest}`));
|
|
648
|
-
}
|
|
582
|
+
function installWindsurfRules(session, root, out) {
|
|
583
|
+
session.applyAll(ruleArtifacts("windsurf", root, out));
|
|
584
|
+
cleanupRetiredRules(session, "windsurf");
|
|
649
585
|
}
|
|
650
586
|
/** MCP server entry for rafter — shared across MCP-native clients */
|
|
651
587
|
const RAFTER_MCP_ENTRY = {
|
|
@@ -749,13 +685,6 @@ function installWindsurfMcp(root, out) {
|
|
|
749
685
|
out.info(fmt.success(`Installed Rafter MCP server to ${mcpPath}`));
|
|
750
686
|
return true;
|
|
751
687
|
}
|
|
752
|
-
/** Skills shipped as Continue.dev rules at .continue/rules/<skill>.md (rf-acz0). */
|
|
753
|
-
const CONTINUE_RULE_SKILLS = [
|
|
754
|
-
"rafter",
|
|
755
|
-
"rafter-secure-design",
|
|
756
|
-
"rafter-code-review",
|
|
757
|
-
"rafter-skill-review",
|
|
758
|
-
];
|
|
759
688
|
/**
|
|
760
689
|
* Install per-skill Continue.dev rules at <root>/.continue/rules/<skill>.md.
|
|
761
690
|
*
|
|
@@ -766,28 +695,9 @@ const CONTINUE_RULE_SKILLS = [
|
|
|
766
695
|
* Continue.dev has no documented hook surface (the prior hooks install was
|
|
767
696
|
* pruned in rf-cia phase b). Rules + MCP are the only intercepts.
|
|
768
697
|
*/
|
|
769
|
-
function installContinueDevRules(root, out) {
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
const candidates = [
|
|
773
|
-
path.resolve(__dirname, "..", "..", "..", "resources", "continue-rules"),
|
|
774
|
-
path.resolve(__dirname, "..", "..", "resources", "continue-rules"),
|
|
775
|
-
];
|
|
776
|
-
const sourceDir = candidates.find((p) => fs.existsSync(p));
|
|
777
|
-
if (!sourceDir) {
|
|
778
|
-
out.warn(fmt.warning(`Continue.dev rule templates not found in resources/continue-rules`));
|
|
779
|
-
return;
|
|
780
|
-
}
|
|
781
|
-
for (const name of CONTINUE_RULE_SKILLS) {
|
|
782
|
-
const src = path.join(sourceDir, `${name}.md`);
|
|
783
|
-
const dest = path.join(rulesDir, `${name}.md`);
|
|
784
|
-
if (!fs.existsSync(src)) {
|
|
785
|
-
out.warn(fmt.warning(`Continue.dev rule template missing: ${src}`));
|
|
786
|
-
continue;
|
|
787
|
-
}
|
|
788
|
-
fs.copyFileSync(src, dest);
|
|
789
|
-
out.info(fmt.success(`Installed Continue.dev rule to ${dest}`));
|
|
790
|
-
}
|
|
698
|
+
function installContinueDevRules(session, root, out) {
|
|
699
|
+
session.applyAll(ruleArtifacts("continue", root, out));
|
|
700
|
+
cleanupRetiredRules(session, "continue");
|
|
791
701
|
}
|
|
792
702
|
/**
|
|
793
703
|
* Install MCP server config for Continue.dev (~/.continue/config.json)
|
|
@@ -942,6 +852,9 @@ function installAiderRead(root, out) {
|
|
|
942
852
|
const RAFTER_READ_ENTRY = "RAFTER.md";
|
|
943
853
|
// 1. Write RAFTER.md (idempotent — the marker block is replaced in place).
|
|
944
854
|
injectInstructionFile(rafterMdPath);
|
|
855
|
+
// 1a. Aider has no skill-loading mechanism — add the note explaining that
|
|
856
|
+
// the skill names in the block above aren't separate files here.
|
|
857
|
+
injectAiderNote(rafterMdPath);
|
|
945
858
|
// 2. Update .aider.conf.yml read: list.
|
|
946
859
|
let raw = "";
|
|
947
860
|
if (fs.existsSync(configPath)) {
|
|
@@ -989,66 +902,30 @@ function installAiderRead(root, out) {
|
|
|
989
902
|
out.info(fmt.success(`Installed Rafter read-only context to ${rafterMdPath} + ${configPath}`));
|
|
990
903
|
return true;
|
|
991
904
|
}
|
|
992
|
-
//
|
|
993
|
-
//
|
|
994
|
-
|
|
995
|
-
function installSkillDir(sourceSkillDir, destSkillDir, label, out) {
|
|
996
|
-
const sourceSkillFile = path.join(sourceSkillDir, "SKILL.md");
|
|
997
|
-
if (!fs.existsSync(sourceSkillFile)) {
|
|
998
|
-
out.warn(fmt.warning(`${label} skill template not found at ${sourceSkillFile}`));
|
|
999
|
-
return;
|
|
1000
|
-
}
|
|
1001
|
-
fs.mkdirSync(destSkillDir, { recursive: true });
|
|
1002
|
-
fs.cpSync(sourceSkillDir, destSkillDir, { recursive: true });
|
|
1003
|
-
out.info(fmt.success(`Installed ${label} skill to ${destSkillDir}`));
|
|
1004
|
-
}
|
|
1005
|
-
function skillResourceDir(name) {
|
|
1006
|
-
return path.join(__dirname, "..", "..", "..", "resources", "skills", name);
|
|
1007
|
-
}
|
|
1008
|
-
function installSkillsTo(skillsDir, out) {
|
|
905
|
+
// Installs every file of every shipped skill (SKILL.md and its docs/) under
|
|
906
|
+
// the write policy in install-files.ts, then retires renamed skills.
|
|
907
|
+
function installSkillsTo(session, skillsDir, platform, component, out) {
|
|
1009
908
|
fs.mkdirSync(skillsDir, { recursive: true });
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
}
|
|
909
|
+
session.applyAll(skillArtifacts(skillsDir, platform, component, out));
|
|
910
|
+
cleanupRetiredSkills(session, skillsDir);
|
|
1013
911
|
}
|
|
1014
|
-
async function installClaudeCodeSkills(root, out) {
|
|
1015
|
-
installSkillsTo(path.join(root, ".claude", "skills"), out);
|
|
912
|
+
async function installClaudeCodeSkills(session, root, out) {
|
|
913
|
+
installSkillsTo(session, path.join(root, ".claude", "skills"), "claude-code", "claude-code.skills", out);
|
|
1016
914
|
}
|
|
1017
915
|
/**
|
|
1018
|
-
* Sub-agents shipped by `rafter agent init --with-claude-code
|
|
1019
|
-
*
|
|
1020
|
-
*
|
|
1021
|
-
*
|
|
1022
|
-
* Code session — distinct from skills, which only surface in the activation
|
|
1023
|
-
* prompt. Source files live in `resources/agents/<name>.md`.
|
|
1024
|
-
*
|
|
1025
|
-
* Keep this list in sync with the Python installer.
|
|
916
|
+
* Sub-agents shipped by `rafter agent init --with-claude-code` land in
|
|
917
|
+
* <root>/.claude/agents/<name>.md and become first-class delegation targets
|
|
918
|
+
* (Agent(subagent_type='<name>')) — distinct from skills, which only surface
|
|
919
|
+
* in the activation prompt. The list lives in install-files.ts.
|
|
1026
920
|
*/
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
];
|
|
1030
|
-
function installClaudeCodeSubAgents(root, out) {
|
|
1031
|
-
const agentsDir = path.join(root, ".claude", "agents");
|
|
1032
|
-
if (!fs.existsSync(agentsDir)) {
|
|
1033
|
-
fs.mkdirSync(agentsDir, { recursive: true });
|
|
1034
|
-
}
|
|
1035
|
-
for (const sub of CLAUDE_CODE_SUBAGENTS) {
|
|
1036
|
-
const destPath = path.join(agentsDir, `${sub.name}.md`);
|
|
1037
|
-
const srcPath = path.join(__dirname, "..", "..", "..", "resources", "agents", `${sub.name}.md`);
|
|
1038
|
-
if (fs.existsSync(srcPath)) {
|
|
1039
|
-
fs.copyFileSync(srcPath, destPath);
|
|
1040
|
-
out.info(fmt.success(`Installed ${sub.description} sub-agent to ${destPath}`));
|
|
1041
|
-
}
|
|
1042
|
-
else {
|
|
1043
|
-
out.warn(fmt.warning(`${sub.description} sub-agent template not found at ${srcPath}`));
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
921
|
+
function installClaudeCodeSubAgents(session, root, out) {
|
|
922
|
+
session.applyAll(claudeAgentArtifacts(root, out));
|
|
1046
923
|
}
|
|
1047
|
-
function installCodexSkills(root, out) {
|
|
1048
|
-
installSkillsTo(path.join(root, ".agents", "skills"), out);
|
|
924
|
+
function installCodexSkills(session, root, out) {
|
|
925
|
+
installSkillsTo(session, path.join(root, ".agents", "skills"), "codex", "codex.skills", out);
|
|
1049
926
|
}
|
|
1050
|
-
function installGeminiSkills(root, out) {
|
|
1051
|
-
installSkillsTo(path.join(root, ".agents", "skills"), out);
|
|
927
|
+
function installGeminiSkills(session, root, out) {
|
|
928
|
+
installSkillsTo(session, path.join(root, ".agents", "skills"), "gemini", "gemini.skills", out);
|
|
1052
929
|
}
|
|
1053
930
|
/**
|
|
1054
931
|
* Register installed skills with Gemini CLI via `gemini skills link <abs-path>`.
|
|
@@ -1076,8 +953,8 @@ function registerGeminiSkills(skillsDir, out) {
|
|
|
1076
953
|
"Skipping registration — skills are still installed to disk."));
|
|
1077
954
|
return;
|
|
1078
955
|
}
|
|
1079
|
-
for (const
|
|
1080
|
-
const absPath = path.resolve(skillsDir,
|
|
956
|
+
for (const name of KNOWN_SKILL_NAMES) {
|
|
957
|
+
const absPath = path.resolve(skillsDir, name);
|
|
1081
958
|
if (!fs.existsSync(absPath))
|
|
1082
959
|
continue;
|
|
1083
960
|
try {
|
|
@@ -1091,11 +968,11 @@ function registerGeminiSkills(skillsDir, out) {
|
|
|
1091
968
|
else {
|
|
1092
969
|
execFileSync("gemini", ["skills", "link", absPath], execOpts);
|
|
1093
970
|
}
|
|
1094
|
-
out.info(fmt.success(`Registered ${
|
|
971
|
+
out.info(fmt.success(`Registered ${name} with Gemini CLI`));
|
|
1095
972
|
}
|
|
1096
973
|
catch (e) {
|
|
1097
974
|
const msg = (e?.stderr?.toString?.() || e?.message || "").trim();
|
|
1098
|
-
out.warn(fmt.warning(`Failed to register ${
|
|
975
|
+
out.warn(fmt.warning(`Failed to register ${name} with Gemini CLI: ${msg.split("\n")[0] || "unknown error"}`));
|
|
1099
976
|
}
|
|
1100
977
|
}
|
|
1101
978
|
}
|
|
@@ -1121,198 +998,212 @@ export function createInitCommand() {
|
|
|
1121
998
|
.option("--local", "Install integration configs project-locally (in CWD) instead of user-globally. " +
|
|
1122
999
|
"Supported for Claude Code, Codex, Gemini, Cursor. Other platforms are skipped in local mode.")
|
|
1123
1000
|
.option("--dry-run", "Print every file path that would be created, modified, or downloaded — without making any changes (rf-hrtd).")
|
|
1001
|
+
.option("--force", "Replace installed skill, rule and sub-agent files even if you modified them (the old file is saved as <file>.bak)", false)
|
|
1124
1002
|
.option("--quiet", "Suppress informational and success output (warnings and errors still go to stderr)", false)
|
|
1125
|
-
.action(async (opts) =>
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1003
|
+
.action(async (opts) => runAgentInit(opts));
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* The body of `rafter agent init`. `rafter agent update` calls it with the
|
|
1007
|
+
* --with-<platform> flags of the platforms already installed, so both
|
|
1008
|
+
* commands refresh skills, rules, marker blocks, hooks and MCP entries
|
|
1009
|
+
* through one code path.
|
|
1010
|
+
*/
|
|
1011
|
+
export async function runAgentInit(opts) {
|
|
1012
|
+
const out = createInitOutput(opts.quiet === true);
|
|
1013
|
+
out.info(fmt.header(opts.mode === "update" ? "Rafter Agent Update" : "Rafter Agent Security Setup"));
|
|
1014
|
+
out.info(fmt.divider());
|
|
1015
|
+
out.info();
|
|
1016
|
+
const manager = new ConfigManager();
|
|
1017
|
+
const root = opts.local ? process.cwd() : os.homedir();
|
|
1018
|
+
const scope = opts.local ? "project" : "user";
|
|
1019
|
+
// Every skill / rule / sub-agent file goes through this session's write
|
|
1020
|
+
// policy and is recorded in <root>/.rafter/installed.json.
|
|
1021
|
+
const session = new InstallSession({ root, out, force: opts.force === true, dryRun: opts.dryRun === true });
|
|
1022
|
+
if (opts.local) {
|
|
1023
|
+
out.info(fmt.info(`Project-local install — writing configs under ${root}`));
|
|
1024
|
+
}
|
|
1025
|
+
// Platforms supported in --local scope: Claude Code, Codex, Gemini, Cursor.
|
|
1026
|
+
// Windsurf, Continue.dev, Aider are skipped in --local because their
|
|
1027
|
+
// project-local config story is not established in their CLIs today.
|
|
1028
|
+
// Detect environments. In local scope, don't probe user-global paths —
|
|
1029
|
+
// the user must opt in explicitly via --with-<platform>.
|
|
1030
|
+
const hasOpenClaw = scope === "user" && fs.existsSync(path.join(os.homedir(), ".openclaw"));
|
|
1031
|
+
const hasClaudeCode = scope === "user" && fs.existsSync(path.join(os.homedir(), ".claude"));
|
|
1032
|
+
const hasCodex = scope === "user" && fs.existsSync(path.join(os.homedir(), ".codex"));
|
|
1033
|
+
const hasGemini = scope === "user" && fs.existsSync(path.join(os.homedir(), ".gemini"));
|
|
1034
|
+
const hasCursor = scope === "user" && fs.existsSync(path.join(os.homedir(), ".cursor"));
|
|
1035
|
+
const hasWindsurf = scope === "user" && fs.existsSync(path.join(os.homedir(), ".codeium", "windsurf"));
|
|
1036
|
+
const hasContinueDev = scope === "user" && fs.existsSync(path.join(os.homedir(), ".continue"));
|
|
1037
|
+
const hasAider = scope === "user" && fs.existsSync(path.join(os.homedir(), ".aider.conf.yml"));
|
|
1038
|
+
const hasHermes = scope === "user" && fs.existsSync(path.join(os.homedir(), ".hermes"));
|
|
1039
|
+
const hasOpenCode = scope === "user" && fs.existsSync(path.join(os.homedir(), ".config", "opencode"));
|
|
1040
|
+
// Resolve opt-in flags (--all enables all detected, --interactive prompts).
|
|
1041
|
+
// In --local scope, --all is restricted to platforms that have a project-local
|
|
1042
|
+
// config story (claudeCode, codex, gemini, cursor). The rest require user scope.
|
|
1043
|
+
// OpenClaw returns to --all in rf-zgwj — the integration was rebuilt
|
|
1044
|
+
// to ship a ClawHub-shaped skill at the canonical workspace path
|
|
1045
|
+
// (~/.openclaw/workspace/skills/rafter-security/SKILL.md), so OpenClaw
|
|
1046
|
+
// actually auto-discovers it now. (User-scope only; --local doesn't
|
|
1047
|
+
// apply since the platform is user-config-driven.)
|
|
1048
|
+
let wantOpenClaw = opts.withOpenclaw || (opts.all && !opts.local);
|
|
1049
|
+
let wantClaudeCode = opts.withClaudeCode || opts.all;
|
|
1050
|
+
let wantCodex = opts.withCodex || opts.all;
|
|
1051
|
+
let wantGemini = opts.withGemini || opts.all;
|
|
1052
|
+
let wantCursor = opts.withCursor || opts.all;
|
|
1053
|
+
// Windsurf can install at --local scope (project rules + AGENTS.md)
|
|
1054
|
+
// since rf-0vr3. User scope still also installs the MCP entry.
|
|
1055
|
+
let wantWindsurf = opts.withWindsurf || opts.all;
|
|
1056
|
+
// Continue.dev can install at --local scope (project rules) since rf-acz0.
|
|
1057
|
+
// User scope additionally registers the MCP entry.
|
|
1058
|
+
let wantContinue = opts.withContinue || opts.all;
|
|
1059
|
+
// Aider can install at --local scope (writes RAFTER.md + .aider.conf.yml
|
|
1060
|
+
// in cwd) since rf-du2o.
|
|
1061
|
+
let wantAider = opts.withAider || opts.all;
|
|
1062
|
+
// Hermes: MCP-only v0 (no hooks confirmed yet). User scope only — Hermes
|
|
1063
|
+
// reads ~/.hermes/config.yaml; the project-local install story isn't
|
|
1064
|
+
// established. Excluded from --all in --local for the same reason.
|
|
1065
|
+
let wantHermes = opts.withHermes || (opts.all && !opts.local);
|
|
1066
|
+
// OpenCode: MCP-based, user scope only. OpenCode reads a global config at
|
|
1067
|
+
// ~/.config/opencode/opencode.json; a project-local install story via
|
|
1068
|
+
// --local isn't wired here, so (like Hermes) it's excluded from --all in
|
|
1069
|
+
// --local scope. It supports MCP local/stdio servers and AGENTS.md
|
|
1070
|
+
// natively (https://opencode.ai/docs/mcp-servers/, sable-l8e5).
|
|
1071
|
+
let wantOpenCode = opts.withOpencode || (opts.all && !opts.local);
|
|
1072
|
+
let wantBetterleaks = opts.withBetterleaks || (opts.all && !opts.local);
|
|
1073
|
+
// skill-scanner is heavy and opt-in only — deliberately NOT folded into --all.
|
|
1074
|
+
const wantSkillScanner = !!opts.withSkillScanner;
|
|
1075
|
+
// Interactive mode: prompt for each detected integration
|
|
1076
|
+
if (opts.interactive && !opts.all) {
|
|
1129
1077
|
out.info();
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
if (opts.withCursor && !hasCursor)
|
|
1260
|
-
out.warn(fmt.warning("Cursor requested but not detected (~/.cursor not found)"));
|
|
1261
|
-
if (opts.withWindsurf && !hasWindsurf)
|
|
1262
|
-
out.warn(fmt.warning("Windsurf requested but not detected (~/.codeium/windsurf not found)"));
|
|
1263
|
-
if (opts.withContinue && !hasContinueDev)
|
|
1264
|
-
out.warn(fmt.warning("Continue.dev requested but not detected (~/.continue not found)"));
|
|
1265
|
-
if (opts.withAider && !hasAider)
|
|
1266
|
-
out.warn(fmt.warning("Aider requested but not detected (~/.aider.conf.yml not found)"));
|
|
1267
|
-
if (opts.withHermes && !hasHermes)
|
|
1268
|
-
out.warn(fmt.warning("Hermes requested but not detected (~/.hermes not found)"));
|
|
1269
|
-
if (opts.withOpencode && !hasOpenCode)
|
|
1270
|
-
out.warn(fmt.warning("OpenCode requested but not detected (~/.config/opencode not found)"));
|
|
1271
|
-
}
|
|
1272
|
-
// --dry-run: print every file path the command would touch, then
|
|
1273
|
-
// exit before any filesystem write happens (rf-hrtd). The plan is
|
|
1274
|
-
// built from the SAME resolved want* / has* booleans the install
|
|
1275
|
-
// path uses, so the listing mirrors what would actually run.
|
|
1276
|
-
if (opts.dryRun) {
|
|
1277
|
-
const bm = new BinaryManager();
|
|
1278
|
-
const betterleaksExisting = !wantBetterleaks || opts.update
|
|
1279
|
-
? null
|
|
1280
|
-
: bm.isBetterleaksInstalled()
|
|
1281
|
-
? bm.getBetterleaksPath()
|
|
1282
|
-
: bm.findBetterleaksOnPath();
|
|
1283
|
-
const components = (manager.get("agent.components") ?? {});
|
|
1284
|
-
printDryRunPlan({
|
|
1285
|
-
root,
|
|
1286
|
-
scope,
|
|
1287
|
-
wantOpenClaw: wantOpenClaw && (hasOpenClaw),
|
|
1288
|
-
wantClaudeCode: wantClaudeCode && (hasClaudeCode || opts.withClaudeCode || opts.local),
|
|
1289
|
-
wantCodex: wantCodex && (hasCodex || opts.local),
|
|
1290
|
-
wantGemini: wantGemini && (hasGemini || opts.local),
|
|
1291
|
-
wantCursor: wantCursor && (hasCursor || opts.local),
|
|
1292
|
-
wantWindsurf: wantWindsurf && (hasWindsurf || opts.local),
|
|
1293
|
-
wantContinue: wantContinue && (hasContinueDev || opts.local),
|
|
1294
|
-
wantAider: wantAider && (hasAider || opts.local),
|
|
1295
|
-
wantHermes: wantHermes && hasHermes,
|
|
1296
|
-
wantOpenCode: wantOpenCode && hasOpenCode,
|
|
1297
|
-
wantBetterleaks,
|
|
1298
|
-
betterleaksExisting,
|
|
1299
|
-
betterleaksSupported: bm.getPlatformInfo().supported,
|
|
1300
|
-
wantSkillScanner,
|
|
1301
|
-
claudeCodeMcpDisabled: components["claude-code.mcp"]?.enabled === false,
|
|
1302
|
-
riskLevel: opts.riskLevel,
|
|
1303
|
-
});
|
|
1304
|
-
return;
|
|
1305
|
-
}
|
|
1306
|
-
// Initialize directory structure
|
|
1307
|
-
try {
|
|
1308
|
-
await manager.initialize();
|
|
1309
|
-
out.info(fmt.success("Created config at ~/.rafter/config.json"));
|
|
1310
|
-
}
|
|
1311
|
-
catch (e) {
|
|
1312
|
-
console.error(fmt.error(`Failed to initialize: ${e}`));
|
|
1313
|
-
process.exit(1);
|
|
1314
|
-
}
|
|
1315
|
-
// Set risk level
|
|
1078
|
+
out.info(fmt.info("Select integrations to install:"));
|
|
1079
|
+
out.info();
|
|
1080
|
+
if (hasClaudeCode && !wantClaudeCode)
|
|
1081
|
+
wantClaudeCode = await askYesNo("Install Claude Code hooks + skills?");
|
|
1082
|
+
if (hasCodex && !wantCodex)
|
|
1083
|
+
wantCodex = await askYesNo("Install Codex CLI skills + hooks?");
|
|
1084
|
+
if (hasOpenClaw && !wantOpenClaw)
|
|
1085
|
+
wantOpenClaw = await askYesNo("Install OpenClaw skill?");
|
|
1086
|
+
if (hasGemini && !wantGemini)
|
|
1087
|
+
wantGemini = await askYesNo("Install Gemini CLI MCP + hooks?");
|
|
1088
|
+
if (hasCursor && !wantCursor)
|
|
1089
|
+
wantCursor = await askYesNo("Install Cursor MCP + hooks?");
|
|
1090
|
+
if (hasWindsurf && !wantWindsurf)
|
|
1091
|
+
wantWindsurf = await askYesNo("Install Windsurf MCP + hooks?");
|
|
1092
|
+
if (hasContinueDev && !wantContinue)
|
|
1093
|
+
wantContinue = await askYesNo("Install Continue.dev MCP server?");
|
|
1094
|
+
if (hasAider && !wantAider)
|
|
1095
|
+
wantAider = await askYesNo("Install Aider MCP server?");
|
|
1096
|
+
if (hasHermes && !wantHermes)
|
|
1097
|
+
wantHermes = await askYesNo("Install Hermes MCP server?");
|
|
1098
|
+
if (hasOpenCode && !wantOpenCode)
|
|
1099
|
+
wantOpenCode = await askYesNo("Install OpenCode MCP server?");
|
|
1100
|
+
if (!wantBetterleaks)
|
|
1101
|
+
wantBetterleaks = await askYesNo("Download Betterleaks binary (enhanced scanning)?");
|
|
1102
|
+
out.info();
|
|
1103
|
+
}
|
|
1104
|
+
// Show detected environments with opt-in hints
|
|
1105
|
+
const detected = [];
|
|
1106
|
+
if (hasOpenClaw)
|
|
1107
|
+
detected.push("OpenClaw");
|
|
1108
|
+
if (hasClaudeCode)
|
|
1109
|
+
detected.push("Claude Code");
|
|
1110
|
+
if (hasCodex)
|
|
1111
|
+
detected.push("Codex CLI");
|
|
1112
|
+
if (hasGemini)
|
|
1113
|
+
detected.push("Gemini CLI");
|
|
1114
|
+
if (hasCursor)
|
|
1115
|
+
detected.push("Cursor");
|
|
1116
|
+
if (hasWindsurf)
|
|
1117
|
+
detected.push("Windsurf");
|
|
1118
|
+
if (hasContinueDev)
|
|
1119
|
+
detected.push("Continue.dev");
|
|
1120
|
+
if (hasAider)
|
|
1121
|
+
detected.push("Aider");
|
|
1122
|
+
if (hasHermes)
|
|
1123
|
+
detected.push("Hermes");
|
|
1124
|
+
if (hasOpenCode)
|
|
1125
|
+
detected.push("OpenCode");
|
|
1126
|
+
if (detected.length > 0) {
|
|
1127
|
+
out.info(fmt.info(`Detected environments: ${detected.join(", ")}`));
|
|
1128
|
+
}
|
|
1129
|
+
else {
|
|
1130
|
+
out.info(fmt.info("No agent environments detected"));
|
|
1131
|
+
}
|
|
1132
|
+
// Warn about requested but undetected environments (user scope only —
|
|
1133
|
+
// in --local scope we create the directories in CWD as needed).
|
|
1134
|
+
// Gated on the EXPLICIT --with-<platform> flag, not the resolved
|
|
1135
|
+
// want* (which --all also sets): --all means "install all DETECTED
|
|
1136
|
+
// integrations" per its own --help text, so an undetected platform
|
|
1137
|
+
// under --all is normal and shouldn't warn individually — 9 such
|
|
1138
|
+
// warnings buried the ones that actually matter (rafter-cli#231).
|
|
1139
|
+
if (scope === "user") {
|
|
1140
|
+
if (opts.withOpenclaw && !hasOpenClaw)
|
|
1141
|
+
out.warn(fmt.warning("OpenClaw requested but not detected (~/.openclaw not found)"));
|
|
1142
|
+
if (opts.withClaudeCode && !hasClaudeCode)
|
|
1143
|
+
out.warn(fmt.warning("Claude Code requested but not detected (~/.claude not found)"));
|
|
1144
|
+
if (opts.withCodex && !hasCodex)
|
|
1145
|
+
out.warn(fmt.warning("Codex CLI requested but not detected (~/.codex not found)"));
|
|
1146
|
+
if (opts.withGemini && !hasGemini)
|
|
1147
|
+
out.warn(fmt.warning("Gemini CLI requested but not detected (~/.gemini not found)"));
|
|
1148
|
+
if (opts.withCursor && !hasCursor)
|
|
1149
|
+
out.warn(fmt.warning("Cursor requested but not detected (~/.cursor not found)"));
|
|
1150
|
+
if (opts.withWindsurf && !hasWindsurf)
|
|
1151
|
+
out.warn(fmt.warning("Windsurf requested but not detected (~/.codeium/windsurf not found)"));
|
|
1152
|
+
if (opts.withContinue && !hasContinueDev)
|
|
1153
|
+
out.warn(fmt.warning("Continue.dev requested but not detected (~/.continue not found)"));
|
|
1154
|
+
if (opts.withAider && !hasAider)
|
|
1155
|
+
out.warn(fmt.warning("Aider requested but not detected (~/.aider.conf.yml not found)"));
|
|
1156
|
+
if (opts.withHermes && !hasHermes)
|
|
1157
|
+
out.warn(fmt.warning("Hermes requested but not detected (~/.hermes not found)"));
|
|
1158
|
+
if (opts.withOpencode && !hasOpenCode)
|
|
1159
|
+
out.warn(fmt.warning("OpenCode requested but not detected (~/.config/opencode not found)"));
|
|
1160
|
+
}
|
|
1161
|
+
// --dry-run: print every file path the command would touch, then
|
|
1162
|
+
// exit before any filesystem write happens (rf-hrtd). The plan is
|
|
1163
|
+
// built from the SAME resolved want* / has* booleans the install
|
|
1164
|
+
// path uses, so the listing mirrors what would actually run.
|
|
1165
|
+
if (opts.dryRun) {
|
|
1166
|
+
const bm = new BinaryManager();
|
|
1167
|
+
const betterleaksExisting = !wantBetterleaks || opts.update
|
|
1168
|
+
? null
|
|
1169
|
+
: bm.isBetterleaksInstalled()
|
|
1170
|
+
? bm.getBetterleaksPath()
|
|
1171
|
+
: bm.findBetterleaksOnPath();
|
|
1172
|
+
const components = (manager.get("agent.components") ?? {});
|
|
1173
|
+
printDryRunPlan({
|
|
1174
|
+
root,
|
|
1175
|
+
scope,
|
|
1176
|
+
wantOpenClaw: wantOpenClaw && (hasOpenClaw),
|
|
1177
|
+
wantClaudeCode: wantClaudeCode && (hasClaudeCode || opts.withClaudeCode || opts.local),
|
|
1178
|
+
wantCodex: wantCodex && (hasCodex || opts.local),
|
|
1179
|
+
wantGemini: wantGemini && (hasGemini || opts.local),
|
|
1180
|
+
wantCursor: wantCursor && (hasCursor || opts.local),
|
|
1181
|
+
wantWindsurf: wantWindsurf && (hasWindsurf || opts.local),
|
|
1182
|
+
wantContinue: wantContinue && (hasContinueDev || opts.local),
|
|
1183
|
+
wantAider: wantAider && (hasAider || opts.local),
|
|
1184
|
+
wantHermes: wantHermes && hasHermes,
|
|
1185
|
+
wantOpenCode: wantOpenCode && hasOpenCode,
|
|
1186
|
+
wantBetterleaks,
|
|
1187
|
+
betterleaksExisting,
|
|
1188
|
+
betterleaksSupported: bm.getPlatformInfo().supported,
|
|
1189
|
+
wantSkillScanner,
|
|
1190
|
+
claudeCodeMcpDisabled: components["claude-code.mcp"]?.enabled === false,
|
|
1191
|
+
riskLevel: opts.riskLevel ?? "unchanged",
|
|
1192
|
+
session,
|
|
1193
|
+
});
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
// Initialize directory structure
|
|
1197
|
+
try {
|
|
1198
|
+
await manager.initialize();
|
|
1199
|
+
out.info(fmt.success("Created config at ~/.rafter/config.json"));
|
|
1200
|
+
}
|
|
1201
|
+
catch (e) {
|
|
1202
|
+
console.error(fmt.error(`Failed to initialize: ${e}`));
|
|
1203
|
+
process.exit(1);
|
|
1204
|
+
}
|
|
1205
|
+
// Set risk level (update leaves it as configured)
|
|
1206
|
+
if (opts.riskLevel !== undefined) {
|
|
1316
1207
|
const validRiskLevels = ["minimal", "moderate", "aggressive"];
|
|
1317
1208
|
if (!validRiskLevels.includes(opts.riskLevel)) {
|
|
1318
1209
|
console.error(fmt.error(`Invalid risk level: ${opts.riskLevel}`));
|
|
@@ -1321,393 +1212,392 @@ export function createInitCommand() {
|
|
|
1321
1212
|
}
|
|
1322
1213
|
manager.set("agent.riskLevel", opts.riskLevel);
|
|
1323
1214
|
out.info(fmt.success(`Set risk level: ${opts.riskLevel}`));
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
}
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1215
|
+
}
|
|
1216
|
+
// Check / download Betterleaks binary (opt-in via --with-betterleaks or --all)
|
|
1217
|
+
if (wantBetterleaks) {
|
|
1218
|
+
const binaryManager = new BinaryManager();
|
|
1219
|
+
const platformInfo = binaryManager.getPlatformInfo();
|
|
1220
|
+
// Helper: show diagnostics for a failing binary (mirrors Python's agent init)
|
|
1221
|
+
const showDiagnostics = async (binaryPath, verResult) => {
|
|
1222
|
+
if (verResult.stderr) {
|
|
1223
|
+
out.warn(fmt.info(` stderr: ${verResult.stderr}`));
|
|
1224
|
+
}
|
|
1225
|
+
const diag = await binaryManager.collectBinaryDiagnostics(binaryPath);
|
|
1226
|
+
if (diag) {
|
|
1227
|
+
out.warn(fmt.info("Diagnostics:"));
|
|
1228
|
+
out.warn(diag);
|
|
1229
|
+
}
|
|
1230
|
+
out.warn(fmt.info("To fix: install betterleaks (https://github.com/betterleaks/betterleaks/releases) and ensure it is on PATH, then re-run 'rafter agent init'."));
|
|
1231
|
+
out.info();
|
|
1232
|
+
};
|
|
1233
|
+
if (!opts.update && binaryManager.isBetterleaksInstalled()) {
|
|
1234
|
+
// Local binary exists — verify it actually works
|
|
1235
|
+
const verResult = await binaryManager.verifyBetterleaksVerbose();
|
|
1236
|
+
if (verResult.ok) {
|
|
1237
|
+
out.info(fmt.success(`Betterleaks already installed (${verResult.stdout})`));
|
|
1238
|
+
}
|
|
1239
|
+
else {
|
|
1240
|
+
out.warn(fmt.warning("Betterleaks binary found locally but failed to execute."));
|
|
1241
|
+
out.warn(fmt.info(` Binary: ${binaryManager.getBetterleaksPath()}`));
|
|
1242
|
+
await showDiagnostics(binaryManager.getBetterleaksPath(), verResult);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
else {
|
|
1246
|
+
// Not installed locally (or --update forcing re-download) — check PATH first
|
|
1247
|
+
// unless --update was passed (in that case force a fresh managed install)
|
|
1248
|
+
const pathBinary = opts.update ? null : binaryManager.findBetterleaksOnPath();
|
|
1249
|
+
if (pathBinary) {
|
|
1250
|
+
const verResult = await binaryManager.verifyBetterleaksVerbose(pathBinary);
|
|
1344
1251
|
if (verResult.ok) {
|
|
1345
|
-
out.info(fmt.success(`Betterleaks
|
|
1252
|
+
out.info(fmt.success(`Betterleaks available on PATH (${verResult.stdout})`));
|
|
1346
1253
|
}
|
|
1347
1254
|
else {
|
|
1348
|
-
out.warn(fmt.warning("Betterleaks
|
|
1349
|
-
out.warn(fmt.info(` Binary: ${
|
|
1350
|
-
await showDiagnostics(
|
|
1255
|
+
out.warn(fmt.warning("Betterleaks found on PATH but failed to execute."));
|
|
1256
|
+
out.warn(fmt.info(` Binary: ${pathBinary}`));
|
|
1257
|
+
await showDiagnostics(pathBinary, verResult);
|
|
1351
1258
|
}
|
|
1352
1259
|
}
|
|
1260
|
+
else if (!platformInfo.supported) {
|
|
1261
|
+
out.info(fmt.info(`Betterleaks not available for ${platformInfo.platform}/${platformInfo.arch}`));
|
|
1262
|
+
out.info(fmt.success("Using pattern-based scanning (21 patterns)"));
|
|
1263
|
+
}
|
|
1353
1264
|
else {
|
|
1354
|
-
// Not
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
else {
|
|
1363
|
-
out.warn(fmt.warning("Betterleaks found on PATH but failed to execute."));
|
|
1364
|
-
out.warn(fmt.info(` Binary: ${pathBinary}`));
|
|
1365
|
-
await showDiagnostics(pathBinary, verResult);
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
else if (!platformInfo.supported) {
|
|
1369
|
-
out.info(fmt.info(`Betterleaks not available for ${platformInfo.platform}/${platformInfo.arch}`));
|
|
1370
|
-
out.info(fmt.success("Using pattern-based scanning (21 patterns)"));
|
|
1265
|
+
// Not on PATH, not installed locally — download
|
|
1266
|
+
out.info();
|
|
1267
|
+
out.info(fmt.info("Downloading Betterleaks (enhanced secret detection)..."));
|
|
1268
|
+
try {
|
|
1269
|
+
await binaryManager.downloadBetterleaks((msg) => {
|
|
1270
|
+
out.info(` ${msg}`);
|
|
1271
|
+
});
|
|
1272
|
+
out.info();
|
|
1371
1273
|
}
|
|
1372
|
-
|
|
1373
|
-
|
|
1274
|
+
catch (e) {
|
|
1275
|
+
out.info();
|
|
1276
|
+
out.warn(fmt.error(`Betterleaks setup failed — pattern-based scanning will be used instead.`));
|
|
1277
|
+
out.warn(fmt.warning(String(e)));
|
|
1278
|
+
out.info();
|
|
1279
|
+
out.warn(fmt.info("To fix: install betterleaks manually (https://github.com/betterleaks/betterleaks/releases) and ensure it is on PATH, then re-run 'rafter agent init'."));
|
|
1374
1280
|
out.info();
|
|
1375
|
-
out.info(fmt.info("Downloading Betterleaks (enhanced secret detection)..."));
|
|
1376
|
-
try {
|
|
1377
|
-
await binaryManager.downloadBetterleaks((msg) => {
|
|
1378
|
-
out.info(` ${msg}`);
|
|
1379
|
-
});
|
|
1380
|
-
out.info();
|
|
1381
|
-
}
|
|
1382
|
-
catch (e) {
|
|
1383
|
-
out.info();
|
|
1384
|
-
out.warn(fmt.error(`Betterleaks setup failed — pattern-based scanning will be used instead.`));
|
|
1385
|
-
out.warn(fmt.warning(String(e)));
|
|
1386
|
-
out.info();
|
|
1387
|
-
out.warn(fmt.info("To fix: install betterleaks manually (https://github.com/betterleaks/betterleaks/releases) and ensure it is on PATH, then re-run 'rafter agent init'."));
|
|
1388
|
-
out.info();
|
|
1389
|
-
}
|
|
1390
1281
|
}
|
|
1391
1282
|
}
|
|
1392
1283
|
}
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
}
|
|
1401
|
-
catch {
|
|
1402
|
-
return null;
|
|
1403
|
-
}
|
|
1404
|
-
})();
|
|
1405
|
-
if (onPath) {
|
|
1406
|
-
out.info(fmt.success(`skill-scanner available on PATH (${onPath})`));
|
|
1284
|
+
}
|
|
1285
|
+
// Install the optional skill-scanner deep engine (opt-in via
|
|
1286
|
+
// --with-skill-scanner only — never via --all, as it's heavy).
|
|
1287
|
+
if (wantSkillScanner) {
|
|
1288
|
+
const onPath = opts.update ? null : (() => {
|
|
1289
|
+
try {
|
|
1290
|
+
const cmd = process.platform === "win32" ? "where skill-scanner" : "which skill-scanner";
|
|
1291
|
+
return execSync(cmd, { timeout: 5000, encoding: "utf-8" }).trim().split("\n")[0].trim() || null;
|
|
1407
1292
|
}
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
out.info(fmt.info("Installing optional skill-scanner deep engine (heavy third-party package; isolated install)..."));
|
|
1411
|
-
const result = await new SkillScannerInstaller().install(SKILL_SCANNER_VERSION, (msg) => out.info(` ${msg}`));
|
|
1412
|
-
if (result.ok) {
|
|
1413
|
-
out.info(fmt.success(`skill-scanner installed (via ${result.via}): ${result.message}`));
|
|
1414
|
-
}
|
|
1415
|
-
else {
|
|
1416
|
-
out.warn(fmt.warning(`skill-scanner install failed: ${result.message}`));
|
|
1417
|
-
out.warn(fmt.info("To fix: run 'rafter agent update-skill-scanner' or install manually with 'uv tool install cisco-ai-skill-scanner'."));
|
|
1418
|
-
}
|
|
1293
|
+
catch {
|
|
1294
|
+
return null;
|
|
1419
1295
|
}
|
|
1296
|
+
})();
|
|
1297
|
+
if (onPath) {
|
|
1298
|
+
out.info(fmt.success(`skill-scanner available on PATH (${onPath})`));
|
|
1420
1299
|
}
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
const
|
|
1425
|
-
const result = await skillManager.installRafterSkillVerbose();
|
|
1426
|
-
openclawOk = result.ok;
|
|
1300
|
+
else {
|
|
1301
|
+
out.info();
|
|
1302
|
+
out.info(fmt.info("Installing optional skill-scanner deep engine (heavy third-party package; isolated install)..."));
|
|
1303
|
+
const result = await new SkillScannerInstaller().install(SKILL_SCANNER_VERSION, (msg) => out.info(` ${msg}`));
|
|
1427
1304
|
if (result.ok) {
|
|
1428
|
-
out.info(fmt.success(`
|
|
1429
|
-
manager.set("agent.environments.openclaw.enabled", true);
|
|
1305
|
+
out.info(fmt.success(`skill-scanner installed (via ${result.via}): ${result.message}`));
|
|
1430
1306
|
}
|
|
1431
1307
|
else {
|
|
1432
|
-
out.warn(fmt.
|
|
1433
|
-
out.warn(fmt.
|
|
1434
|
-
out.warn(fmt.warning(` Destination: ${result.destPath}`));
|
|
1435
|
-
if (result.error) {
|
|
1436
|
-
out.warn(fmt.warning(` Error: ${result.error}`));
|
|
1437
|
-
}
|
|
1308
|
+
out.warn(fmt.warning(`skill-scanner install failed: ${result.message}`));
|
|
1309
|
+
out.warn(fmt.info("To fix: run 'rafter agent update-skill-scanner' or install manually with 'uv tool install cisco-ai-skill-scanner'."));
|
|
1438
1310
|
}
|
|
1439
1311
|
}
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1312
|
+
}
|
|
1313
|
+
// Install OpenClaw skill if opted in (user scope only, so session.root is home)
|
|
1314
|
+
let openclawOk = false;
|
|
1315
|
+
if (hasOpenClaw && wantOpenClaw) {
|
|
1316
|
+
try {
|
|
1317
|
+
const artifacts = openclawSkillArtifacts(root, out);
|
|
1318
|
+
session.applyAll(artifacts);
|
|
1319
|
+
cleanupLegacyOpenClaw(session);
|
|
1320
|
+
openclawOk = artifacts.length > 0;
|
|
1321
|
+
if (openclawOk)
|
|
1322
|
+
manager.set("agent.environments.openclaw.enabled", true);
|
|
1323
|
+
}
|
|
1324
|
+
catch (e) {
|
|
1325
|
+
out.warn(fmt.error(`Failed to install Rafter Security skill to ${openclawSkillPath(root)}: ${e}`));
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
// Helper: warn that a platform is not supported in --local mode.
|
|
1329
|
+
const localUnsupported = (label) => {
|
|
1330
|
+
out.warn(fmt.warning(`${label} is not supported in --local mode yet. Skipping. ` +
|
|
1331
|
+
`Re-run without --local to install for this platform user-globally.`));
|
|
1332
|
+
};
|
|
1333
|
+
// Install Claude Code skills + hooks if opted in
|
|
1334
|
+
// When --with-claude-code is explicitly passed (or --local), install even if <root>/.claude doesn't exist yet
|
|
1335
|
+
let claudeCodeOk = false;
|
|
1336
|
+
if ((hasClaudeCode || opts.withClaudeCode || (opts.local && wantClaudeCode)) && wantClaudeCode) {
|
|
1337
|
+
try {
|
|
1338
|
+
await installClaudeCodeSkills(session, root, out);
|
|
1339
|
+
installClaudeCodeSubAgents(session, root, out);
|
|
1340
|
+
installClaudeCodeHooks(root, out);
|
|
1341
|
+
if (scope === "project") {
|
|
1342
|
+
const components = (manager.get("agent.components") ?? {});
|
|
1343
|
+
if (components["claude-code.mcp"]?.enabled === false) {
|
|
1344
|
+
out.info(fmt.info("Skipped .mcp.json (claude-code.mcp disabled; re-enable with `rafter agent enable claude-code.mcp`)"));
|
|
1345
|
+
}
|
|
1346
|
+
else {
|
|
1347
|
+
installClaudeCodeMcp(root, out);
|
|
1348
|
+
components["claude-code.mcp"] = { enabled: true, updatedAt: new Date().toISOString() };
|
|
1349
|
+
manager.set("agent.components", components);
|
|
1463
1350
|
}
|
|
1464
|
-
if (scope === "user")
|
|
1465
|
-
manager.set("agent.environments.claudeCode.enabled", true);
|
|
1466
|
-
claudeCodeOk = true;
|
|
1467
|
-
}
|
|
1468
|
-
catch (e) {
|
|
1469
|
-
console.error(fmt.error(`Failed to install Claude Code integration: ${e}`));
|
|
1470
1351
|
}
|
|
1352
|
+
if (scope === "user")
|
|
1353
|
+
manager.set("agent.environments.claudeCode.enabled", true);
|
|
1354
|
+
claudeCodeOk = true;
|
|
1471
1355
|
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
if ((hasCodex || (opts.local && wantCodex)) && wantCodex) {
|
|
1475
|
-
try {
|
|
1476
|
-
installCodexSkills(root, out);
|
|
1477
|
-
installCodexHooks(root, out);
|
|
1478
|
-
if (scope === "user")
|
|
1479
|
-
manager.set("agent.environments.codex.enabled", true);
|
|
1480
|
-
codexOk = true;
|
|
1481
|
-
}
|
|
1482
|
-
catch (e) {
|
|
1483
|
-
console.error(fmt.error(`Failed to install Codex CLI integration: ${e}`));
|
|
1484
|
-
}
|
|
1356
|
+
catch (e) {
|
|
1357
|
+
console.error(fmt.error(`Failed to install Claude Code integration: ${e}`));
|
|
1485
1358
|
}
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
}
|
|
1497
|
-
catch (e) {
|
|
1498
|
-
console.error(fmt.error(`Failed to install Gemini CLI integration: ${e}`));
|
|
1499
|
-
}
|
|
1359
|
+
}
|
|
1360
|
+
// Install Codex CLI skills + hooks if opted in
|
|
1361
|
+
let codexOk = false;
|
|
1362
|
+
if ((hasCodex || (opts.local && wantCodex)) && wantCodex) {
|
|
1363
|
+
try {
|
|
1364
|
+
installCodexSkills(session, root, out);
|
|
1365
|
+
installCodexHooks(root, out);
|
|
1366
|
+
if (scope === "user")
|
|
1367
|
+
manager.set("agent.environments.codex.enabled", true);
|
|
1368
|
+
codexOk = true;
|
|
1500
1369
|
}
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
if ((hasCursor || (opts.local && wantCursor)) && wantCursor) {
|
|
1504
|
-
try {
|
|
1505
|
-
cursorOk = installCursorMcp(root, out);
|
|
1506
|
-
installCursorHooks(root, out);
|
|
1507
|
-
installCursorRules(root, out);
|
|
1508
|
-
installCursorSubAgents(root, out);
|
|
1509
|
-
if (cursorOk && scope === "user")
|
|
1510
|
-
manager.set("agent.environments.cursor.enabled", true);
|
|
1511
|
-
}
|
|
1512
|
-
catch (e) {
|
|
1513
|
-
console.error(fmt.error(`Failed to install Cursor integration: ${e}`));
|
|
1514
|
-
}
|
|
1370
|
+
catch (e) {
|
|
1371
|
+
console.error(fmt.error(`Failed to install Codex CLI integration: ${e}`));
|
|
1515
1372
|
}
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
if (hasWindsurf) {
|
|
1528
|
-
windsurfOk = installWindsurfMcp(root, out);
|
|
1529
|
-
if (windsurfOk)
|
|
1530
|
-
manager.set("agent.environments.windsurf.enabled", true);
|
|
1531
|
-
}
|
|
1532
|
-
installWindsurfRules(root, out);
|
|
1533
|
-
// AGENTS.md is written below in installGlobalInstructions when
|
|
1534
|
-
// platforms.windsurf is true.
|
|
1535
|
-
if (!hasWindsurf)
|
|
1536
|
-
windsurfOk = true; // local-scope success: rules + AGENTS.md
|
|
1537
|
-
}
|
|
1538
|
-
catch (e) {
|
|
1539
|
-
console.error(fmt.error(`Failed to install Windsurf integration: ${e}`));
|
|
1540
|
-
}
|
|
1373
|
+
}
|
|
1374
|
+
// Install Gemini CLI MCP + skills + hooks if opted in
|
|
1375
|
+
let geminiOk = false;
|
|
1376
|
+
if ((hasGemini || (opts.local && wantGemini)) && wantGemini) {
|
|
1377
|
+
try {
|
|
1378
|
+
geminiOk = installGeminiMcp(root, out);
|
|
1379
|
+
installGeminiSkills(session, root, out);
|
|
1380
|
+
registerGeminiSkills(path.join(root, ".agents", "skills"), out);
|
|
1381
|
+
installGeminiHooks(root, out);
|
|
1382
|
+
if (geminiOk && scope === "user")
|
|
1383
|
+
manager.set("agent.environments.gemini.enabled", true);
|
|
1541
1384
|
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
// ~/.continue/config.json.
|
|
1545
|
-
// - Project scope (--local): rules only.
|
|
1546
|
-
// Continue.dev has no hook surface — the prior hooks install was pruned
|
|
1547
|
-
// in rf-cia phase b.
|
|
1548
|
-
let continueOk = false;
|
|
1549
|
-
if (wantContinue && (hasContinueDev || opts.local)) {
|
|
1550
|
-
try {
|
|
1551
|
-
if (hasContinueDev) {
|
|
1552
|
-
continueOk = installContinueDevMcp(root, out);
|
|
1553
|
-
if (continueOk)
|
|
1554
|
-
manager.set("agent.environments.continueDev.enabled", true);
|
|
1555
|
-
}
|
|
1556
|
-
installContinueDevRules(root, out);
|
|
1557
|
-
if (!hasContinueDev)
|
|
1558
|
-
continueOk = true; // local-scope success: rules only
|
|
1559
|
-
}
|
|
1560
|
-
catch (e) {
|
|
1561
|
-
console.error(fmt.error(`Failed to install Continue.dev integration: ${e}`));
|
|
1562
|
-
}
|
|
1385
|
+
catch (e) {
|
|
1386
|
+
console.error(fmt.error(`Failed to install Gemini CLI integration: ${e}`));
|
|
1563
1387
|
}
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
}
|
|
1576
|
-
catch (e) {
|
|
1577
|
-
console.error(fmt.error(`Failed to install Aider integration: ${e}`));
|
|
1578
|
-
}
|
|
1388
|
+
}
|
|
1389
|
+
// Install Cursor MCP + hooks + per-skill rules + sub-agent if opted in
|
|
1390
|
+
let cursorOk = false;
|
|
1391
|
+
if ((hasCursor || (opts.local && wantCursor)) && wantCursor) {
|
|
1392
|
+
try {
|
|
1393
|
+
cursorOk = installCursorMcp(root, out);
|
|
1394
|
+
installCursorHooks(root, out);
|
|
1395
|
+
installCursorRules(session, root, out);
|
|
1396
|
+
installCursorSubAgents(session, root, out);
|
|
1397
|
+
if (cursorOk && scope === "user")
|
|
1398
|
+
manager.set("agent.environments.cursor.enabled", true);
|
|
1579
1399
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1400
|
+
catch (e) {
|
|
1401
|
+
console.error(fmt.error(`Failed to install Cursor integration: ${e}`));
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
// Install Windsurf integration if opted in.
|
|
1405
|
+
// - User scope: MCP entry under ~/.codeium/windsurf/ + per-skill rules
|
|
1406
|
+
// at .windsurf/rules/ (workspace) + AGENTS.md (workspace, written by
|
|
1407
|
+
// installGlobalInstructions below).
|
|
1408
|
+
// - Project scope (--local): per-skill rules + AGENTS.md only (no
|
|
1409
|
+
// user-scope MCP entry written from a project init).
|
|
1410
|
+
// The previous ~/.windsurf/hooks.json install was pruned: Windsurf has
|
|
1411
|
+
// no documented hook surface (rf-0vr3).
|
|
1412
|
+
let windsurfOk = false;
|
|
1413
|
+
if (wantWindsurf && (hasWindsurf || opts.local)) {
|
|
1414
|
+
try {
|
|
1415
|
+
if (hasWindsurf) {
|
|
1416
|
+
windsurfOk = installWindsurfMcp(root, out);
|
|
1417
|
+
if (windsurfOk)
|
|
1418
|
+
manager.set("agent.environments.windsurf.enabled", true);
|
|
1592
1419
|
}
|
|
1420
|
+
installWindsurfRules(session, root, out);
|
|
1421
|
+
// AGENTS.md is written below in installGlobalInstructions when
|
|
1422
|
+
// platforms.windsurf is true.
|
|
1423
|
+
if (!hasWindsurf)
|
|
1424
|
+
windsurfOk = true; // local-scope success: rules + AGENTS.md
|
|
1593
1425
|
}
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1426
|
+
catch (e) {
|
|
1427
|
+
console.error(fmt.error(`Failed to install Windsurf integration: ${e}`));
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
// Install Continue.dev integration if opted in (rf-acz0).
|
|
1431
|
+
// - User scope: per-skill rules (.continue/rules/) + MCP entry under
|
|
1432
|
+
// ~/.continue/config.json.
|
|
1433
|
+
// - Project scope (--local): rules only.
|
|
1434
|
+
// Continue.dev has no hook surface — the prior hooks install was pruned
|
|
1435
|
+
// in rf-cia phase b.
|
|
1436
|
+
let continueOk = false;
|
|
1437
|
+
if (wantContinue && (hasContinueDev || opts.local)) {
|
|
1438
|
+
try {
|
|
1439
|
+
if (hasContinueDev) {
|
|
1440
|
+
continueOk = installContinueDevMcp(root, out);
|
|
1441
|
+
if (continueOk)
|
|
1442
|
+
manager.set("agent.environments.continueDev.enabled", true);
|
|
1607
1443
|
}
|
|
1444
|
+
installContinueDevRules(session, root, out);
|
|
1445
|
+
if (!hasContinueDev)
|
|
1446
|
+
continueOk = true; // local-scope success: rules only
|
|
1608
1447
|
}
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
// rafter sub-agent installed in the Cursor branch above (rf-svn3).
|
|
1612
|
-
installGlobalInstructions({
|
|
1613
|
-
claudeCode: claudeCodeOk,
|
|
1614
|
-
codex: codexOk,
|
|
1615
|
-
gemini: geminiOk,
|
|
1616
|
-
windsurf: windsurfOk,
|
|
1617
|
-
}, root, scope, out);
|
|
1618
|
-
out.info();
|
|
1619
|
-
// rf-er8a: do not report a clean success if the hook we just wrote cannot
|
|
1620
|
-
// execute and enforce. A silent 127 (or an npx-cache entrypoint) means the
|
|
1621
|
-
// gate is inert even though settings.json looks configured.
|
|
1622
|
-
const hookWarnings = claudeCodeOk ? installedHookWarnings() : [];
|
|
1623
|
-
if (hookWarnings.length > 0) {
|
|
1624
|
-
for (const w of hookWarnings)
|
|
1625
|
-
out.warn(fmt.warning(w));
|
|
1626
|
-
out.warn(fmt.warning("Agent security initialized WITH WARNINGS — the command gate may NOT be active (see above). Run 'rafter agent verify' to confirm."));
|
|
1448
|
+
catch (e) {
|
|
1449
|
+
console.error(fmt.error(`Failed to install Continue.dev integration: ${e}`));
|
|
1627
1450
|
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1451
|
+
}
|
|
1452
|
+
// Install Aider integration if opted in (rf-du2o).
|
|
1453
|
+
// Aider has no MCP and no hook surface — its only intercept is the
|
|
1454
|
+
// `read:` flag in .aider.conf.yml. We write RAFTER.md and ensure
|
|
1455
|
+
// `read:` includes it. The legacy mcp-server-command YAML line (a
|
|
1456
|
+
// silent no-op) is stripped on reinstall.
|
|
1457
|
+
let aiderOk = false;
|
|
1458
|
+
if (wantAider && (hasAider || opts.local)) {
|
|
1459
|
+
try {
|
|
1460
|
+
aiderOk = installAiderRead(root, out);
|
|
1461
|
+
if (aiderOk && hasAider)
|
|
1462
|
+
manager.set("agent.environments.aider.enabled", true);
|
|
1630
1463
|
}
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
out.info(" - Restart Gemini CLI to load MCP server");
|
|
1643
|
-
if (cursorOk)
|
|
1644
|
-
out.info(" - Restart Cursor to load MCP server");
|
|
1645
|
-
if (windsurfOk)
|
|
1646
|
-
out.info(" - Restart Windsurf to load MCP server");
|
|
1647
|
-
if (continueOk)
|
|
1648
|
-
out.info(" - Restart Continue.dev to load MCP server");
|
|
1649
|
-
if (aiderOk)
|
|
1650
|
-
out.info(" - Restart Aider to load RAFTER.md from .aider.conf.yml read:");
|
|
1464
|
+
catch (e) {
|
|
1465
|
+
console.error(fmt.error(`Failed to install Aider integration: ${e}`));
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
// Install Hermes integration if opted in (sable-gyw).
|
|
1469
|
+
// User scope only — Hermes reads ~/.hermes/config.yaml. MCP-only v0;
|
|
1470
|
+
// hooks deferred pending confirmation Hermes exposes a hook surface.
|
|
1471
|
+
let hermesOk = false;
|
|
1472
|
+
if (wantHermes && hasHermes) {
|
|
1473
|
+
try {
|
|
1474
|
+
hermesOk = installHermesMcp(root, out);
|
|
1651
1475
|
if (hermesOk)
|
|
1652
|
-
|
|
1653
|
-
if (openCodeOk)
|
|
1654
|
-
out.info(" - Restart OpenCode to load MCP server");
|
|
1655
|
-
}
|
|
1656
|
-
else if (scope === "project") {
|
|
1657
|
-
out.info("No integrations were installed. In --local mode, pass one or more opt-in flags:");
|
|
1658
|
-
out.info(" rafter agent init --local --with-claude-code");
|
|
1659
|
-
out.info(" rafter agent init --local --with-codex");
|
|
1660
|
-
out.info(" rafter agent init --local --with-gemini");
|
|
1661
|
-
out.info(" rafter agent init --local --with-cursor");
|
|
1662
|
-
}
|
|
1663
|
-
else if (detected.length > 0) {
|
|
1664
|
-
out.info("No integrations were installed. To install, re-run with opt-in flags:");
|
|
1665
|
-
out.info(" rafter agent init --all # Install all detected");
|
|
1666
|
-
if (hasClaudeCode)
|
|
1667
|
-
out.info(" rafter agent init --with-claude-code # Claude Code only");
|
|
1668
|
-
if (hasOpenClaw)
|
|
1669
|
-
out.info(" rafter agent init --with-openclaw # OpenClaw only");
|
|
1670
|
-
if (hasCodex)
|
|
1671
|
-
out.info(" rafter agent init --with-codex # Codex CLI only");
|
|
1672
|
-
if (hasGemini)
|
|
1673
|
-
out.info(" rafter agent init --with-gemini # Gemini CLI only");
|
|
1674
|
-
if (hasCursor)
|
|
1675
|
-
out.info(" rafter agent init --with-cursor # Cursor only");
|
|
1676
|
-
if (hasWindsurf)
|
|
1677
|
-
out.info(" rafter agent init --with-windsurf # Windsurf only");
|
|
1678
|
-
if (hasContinueDev)
|
|
1679
|
-
out.info(" rafter agent init --with-continue # Continue.dev only");
|
|
1680
|
-
if (hasAider)
|
|
1681
|
-
out.info(" rafter agent init --with-aider # Aider only");
|
|
1682
|
-
if (hasHermes)
|
|
1683
|
-
out.info(" rafter agent init --with-hermes # Hermes only");
|
|
1684
|
-
if (hasOpenCode)
|
|
1685
|
-
out.info(" rafter agent init --with-opencode # OpenCode only");
|
|
1476
|
+
manager.set("agent.environments.hermes.enabled", true);
|
|
1686
1477
|
}
|
|
1687
|
-
|
|
1688
|
-
|
|
1478
|
+
catch (e) {
|
|
1479
|
+
console.error(fmt.error(`Failed to install Hermes integration: ${e}`));
|
|
1689
1480
|
}
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1481
|
+
}
|
|
1482
|
+
// Install OpenCode integration if opted in (sable-l8e5).
|
|
1483
|
+
// User scope only — OpenCode reads a global config at
|
|
1484
|
+
// ~/.config/opencode/opencode.json. MCP-based: we register the local
|
|
1485
|
+
// stdio server `rafter mcp serve` under the `mcp` block.
|
|
1486
|
+
let openCodeOk = false;
|
|
1487
|
+
if (wantOpenCode && hasOpenCode) {
|
|
1695
1488
|
try {
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
encoding: "utf-8",
|
|
1700
|
-
timeout: 5000,
|
|
1701
|
-
stdio: ["pipe", "pipe", "ignore"],
|
|
1702
|
-
}).trim();
|
|
1703
|
-
if (pathVersion && pathVersion !== thisVersion && !pathVersion.includes(thisVersion)) {
|
|
1704
|
-
out.warn(fmt.warning(`PATH version mismatch: 'rafter --version' reports ${pathVersion}, but this install is ${thisVersion}.`));
|
|
1705
|
-
out.warn(fmt.info("Another rafter binary may be shadowing this one. Check: which rafter"));
|
|
1706
|
-
out.info();
|
|
1707
|
-
}
|
|
1489
|
+
openCodeOk = installOpenCodeMcp(root, out);
|
|
1490
|
+
if (openCodeOk)
|
|
1491
|
+
manager.set("agent.environments.opencode.enabled", true);
|
|
1708
1492
|
}
|
|
1709
|
-
catch {
|
|
1710
|
-
|
|
1493
|
+
catch (e) {
|
|
1494
|
+
console.error(fmt.error(`Failed to install OpenCode integration: ${e}`));
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
// Install global instruction files for platforms that support them.
|
|
1498
|
+
// Cursor is intentionally absent — Cursor uses per-skill rules + the
|
|
1499
|
+
// rafter sub-agent installed in the Cursor branch above (rf-svn3).
|
|
1500
|
+
installGlobalInstructions({
|
|
1501
|
+
claudeCode: claudeCodeOk,
|
|
1502
|
+
codex: codexOk,
|
|
1503
|
+
gemini: geminiOk,
|
|
1504
|
+
windsurf: windsurfOk,
|
|
1505
|
+
}, root, scope, out);
|
|
1506
|
+
session.save();
|
|
1507
|
+
reportUnchangedSummary(session);
|
|
1508
|
+
reportKeptSummary(session, FORCE_HINT, opts.local ? "rafter agent update --local" : "rafter agent update");
|
|
1509
|
+
out.info();
|
|
1510
|
+
// rf-er8a: do not report a clean success if the hook we just wrote cannot
|
|
1511
|
+
// execute and enforce. A silent 127 (or an npx-cache entrypoint) means the
|
|
1512
|
+
// gate is inert even though settings.json looks configured.
|
|
1513
|
+
const hookWarnings = claudeCodeOk ? installedHookWarnings() : [];
|
|
1514
|
+
if (hookWarnings.length > 0) {
|
|
1515
|
+
for (const w of hookWarnings)
|
|
1516
|
+
out.warn(fmt.warning(w));
|
|
1517
|
+
out.warn(fmt.warning("Agent security initialized WITH WARNINGS — the command gate may NOT be active (see above). Run 'rafter agent verify' to confirm."));
|
|
1518
|
+
}
|
|
1519
|
+
else {
|
|
1520
|
+
out.info(fmt.success("Agent security initialized!"));
|
|
1521
|
+
}
|
|
1522
|
+
out.info();
|
|
1523
|
+
const anyIntegration = openclawOk || claudeCodeOk || codexOk || geminiOk || cursorOk || windsurfOk || continueOk || aiderOk || hermesOk || openCodeOk;
|
|
1524
|
+
if (anyIntegration) {
|
|
1525
|
+
out.info("Next steps:");
|
|
1526
|
+
if (openclawOk)
|
|
1527
|
+
out.info(" - Restart OpenClaw to load skill");
|
|
1528
|
+
if (claudeCodeOk)
|
|
1529
|
+
out.info(" - Restart Claude Code to load skills");
|
|
1530
|
+
if (codexOk)
|
|
1531
|
+
out.info(" - Restart Codex CLI to load skills");
|
|
1532
|
+
if (geminiOk)
|
|
1533
|
+
out.info(" - Restart Gemini CLI to load MCP server");
|
|
1534
|
+
if (cursorOk)
|
|
1535
|
+
out.info(" - Restart Cursor to load MCP server");
|
|
1536
|
+
if (windsurfOk)
|
|
1537
|
+
out.info(" - Restart Windsurf to load MCP server");
|
|
1538
|
+
if (continueOk)
|
|
1539
|
+
out.info(" - Restart Continue.dev to load MCP server");
|
|
1540
|
+
if (aiderOk)
|
|
1541
|
+
out.info(" - Restart Aider to load RAFTER.md from .aider.conf.yml read:");
|
|
1542
|
+
if (hermesOk)
|
|
1543
|
+
out.info(" - Restart Hermes to load MCP server");
|
|
1544
|
+
if (openCodeOk)
|
|
1545
|
+
out.info(" - Restart OpenCode to load MCP server");
|
|
1546
|
+
}
|
|
1547
|
+
else if (scope === "project") {
|
|
1548
|
+
out.info("No integrations were installed. In --local mode, pass one or more opt-in flags:");
|
|
1549
|
+
out.info(" rafter agent init --local --with-claude-code");
|
|
1550
|
+
out.info(" rafter agent init --local --with-codex");
|
|
1551
|
+
out.info(" rafter agent init --local --with-gemini");
|
|
1552
|
+
out.info(" rafter agent init --local --with-cursor");
|
|
1553
|
+
}
|
|
1554
|
+
else if (detected.length > 0) {
|
|
1555
|
+
out.info("No integrations were installed. To install, re-run with opt-in flags:");
|
|
1556
|
+
out.info(" rafter agent init --all # Install all detected");
|
|
1557
|
+
if (hasClaudeCode)
|
|
1558
|
+
out.info(" rafter agent init --with-claude-code # Claude Code only");
|
|
1559
|
+
if (hasOpenClaw)
|
|
1560
|
+
out.info(" rafter agent init --with-openclaw # OpenClaw only");
|
|
1561
|
+
if (hasCodex)
|
|
1562
|
+
out.info(" rafter agent init --with-codex # Codex CLI only");
|
|
1563
|
+
if (hasGemini)
|
|
1564
|
+
out.info(" rafter agent init --with-gemini # Gemini CLI only");
|
|
1565
|
+
if (hasCursor)
|
|
1566
|
+
out.info(" rafter agent init --with-cursor # Cursor only");
|
|
1567
|
+
if (hasWindsurf)
|
|
1568
|
+
out.info(" rafter agent init --with-windsurf # Windsurf only");
|
|
1569
|
+
if (hasContinueDev)
|
|
1570
|
+
out.info(" rafter agent init --with-continue # Continue.dev only");
|
|
1571
|
+
if (hasAider)
|
|
1572
|
+
out.info(" rafter agent init --with-aider # Aider only");
|
|
1573
|
+
if (hasHermes)
|
|
1574
|
+
out.info(" rafter agent init --with-hermes # Hermes only");
|
|
1575
|
+
if (hasOpenCode)
|
|
1576
|
+
out.info(" rafter agent init --with-opencode # OpenCode only");
|
|
1577
|
+
}
|
|
1578
|
+
else {
|
|
1579
|
+
out.info("No agent environments detected. Install an agent tool and re-run with --with-<tool>.");
|
|
1580
|
+
}
|
|
1581
|
+
out.info();
|
|
1582
|
+
out.info(" - Run: rafter secrets . (test secret scanning)");
|
|
1583
|
+
out.info(" - Configure: rafter agent config show");
|
|
1584
|
+
out.info();
|
|
1585
|
+
// Warn if a different rafter version shadows this one on PATH
|
|
1586
|
+
try {
|
|
1587
|
+
const _require = createRequire(import.meta.url);
|
|
1588
|
+
const { version: thisVersion } = _require("../../../package.json");
|
|
1589
|
+
const pathVersion = execSync("rafter --version", {
|
|
1590
|
+
encoding: "utf-8",
|
|
1591
|
+
timeout: 5000,
|
|
1592
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
1593
|
+
}).trim();
|
|
1594
|
+
if (pathVersion && pathVersion !== thisVersion && !pathVersion.includes(thisVersion)) {
|
|
1595
|
+
out.warn(fmt.warning(`PATH version mismatch: 'rafter --version' reports ${pathVersion}, but this install is ${thisVersion}.`));
|
|
1596
|
+
out.warn(fmt.info("Another rafter binary may be shadowing this one. Check: which rafter"));
|
|
1597
|
+
out.info();
|
|
1711
1598
|
}
|
|
1712
|
-
}
|
|
1599
|
+
}
|
|
1600
|
+
catch {
|
|
1601
|
+
// Ignore — rafter may not be on PATH yet
|
|
1602
|
+
}
|
|
1713
1603
|
}
|