惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
人人都是产品经理
人人都是产品经理
Engineering at Meta
Engineering at Meta
小众软件
小众软件
I
InfoQ
有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Martin Fowler
Martin Fowler
月光博客
月光博客
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
V
Visual Studio Blog
博客园 - 叶小钗
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
GbyAI
GbyAI
P
Proofpoint News Feed
Apple Machine Learning Research
Apple Machine Learning Research

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(cli): show concrete PowerShell completion profile pat...
yu-xin-c · 2026-05-17 · via Recent Commits to openclaw:main

@@ -63,17 +63,31 @@ export async function completionCacheExists(

6363

return pathExists(cachePath);

6464

}

656566-

function formatCompletionSourceLine(

66+

function escapePowerShellSingleQuotedString(value: string): string {

67+

return value.replace(/'/g, "''");

68+

}

69+70+

export function formatCompletionSourceLine(

6771

shell: CompletionShell,

6872

_binName: string,

6973

cachePath: string,

7074

): string {

75+

if (shell === "powershell") {

76+

return `. '${escapePowerShellSingleQuotedString(cachePath)}'`;

77+

}

7178

if (shell === "fish") {

7279

return `test -f "${cachePath}"; and source "${cachePath}"`;

7380

}

7481

return `[ -f "${cachePath}" ] && source "${cachePath}"`;

7582

}

768384+

export function formatCompletionReloadCommand(shell: CompletionShell, profilePath: string): string {

85+

if (shell === "powershell") {

86+

return `. '${escapePowerShellSingleQuotedString(profilePath)}'`;

87+

}

88+

return `source ${profilePath}`;

89+

}

90+7791

function isCompletionProfileHeader(line: string): boolean {

7892

return line.trim() === "# OpenClaw Completion";

7993

}

@@ -126,8 +140,18 @@ function updateCompletionProfile(

126140

return { next, changed: next !== content, hadExisting };

127141

}

128142129-

function getShellProfilePath(shell: CompletionShell): string {

130-

const home = process.env.HOME || os.homedir();

143+

export function resolveCompletionProfilePath(

144+

shell: CompletionShell,

145+

options: {

146+

env?: NodeJS.ProcessEnv;

147+

homeDir?: () => string;

148+

platform?: NodeJS.Platform;

149+

} = {},

150+

): string {

151+

const env = options.env ?? process.env;

152+

const homeDir = options.homeDir ?? os.homedir;

153+

const platform = options.platform ?? process.platform;

154+

const home = env.HOME || homeDir();

131155

if (shell === "zsh") {

132156

return path.join(home, ".zshrc");

133157

}

@@ -137,9 +161,9 @@ function getShellProfilePath(shell: CompletionShell): string {

137161

if (shell === "fish") {

138162

return path.join(home, ".config", "fish", "config.fish");

139163

}

140-

if (process.platform === "win32") {

141-

return path.join(

142-

process.env.USERPROFILE || home,

164+

if (platform === "win32") {

165+

return path.win32.join(

166+

env.USERPROFILE || home,

143167

"Documents",

144168

"PowerShell",

145169

"Microsoft.PowerShell_profile.ps1",

@@ -152,7 +176,7 @@ export async function isCompletionInstalled(

152176

shell: CompletionShell,

153177

binName = "openclaw",

154178

): Promise<boolean> {

155-

const profilePath = getShellProfilePath(shell);

179+

const profilePath = resolveCompletionProfilePath(shell);

156180157181

if (!(await pathExists(profilePath))) {

158182

return false;

@@ -174,7 +198,7 @@ export async function usesSlowDynamicCompletion(

174198

shell: CompletionShell,

175199

binName = "openclaw",

176200

): Promise<boolean> {

177-

const profilePath = getShellProfilePath(shell);

201+

const profilePath = resolveCompletionProfilePath(shell);

178202179203

if (!(await pathExists(profilePath))) {

180204

return false;

@@ -193,7 +217,6 @@ export async function usesSlowDynamicCompletion(

193217

}

194218195219

export async function installCompletion(shell: string, yes: boolean, binName = "openclaw") {

196-

const home = process.env.HOME || os.homedir();

197220

let profilePath = "";

198221

let sourceLine = "";

199222

@@ -213,19 +236,23 @@ export async function installCompletion(shell: string, yes: boolean, binName = "

213236

}

214237215238

if (shell === "zsh") {

216-

profilePath = path.join(home, ".zshrc");

239+

profilePath = resolveCompletionProfilePath("zsh");

217240

sourceLine = formatCompletionSourceLine("zsh", binName, cachePath);

218241

} else if (shell === "bash") {

219-

profilePath = path.join(home, ".bashrc");

242+

profilePath = resolveCompletionProfilePath("bash");

220243

try {

221244

await fs.access(profilePath);

222245

} catch {

246+

const home = process.env.HOME || os.homedir();

223247

profilePath = path.join(home, ".bash_profile");

224248

}

225249

sourceLine = formatCompletionSourceLine("bash", binName, cachePath);

226250

} else if (shell === "fish") {

227-

profilePath = path.join(home, ".config", "fish", "config.fish");

251+

profilePath = resolveCompletionProfilePath("fish");

228252

sourceLine = formatCompletionSourceLine("fish", binName, cachePath);

253+

} else if (shell === "powershell") {

254+

profilePath = resolveCompletionProfilePath("powershell");

255+

sourceLine = formatCompletionSourceLine("powershell", binName, cachePath);

229256

} else {

230257

console.error(`Automated installation not supported for ${shell} yet.`);

231258

return;

@@ -258,7 +285,9 @@ export async function installCompletion(shell: string, yes: boolean, binName = "

258285259286

await fs.writeFile(profilePath, update.next, "utf-8");

260287

if (!yes) {

261-

console.log(`Completion installed. Restart your shell or run: source ${profilePath}`);

288+

console.log(

289+

`Completion installed. Restart your shell or run: ${formatCompletionReloadCommand(shell, profilePath)}`,

290+

);

262291

}

263292

} catch (err) {

264293

console.error(`Failed to install completion: ${err as string}`);