@aikdna/kdna-cli 0.22.5 → 0.23.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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/cli.js +31 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aikdna/kdna-cli",
3
- "version": "0.22.5",
3
+ "version": "0.23.0",
4
4
  "description": "KDNA CLI — runtime control plane for verifying, installing, loading, comparing, publishing, and auditing existing .kdna assets.",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -55,7 +55,7 @@
55
55
  "node": ">=18"
56
56
  },
57
57
  "dependencies": {
58
- "@aikdna/kdna-core": "^0.9.1"
58
+ "@aikdna/kdna-core": "^0.10.0"
59
59
  },
60
60
  "optionalDependencies": {
61
61
  "ajv": "^8.20.0",
package/src/cli.js CHANGED
@@ -429,6 +429,37 @@ switch (cmd) {
429
429
  break;
430
430
  }
431
431
  case 'load': {
432
+ const target = args.filter((a) => !a.startsWith('--'))[1];
433
+ if (target) {
434
+ const { isV1SourceDir, detectContainerFormat, loadV1 } = require('@aikdna/kdna-core');
435
+ const abs = require('node:path').resolve(target);
436
+ if (isV1SourceDir(abs) || detectContainerFormat(abs) === 'v1') {
437
+ const getFlag = (name) => {
438
+ const eq = args.find((a) => a.startsWith(name + '='));
439
+ if (eq) return eq.split('=')[1];
440
+ const idx = args.indexOf(name);
441
+ return idx >= 0 ? args[idx + 1] : null;
442
+ };
443
+ const profile = getFlag('--profile') || 'compact';
444
+ const as = getFlag('--as') || 'json';
445
+ try {
446
+ const r = loadV1(target, { profile, as });
447
+ if (as === 'prompt') {
448
+ process.stdout.write(r.text + '\n');
449
+ } else {
450
+ console.log(JSON.stringify(r, null, 2));
451
+ }
452
+ return;
453
+ } catch (e) {
454
+ if (e.code === 'requires_decryption') {
455
+ process.stderr.write('Error: payload requires decryption.\n');
456
+ process.exit(4);
457
+ }
458
+ process.stderr.write('Error: ' + e.message + '\n');
459
+ process.exit(1);
460
+ }
461
+ }
462
+ }
432
463
  cmdLoad(args);
433
464
  break;
434
465
  }