@highway1/cli 0.1.20 → 0.1.22

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 CHANGED
@@ -19,8 +19,8 @@ import { Command } from 'commander';
19
19
  import Conf from 'conf';
20
20
  import chalk from 'chalk';
21
21
  import ora from 'ora';
22
- import inquirer from 'inquirer';
23
22
  import Table from 'cli-table3';
23
+ import inquirer from 'inquirer';
24
24
 
25
25
  var __create = Object.create;
26
26
  var __defProp = Object.defineProperty;
@@ -116169,9 +116169,10 @@ async function createNode(config2) {
116169
116169
  bootstrapPeers = [],
116170
116170
  enableDHT = true,
116171
116171
  enableRelay = false,
116172
+ reserveRelaySlot = false,
116172
116173
  privateKey
116173
116174
  } = config2;
116174
- const relayListenAddrs = bootstrapPeers.map((peer) => `${peer}/p2p-circuit`);
116175
+ const relayListenAddrs = reserveRelaySlot ? bootstrapPeers.map((peer) => `${peer}/p2p-circuit`) : [];
116175
116176
  const libp2pConfig = {
116176
116177
  addresses: {
116177
116178
  listen: [...listenAddresses, ...relayListenAddrs]
@@ -118159,36 +118160,16 @@ function printSection(title) {
118159
118160
  console.log();
118160
118161
  console.log(chalk.bold(title));
118161
118162
  }
118163
+
118164
+ // src/commands/init.ts
118162
118165
  function registerInitCommand(program2) {
118163
- program2.command("init").description("Initialize a new Clawiverse identity").option("--name <name>", "Agent name").option("--description <description>", "Agent description").option("--force", "Overwrite existing identity").action(async (options) => {
118166
+ program2.command("init").description("Initialize a new Clawiverse identity").option("--name <name>", "Agent name", "My Agent").option("--description <description>", "Agent description", "A Clawiverse agent").option("--force", "Overwrite existing identity").action(async (options) => {
118164
118167
  try {
118165
118168
  printHeader("Initialize Clawiverse Identity");
118166
118169
  if (hasIdentity() && !options.force) {
118167
118170
  error("Identity already exists. Use --force to overwrite.");
118168
118171
  process.exit(1);
118169
118172
  }
118170
- let name3 = options.name;
118171
- let description = options.description;
118172
- if (!name3) name3 = "My Agent";
118173
- if (!description) description = "A Clawiverse agent";
118174
- if (!options.name) {
118175
- const { name: inputName } = await inquirer.prompt({
118176
- type: "input",
118177
- name: "name",
118178
- message: "Agent name:",
118179
- default: name3
118180
- });
118181
- name3 = inputName || name3;
118182
- }
118183
- if (!options.description) {
118184
- const { description: inputDesc } = await inquirer.prompt({
118185
- type: "input",
118186
- name: "description",
118187
- message: "Agent description:",
118188
- default: description
118189
- });
118190
- description = inputDesc || description;
118191
- }
118192
118173
  const spin = spinner("Generating key pair...");
118193
118174
  const keyPair = await generateKeyPair2();
118194
118175
  const exported = exportKeyPair(keyPair);
@@ -118199,15 +118180,15 @@ function registerInitCommand(program2) {
118199
118180
  privateKey: exported.privateKey
118200
118181
  });
118201
118182
  setAgentCard({
118202
- name: name3,
118203
- description,
118183
+ name: options.name,
118184
+ description: options.description,
118204
118185
  capabilities: []
118205
118186
  });
118206
118187
  spin.succeed("Identity created successfully!");
118207
118188
  console.log();
118208
118189
  printKeyValue("DID", did);
118209
- printKeyValue("Name", name3);
118210
- printKeyValue("Description", description);
118190
+ printKeyValue("Name", options.name);
118191
+ printKeyValue("Description", options.description);
118211
118192
  console.log();
118212
118193
  success('Run "hw1 join" to connect to the network');
118213
118194
  } catch (err2) {
@@ -118239,7 +118220,8 @@ function registerJoinCommand(program2) {
118239
118220
  const node = await createNode({
118240
118221
  keyPair,
118241
118222
  bootstrapPeers,
118242
- enableDHT: true
118223
+ enableDHT: true,
118224
+ reserveRelaySlot: true
118243
118225
  });
118244
118226
  await node.start();
118245
118227
  spin.succeed("Node started successfully!");
@@ -118645,7 +118627,7 @@ function registerCardCommand(program2) {
118645
118627
  process.exit(1);
118646
118628
  }
118647
118629
  });
118648
- card.command("edit").description("Edit Agent Card").action(async () => {
118630
+ card.command("edit").description("Edit Agent Card").option("--name <name>", "Agent name").option("--description <description>", "Agent description").option("--capabilities <capabilities>", "Capabilities (comma-separated)").action(async (options) => {
118649
118631
  try {
118650
118632
  printHeader("Edit Agent Card");
118651
118633
  const currentCard = getAgentCard();
@@ -118653,31 +118635,40 @@ function registerCardCommand(program2) {
118653
118635
  error('No Agent Card found. Run "hw1 init" first.');
118654
118636
  process.exit(1);
118655
118637
  }
118656
- const answers = await inquirer.prompt([
118657
- {
118658
- type: "input",
118659
- name: "name",
118660
- message: "Agent name:",
118661
- default: currentCard.name
118662
- },
118663
- {
118664
- type: "input",
118665
- name: "description",
118666
- message: "Agent description:",
118667
- default: currentCard.description
118668
- },
118669
- {
118670
- type: "input",
118671
- name: "capabilities",
118672
- message: "Capabilities (comma-separated):",
118673
- default: currentCard.capabilities.join(", ")
118674
- }
118675
- ]);
118676
- const updatedCard = {
118677
- name: answers.name,
118678
- description: answers.description,
118679
- capabilities: answers.capabilities.split(",").map((c2) => c2.trim()).filter((c2) => c2.length > 0)
118680
- };
118638
+ let updatedCard;
118639
+ if (options.name || options.description || options.capabilities) {
118640
+ updatedCard = {
118641
+ name: options.name || currentCard.name,
118642
+ description: options.description || currentCard.description,
118643
+ capabilities: options.capabilities ? options.capabilities.split(",").map((c2) => c2.trim()).filter((c2) => c2.length > 0) : currentCard.capabilities
118644
+ };
118645
+ } else {
118646
+ const answers = await inquirer.prompt([
118647
+ {
118648
+ type: "input",
118649
+ name: "name",
118650
+ message: "Agent name:",
118651
+ default: currentCard.name
118652
+ },
118653
+ {
118654
+ type: "input",
118655
+ name: "description",
118656
+ message: "Agent description:",
118657
+ default: currentCard.description
118658
+ },
118659
+ {
118660
+ type: "input",
118661
+ name: "capabilities",
118662
+ message: "Capabilities (comma-separated):",
118663
+ default: currentCard.capabilities.join(", ")
118664
+ }
118665
+ ]);
118666
+ updatedCard = {
118667
+ name: answers.name,
118668
+ description: answers.description,
118669
+ capabilities: answers.capabilities.split(",").map((c2) => c2.trim()).filter((c2) => c2.length > 0)
118670
+ };
118671
+ }
118681
118672
  setAgentCard(updatedCard);
118682
118673
  success("Agent Card updated successfully!");
118683
118674
  } catch (err2) {