@invizi/cli 0.1.4 → 0.1.5
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/dist/invizi.js +9 -0
- package/dist/setup.js +31 -2
- package/package.json +1 -1
package/dist/invizi.js
CHANGED
|
@@ -103,6 +103,15 @@ async function executeRemote(args, options = {}) {
|
|
|
103
103
|
export async function main(rawArgs = process.argv.slice(2)) {
|
|
104
104
|
const args = rawArgs;
|
|
105
105
|
const command = args[0];
|
|
106
|
+
// First-run: if no config exists and user isn't running setup/version/config, prompt
|
|
107
|
+
if (command && !['setup', 'version', 'config', '--version', '-v', '--help', '-h'].includes(command)) {
|
|
108
|
+
const config = loadConfig();
|
|
109
|
+
if (!config.apiUrl) {
|
|
110
|
+
console.log('First run detected. Running setup...\n');
|
|
111
|
+
await setup([]);
|
|
112
|
+
console.log('');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
106
115
|
if (!command || command === '--help' || command === '-h') {
|
|
107
116
|
showLocalHelp();
|
|
108
117
|
const header = await getAuthorizationHeader();
|
package/dist/setup.js
CHANGED
|
@@ -89,6 +89,16 @@ export async function setup(args) {
|
|
|
89
89
|
}
|
|
90
90
|
const skills = (await listRes.json());
|
|
91
91
|
for (const name of skills) {
|
|
92
|
+
const skillPath = join(skillsDir, name, 'SKILL.md');
|
|
93
|
+
const exists = existsSync(skillPath);
|
|
94
|
+
if (exists) {
|
|
95
|
+
console.log(` [exists] ${name} — overwrite? (y/n) `);
|
|
96
|
+
const answer = await promptYN();
|
|
97
|
+
if (!answer) {
|
|
98
|
+
console.log(` [skip] ${name}`);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
92
102
|
const res = await fetch(`${SKILLS_URL}/${name}/SKILL.md`);
|
|
93
103
|
if (!res.ok) {
|
|
94
104
|
console.error(` [x] ${name} (download failed)`);
|
|
@@ -98,7 +108,7 @@ export async function setup(args) {
|
|
|
98
108
|
if (!dryRun) {
|
|
99
109
|
const dir = join(skillsDir, name);
|
|
100
110
|
mkdirSync(dir, { recursive: true });
|
|
101
|
-
writeFileSync(
|
|
111
|
+
writeFileSync(skillPath, content);
|
|
102
112
|
}
|
|
103
113
|
console.log(` [ok] ${name}`);
|
|
104
114
|
}
|
|
@@ -107,8 +117,27 @@ export async function setup(args) {
|
|
|
107
117
|
console.log('Dry run complete. No files written.');
|
|
108
118
|
}
|
|
109
119
|
else {
|
|
110
|
-
console.log(`
|
|
120
|
+
console.log(`Skills installed to ${skillsDir}`);
|
|
111
121
|
console.log('Try /invizi-trade in your AI tool.');
|
|
112
122
|
}
|
|
113
123
|
return 0;
|
|
114
124
|
}
|
|
125
|
+
function promptYN() {
|
|
126
|
+
return new Promise(resolve => {
|
|
127
|
+
const { stdin, stdout } = process;
|
|
128
|
+
if (!stdin.isTTY) {
|
|
129
|
+
// Non-interactive (CI, piped) — don't overwrite by default
|
|
130
|
+
resolve(false);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
stdin.setRawMode(true);
|
|
134
|
+
stdin.resume();
|
|
135
|
+
stdin.once('data', (data) => {
|
|
136
|
+
stdin.setRawMode(false);
|
|
137
|
+
stdin.pause();
|
|
138
|
+
const key = data.toString().toLowerCase();
|
|
139
|
+
stdout.write(key === 'y' ? 'yes\n' : 'no\n');
|
|
140
|
+
resolve(key === 'y');
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
}
|