@aikdna/kdna-core 0.8.0 → 0.9.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/package.json +1 -1
- package/src/asset-reader.js +10 -42
- package/src/lint-pure.js +2 -2
- package/src/types.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aikdna/kdna-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "KDNA core library — pure logic for loading, validating, linting, and rendering KDNA domain cognition packages. Zero Node.js dependencies.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "src/index.js",
|
package/src/asset-reader.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* KDNA Asset Reader — direct .kdna container access.
|
|
3
|
-
*
|
|
4
|
-
* Supports KDNA Container v2 (payload.kdnab via CBOR).
|
|
5
|
-
* V1 plaintext containers (KDNA_Core.json etc. as ZIP entries) are rejected.
|
|
6
3
|
*/
|
|
7
4
|
|
|
8
5
|
const fs = require('fs');
|
|
@@ -11,27 +8,6 @@ const zlib = require('zlib');
|
|
|
11
8
|
const cbor = require('cbor-x');
|
|
12
9
|
const { loadDomainFromFiles, formatContext } = require('./loader');
|
|
13
10
|
|
|
14
|
-
const STANDARD_ENTRIES = [
|
|
15
|
-
'kdna.json',
|
|
16
|
-
'payload.kdnab',
|
|
17
|
-
'KDNA_Core.json',
|
|
18
|
-
'KDNA_Patterns.json',
|
|
19
|
-
'KDNA_Scenarios.json',
|
|
20
|
-
'KDNA_Cases.json',
|
|
21
|
-
'KDNA_Reasoning.json',
|
|
22
|
-
'KDNA_Evolution.json',
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
const V1_ENTRIES = [
|
|
26
|
-
'KDNA_Core.json',
|
|
27
|
-
'KDNA_Patterns.json',
|
|
28
|
-
'KDNA_Scenarios.json',
|
|
29
|
-
'KDNA_Cases.json',
|
|
30
|
-
'KDNA_Reasoning.json',
|
|
31
|
-
'KDNA_Evolution.json',
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
const JSON_ENTRY_RE = /\.json$/i;
|
|
35
11
|
const KDNA_MEDIA_TYPE = 'application/vnd.aikdna.kdna+zip';
|
|
36
12
|
|
|
37
13
|
function sha256Hex(buf) {
|
|
@@ -338,9 +314,9 @@ function validateManifestIdentity(manifest, errors, _warnings) {
|
|
|
338
314
|
if (manifest.format && manifest.format !== 'kdna') {
|
|
339
315
|
errors.push(`kdna.json.format: invalid value "${manifest.format}". Expected "kdna".`);
|
|
340
316
|
}
|
|
341
|
-
if (manifest.format_version && manifest.format_version !== '
|
|
317
|
+
if (manifest.format_version && manifest.format_version !== '2.0') {
|
|
342
318
|
errors.push(
|
|
343
|
-
`kdna.json.format_version: invalid value "${manifest.format_version}". Expected "
|
|
319
|
+
`kdna.json.format_version: invalid value "${manifest.format_version}". Expected "2.0".`,
|
|
344
320
|
);
|
|
345
321
|
}
|
|
346
322
|
if (!manifest.spec_version) errors.push('kdna.json: missing required field "spec_version"');
|
|
@@ -380,11 +356,10 @@ function readManifest(asset) {
|
|
|
380
356
|
return parseJson(asset.readEntry('kdna.json'), 'kdna.json');
|
|
381
357
|
}
|
|
382
358
|
|
|
383
|
-
function readDataMapSync(asset,
|
|
359
|
+
function readDataMapSync(asset, options = {}) {
|
|
384
360
|
const dataMap = {};
|
|
385
361
|
const manifest = readManifest(asset);
|
|
386
362
|
|
|
387
|
-
// ── KDNA Container v2: decode CBOR payload ──
|
|
388
363
|
if (asset.entries.has('payload.kdnab')) {
|
|
389
364
|
const payloadBuf = asset.readEntry('payload.kdnab');
|
|
390
365
|
const payload = cbor.decode(payloadBuf);
|
|
@@ -396,19 +371,15 @@ function readDataMapSync(asset, entries = STANDARD_ENTRIES, options = {}) {
|
|
|
396
371
|
if (payload.judgment.reasoning) dataMap['KDNA_Reasoning.json'] = payload.judgment.reasoning;
|
|
397
372
|
if (payload.judgment.evolution) dataMap['KDNA_Evolution.json'] = payload.judgment.evolution;
|
|
398
373
|
}
|
|
374
|
+
|
|
375
|
+
const encrypted = encryptedEntries(manifest);
|
|
376
|
+
if (encrypted.length && typeof options.decryptEntry !== 'function') {
|
|
377
|
+
throw new Error(`encrypted entries require decryptEntry hook: ${encrypted.join(', ')}`);
|
|
378
|
+
}
|
|
399
379
|
return dataMap;
|
|
400
380
|
}
|
|
401
381
|
|
|
402
|
-
|
|
403
|
-
if (encrypted.length && typeof options.decryptEntry !== 'function') {
|
|
404
|
-
throw new Error(`encrypted entries require decryptEntry hook: ${encrypted.join(', ')}`);
|
|
405
|
-
}
|
|
406
|
-
for (const entryName of entries) {
|
|
407
|
-
if (!asset.entries.has(entryName)) continue;
|
|
408
|
-
const buf = maybeDecryptEntrySync(asset, manifest, entryName, asset.readEntry(entryName), options);
|
|
409
|
-
dataMap[entryName] = parseJson(buf, entryName);
|
|
410
|
-
}
|
|
411
|
-
return dataMap;
|
|
382
|
+
throw new Error('Not a KDNA asset: missing payload.kdnab');
|
|
412
383
|
}
|
|
413
384
|
|
|
414
385
|
function verifySync(asset, options = {}) {
|
|
@@ -418,10 +389,7 @@ function verifySync(asset, options = {}) {
|
|
|
418
389
|
|
|
419
390
|
if (!asset.entries.has('kdna.json')) errors.push('required entry missing: kdna.json');
|
|
420
391
|
verifyMediaType(asset, errors);
|
|
421
|
-
if (!asset.entries.has('
|
|
422
|
-
if (!asset.entries.has('KDNA_Patterns.json')) {
|
|
423
|
-
errors.push('required entry missing: KDNA_Patterns.json');
|
|
424
|
-
}
|
|
392
|
+
if (!asset.entries.has('payload.kdnab')) errors.push('required entry missing: payload.kdnab');
|
|
425
393
|
|
|
426
394
|
const content_digest = buildContentDigest(asset);
|
|
427
395
|
const asset_digest = asset.asset_digest;
|
package/src/lint-pure.js
CHANGED
|
@@ -318,9 +318,9 @@ function validateManifest(manifest) {
|
|
|
318
318
|
if (manifest.format && manifest.format !== 'kdna') {
|
|
319
319
|
errors.push(`kdna.json.format: invalid value "${manifest.format}". Expected "kdna".`);
|
|
320
320
|
}
|
|
321
|
-
if (manifest.format_version && manifest.format_version !== '
|
|
321
|
+
if (manifest.format_version && manifest.format_version !== '2.0') {
|
|
322
322
|
errors.push(
|
|
323
|
-
`kdna.json.format_version: invalid value "${manifest.format_version}". Expected "
|
|
323
|
+
`kdna.json.format_version: invalid value "${manifest.format_version}". Expected "2.0".`,
|
|
324
324
|
);
|
|
325
325
|
}
|
|
326
326
|
if (manifest.status && !VALID_STATUS.has(manifest.status)) {
|