@aikdna/kdna-studio-cli 0.6.0 → 0.6.2
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/bin/kdna-studio.js +27 -13
- package/package.json +2 -2
- package/tests/cli.test.js +1 -0
package/bin/kdna-studio.js
CHANGED
|
@@ -908,16 +908,27 @@ function cmdFilter(args) {
|
|
|
908
908
|
}
|
|
909
909
|
}
|
|
910
910
|
|
|
911
|
-
const
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
911
|
+
const CARD_REQUIRED_FIELDS = {
|
|
912
|
+
axiom: [
|
|
913
|
+
'one_sentence', 'full_statement', 'why',
|
|
914
|
+
'applies_when', 'does_not_apply_when', 'failure_risk',
|
|
915
|
+
'confidence', 'evidence_type',
|
|
916
|
+
],
|
|
917
|
+
boundary: ['scope', 'out_of_scope'],
|
|
918
|
+
misunderstanding: ['wrong', 'correct', 'key_distinction', 'why'],
|
|
919
|
+
self_check: ['question'],
|
|
920
|
+
scenario: ['name', 'trigger', 'action', 'expected'],
|
|
921
|
+
case: ['title', 'scenario', 'input', 'expected'],
|
|
922
|
+
risk: ['name', 'description', 'mitigation'],
|
|
923
|
+
stance: ['statement'],
|
|
924
|
+
pattern: ['type', 'name', 'one_sentence', 'what_it_looks_like', 'how_to_fix', 'failure_risk'],
|
|
925
|
+
};
|
|
916
926
|
|
|
917
927
|
function checkRequiredFields(type, fields) {
|
|
918
|
-
|
|
928
|
+
const required = CARD_REQUIRED_FIELDS[type];
|
|
929
|
+
if (!required) return [];
|
|
919
930
|
const missing = [];
|
|
920
|
-
for (const f of
|
|
931
|
+
for (const f of required) {
|
|
921
932
|
const val = fields[f];
|
|
922
933
|
if (val === undefined || val === null || val === '' ||
|
|
923
934
|
(Array.isArray(val) && val.length === 0)) {
|
|
@@ -927,9 +938,11 @@ function checkRequiredFields(type, fields) {
|
|
|
927
938
|
return missing;
|
|
928
939
|
}
|
|
929
940
|
|
|
930
|
-
function
|
|
941
|
+
function cardStrictTemplate(type, fields) {
|
|
942
|
+
const required = CARD_REQUIRED_FIELDS[type];
|
|
943
|
+
if (!required) return fields;
|
|
931
944
|
const filled = { ...fields };
|
|
932
|
-
for (const f of
|
|
945
|
+
for (const f of required) {
|
|
933
946
|
const val = filled[f];
|
|
934
947
|
if (val === undefined || val === null || val === '' ||
|
|
935
948
|
(Array.isArray(val) && val.length === 0)) {
|
|
@@ -957,16 +970,17 @@ function cmdCard(args) {
|
|
|
957
970
|
|
|
958
971
|
const useTemplate = option(args, '--template');
|
|
959
972
|
if (useTemplate === 'axiom-strict') {
|
|
960
|
-
|
|
973
|
+
if (type !== 'axiom') fail('--template axiom-strict only applies to axiom cards');
|
|
974
|
+
fields = cardStrictTemplate('axiom', fields);
|
|
961
975
|
}
|
|
962
976
|
|
|
963
977
|
const isNoStrict = args.includes('--no-strict');
|
|
964
|
-
if (!isNoStrict
|
|
978
|
+
if (!isNoStrict) {
|
|
965
979
|
const missing = checkRequiredFields(type, fields);
|
|
966
980
|
if (missing.length > 0) {
|
|
967
981
|
fail(
|
|
968
|
-
`Missing required fields for
|
|
969
|
-
`Use --no-strict to add a partial card
|
|
982
|
+
`Missing required fields for ${type}: ${missing.join(', ')}\n` +
|
|
983
|
+
`Use --no-strict to add a partial card.`
|
|
970
984
|
);
|
|
971
985
|
}
|
|
972
986
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aikdna/kdna-studio-cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
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": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"node": ">=18"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@aikdna/kdna-studio-core": "^1.5.
|
|
41
|
+
"@aikdna/kdna-studio-core": "^1.5.9",
|
|
42
42
|
"ajv": "^8.20.0",
|
|
43
43
|
"ajv-formats": "^3.0.1",
|
|
44
44
|
"cbor-x": "^1.6.4"
|
package/tests/cli.test.js
CHANGED
|
@@ -677,6 +677,7 @@ test('E2E blank: create → approve → lock → export → runtime digest match
|
|
|
677
677
|
'--field', 'wrong=E2E tests are unnecessary.',
|
|
678
678
|
'--field', 'correct=E2E tests catch integration issues not visible in unit tests.',
|
|
679
679
|
'--field', 'key_distinction=E2E tests validate the full pipeline, not individual functions.',
|
|
680
|
+
'--field', 'why=E2E test failures are hard to debug without a full integration test running.',
|
|
680
681
|
], { tmp });
|
|
681
682
|
assert.equal(result.status, 0, result.stderr);
|
|
682
683
|
|