refactor: rename clawdbot to moltbot with legacy compat

This commit is contained in:
Peter Steinberger
2026-01-27 12:19:58 +00:00
parent 83460df96f
commit 6d16a658e5
1839 changed files with 11250 additions and 11199 deletions

View File

@@ -1,13 +1,13 @@
import Foundation
enum CommandResolver {
private static let projectRootDefaultsKey = "clawdbot.gatewayProjectRootPath"
private static let helperName = "clawdbot"
private static let projectRootDefaultsKey = "moltbot.gatewayProjectRootPath"
private static let helperName = "moltbot"
static func gatewayEntrypoint(in root: URL) -> String? {
let distEntry = root.appendingPathComponent("dist/index.js").path
if FileManager().isReadableFile(atPath: distEntry) { return distEntry }
let binEntry = root.appendingPathComponent("bin/clawdbot.js").path
let binEntry = root.appendingPathComponent("bin/moltbot.js").path
if FileManager().isReadableFile(atPath: binEntry) { return binEntry }
return nil
}
@@ -52,7 +52,7 @@ enum CommandResolver {
return url
}
let fallback = FileManager().homeDirectoryForCurrentUser
.appendingPathComponent("Projects/clawdbot")
.appendingPathComponent("Projects/moltbot")
if FileManager().fileExists(atPath: fallback.path) {
return fallback
}
@@ -87,17 +87,17 @@ enum CommandResolver {
// Dev-only convenience. Avoid project-local PATH hijacking in release builds.
extras.insert(projectRoot.appendingPathComponent("node_modules/.bin").path, at: 0)
#endif
let clawdbotPaths = self.clawdbotManagedPaths(home: home)
if !clawdbotPaths.isEmpty {
extras.insert(contentsOf: clawdbotPaths, at: 1)
let moltbotPaths = self.clawdbotManagedPaths(home: home)
if !moltbotPaths.isEmpty {
extras.insert(contentsOf: moltbotPaths, at: 1)
}
extras.insert(contentsOf: self.nodeManagerBinPaths(home: home), at: 1 + clawdbotPaths.count)
extras.insert(contentsOf: self.nodeManagerBinPaths(home: home), at: 1 + moltbotPaths.count)
var seen = Set<String>()
// Preserve order while stripping duplicates so PATH lookups remain deterministic.
return (extras + current).filter { seen.insert($0).inserted }
}
private static func clawdbotManagedPaths(home: URL) -> [String] {
private static func moltbotManagedPaths(home: URL) -> [String] {
let base = home.appendingPathComponent(".clawdbot")
let bin = base.appendingPathComponent("bin")
let nodeBin = base.appendingPathComponent("tools/node/bin")
@@ -187,11 +187,11 @@ enum CommandResolver {
return nil
}
static func clawdbotExecutable(searchPaths: [String]? = nil) -> String? {
static func moltbotExecutable(searchPaths: [String]? = nil) -> String? {
self.findExecutable(named: self.helperName, searchPaths: searchPaths)
}
static func projectClawdbotExecutable(projectRoot: URL? = nil) -> String? {
static func projectMoltbotExecutable(projectRoot: URL? = nil) -> String? {
#if DEBUG
let root = projectRoot ?? self.projectRoot()
let candidate = root.appendingPathComponent("node_modules/.bin").appendingPathComponent(self.helperName).path
@@ -202,11 +202,11 @@ enum CommandResolver {
}
static func nodeCliPath() -> String? {
let candidate = self.projectRoot().appendingPathComponent("bin/clawdbot.js").path
let candidate = self.projectRoot().appendingPathComponent("bin/moltbot.js").path
return FileManager().isReadableFile(atPath: candidate) ? candidate : nil
}
static func hasAnyClawdbotInvoker(searchPaths: [String]? = nil) -> Bool {
static func hasAnyMoltbotInvoker(searchPaths: [String]? = nil) -> Bool {
if self.clawdbotExecutable(searchPaths: searchPaths) != nil { return true }
if self.findExecutable(named: "pnpm", searchPaths: searchPaths) != nil { return true }
if self.findExecutable(named: "node", searchPaths: searchPaths) != nil,
@@ -217,7 +217,7 @@ enum CommandResolver {
return false
}
static func clawdbotNodeCommand(
static func moltbotNodeCommand(
subcommand: String,
extraArgs: [String] = [],
defaults: UserDefaults = .standard,
@@ -238,8 +238,8 @@ enum CommandResolver {
switch runtimeResult {
case let .success(runtime):
let root = self.projectRoot()
if let clawdbotPath = self.projectClawdbotExecutable(projectRoot: root) {
return [clawdbotPath, subcommand] + extraArgs
if let moltbotPath = self.projectMoltbotExecutable(projectRoot: root) {
return [moltbotPath, subcommand] + extraArgs
}
if let entry = self.gatewayEntrypoint(in: root) {
@@ -251,14 +251,14 @@ enum CommandResolver {
}
if let pnpm = self.findExecutable(named: "pnpm", searchPaths: searchPaths) {
// Use --silent to avoid pnpm lifecycle banners that would corrupt JSON outputs.
return [pnpm, "--silent", "clawdbot", subcommand] + extraArgs
return [pnpm, "--silent", "moltbot", subcommand] + extraArgs
}
if let clawdbotPath = self.clawdbotExecutable(searchPaths: searchPaths) {
return [clawdbotPath, subcommand] + extraArgs
if let moltbotPath = self.clawdbotExecutable(searchPaths: searchPaths) {
return [moltbotPath, subcommand] + extraArgs
}
let missingEntry = """
clawdbot entrypoint missing (looked for dist/index.js or bin/clawdbot.js); run pnpm build.
moltbot entrypoint missing (looked for dist/index.js or bin/moltbot.js); run pnpm build.
"""
return self.errorCommand(with: missingEntry)
@@ -267,8 +267,8 @@ enum CommandResolver {
}
}
// Existing callers still refer to clawdbotCommand; keep it as node alias.
static func clawdbotCommand(
// Existing callers still refer to moltbotCommand; keep it as node alias.
static func moltbotCommand(
subcommand: String,
extraArgs: [String] = [],
defaults: UserDefaults = .standard,
@@ -289,7 +289,7 @@ enum CommandResolver {
guard !settings.target.isEmpty else { return nil }
guard let parsed = self.parseSSHTarget(settings.target) else { return nil }
// Run the real clawdbot CLI on the remote host.
// Run the real moltbot CLI on the remote host.
let exportedPath = [
"/opt/homebrew/bin",
"/usr/local/bin",
@@ -306,7 +306,7 @@ enum CommandResolver {
let projectSection = if userPRJ.isEmpty {
"""
DEFAULT_PRJ="$HOME/Projects/clawdbot"
DEFAULT_PRJ="$HOME/Projects/moltbot"
if [ -d "$DEFAULT_PRJ" ]; then
PRJ="$DEFAULT_PRJ"
cd "$PRJ" || { echo "Project root not found: $PRJ"; exit 127; }
@@ -345,9 +345,9 @@ enum CommandResolver {
CLI="";
\(cliSection)
\(projectSection)
if command -v clawdbot >/dev/null 2>&1; then
CLI="$(command -v clawdbot)"
clawdbot \(quotedArgs);
if command -v moltbot >/dev/null 2>&1; then
CLI="$(command -v moltbot)"
moltbot \(quotedArgs);
elif [ -n "${PRJ:-}" ] && [ -f "$PRJ/dist/index.js" ]; then
if command -v node >/dev/null 2>&1; then
CLI="node $PRJ/dist/index.js"
@@ -355,18 +355,18 @@ enum CommandResolver {
else
echo "Node >=22 required on remote host"; exit 127;
fi
elif [ -n "${PRJ:-}" ] && [ -f "$PRJ/bin/clawdbot.js" ]; then
elif [ -n "${PRJ:-}" ] && [ -f "$PRJ/bin/moltbot.js" ]; then
if command -v node >/dev/null 2>&1; then
CLI="node $PRJ/bin/clawdbot.js"
node "$PRJ/bin/clawdbot.js" \(quotedArgs);
CLI="node $PRJ/bin/moltbot.js"
node "$PRJ/bin/moltbot.js" \(quotedArgs);
else
echo "Node >=22 required on remote host"; exit 127;
fi
elif command -v pnpm >/dev/null 2>&1; then
CLI="pnpm --silent clawdbot"
pnpm --silent clawdbot \(quotedArgs);
CLI="pnpm --silent moltbot"
pnpm --silent moltbot \(quotedArgs);
else
echo "clawdbot CLI missing on remote host"; exit 127;
echo "moltbot CLI missing on remote host"; exit 127;
fi
"""
let options: [String] = [
@@ -394,7 +394,7 @@ enum CommandResolver {
defaults: UserDefaults = .standard,
configRoot: [String: Any]? = nil) -> RemoteSettings
{
let root = configRoot ?? ClawdbotConfigFile.loadDict()
let root = configRoot ?? MoltbotConfigFile.loadDict()
let mode = ConnectionModeResolver.resolve(root: root, defaults: defaults).mode
let target = defaults.string(forKey: remoteTargetKey) ?? ""
let identity = defaults.string(forKey: remoteIdentityKey) ?? ""