@yamo/cli 1.0.7 → 1.3.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/dist/index.js +65 -1
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -44,6 +44,7 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
44
44
|
const path_1 = __importDefault(require("path"));
|
|
45
45
|
const dotenv = __importStar(require("dotenv"));
|
|
46
46
|
const core_1 = require("@yamo/core");
|
|
47
|
+
const pkg = JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, '../package.json'), 'utf8'));
|
|
47
48
|
dotenv.config();
|
|
48
49
|
const program = new commander_1.Command();
|
|
49
50
|
const ipfsManager = new core_1.IpfsManager();
|
|
@@ -51,7 +52,7 @@ const chainClient = new core_1.YamoChainClient();
|
|
|
51
52
|
program
|
|
52
53
|
.name("yamo")
|
|
53
54
|
.description("YAMO Protocol CLI - Manage Agentic Reasoning Chains")
|
|
54
|
-
.version(
|
|
55
|
+
.version(pkg.version);
|
|
55
56
|
program
|
|
56
57
|
.command("hash")
|
|
57
58
|
.description("Calculate the content hash of a YAMO block")
|
|
@@ -104,6 +105,26 @@ program
|
|
|
104
105
|
.option("-k, --key <key>", "Encryption key (or set YAMO_ENCRYPTION_KEY)")
|
|
105
106
|
.action(async (file, options) => {
|
|
106
107
|
try {
|
|
108
|
+
// Validate password if encryption is enabled
|
|
109
|
+
if (options.encrypt) {
|
|
110
|
+
const key = options.key || process.env.YAMO_ENCRYPTION_KEY;
|
|
111
|
+
if (!key) {
|
|
112
|
+
throw new Error("Encryption enabled but no key provided. Use --key or set YAMO_ENCRYPTION_KEY");
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
const { validatePasswordStrength } = await import("@yamo/core");
|
|
116
|
+
validatePasswordStrength(key);
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
console.error(chalk_1.default.red("Password validation failed:"));
|
|
120
|
+
console.error(chalk_1.default.red(e.message));
|
|
121
|
+
console.error(chalk_1.default.yellow("\nKey requirements:"));
|
|
122
|
+
console.error(" • Minimum 12 characters");
|
|
123
|
+
console.error(" • Mix of uppercase, lowercase, numbers, symbols");
|
|
124
|
+
console.error(" • Avoid common patterns (password, 123456, qwerty)");
|
|
125
|
+
throw e;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
107
128
|
const content = fs_1.default.readFileSync(file, "utf8").trim();
|
|
108
129
|
const contentHash = "0x" + crypto_1.default.createHash("sha256").update(content).digest("hex");
|
|
109
130
|
console.log(chalk_1.default.blue(`Calculated Hash: ${contentHash}`));
|
|
@@ -175,4 +196,47 @@ program
|
|
|
175
196
|
console.error(chalk_1.default.red(`Error: ${error.message}`));
|
|
176
197
|
}
|
|
177
198
|
});
|
|
199
|
+
program
|
|
200
|
+
.command("download-bundle")
|
|
201
|
+
.description("Download complete IPFS bundle including all artifacts")
|
|
202
|
+
.argument("<cid>", "IPFS CID to download")
|
|
203
|
+
.option("-k, --key <key>", "Decryption key (if encrypted)")
|
|
204
|
+
.option("-o, --output <dir>", "Output directory (default: ./bundle_<cid>)", "./bundle_<cid>")
|
|
205
|
+
.action(async (cid, options) => {
|
|
206
|
+
try {
|
|
207
|
+
console.log(chalk_1.default.blue(`Downloading bundle ${cid}...`));
|
|
208
|
+
const { IpfsManager } = await import("@yamo/core");
|
|
209
|
+
const ipfs = new IpfsManager();
|
|
210
|
+
const key = options.key || process.env.YAMO_ENCRYPTION_KEY;
|
|
211
|
+
const bundle = await ipfs.downloadBundle(cid, key);
|
|
212
|
+
// Create output directory
|
|
213
|
+
const outputDir = options.output.replace("<cid>", cid.substring(0, 8));
|
|
214
|
+
if (!fs_1.default.existsSync(outputDir)) {
|
|
215
|
+
fs_1.default.mkdirSync(outputDir, { recursive: true });
|
|
216
|
+
}
|
|
217
|
+
// Write block.yamo
|
|
218
|
+
fs_1.default.writeFileSync(path_1.default.join(outputDir, "block.yamo"), bundle.block);
|
|
219
|
+
console.log(chalk_1.default.green(`✓ Downloaded block.yamo`));
|
|
220
|
+
// Write metadata
|
|
221
|
+
if (bundle.metadata) {
|
|
222
|
+
fs_1.default.writeFileSync(path_1.default.join(outputDir, "metadata.json"), JSON.stringify(bundle.metadata, null, 2));
|
|
223
|
+
console.log(chalk_1.default.green(`✓ Downloaded metadata.json`));
|
|
224
|
+
}
|
|
225
|
+
// Write artifact files
|
|
226
|
+
for (const [filename, content] of Object.entries(bundle.files)) {
|
|
227
|
+
const filePath = path_1.default.join(outputDir, filename);
|
|
228
|
+
fs_1.default.writeFileSync(filePath, content);
|
|
229
|
+
console.log(chalk_1.default.green(`✓ Downloaded ${filename}`));
|
|
230
|
+
}
|
|
231
|
+
console.log(chalk_1.default.green(`\nBundle saved to: ${outputDir}`));
|
|
232
|
+
console.log(chalk_1.default.gray(`Files: ${1 + Object.keys(bundle.files).length} total`));
|
|
233
|
+
if (bundle.metadata?.hasEncryption) {
|
|
234
|
+
console.log(chalk_1.default.yellow("🔒 Bundle was decrypted using provided key"));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
console.error(chalk_1.default.red(`Error: ${error.message}`));
|
|
239
|
+
console.error(chalk_1.default.gray("\nIf the bundle is encrypted, provide --key or set YAMO_ENCRYPTION_KEY"));
|
|
240
|
+
}
|
|
241
|
+
});
|
|
178
242
|
program.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yamo/cli",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "YAMO Protocol v0.4 - Command-line tools for blockchain integration",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist/",
|
|
12
|
+
"package.json",
|
|
12
13
|
"README.md",
|
|
13
14
|
"LICENSE"
|
|
14
15
|
],
|
|
15
16
|
"scripts": {
|
|
16
|
-
"build": "tsc",
|
|
17
|
+
"build": "tsc && chmod +x dist/index.js",
|
|
17
18
|
"prepublishOnly": "npm run build",
|
|
18
19
|
"start": "node dist/index.js"
|
|
19
20
|
},
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"typescript": "^5.9.3"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"@yamo/core": "^1.
|
|
44
|
+
"@yamo/core": "^1.1.0",
|
|
44
45
|
"axios": "^1.13.2",
|
|
45
46
|
"chalk": "^4.1.2",
|
|
46
47
|
"commander": "^12.0.0",
|