@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 +47 -56
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/card.ts +46 -29
- package/src/commands/init.ts +6 -31
- package/src/commands/join.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@highway1/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "CLI tool for Clawiverse network",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"clean": "rm -rf dist"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@highway1/core": "0.1.
|
|
16
|
+
"@highway1/core": "0.1.18",
|
|
17
17
|
"chalk": "^5.3.0",
|
|
18
18
|
"cli-table3": "^0.6.5",
|
|
19
19
|
"commander": "^12.1.0",
|
package/src/commands/card.ts
CHANGED
|
@@ -30,7 +30,10 @@ export function registerCardCommand(program: Command): void {
|
|
|
30
30
|
card
|
|
31
31
|
.command('edit')
|
|
32
32
|
.description('Edit Agent Card')
|
|
33
|
-
.
|
|
33
|
+
.option('--name <name>', 'Agent name')
|
|
34
|
+
.option('--description <description>', 'Agent description')
|
|
35
|
+
.option('--capabilities <capabilities>', 'Capabilities (comma-separated)')
|
|
36
|
+
.action(async (options) => {
|
|
34
37
|
try {
|
|
35
38
|
printHeader('Edit Agent Card');
|
|
36
39
|
|
|
@@ -41,35 +44,49 @@ export function registerCardCommand(program: Command): void {
|
|
|
41
44
|
process.exit(1);
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
47
|
+
let updatedCard;
|
|
48
|
+
|
|
49
|
+
// If any options provided, use non-interactive mode
|
|
50
|
+
if (options.name || options.description || options.capabilities) {
|
|
51
|
+
updatedCard = {
|
|
52
|
+
name: options.name || currentCard.name,
|
|
53
|
+
description: options.description || currentCard.description,
|
|
54
|
+
capabilities: options.capabilities
|
|
55
|
+
? options.capabilities.split(',').map((c: string) => c.trim()).filter((c: string) => c.length > 0)
|
|
56
|
+
: currentCard.capabilities,
|
|
57
|
+
};
|
|
58
|
+
} else {
|
|
59
|
+
// Interactive mode
|
|
60
|
+
const answers = await inquirer.prompt([
|
|
61
|
+
{
|
|
62
|
+
type: 'input',
|
|
63
|
+
name: 'name',
|
|
64
|
+
message: 'Agent name:',
|
|
65
|
+
default: currentCard.name,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
type: 'input',
|
|
69
|
+
name: 'description',
|
|
70
|
+
message: 'Agent description:',
|
|
71
|
+
default: currentCard.description,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
type: 'input',
|
|
75
|
+
name: 'capabilities',
|
|
76
|
+
message: 'Capabilities (comma-separated):',
|
|
77
|
+
default: currentCard.capabilities.join(', '),
|
|
78
|
+
},
|
|
79
|
+
]);
|
|
64
80
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
updatedCard = {
|
|
82
|
+
name: answers.name,
|
|
83
|
+
description: answers.description,
|
|
84
|
+
capabilities: answers.capabilities
|
|
85
|
+
.split(',')
|
|
86
|
+
.map((c: string) => c.trim())
|
|
87
|
+
.filter((c: string) => c.length > 0),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
73
90
|
|
|
74
91
|
setAgentCard(updatedCard);
|
|
75
92
|
|
package/src/commands/init.ts
CHANGED
|
@@ -2,63 +2,38 @@ import { Command } from 'commander';
|
|
|
2
2
|
import { generateKeyPair, exportKeyPair, deriveDID } from '@highway1/core';
|
|
3
3
|
import { hasIdentity, setIdentity, setAgentCard } from '../config.js';
|
|
4
4
|
import { success, error, spinner, printHeader, printKeyValue } from '../ui.js';
|
|
5
|
-
import inquirer from 'inquirer';
|
|
6
5
|
|
|
7
6
|
export function registerInitCommand(program: Command): void {
|
|
8
7
|
program
|
|
9
8
|
.command('init')
|
|
10
9
|
.description('Initialize a new Clawiverse identity')
|
|
11
|
-
.option('--name <name>', 'Agent name')
|
|
12
|
-
.option('--description <description>', 'Agent description')
|
|
10
|
+
.option('--name <name>', 'Agent name', 'My Agent')
|
|
11
|
+
.option('--description <description>', 'Agent description', 'A Clawiverse agent')
|
|
13
12
|
.option('--force', 'Overwrite existing identity')
|
|
14
13
|
.action(async (options) => {
|
|
15
14
|
try {
|
|
16
15
|
printHeader('Initialize Clawiverse Identity');
|
|
17
16
|
|
|
18
|
-
// Check if identity already exists
|
|
19
17
|
if (hasIdentity() && !options.force) {
|
|
20
18
|
error('Identity already exists. Use --force to overwrite.');
|
|
21
19
|
process.exit(1);
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
// Prompt for agent details if not provided
|
|
25
|
-
let name = options.name;
|
|
26
|
-
let description = options.description;
|
|
27
|
-
|
|
28
|
-
if (!name) name = 'My Agent';
|
|
29
|
-
if (!description) description = 'A Clawiverse agent';
|
|
30
|
-
|
|
31
|
-
if (!options.name) {
|
|
32
|
-
const { name: inputName } = await inquirer.prompt({
|
|
33
|
-
type: 'input', name: 'name', message: 'Agent name:', default: name,
|
|
34
|
-
});
|
|
35
|
-
name = inputName || name;
|
|
36
|
-
}
|
|
37
|
-
if (!options.description) {
|
|
38
|
-
const { description: inputDesc } = await inquirer.prompt({
|
|
39
|
-
type: 'input', name: 'description', message: 'Agent description:', default: description,
|
|
40
|
-
});
|
|
41
|
-
description = inputDesc || description;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
22
|
const spin = spinner('Generating key pair...');
|
|
45
23
|
|
|
46
|
-
// Generate key pair
|
|
47
24
|
const keyPair = await generateKeyPair();
|
|
48
25
|
const exported = exportKeyPair(keyPair);
|
|
49
26
|
const did = deriveDID(keyPair.publicKey);
|
|
50
27
|
|
|
51
|
-
// Save identity
|
|
52
28
|
setIdentity({
|
|
53
29
|
did,
|
|
54
30
|
publicKey: exported.publicKey,
|
|
55
31
|
privateKey: exported.privateKey,
|
|
56
32
|
});
|
|
57
33
|
|
|
58
|
-
// Save agent card
|
|
59
34
|
setAgentCard({
|
|
60
|
-
name,
|
|
61
|
-
description,
|
|
35
|
+
name: options.name,
|
|
36
|
+
description: options.description,
|
|
62
37
|
capabilities: [],
|
|
63
38
|
});
|
|
64
39
|
|
|
@@ -66,8 +41,8 @@ export function registerInitCommand(program: Command): void {
|
|
|
66
41
|
|
|
67
42
|
console.log();
|
|
68
43
|
printKeyValue('DID', did);
|
|
69
|
-
printKeyValue('Name', name);
|
|
70
|
-
printKeyValue('Description', description);
|
|
44
|
+
printKeyValue('Name', options.name);
|
|
45
|
+
printKeyValue('Description', options.description);
|
|
71
46
|
console.log();
|
|
72
47
|
|
|
73
48
|
success('Run "hw1 join" to connect to the network');
|