wispy-cli 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/onboarding.mjs +43 -1
- package/package.json +1 -1
package/core/onboarding.mjs
CHANGED
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
|
|
24
24
|
import os from "node:os";
|
|
25
25
|
import path from "node:path";
|
|
26
|
-
import { mkdir, writeFile, readFile } from "node:fs/promises";
|
|
26
|
+
import { mkdir, writeFile, readFile, appendFile } from "node:fs/promises";
|
|
27
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
28
|
+
import { execSync } from "node:child_process";
|
|
27
29
|
|
|
28
30
|
import { confirm, checkbox, select, input, password } from "@inquirer/prompts";
|
|
29
31
|
|
|
@@ -219,6 +221,42 @@ function printSummaryBox(config) {
|
|
|
219
221
|
// OnboardingWizard class
|
|
220
222
|
// ──────────────────────────────────────────────────────────────────────────────
|
|
221
223
|
|
|
224
|
+
// ── Auto-install shell completion ──────────────────────────────────────────────
|
|
225
|
+
|
|
226
|
+
async function autoInstallCompletion() {
|
|
227
|
+
try {
|
|
228
|
+
const shell = process.env.SHELL ?? "";
|
|
229
|
+
const home = os.homedir();
|
|
230
|
+
const completionLine = 'eval "$(wispy completion zsh)"';
|
|
231
|
+
const completionBash = 'eval "$(wispy completion bash)"';
|
|
232
|
+
|
|
233
|
+
if (shell.includes("zsh")) {
|
|
234
|
+
const rcPath = path.join(home, ".zshrc");
|
|
235
|
+
if (existsSync(rcPath)) {
|
|
236
|
+
const content = readFileSync(rcPath, "utf8");
|
|
237
|
+
if (!content.includes("wispy completion")) {
|
|
238
|
+
await appendFile(rcPath, `\n# Wispy CLI completion\n${completionLine}\n`);
|
|
239
|
+
console.log(dim(" ✅ Shell completion added to ~/.zshrc"));
|
|
240
|
+
}
|
|
241
|
+
} else {
|
|
242
|
+
await writeFile(rcPath, `# Wispy CLI completion\n${completionLine}\n`);
|
|
243
|
+
console.log(dim(" ✅ Shell completion added to ~/.zshrc"));
|
|
244
|
+
}
|
|
245
|
+
} else if (shell.includes("bash")) {
|
|
246
|
+
const rcPath = path.join(home, ".bashrc");
|
|
247
|
+
if (existsSync(rcPath)) {
|
|
248
|
+
const content = readFileSync(rcPath, "utf8");
|
|
249
|
+
if (!content.includes("wispy completion")) {
|
|
250
|
+
await appendFile(rcPath, `\n# Wispy CLI completion\n${completionBash}\n`);
|
|
251
|
+
console.log(dim(" ✅ Shell completion added to ~/.bashrc"));
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
} catch {
|
|
256
|
+
// Silent fail — completion is nice-to-have
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
222
260
|
export class OnboardingWizard {
|
|
223
261
|
constructor() {
|
|
224
262
|
this._config = {};
|
|
@@ -689,6 +727,10 @@ export class OnboardingWizard {
|
|
|
689
727
|
delete config._memoryRole;
|
|
690
728
|
|
|
691
729
|
await saveConfig(config);
|
|
730
|
+
|
|
731
|
+
// Auto-register shell completion
|
|
732
|
+
await autoInstallCompletion();
|
|
733
|
+
|
|
692
734
|
printSummaryBox(config);
|
|
693
735
|
|
|
694
736
|
return config;
|