fix(workspace): align clawd + bootstrap

This commit is contained in:
Peter Steinberger
2026-01-06 19:50:06 +01:00
parent bdf597eb95
commit d07e78855c
13 changed files with 105 additions and 33 deletions

View File

@@ -247,15 +247,28 @@ async function noteSecurityWarnings(cfg: ClawdbotConfig) {
}
}
function replacePathSegment(
function normalizeDefaultWorkspacePath(
value: string | undefined,
from: string,
to: string,
): string | undefined {
if (!value) return value;
const pattern = new RegExp(`(^|[\\/])${from}([\\/]|$)`, "g");
if (!pattern.test(value)) return value;
return value.replace(pattern, `$1${to}$2`);
const resolved = resolveUserPath(value);
const home = os.homedir();
const next = [
["clawdis", "clawd"],
["clawdbot", "clawd"],
].reduce((acc, [from, to]) => {
const fromPrefix = path.join(home, from);
if (acc === fromPrefix) return path.join(home, to);
const withSep = `${fromPrefix}${path.sep}`;
if (acc.startsWith(withSep)) {
return path.join(home, to).concat(acc.slice(fromPrefix.length));
}
return acc;
}, resolved);
return next === resolved ? value : next;
}
function replaceLegacyName(value: string | undefined): string | undefined {
@@ -556,11 +569,7 @@ function normalizeLegacyConfigValues(cfg: ClawdbotConfig): {
let next: ClawdbotConfig = cfg;
const workspace = cfg.agent?.workspace;
const updatedWorkspace = replacePathSegment(
replacePathSegment(workspace, "clawdis", "clawdbot"),
"clawd",
"clawdbot",
);
const updatedWorkspace = normalizeDefaultWorkspacePath(workspace);
if (updatedWorkspace && updatedWorkspace !== workspace) {
next = {
...next,
@@ -573,11 +582,7 @@ function normalizeLegacyConfigValues(cfg: ClawdbotConfig): {
}
const workspaceRoot = cfg.agent?.sandbox?.workspaceRoot;
const updatedWorkspaceRoot = replacePathSegment(
replacePathSegment(workspaceRoot, "clawdis", "clawdbot"),
"clawd",
"clawdbot",
);
const updatedWorkspaceRoot = normalizeDefaultWorkspacePath(workspaceRoot);
if (updatedWorkspaceRoot && updatedWorkspaceRoot !== workspaceRoot) {
next = {
...next,