@the-aico/cli 1.0.3 → 1.0.4
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/index.js +20 -209
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { Command as
|
|
4
|
+
import { Command as Command9 } from "commander";
|
|
5
5
|
|
|
6
6
|
// src/utils/errors.ts
|
|
7
7
|
import kleur from "kleur";
|
|
@@ -349,26 +349,6 @@ async function removeSkill(cwd, skillFullName) {
|
|
|
349
349
|
}
|
|
350
350
|
await writeConfig(cwd, config);
|
|
351
351
|
}
|
|
352
|
-
async function getInstalledSkills(cwd) {
|
|
353
|
-
const config = await getConfig(cwd);
|
|
354
|
-
if (!config) {
|
|
355
|
-
return [];
|
|
356
|
-
}
|
|
357
|
-
const skills = /* @__PURE__ */ new Set();
|
|
358
|
-
if (config.skills) {
|
|
359
|
-
for (const skillName of Object.keys(config.skills)) {
|
|
360
|
-
skills.add(skillName);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
for (const empState of Object.values(config.employees)) {
|
|
364
|
-
if (empState.skills) {
|
|
365
|
-
for (const skillName of empState.skills) {
|
|
366
|
-
skills.add(skillName);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
return Array.from(skills);
|
|
371
|
-
}
|
|
372
352
|
async function addSharedSkillReference(cwd, sharedSkillFullName, employeeName, version, platforms) {
|
|
373
353
|
const config = await getConfig(cwd);
|
|
374
354
|
if (!config) {
|
|
@@ -3032,177 +3012,9 @@ var diff = new Command6().name("diff").description("Check for updates against th
|
|
|
3032
3012
|
}
|
|
3033
3013
|
});
|
|
3034
3014
|
|
|
3035
|
-
// src/commands/
|
|
3015
|
+
// src/commands/search.ts
|
|
3036
3016
|
import { Command as Command7 } from "commander";
|
|
3037
|
-
import prompts5 from "prompts";
|
|
3038
|
-
import { z as z11 } from "zod";
|
|
3039
3017
|
import kleur3 from "kleur";
|
|
3040
|
-
|
|
3041
|
-
// src/utils/version.ts
|
|
3042
|
-
function compareVersions(a, b) {
|
|
3043
|
-
const partsA = a.split(".").map(Number);
|
|
3044
|
-
const partsB = b.split(".").map(Number);
|
|
3045
|
-
for (let i = 0; i < 3; i++) {
|
|
3046
|
-
const partA = partsA[i] ?? 0;
|
|
3047
|
-
const partB = partsB[i] ?? 0;
|
|
3048
|
-
if (partA < partB) return -1;
|
|
3049
|
-
if (partA > partB) return 1;
|
|
3050
|
-
}
|
|
3051
|
-
return 0;
|
|
3052
|
-
}
|
|
3053
|
-
function hasUpdate(current, latest) {
|
|
3054
|
-
return compareVersions(current, latest) < 0;
|
|
3055
|
-
}
|
|
3056
|
-
function formatVersionChange(current, latest) {
|
|
3057
|
-
if (hasUpdate(current, latest)) {
|
|
3058
|
-
return `${current} \u2192 ${latest}`;
|
|
3059
|
-
}
|
|
3060
|
-
return `${current} (up to date)`;
|
|
3061
|
-
}
|
|
3062
|
-
|
|
3063
|
-
// src/commands/update.ts
|
|
3064
|
-
var updateOptionsSchema = z11.object({
|
|
3065
|
-
skills: z11.array(z11.string()),
|
|
3066
|
-
cwd: z11.string(),
|
|
3067
|
-
yes: z11.boolean(),
|
|
3068
|
-
dryRun: z11.boolean()
|
|
3069
|
-
});
|
|
3070
|
-
async function runUpdate(options) {
|
|
3071
|
-
const { skills, cwd, yes, dryRun } = options;
|
|
3072
|
-
const config = await getConfig(cwd);
|
|
3073
|
-
if (!config) {
|
|
3074
|
-
throw notInitializedError();
|
|
3075
|
-
}
|
|
3076
|
-
logger.info("Checking for updates...");
|
|
3077
|
-
let skillsToCheck;
|
|
3078
|
-
if (skills.length > 0) {
|
|
3079
|
-
skillsToCheck = skills.map((s2) => parseTarget(s2).fullName);
|
|
3080
|
-
} else {
|
|
3081
|
-
skillsToCheck = await getInstalledSkills(cwd);
|
|
3082
|
-
}
|
|
3083
|
-
if (skillsToCheck.length === 0) {
|
|
3084
|
-
logger.info("No skills installed.");
|
|
3085
|
-
return;
|
|
3086
|
-
}
|
|
3087
|
-
const s = spinner("Fetching latest versions...").start();
|
|
3088
|
-
const updateResults = [];
|
|
3089
|
-
for (const skillName of skillsToCheck) {
|
|
3090
|
-
try {
|
|
3091
|
-
const currentState = config.skills?.[skillName];
|
|
3092
|
-
const currentVersion = currentState?.version ?? "0.0.0";
|
|
3093
|
-
const latestSkill = await fetchSkill(skillName, config, cwd);
|
|
3094
|
-
updateResults.push({
|
|
3095
|
-
skillName,
|
|
3096
|
-
currentVersion,
|
|
3097
|
-
latestVersion: latestSkill.version,
|
|
3098
|
-
hasUpdate: hasUpdate(currentVersion, latestSkill.version)
|
|
3099
|
-
});
|
|
3100
|
-
} catch {
|
|
3101
|
-
logger.dim(` Could not check ${skillName}`);
|
|
3102
|
-
}
|
|
3103
|
-
}
|
|
3104
|
-
s.stop();
|
|
3105
|
-
const updatesAvailable = updateResults.filter((r) => r.hasUpdate);
|
|
3106
|
-
if (updatesAvailable.length === 0) {
|
|
3107
|
-
logger.success("All skills are up to date!");
|
|
3108
|
-
return;
|
|
3109
|
-
}
|
|
3110
|
-
logger.break();
|
|
3111
|
-
logger.log(formatUpdateTable(updateResults));
|
|
3112
|
-
logger.break();
|
|
3113
|
-
if (dryRun) {
|
|
3114
|
-
logger.info(`${updatesAvailable.length} update(s) available.`);
|
|
3115
|
-
return;
|
|
3116
|
-
}
|
|
3117
|
-
if (!yes) {
|
|
3118
|
-
const { confirmed } = await prompts5({
|
|
3119
|
-
type: "confirm",
|
|
3120
|
-
name: "confirmed",
|
|
3121
|
-
message: `Update ${updatesAvailable.length} skill(s)?`,
|
|
3122
|
-
initial: true
|
|
3123
|
-
});
|
|
3124
|
-
if (!confirmed) {
|
|
3125
|
-
logger.info("Cancelled.");
|
|
3126
|
-
return;
|
|
3127
|
-
}
|
|
3128
|
-
}
|
|
3129
|
-
for (const result of updatesAvailable) {
|
|
3130
|
-
const updateSpinner = spinner(`Updating ${result.skillName}...`).start();
|
|
3131
|
-
try {
|
|
3132
|
-
const latestSkill = await fetchSkill(result.skillName, config, cwd);
|
|
3133
|
-
const platform = config.defaultPlatform;
|
|
3134
|
-
await uninstallSkill(result.skillName, config, cwd, { platform });
|
|
3135
|
-
await installSkill(latestSkill, config, cwd, {
|
|
3136
|
-
platform,
|
|
3137
|
-
overwrite: true
|
|
3138
|
-
});
|
|
3139
|
-
await updateSkill(
|
|
3140
|
-
cwd,
|
|
3141
|
-
result.skillName,
|
|
3142
|
-
latestSkill.version,
|
|
3143
|
-
[platform],
|
|
3144
|
-
"standalone"
|
|
3145
|
-
);
|
|
3146
|
-
updateSpinner.succeed(
|
|
3147
|
-
`Updated ${result.skillName} (${formatVersionChange(result.currentVersion, result.latestVersion)})`
|
|
3148
|
-
);
|
|
3149
|
-
} catch (error) {
|
|
3150
|
-
updateSpinner.fail(`Failed to update ${result.skillName}`);
|
|
3151
|
-
throw error;
|
|
3152
|
-
}
|
|
3153
|
-
}
|
|
3154
|
-
logger.break();
|
|
3155
|
-
logger.success("Update complete!");
|
|
3156
|
-
}
|
|
3157
|
-
function formatUpdateTable(results) {
|
|
3158
|
-
const maxNameLen = Math.max(...results.map((r) => r.skillName.length), 20);
|
|
3159
|
-
const maxVerLen = 10;
|
|
3160
|
-
const lines = [];
|
|
3161
|
-
const header = [
|
|
3162
|
-
"Skill".padEnd(maxNameLen),
|
|
3163
|
-
"Current".padEnd(maxVerLen),
|
|
3164
|
-
"Latest".padEnd(maxVerLen),
|
|
3165
|
-
"Status"
|
|
3166
|
-
].join(" \u2502 ");
|
|
3167
|
-
const separator = [
|
|
3168
|
-
"\u2500".repeat(maxNameLen),
|
|
3169
|
-
"\u2500".repeat(maxVerLen),
|
|
3170
|
-
"\u2500".repeat(maxVerLen),
|
|
3171
|
-
"\u2500".repeat(16)
|
|
3172
|
-
].join("\u2500\u253C\u2500");
|
|
3173
|
-
lines.push("\u250C" + separator.replace(/─┼─/g, "\u2500\u252C\u2500") + "\u2510");
|
|
3174
|
-
lines.push("\u2502 " + header + " \u2502");
|
|
3175
|
-
lines.push("\u251C" + separator + "\u2524");
|
|
3176
|
-
for (const r of results) {
|
|
3177
|
-
const status = r.hasUpdate ? kleur3.yellow("update available") : kleur3.green("up to date");
|
|
3178
|
-
const row = [
|
|
3179
|
-
r.skillName.padEnd(maxNameLen),
|
|
3180
|
-
r.currentVersion.padEnd(maxVerLen),
|
|
3181
|
-
r.latestVersion.padEnd(maxVerLen),
|
|
3182
|
-
status
|
|
3183
|
-
].join(" \u2502 ");
|
|
3184
|
-
lines.push("\u2502 " + row + " \u2502");
|
|
3185
|
-
}
|
|
3186
|
-
lines.push("\u2514" + separator.replace(/─┼─/g, "\u2500\u2534\u2500") + "\u2518");
|
|
3187
|
-
return lines.join("\n");
|
|
3188
|
-
}
|
|
3189
|
-
var update = new Command7().name("update").description("Update installed skills to latest versions").argument("[skills...]", "Skill names to update (all if empty)").option("--dry-run", "Preview updates without applying", false).option("-y, --yes", "Skip confirmation", false).option("-c, --cwd <cwd>", "Working directory", process.cwd()).action(async (skills, opts) => {
|
|
3190
|
-
try {
|
|
3191
|
-
const options = updateOptionsSchema.parse({
|
|
3192
|
-
skills,
|
|
3193
|
-
cwd: opts.cwd,
|
|
3194
|
-
yes: opts.yes,
|
|
3195
|
-
dryRun: opts.dryRun
|
|
3196
|
-
});
|
|
3197
|
-
await runUpdate(options);
|
|
3198
|
-
} catch (error) {
|
|
3199
|
-
handleError(error);
|
|
3200
|
-
}
|
|
3201
|
-
});
|
|
3202
|
-
|
|
3203
|
-
// src/commands/search.ts
|
|
3204
|
-
import { Command as Command8 } from "commander";
|
|
3205
|
-
import kleur4 from "kleur";
|
|
3206
3018
|
function searchItems(query, items) {
|
|
3207
3019
|
const q = query.toLowerCase();
|
|
3208
3020
|
return items.filter((item) => {
|
|
@@ -3244,7 +3056,7 @@ function filterByType(items, type) {
|
|
|
3244
3056
|
}
|
|
3245
3057
|
function formatTable(items) {
|
|
3246
3058
|
if (items.length === 0) {
|
|
3247
|
-
return
|
|
3059
|
+
return kleur3.yellow("No results found.");
|
|
3248
3060
|
}
|
|
3249
3061
|
const nameWidth = Math.max(
|
|
3250
3062
|
"Name".length,
|
|
@@ -3277,7 +3089,7 @@ function formatTable(items) {
|
|
|
3277
3089
|
desc
|
|
3278
3090
|
].join(" \u2502 ");
|
|
3279
3091
|
});
|
|
3280
|
-
return [
|
|
3092
|
+
return [kleur3.bold(header), separator, ...rows].join("\n");
|
|
3281
3093
|
}
|
|
3282
3094
|
function formatJSON(items) {
|
|
3283
3095
|
const output = {
|
|
@@ -3294,7 +3106,7 @@ function formatJSON(items) {
|
|
|
3294
3106
|
};
|
|
3295
3107
|
return JSON.stringify(output, null, 2);
|
|
3296
3108
|
}
|
|
3297
|
-
var search = new
|
|
3109
|
+
var search = new Command7().name("search").description("Search for skills and employees").argument("<query>", "Search query").option(
|
|
3298
3110
|
"-c, --category <category>",
|
|
3299
3111
|
"Filter by category (pm, frontend, backend)"
|
|
3300
3112
|
).option("-t, --type <type>", "Filter by type (skill, employee)").option("--json", "Output as JSON").option("--limit <n>", "Limit results", "10").option("--cwd <cwd>", "Working directory", process.cwd()).action(async (query, opts) => {
|
|
@@ -3329,7 +3141,7 @@ var search = new Command8().name("search").description("Search for skills and em
|
|
|
3329
3141
|
logger.log(formatJSON(results));
|
|
3330
3142
|
} else {
|
|
3331
3143
|
logger.log(
|
|
3332
|
-
|
|
3144
|
+
kleur3.cyan(`Found ${results.length} result(s) for "${query}":`)
|
|
3333
3145
|
);
|
|
3334
3146
|
logger.break();
|
|
3335
3147
|
logger.log(formatTable(results));
|
|
@@ -3344,8 +3156,8 @@ var search = new Command8().name("search").description("Search for skills and em
|
|
|
3344
3156
|
});
|
|
3345
3157
|
|
|
3346
3158
|
// src/commands/check.ts
|
|
3347
|
-
import { Command as
|
|
3348
|
-
import
|
|
3159
|
+
import { Command as Command8 } from "commander";
|
|
3160
|
+
import kleur4 from "kleur";
|
|
3349
3161
|
import { existsSync, readdirSync, statSync } from "fs";
|
|
3350
3162
|
import { join } from "path";
|
|
3351
3163
|
function checkNodeVersion() {
|
|
@@ -3514,10 +3326,10 @@ function checkInstalled(cwd, platformConfig) {
|
|
|
3514
3326
|
}
|
|
3515
3327
|
function getSymbol(status) {
|
|
3516
3328
|
const symbols = {
|
|
3517
|
-
pass:
|
|
3518
|
-
fail:
|
|
3519
|
-
warn:
|
|
3520
|
-
skip:
|
|
3329
|
+
pass: kleur4.green("\u25CF"),
|
|
3330
|
+
fail: kleur4.red("\u2716"),
|
|
3331
|
+
warn: kleur4.yellow("\u25D0"),
|
|
3332
|
+
skip: kleur4.gray("\u25CB")
|
|
3521
3333
|
};
|
|
3522
3334
|
return symbols[status];
|
|
3523
3335
|
}
|
|
@@ -3528,14 +3340,14 @@ function formatResults(results) {
|
|
|
3528
3340
|
const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
3529
3341
|
const extension = isLast ? " " : "\u2502 ";
|
|
3530
3342
|
const symbol = getSymbol(result.status);
|
|
3531
|
-
const message = result.message ?
|
|
3343
|
+
const message = result.message ? kleur4.dim(` (${result.message})`) : "";
|
|
3532
3344
|
lines.push(`${connector}${symbol} ${result.name}${message}`);
|
|
3533
3345
|
if (result.children) {
|
|
3534
3346
|
result.children.forEach((child, childIndex) => {
|
|
3535
3347
|
const childIsLast = childIndex === result.children.length - 1;
|
|
3536
3348
|
const childConnector = childIsLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
3537
3349
|
const childSymbol = getSymbol(child.status);
|
|
3538
|
-
const childMessage = child.message ?
|
|
3350
|
+
const childMessage = child.message ? kleur4.dim(` (${child.message})`) : "";
|
|
3539
3351
|
lines.push(
|
|
3540
3352
|
`${extension}${childConnector}${childSymbol} ${child.name}${childMessage}`
|
|
3541
3353
|
);
|
|
@@ -3544,11 +3356,11 @@ function formatResults(results) {
|
|
|
3544
3356
|
});
|
|
3545
3357
|
return lines.join("\n");
|
|
3546
3358
|
}
|
|
3547
|
-
var check = new
|
|
3359
|
+
var check = new Command8().name("check").description("Check environment and configuration").option("--json", "Output as JSON").option("--cwd <cwd>", "Working directory", process.cwd()).action(async (opts) => {
|
|
3548
3360
|
try {
|
|
3549
3361
|
const cwd = opts.cwd;
|
|
3550
3362
|
logger.break();
|
|
3551
|
-
logger.bold(
|
|
3363
|
+
logger.bold(kleur4.cyan("AICO Environment Check"));
|
|
3552
3364
|
logger.break();
|
|
3553
3365
|
const results = [];
|
|
3554
3366
|
results.push(checkNodeVersion());
|
|
@@ -3606,14 +3418,14 @@ var check = new Command9().name("check").description("Check environment and conf
|
|
|
3606
3418
|
const hasWarn = results.some((r) => r.status === "warn");
|
|
3607
3419
|
if (hasError) {
|
|
3608
3420
|
logger.log(
|
|
3609
|
-
|
|
3421
|
+
kleur4.red("\u2716 Some checks failed. Run `aico init` to fix.")
|
|
3610
3422
|
);
|
|
3611
3423
|
} else if (hasWarn) {
|
|
3612
3424
|
logger.log(
|
|
3613
|
-
|
|
3425
|
+
kleur4.yellow("\u25D0 Some checks have warnings. AICO should work.")
|
|
3614
3426
|
);
|
|
3615
3427
|
} else {
|
|
3616
|
-
logger.log(
|
|
3428
|
+
logger.log(kleur4.green("\u2713 All checks passed! AICO is ready to use."));
|
|
3617
3429
|
}
|
|
3618
3430
|
logger.break();
|
|
3619
3431
|
}
|
|
@@ -3626,7 +3438,7 @@ var check = new Command9().name("check").description("Check environment and conf
|
|
|
3626
3438
|
var VERSION = "1.0.0";
|
|
3627
3439
|
var globalVerbose = false;
|
|
3628
3440
|
async function main() {
|
|
3629
|
-
const program = new
|
|
3441
|
+
const program = new Command9().name("aico").description(
|
|
3630
3442
|
"AI employee management tool - Build your AI team in seconds, start working immediately"
|
|
3631
3443
|
).version(VERSION).option("-v, --verbose", "Show detailed error information").option("--proxy <url>", "Use HTTP/HTTPS proxy for requests");
|
|
3632
3444
|
program.hook("preAction", (thisCommand) => {
|
|
@@ -3636,7 +3448,6 @@ async function main() {
|
|
|
3636
3448
|
program.addCommand(init);
|
|
3637
3449
|
program.addCommand(add);
|
|
3638
3450
|
program.addCommand(remove);
|
|
3639
|
-
program.addCommand(update);
|
|
3640
3451
|
program.addCommand(list);
|
|
3641
3452
|
program.addCommand(diff);
|
|
3642
3453
|
program.addCommand(build);
|