fix(memory): expand home paths in extra memory paths (#85449) · openclaw/openclaw@48bf037
steipete
·
2026-05-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -45,6 +45,7 @@ Docs: https://docs.openclaw.ai
|
45 | 45 | - Gateway/LaunchAgent: treat a concurrent launchd bootstrap as a successful restart when the service is already loaded, avoiding false macOS Gateway restart failures. Fixes #84721. (#84722) Thanks @googlerest. |
46 | 46 | - Gateway/service: include the active `openclaw` command bin directory in managed service PATH generation and doctor audit expectations for npm-global macOS installs. Fixes #84201. (#84475) Thanks @jbetala7. |
47 | 47 | - Control UI/chat: disable the thinking selector for known non-reasoning models instead of showing duplicate Off choices. Fixes #84069. Thanks @DrippingMellow. |
| 48 | +- Memory: expand `~` in configured extra memory paths before resolving them, so home-relative folders are not treated as workspace-relative. Fixes #58026. Thanks @stadman. |
48 | 49 | - CLI/update: preserve managed Gateway service environment during package cutovers so macOS LaunchAgent repair/restart reads the pre-update service state instead of caller shell state. (#83026) |
49 | 50 | - Agents/providers: honor per-model `api` and `baseUrl` overrides in custom provider auth hooks and transport selection. Fixes #80487. (#80488) Thanks @huveewomg. |
50 | 51 | - Gateway/restart: eager-load the lifecycle runtime before in-place upgrade signal handling so package replacement does not deadlock restart imports. (#84890) Thanks @myps6415. |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -97,8 +97,21 @@ describe("memory host SDK package internals", () => {
|
97 | 97 | const workspaceDir = path.join(os.tmpdir(), "memory-test-workspace"); |
98 | 98 | const absPath = path.resolve(path.sep, "shared-notes"); |
99 | 99 | expect( |
100 | | -normalizeExtraMemoryPaths(workspaceDir, [" notes ", "./notes", absPath, absPath, ""]), |
101 | | -).toEqual([path.resolve(workspaceDir, "notes"), absPath]); |
| 100 | +normalizeExtraMemoryPaths(workspaceDir, [ |
| 101 | +" notes ", |
| 102 | +"./notes", |
| 103 | +absPath, |
| 104 | +absPath, |
| 105 | +"~/shared-notes", |
| 106 | +"~", |
| 107 | +"", |
| 108 | +]), |
| 109 | +).toEqual([ |
| 110 | +path.resolve(workspaceDir, "notes"), |
| 111 | +absPath, |
| 112 | +path.join(os.homedir(), "shared-notes"), |
| 113 | +os.homedir(), |
| 114 | +]); |
102 | 115 | }); |
103 | 116 | |
104 | 117 | it("lists canonical markdown and enabled multimodal files", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import crypto from "node:crypto"; |
2 | 2 | import fsSync from "node:fs"; |
3 | 3 | import fs from "node:fs/promises"; |
| 4 | +import { homedir } from "node:os"; |
4 | 5 | import path from "node:path"; |
5 | 6 | import { CANONICAL_ROOT_MEMORY_FILENAME } from "./config-utils.js"; |
6 | 7 | import { estimateStructuredEmbeddingInputBytes } from "./embedding-input-limits.js"; |
@@ -74,13 +75,24 @@ export function normalizeRelPath(value: string): string {
|
74 | 75 | return trimmed.replace(/\\/g, "/"); |
75 | 76 | } |
76 | 77 | |
| 78 | +function expandHomePath(value: string): string { |
| 79 | +if (value === "~") { |
| 80 | +return homedir(); |
| 81 | +} |
| 82 | +if (value.startsWith("~/") || value.startsWith("~\\")) { |
| 83 | +return path.join(homedir(), value.slice(2)); |
| 84 | +} |
| 85 | +return value; |
| 86 | +} |
| 87 | + |
77 | 88 | export function normalizeExtraMemoryPaths(workspaceDir: string, extraPaths?: string[]): string[] { |
78 | 89 | if (!extraPaths?.length) { |
79 | 90 | return []; |
80 | 91 | } |
81 | 92 | const resolved = extraPaths |
82 | 93 | .map((value) => value.trim()) |
83 | 94 | .filter(Boolean) |
| 95 | +.map((value) => expandHomePath(value)) |
84 | 96 | .map((value) => |
85 | 97 | path.isAbsolute(value) ? path.resolve(value) : path.resolve(workspaceDir, value), |
86 | 98 | ); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。