@darkrei08/setup-ai 3.0.2 → 3.0.3
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/bin/setup-ai.mjs +48 -12
- package/package.json +1 -1
- package/setup-ai.ps1 +9 -1
- package/setup-ai.sh +1 -1
package/bin/setup-ai.mjs
CHANGED
|
@@ -106,7 +106,7 @@ function toScriptArgs(mode, csv) {
|
|
|
106
106
|
|
|
107
107
|
// ---- interactive multi-select (gentle-ai style) ---------------------------
|
|
108
108
|
function interactiveMenu() {
|
|
109
|
-
return new Promise((resolve) => {
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
110
|
const items = menuModules.map((m) => ({ ...m, checked: m.core }));
|
|
111
111
|
let cursor = 0;
|
|
112
112
|
const out = process.stdout;
|
|
@@ -125,17 +125,29 @@ function interactiveMenu() {
|
|
|
125
125
|
};
|
|
126
126
|
|
|
127
127
|
const stdin = process.stdin;
|
|
128
|
-
stdin.setRawMode
|
|
128
|
+
if (typeof stdin.setRawMode !== "function") {
|
|
129
|
+
return reject(new Error("stdin is not a raw-capable TTY"));
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
stdin.setRawMode(true);
|
|
133
|
+
} catch (err) {
|
|
134
|
+
return reject(err);
|
|
135
|
+
}
|
|
129
136
|
stdin.resume();
|
|
130
137
|
stdin.setEncoding("utf8");
|
|
131
138
|
render(true);
|
|
132
139
|
|
|
133
140
|
const cleanup = () => {
|
|
134
|
-
stdin.setRawMode(false);
|
|
141
|
+
try { stdin.setRawMode(false); } catch { /* ignore */ }
|
|
135
142
|
stdin.pause();
|
|
136
143
|
stdin.removeListener("data", onData);
|
|
144
|
+
stdin.removeListener("end", onEnd);
|
|
137
145
|
};
|
|
138
146
|
|
|
147
|
+
// If stdin closes before a choice (e.g. npx consumed it), fall back instead
|
|
148
|
+
// of hanging or exiting silently.
|
|
149
|
+
const onEnd = () => { cleanup(); reject(new Error("stdin closed before a choice was made")); };
|
|
150
|
+
|
|
139
151
|
const onData = (key) => {
|
|
140
152
|
if (key === "\x03" || key === "q") { // ctrl-c / q
|
|
141
153
|
cleanup();
|
|
@@ -156,6 +168,7 @@ function interactiveMenu() {
|
|
|
156
168
|
}
|
|
157
169
|
};
|
|
158
170
|
stdin.on("data", onData);
|
|
171
|
+
stdin.on("end", onEnd);
|
|
159
172
|
});
|
|
160
173
|
}
|
|
161
174
|
|
|
@@ -165,6 +178,11 @@ function defaultSelection() {
|
|
|
165
178
|
}
|
|
166
179
|
|
|
167
180
|
async function main() {
|
|
181
|
+
// Always emit a first line so the user sees the launcher started, even if
|
|
182
|
+
// something downstream fails (this is what "npx returns to prompt silently"
|
|
183
|
+
// needed).
|
|
184
|
+
console.log(`setup-ai launcher · ${process.platform}`);
|
|
185
|
+
|
|
168
186
|
if (has("--help") || has("-h")) return runScript(toScriptArgs("help"));
|
|
169
187
|
if (has("--list")) return runScript(toScriptArgs("list"));
|
|
170
188
|
if (has("--all")) return runScript(toScriptArgs("all"));
|
|
@@ -174,18 +192,36 @@ async function main() {
|
|
|
174
192
|
|
|
175
193
|
if (has("--yes") || has("-y")) return runScript(toScriptArgs("yes"));
|
|
176
194
|
|
|
177
|
-
// No selection flag: interactive menu
|
|
195
|
+
// No selection flag: try the interactive menu; fall back cleanly if the
|
|
196
|
+
// terminal/stdin can't drive it (common under some npx/CI shells).
|
|
197
|
+
let chosen = null;
|
|
178
198
|
if (process.stdin.isTTY && process.stdout.isTTY) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
199
|
+
try {
|
|
200
|
+
chosen = await interactiveMenu();
|
|
201
|
+
} catch (err) {
|
|
202
|
+
console.log(`\n(interactive menu unavailable: ${err.message})`);
|
|
203
|
+
chosen = null;
|
|
183
204
|
}
|
|
184
|
-
|
|
205
|
+
} else {
|
|
206
|
+
console.log("No interactive terminal detected.");
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (!chosen) {
|
|
210
|
+
console.log("Installing the CORE set. Customize with:");
|
|
211
|
+
console.log(" npx github:darkrei08/setup-ai --only pi,codex,opencode");
|
|
212
|
+
console.log(" npx github:darkrei08/setup-ai --all (everything)");
|
|
213
|
+
console.log(" npx github:darkrei08/setup-ai --list (see modules)\n");
|
|
214
|
+
chosen = defaultSelection();
|
|
185
215
|
}
|
|
186
216
|
|
|
187
|
-
|
|
188
|
-
|
|
217
|
+
if (!chosen.length) {
|
|
218
|
+
console.log("Nothing selected — exiting.");
|
|
219
|
+
process.exit(0);
|
|
220
|
+
}
|
|
221
|
+
return runScript(toScriptArgs("only", chosen.join(",")));
|
|
189
222
|
}
|
|
190
223
|
|
|
191
|
-
main()
|
|
224
|
+
main().catch((err) => {
|
|
225
|
+
console.error(`setup-ai launcher error: ${err?.message || err}`);
|
|
226
|
+
process.exit(1);
|
|
227
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkrei08/setup-ai",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Cross-OS installer for an AI coding toolchain (pi, codex, antigravity, opencode, herdr, gentle-ai, engram, Engineering Excellence) with an interactive module menu.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/setup-ai.ps1
CHANGED
|
@@ -33,7 +33,15 @@ param(
|
|
|
33
33
|
$ErrorActionPreference = 'Stop'
|
|
34
34
|
Set-StrictMode -Version Latest
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
# Render child-process UTF-8 output (npx skills box-drawing, banners) correctly
|
|
37
|
+
# instead of mojibake on the default Windows console codepage.
|
|
38
|
+
try {
|
|
39
|
+
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
40
|
+
$OutputEncoding = [System.Text.Encoding]::UTF8
|
|
41
|
+
if (Get-Command chcp -ErrorAction SilentlyContinue) { chcp 65001 | Out-Null }
|
|
42
|
+
} catch { }
|
|
43
|
+
|
|
44
|
+
$ScriptVersion = "3.0.3"
|
|
37
45
|
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
38
46
|
$LogDir = Join-Path $ScriptDir "logs"
|
|
39
47
|
New-Item -ItemType Directory -Force -Path $LogDir | Out-Null
|