wispy-cli 2.4.0 → 2.4.2
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/lib/wispy-repl.mjs +2 -16
- 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;
|
package/lib/wispy-repl.mjs
CHANGED
|
@@ -1239,22 +1239,8 @@ async function runRepl(engine) {
|
|
|
1239
1239
|
completer: makeCompleter(engine),
|
|
1240
1240
|
});
|
|
1241
1241
|
|
|
1242
|
-
//
|
|
1243
|
-
|
|
1244
|
-
if (process.stdin.isTTY) {
|
|
1245
|
-
process.stdin.on('keypress', (_ch, key) => {
|
|
1246
|
-
if (!key) return;
|
|
1247
|
-
// Slight delay to let readline update its line buffer
|
|
1248
|
-
setImmediate(() => {
|
|
1249
|
-
const line = rl.line ?? '';
|
|
1250
|
-
if (line.startsWith('/')) {
|
|
1251
|
-
showCommandHint(line, engine);
|
|
1252
|
-
} else {
|
|
1253
|
-
clearCommandHint();
|
|
1254
|
-
}
|
|
1255
|
-
});
|
|
1256
|
-
});
|
|
1257
|
-
}
|
|
1242
|
+
// Inline hints disabled — caused display corruption with readline.
|
|
1243
|
+
// Tab completion via makeCompleter() handles autocomplete instead.
|
|
1258
1244
|
|
|
1259
1245
|
// Dynamic prompt — shows workstream and dry-run status
|
|
1260
1246
|
function updatePrompt() {
|