agent-skill-installer 0.1.5 → 0.1.6
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/cli.js +37 -6
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const fs = require("node:fs/promises");
|
|
4
4
|
const path = require("node:path");
|
|
5
5
|
const os = require("node:os");
|
|
6
|
+
const readline = require("node:readline/promises");
|
|
6
7
|
|
|
7
8
|
const REPO_ROOT = path.resolve(__dirname, "..");
|
|
8
9
|
const SKILLS_SOURCE_DIR = path.join(REPO_ROOT, "skills");
|
|
@@ -21,7 +22,7 @@ Commands:
|
|
|
21
22
|
|
|
22
23
|
Options:
|
|
23
24
|
--dest <path> Custom destination directory.
|
|
24
|
-
--force Overwrite destination if a skill already exists.
|
|
25
|
+
--force Overwrite destination if a skill already exists (no prompt).
|
|
25
26
|
-h, --help Show this help.
|
|
26
27
|
`);
|
|
27
28
|
}
|
|
@@ -112,6 +113,33 @@ async function listSkills() {
|
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
|
|
116
|
+
async function confirmOverwrite(name, targetPath) {
|
|
117
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
118
|
+
throw new Error(
|
|
119
|
+
`Destination already exists for "${name}": ${targetPath} (non-interactive mode, use --force to overwrite)`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const rl = readline.createInterface({
|
|
124
|
+
input: process.stdin,
|
|
125
|
+
output: process.stdout
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
const answer = (
|
|
130
|
+
await rl.question(
|
|
131
|
+
`Skill "${name}" already exists at ${targetPath}. Overwrite it? [y/N] `
|
|
132
|
+
)
|
|
133
|
+
)
|
|
134
|
+
.trim()
|
|
135
|
+
.toLowerCase();
|
|
136
|
+
|
|
137
|
+
return answer === "y" || answer === "yes";
|
|
138
|
+
} finally {
|
|
139
|
+
rl.close();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
115
143
|
async function installSkills(rawArgs) {
|
|
116
144
|
const parsed = parseInstallArgs(rawArgs);
|
|
117
145
|
if (parsed.help) {
|
|
@@ -137,13 +165,16 @@ async function installSkills(rawArgs) {
|
|
|
137
165
|
const to = path.join(parsed.dest, name);
|
|
138
166
|
const exists = await dirExists(to);
|
|
139
167
|
|
|
140
|
-
if (exists &&
|
|
141
|
-
|
|
142
|
-
`Destination already exists for "${name}": ${to} (use --force to overwrite)`
|
|
143
|
-
);
|
|
168
|
+
if (exists && parsed.force) {
|
|
169
|
+
await fs.rm(to, { recursive: true, force: true });
|
|
144
170
|
}
|
|
145
171
|
|
|
146
|
-
if (exists && parsed.force) {
|
|
172
|
+
if (exists && !parsed.force) {
|
|
173
|
+
const shouldOverwrite = await confirmOverwrite(name, to);
|
|
174
|
+
if (!shouldOverwrite) {
|
|
175
|
+
console.log(`Skipped "${name}" (kept existing skill).`);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
147
178
|
await fs.rm(to, { recursive: true, force: true });
|
|
148
179
|
}
|
|
149
180
|
|