mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 09:12:42 +00:00
fix(workspace): align clawd + bootstrap
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user