@aikdna/kdna-studio-cli 0.9.2 → 0.10.1

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
@@ -125,6 +125,11 @@ A KDNA runtime export contains only these top-level entries:
125
125
  - `payload.kdnab`
126
126
  - `checksums.json`
127
127
 
128
+ The current producer writes `format_version: 0.1.0`, payload profile
129
+ `kdna.payload.judgment` with `profile_version: 0.1.0`, and digest profile
130
+ `kdna.digest-basis.runtime-entry-set` with `digest_profile_version: 0.1.0`.
131
+ These compatibility coordinates are independent of package versions.
132
+
128
133
  Authoring/source entries such as `KDNA_Core.json`, `KDNA_Patterns.json`, and
129
134
  `source_cards` are not runtime distribution entries. They may exist in Studio
130
135
  compile output or legacy imports, but they must not be emitted by the runtime
@@ -161,6 +166,11 @@ kdna-studio create forked --from-kdna ./parent.kdna --name @scope/forked
161
166
  kdna-studio create migrated --from-folder ./old-domain-json --name @scope/migrated
162
167
  ```
163
168
 
169
+ Current `.kdna` imports also preserve explicitly declared `highest_question`,
170
+ `worldview`, ordered `value_order`, and `judgment_role` values in the editable
171
+ project. Re-export writes those values back exactly; Studio does not infer a
172
+ replacement judgment core from an axiom.
173
+
164
174
  ## Related
165
175
 
166
176
  - [KDNA Core](https://github.com/aikdna/kdna) — Official format specification
@@ -9,7 +9,7 @@ const { execFileSync } = require('child_process');
9
9
 
10
10
  function loadStudioCore() {
11
11
  const publishedCore = require('@aikdna/kdna-studio-core');
12
- if (publishedCore.exportRuntime) return publishedCore;
12
+ if (publishedCore.exportRuntime && publishedCore.protocolContract) return publishedCore;
13
13
  try {
14
14
  return require('../../kdna-studio-core/src');
15
15
  } catch (_) {
@@ -26,6 +26,7 @@ const {
26
26
  creator: creatorApi,
27
27
  distillation: distillationApi,
28
28
  exportRuntime,
29
+ protocolContract,
29
30
  } = loadStudioCore();
30
31
 
31
32
  const llm = require('../src/llm');
@@ -513,14 +514,10 @@ function cardsFromRuntimePayload(payload) {
513
514
  for (const item of (Array.isArray(payload.cases) ? payload.cases : [])) {
514
515
  pushImportedCard(cards, 'case', item, item.id || null);
515
516
  }
516
- // Accept both `self_check` (canonical) and `self_checks` (legacy schema
517
- // name) so we round-trip assets written by either version of the
518
- // payload-profile schema. Bug (#53): prior version used
519
- // `arr || []`, which would crash with "object is not iterable" if
520
- // the field was a truthy non-array (e.g. a single `{question: ...}`
521
- // object instead of an array). The fix guards with Array.isArray.
522
- const rawSelfCheck = payload.reasoning?.self_check
523
- || payload.reasoning?.self_checks;
517
+ // The current payload contract has one self-check field. Refuse to infer a
518
+ // parallel field name: Core validation owns format migration, while Studio
519
+ // imports only the current validated payload shape.
520
+ const rawSelfCheck = payload.reasoning?.self_check;
524
521
  const selfCheckArr = Array.isArray(rawSelfCheck) ? rawSelfCheck : [];
525
522
  for (const selfCheck of selfCheckArr) {
526
523
  const fields = typeof selfCheck === 'string' ? { question: selfCheck } : selfCheck;
@@ -567,12 +564,27 @@ function cardsFromRuntimePayload(payload) {
567
564
 
568
565
  function cardsFromPayload(payload) {
569
566
  if (!payload || typeof payload !== 'object') return [];
570
- if (payload.profile === 'judgment-profile-v1' || payload.core || payload.source_cards) {
567
+ if (
568
+ payload.profile === protocolContract.PAYLOAD_PROFILE &&
569
+ payload.profile_version === protocolContract.PAYLOAD_PROFILE_VERSION
570
+ ) {
571
571
  return cardsFromRuntimePayload(payload);
572
572
  }
573
573
  return [];
574
574
  }
575
575
 
576
+ function judgmentCoreFromRuntimePayload(payload) {
577
+ const core = payload?.core;
578
+ if (!core || typeof core !== 'object' || Array.isArray(core)) return null;
579
+ const declared = {};
580
+ for (const field of ['highest_question', 'worldview', 'value_order', 'judgment_role']) {
581
+ if (Object.hasOwn(core, field)) {
582
+ declared[field] = JSON.parse(JSON.stringify(core[field]));
583
+ }
584
+ }
585
+ return Object.keys(declared).length > 0 ? declared : null;
586
+ }
587
+
576
588
  function buildManifest(project, name) {
577
589
  // Bug (#58): prior version was a hand-rolled manifest builder that
578
590
  // shared zero logic with the canonical buildManifest in
@@ -591,7 +603,7 @@ function buildManifest(project, name) {
591
603
  const assetId = assetIdFromName(name || source.name || project.name);
592
604
  const author = source.author || project.author || {};
593
605
  return {
594
- kdna_version: '1.0',
606
+ format_version: protocolContract.FORMAT_VERSION,
595
607
  asset_id: assetId,
596
608
  asset_uid: project.asset_uid || source.asset_uid || 'urn:uuid:' + crypto.randomUUID(),
597
609
  asset_type: project.type === 'cluster' ? 'cluster' : 'domain',
@@ -605,7 +617,11 @@ function buildManifest(project, name) {
605
617
  name: author.name || project.author?.name || 'Studio Export',
606
618
  id: author.id || project.author?.id || undefined,
607
619
  },
608
- compatibility: { min_loader_version: '1.0.0', profile: 'judgment-profile-v1' },
620
+ compatibility: {
621
+ min_loader_version: '0.19.0',
622
+ profile: protocolContract.PAYLOAD_PROFILE,
623
+ profile_version: protocolContract.PAYLOAD_PROFILE_VERSION,
624
+ },
609
625
  payload: { path: 'payload.kdnab', encoding: 'cbor', encrypted: false },
610
626
  summary: source.core_insight || project.release?.description || source.description || '',
611
627
  description: source.description || project.release?.description || '',
@@ -664,6 +680,7 @@ function cmdCreate(args) {
664
680
  sourceMode,
665
681
  creatorIdentity,
666
682
  lineage,
683
+ judgmentCore: kdnaData.judgment_core,
667
684
  });
668
685
  project.cards = kdnaData.cards;
669
686
  // Bug #15 / #28 follow-up: store the source KDNA_* files on the
@@ -763,12 +780,14 @@ function importFromKdna(kdnaPath) {
763
780
  // Current assets carry strict-CBOR `payload.kdnab`. Legacy source folders
764
781
  // are migrated explicitly with --from-folder; they are not runtime assets.
765
782
  const importedCards = [];
783
+ let judgmentCore = null;
766
784
  if (!entries.has('payload.kdnab')) {
767
785
  fail('Not a current .kdna asset: missing payload.kdnab. Use --from-folder for legacy JSON source migration.');
768
786
  }
769
787
  try {
770
788
  const payload = decodePayload(entries.get('payload.kdnab'), manifest);
771
789
  importedCards.push(...cardsFromPayload(payload));
790
+ judgmentCore = judgmentCoreFromRuntimePayload(payload);
772
791
  } catch (e) {
773
792
  fail(`Could not import cards from payload.kdnab: ${e.message}`);
774
793
  }
@@ -786,6 +805,7 @@ function importFromKdna(kdnaPath) {
786
805
  return {
787
806
  lineage,
788
807
  cards: importedCards,
808
+ judgment_core: judgmentCore,
789
809
  source_manifest: manifest,
790
810
  source_patterns: null,
791
811
  source_reasoning: null,
@@ -834,6 +854,8 @@ function importFromFolder(sourceDir, projectDir, projectName, creatorIdentity, o
834
854
  if (manifest.core_insight) manifestData.core_insight = manifest.core_insight;
835
855
  if (manifest.created_at || manifest.created) manifestData.created = manifest.created_at || manifest.created;
836
856
  if (manifest.updated_at || manifest.updated) manifestData.updated = manifest.updated_at || manifest.updated;
857
+ // legacy-migration bookkeeping only: preserved in the Studio project for
858
+ // issuer-scoped governance; the Core 0.20 export manifest never projects it
837
859
  if (manifest.risk_level) manifestData.risk_level = manifest.risk_level;
838
860
  if (manifest.fitness_for_purpose) manifestData.fitness_for_purpose = manifest.fitness_for_purpose;
839
861
  }
@@ -1936,7 +1958,7 @@ function cmdStudioInstall(args) {
1936
1958
  function cmdStudioUpdate(args) {
1937
1959
  const target = args[0];
1938
1960
  if (!target) fail('Usage: kdna-studio update <@scope/name>');
1939
- // kdna update does not exist in kdna-cli v0.28.x. The correct
1961
+ // kdna update does not exist in kdna-cli 0.28.x. The correct
1940
1962
  // path is to re-install via npm or use kdna install to pull
1941
1963
  // the latest published version of the asset.
1942
1964
  console.log(`To update ${target}, run:`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aikdna/kdna-studio-cli",
3
- "version": "0.9.2",
3
+ "version": "0.10.1",
4
4
  "description": "Official KDNA Studio command-line authoring entry for creating, reviewing, compiling, and exporting .kdna judgment assets through the KDNA toolchain.",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -14,11 +14,18 @@
14
14
  "README.md"
15
15
  ],
16
16
  "scripts": {
17
- "lint": "node --check bin/kdna-studio.js && node --check tests/cli.test.js",
17
+ "lint": "node scripts/run-lint.js",
18
+ "pretest": "node scripts/acquire-trusted-npm-release.js",
18
19
  "test": "node --test tests/*.test.js",
19
- "test:all": "npm run lint && npm test",
20
+ "test:all": "node scripts/run-test-all.js",
21
+ "test:runtime": "node scripts/run-product-tests.js",
22
+ "test:candidate-chain": "node scripts/verify-runtime-candidate-chain.js",
23
+ "verify:candidate-sources": "node scripts/verify-runtime-candidate-sources.js",
24
+ "check:protocol-names": "node scripts/check-current-protocol-names.js",
20
25
  "release:check": "node scripts/release-check.js",
21
- "prepublishOnly": "npm test && npm run release:check"
26
+ "release:generate-evidence": "node scripts/generate-release-evidence.js",
27
+ "release:publish-verified": "node scripts/publish-verified-artifact.js",
28
+ "prepublishOnly": "node scripts/run-test-all.js && node scripts/verify-runtime-candidate-chain.js && node scripts/release-check.js"
22
29
  },
23
30
  "keywords": [
24
31
  "kdna",
@@ -41,13 +48,12 @@
41
48
  "node": ">=18"
42
49
  },
43
50
  "dependencies": {
44
- "@aikdna/kdna-core": "0.17.0",
45
- "@aikdna/kdna-studio-core": "1.9.0",
51
+ "@aikdna/kdna-core": "0.20.0",
52
+ "@aikdna/kdna-studio-core": "2.0.1",
46
53
  "ajv": "^8.20.0",
47
54
  "ajv-formats": "^3.0.1",
48
55
  "cbor-x": "^1.6.4"
49
56
  },
50
- "main": "index.js",
51
57
  "directories": {
52
58
  "test": "tests"
53
59
  },