@aikdna/kdna-studio-cli 0.3.3 → 0.4.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/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Official Studio command-line entry for KDNA judgment asset creation — turns your notes, documents, works, and feedback into loadable .kdna domains.
4
4
 
5
+ **Official** means this package is part of the KDNA official toolchain. It does not imply content trust, asset endorsement, registry status, or quality rating.
6
+
5
7
  Two authoring paths: interview-first (articulate your judgment directly) and distillation-first (provide content, find the patterns, confirm what's really you).
6
8
 
7
9
  Distillation-first authoring is domain-first: declare the target domain, owner scope, granularity, task scope, include areas, exclude areas, and load condition before extracting candidates. A single `.kdna` should stay scoped; complex work should compose multiple domain assets through a KDNA Cluster.
@@ -777,6 +777,77 @@ function cmdMigrate(args) {
777
777
  const files = { ...result.files };
778
778
  files['README.md'] = compileApi.generateReadme(project);
779
779
  files.LICENSE = project.license?.type || 'UNSPECIFIED';
780
+
781
+ if (args.includes('--format') && option(args, '--format') === 'v1') {
782
+ process.stderr.write('[debug] v1 export path triggered\n');
783
+ // ── v1 export: use @aikdna/kdna-core for pack/checksum ──
784
+ let core;
785
+ try {
786
+ core = require('@aikdna/kdna-core');
787
+ } catch (e) {
788
+ fail('@aikdna/kdna-core@0.11.0+ is required for v1 export. Run: npm install -g @aikdna/kdna-core@latest', 2);
789
+ }
790
+ const v2Manifest = JSON.parse(files['kdna.json']);
791
+ let payloadObj;
792
+ try {
793
+ const payloadBuf = files['payload.kdnab'];
794
+ payloadObj = cbor.decode(Buffer.isBuffer(payloadBuf) ? payloadBuf : Buffer.from(payloadBuf));
795
+ } catch (e) {
796
+ fail('Cannot decode v1 payload from Studio compile output: ' + e.message);
797
+ }
798
+ // Build a v1 source dir
799
+ const v1Dir = fs.mkdtempSync(path.join(require('os').tmpdir(), 'kdna-v1-'));
800
+ fs.writeFileSync(path.join(v1Dir, 'mimetype'), 'application/vnd.kdna.asset');
801
+ fs.writeFileSync(path.join(v1Dir, 'kdna.json'), JSON.stringify({
802
+ kdna_version: '1.0',
803
+ asset_id: v2Manifest.name || 'studio:v1-export',
804
+ asset_uid: 'urn:uuid:' + uuidv7(),
805
+ asset_type: 'domain',
806
+ title: v2Manifest.name || 'Studio v1 Export',
807
+ version: v2Manifest.version || '1.0.0',
808
+ judgment_version: v2Manifest.judgment_version || '1.0.0',
809
+ created_at: v2Manifest.created || new Date().toISOString(),
810
+ updated_at: v2Manifest.updated || new Date().toISOString(),
811
+ creator: { name: v2Manifest.author?.name || 'Studio Export', id: v2Manifest.author?.id },
812
+ compatibility: { min_loader_version: '1.0.0', profile: 'judgment-profile-v1' },
813
+ payload: { path: 'payload.kdnab', encoding: 'json', encrypted: false },
814
+ summary: v2Manifest.description || '',
815
+ language: v2Manifest.default_language || 'en',
816
+ lineage: { type: 'original', fork_of: null, derived_from: null },
817
+ }, null, 2));
818
+ // Build v1 payload: minimal mapping from v2 compile output
819
+ const v1Payload = {
820
+ profile: 'judgment-profile-v1',
821
+ core: {
822
+ highest_question: project.stages?.judgment_cards?.goal || '',
823
+ axioms: (project.cards || []).filter(c => c.type === 'axiom' && c.locked).map(c => ({
824
+ one_sentence: c.fields?.one_sentence || c.summary || '',
825
+ })),
826
+ boundaries: [],
827
+ risk_model: {},
828
+ },
829
+ patterns: [],
830
+ scenarios: [],
831
+ cases: [],
832
+ reasoning: { self_checks: [], failure_modes: [] },
833
+ };
834
+ fs.writeFileSync(path.join(v1Dir, 'payload.kdnab'), JSON.stringify(v1Payload, null, 2));
835
+ // Use official core to pack + checksum
836
+ core.pack(v1Dir, absOut);
837
+ // Re-validate
838
+ const vr = core.validate(absOut);
839
+ if (!vr.overall_valid) {
840
+ fail('v1 export validation failed: ' + (vr.problems || []).join('; '));
841
+ }
842
+ console.log(`Exported (v1): ${absOut}`);
843
+ console.log(` Name: ${name}`);
844
+ console.log(` Axioms: ${v1Payload.core.axioms.length}`);
845
+ console.log(` Validated: ${vr.overall_valid ? 'all gates pass' : 'FAIL'}`);
846
+ try { fs.rmSync(v1Dir, { recursive: true }); } catch { /* best effort */ }
847
+ try { fs.rmSync(tmpDir, { recursive: true }); } catch { /* best effort */ }
848
+ return;
849
+ }
850
+
780
851
  files.mimetype = 'application/vnd.aikdna.kdna+zip';
781
852
 
782
853
  if (args.includes('--sign')) applySignature(files, option(args, '--passphrase'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aikdna/kdna-studio-cli",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "Official KDNA Studio command-line authoring entry for creating, locking, compiling, and exporting .kdna judgment assets through the KDNA toolchain.",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -41,6 +41,6 @@
41
41
  "@aikdna/kdna-studio-core": "^1.5.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@aikdna/kdna-core": "^0.9.1"
44
+ "@aikdna/kdna-core": "^0.11.0"
45
45
  }
46
46
  }