@highway1/cli 0.1.20 → 0.1.21
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 +43 -54
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/card.ts +46 -29
- package/src/commands/init.ts +6 -31
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;
|
|
@@ -118159,36 +118159,16 @@ function printSection(title) {
|
|
|
118159
118159
|
console.log();
|
|
118160
118160
|
console.log(chalk.bold(title));
|
|
118161
118161
|
}
|
|
118162
|
+
|
|
118163
|
+
// src/commands/init.ts
|
|
118162
118164
|
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) => {
|
|
118165
|
+
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
118166
|
try {
|
|
118165
118167
|
printHeader("Initialize Clawiverse Identity");
|
|
118166
118168
|
if (hasIdentity() && !options.force) {
|
|
118167
118169
|
error("Identity already exists. Use --force to overwrite.");
|
|
118168
118170
|
process.exit(1);
|
|
118169
118171
|
}
|
|
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
118172
|
const spin = spinner("Generating key pair...");
|
|
118193
118173
|
const keyPair = await generateKeyPair2();
|
|
118194
118174
|
const exported = exportKeyPair(keyPair);
|
|
@@ -118199,15 +118179,15 @@ function registerInitCommand(program2) {
|
|
|
118199
118179
|
privateKey: exported.privateKey
|
|
118200
118180
|
});
|
|
118201
118181
|
setAgentCard({
|
|
118202
|
-
name:
|
|
118203
|
-
description,
|
|
118182
|
+
name: options.name,
|
|
118183
|
+
description: options.description,
|
|
118204
118184
|
capabilities: []
|
|
118205
118185
|
});
|
|
118206
118186
|
spin.succeed("Identity created successfully!");
|
|
118207
118187
|
console.log();
|
|
118208
118188
|
printKeyValue("DID", did);
|
|
118209
|
-
printKeyValue("Name",
|
|
118210
|
-
printKeyValue("Description", description);
|
|
118189
|
+
printKeyValue("Name", options.name);
|
|
118190
|
+
printKeyValue("Description", options.description);
|
|
118211
118191
|
console.log();
|
|
118212
118192
|
success('Run "hw1 join" to connect to the network');
|
|
118213
118193
|
} catch (err2) {
|
|
@@ -118645,7 +118625,7 @@ function registerCardCommand(program2) {
|
|
|
118645
118625
|
process.exit(1);
|
|
118646
118626
|
}
|
|
118647
118627
|
});
|
|
118648
|
-
card.command("edit").description("Edit Agent Card").action(async () => {
|
|
118628
|
+
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
118629
|
try {
|
|
118650
118630
|
printHeader("Edit Agent Card");
|
|
118651
118631
|
const currentCard = getAgentCard();
|
|
@@ -118653,31 +118633,40 @@ function registerCardCommand(program2) {
|
|
|
118653
118633
|
error('No Agent Card found. Run "hw1 init" first.');
|
|
118654
118634
|
process.exit(1);
|
|
118655
118635
|
}
|
|
118656
|
-
|
|
118657
|
-
|
|
118658
|
-
|
|
118659
|
-
name:
|
|
118660
|
-
|
|
118661
|
-
|
|
118662
|
-
}
|
|
118663
|
-
|
|
118664
|
-
|
|
118665
|
-
|
|
118666
|
-
|
|
118667
|
-
|
|
118668
|
-
|
|
118669
|
-
|
|
118670
|
-
|
|
118671
|
-
|
|
118672
|
-
|
|
118673
|
-
|
|
118674
|
-
|
|
118675
|
-
|
|
118676
|
-
|
|
118677
|
-
|
|
118678
|
-
|
|
118679
|
-
|
|
118680
|
-
|
|
118636
|
+
let updatedCard;
|
|
118637
|
+
if (options.name || options.description || options.capabilities) {
|
|
118638
|
+
updatedCard = {
|
|
118639
|
+
name: options.name || currentCard.name,
|
|
118640
|
+
description: options.description || currentCard.description,
|
|
118641
|
+
capabilities: options.capabilities ? options.capabilities.split(",").map((c2) => c2.trim()).filter((c2) => c2.length > 0) : currentCard.capabilities
|
|
118642
|
+
};
|
|
118643
|
+
} else {
|
|
118644
|
+
const answers = await inquirer.prompt([
|
|
118645
|
+
{
|
|
118646
|
+
type: "input",
|
|
118647
|
+
name: "name",
|
|
118648
|
+
message: "Agent name:",
|
|
118649
|
+
default: currentCard.name
|
|
118650
|
+
},
|
|
118651
|
+
{
|
|
118652
|
+
type: "input",
|
|
118653
|
+
name: "description",
|
|
118654
|
+
message: "Agent description:",
|
|
118655
|
+
default: currentCard.description
|
|
118656
|
+
},
|
|
118657
|
+
{
|
|
118658
|
+
type: "input",
|
|
118659
|
+
name: "capabilities",
|
|
118660
|
+
message: "Capabilities (comma-separated):",
|
|
118661
|
+
default: currentCard.capabilities.join(", ")
|
|
118662
|
+
}
|
|
118663
|
+
]);
|
|
118664
|
+
updatedCard = {
|
|
118665
|
+
name: answers.name,
|
|
118666
|
+
description: answers.description,
|
|
118667
|
+
capabilities: answers.capabilities.split(",").map((c2) => c2.trim()).filter((c2) => c2.length > 0)
|
|
118668
|
+
};
|
|
118669
|
+
}
|
|
118681
118670
|
setAgentCard(updatedCard);
|
|
118682
118671
|
success("Agent Card updated successfully!");
|
|
118683
118672
|
} catch (err2) {
|