antikit 1.3.1 → 1.4.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antikit",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "CLI tool to manage AI agent skills from Anti Gravity skills repository",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -0,0 +1,76 @@
1
+ import chalk from 'chalk';
2
+ import ora from 'ora';
3
+ import { execSync } from 'child_process';
4
+ import { confirm } from '@inquirer/prompts';
5
+
6
+ // Since fetchLatestVersion was internal in updateNotifier.js, let's create a helper
7
+ // or I can duplicate the fetch logic here for simplicity, or refactor updateNotifier.js.
8
+ // Refactoring is better practice.
9
+
10
+ /**
11
+ * Update the CLI tool to the latest version
12
+ */
13
+ export async function updateCli() {
14
+ const spinner = ora('Checking for updates...').start();
15
+
16
+ try {
17
+ // Fetch latest version from npm
18
+ const response = await fetch(`https://registry.npmjs.org/antikit/latest`, {
19
+ headers: { 'Accept': 'application/json' },
20
+ signal: AbortSignal.timeout(5000)
21
+ });
22
+
23
+ if (!response.ok) {
24
+ throw new Error('Failed to fetch version info from npm registry');
25
+ }
26
+
27
+ const data = await response.json();
28
+ const latestVersion = data.version;
29
+
30
+ // Import package.json to get current version
31
+ // Using dynamic import to avoid requiring createRequire in this module if possible,
32
+ // but for consistency with index.js style
33
+ const { createRequire } = await import('module');
34
+ const require = createRequire(import.meta.url);
35
+ const pkg = require('../../package.json');
36
+ const currentVersion = pkg.version;
37
+
38
+ spinner.stop();
39
+
40
+ if (latestVersion === currentVersion) {
41
+ console.log(chalk.green(`\n✓ You are already on the latest version (${currentVersion})`));
42
+ return;
43
+ }
44
+
45
+ console.log(chalk.bold(`\nUpdate available: ${chalk.dim(currentVersion)} → ${chalk.green(latestVersion)}`));
46
+
47
+ const shouldUpdate = await confirm({
48
+ message: 'Do you want to update now?',
49
+ default: true
50
+ });
51
+
52
+ if (!shouldUpdate) {
53
+ console.log(chalk.yellow('Update cancelled.'));
54
+ return;
55
+ }
56
+
57
+ const updateSpinner = ora('Updating antikit...').start();
58
+
59
+ try {
60
+ execSync('npm install -g antikit@latest', { stdio: 'pipe' });
61
+ updateSpinner.succeed(chalk.green(`Updated to version ${latestVersion}`));
62
+ console.log(chalk.dim('\nYou may need to restart your terminal for changes to take effect.'));
63
+ } catch (err) {
64
+ updateSpinner.fail('Update failed');
65
+ console.log(chalk.red('Please try running: npm install -g antikit@latest'));
66
+ // Check for permission error
67
+ if (err.message.includes('EACCES')) {
68
+ console.log(chalk.yellow('Note: You might need to run with sudo'));
69
+ }
70
+ }
71
+
72
+ } catch (error) {
73
+ spinner.fail('Failed to check for updates');
74
+ console.error(chalk.red(error.message));
75
+ }
76
+ }
package/src/index.js CHANGED
@@ -7,6 +7,7 @@ import { listRemoteSkills } from './commands/list.js';
7
7
  import { listLocalSkills } from './commands/local.js';
8
8
  import { installSkill } from './commands/install.js';
9
9
  import { removeSkill } from './commands/remove.js';
10
+ import { updateCli } from './commands/update.js';
10
11
  import { listSources, addNewSource, removeExistingSource, setDefault } from './commands/source.js';
11
12
  import { checkForUpdates } from './utils/updateNotifier.js';
12
13
 
@@ -52,6 +53,12 @@ program
52
53
  .description('Remove an installed skill')
53
54
  .action(removeSkill);
54
55
 
56
+ program
57
+ .command('update')
58
+ .alias('up')
59
+ .description('Update antikit to the latest version')
60
+ .action(updateCli);
61
+
55
62
  // Source management commands
56
63
  const sourceCmd = program
57
64
  .command('source')